1 package org.apache.archiva.web.test;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
23 import org.testng.Assert;
24 import org.testng.annotations.Test;
26 @Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
27 public class RepositoryScanningTest
28 extends AbstractRepositoryTest
30 public void testAddArtifactFileType_NullValue()
32 goToRepositoryScanningPage();
33 clickAddIcon( "newpattern_0" );
34 assertTextPresent( "Unable to process blank pattern." );
38 public void testAddArtifactFileType()
40 goToRepositoryScanningPage();
41 setFieldValue( "newpattern_0", "**/*.dll" );
42 clickAddIcon( "newpattern_0" );
43 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table.13.0" ), "**/*.dll" );
46 @Test( dependsOnMethods = { "testAddArtifactFileType" }, enabled = false )
47 public void testAddArtifactFileType_ExistingValue()
50 setFieldValue( "newpattern_0", "**/*.zip" );
51 clickAddIcon( "newpattern_0" );
52 Assert.assertEquals( getErrorMessageText(),
53 "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." );
56 @Test( dependsOnMethods = { "testAddArtifactFileType" } )
57 public void testDeleteArtifactFileType()
59 goToRepositoryScanningPage();
60 String path = "//div[@id='contentArea']/div/div/table/tbody/tr[14]/td/code";
61 assertElementPresent( path );
62 Assert.assertEquals( getSelenium().getText( path ), "**/*.dll" );
63 clickDeleteIcon( "**/*.dll" );
64 assertElementNotPresent( path );
67 @Test( dependsOnMethods = { "testDeleteArtifactFileType" } )
68 public void testAddAutoRemove_NullValue()
70 goToRepositoryScanningPage();
71 setFieldValue( "newpattern_1", "" );
72 clickAddIcon( "newpattern_1" );
73 assertTextPresent( "Unable to process blank pattern." );
76 @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" }, enabled = false )
77 public void testAddAutoRemove_ExistingValue()
79 setFieldValue( "newpattern_1", "**/*-" );
80 clickAddIcon( "newpattern_1" );
82 Assert.assertEquals( getErrorMessageText(),
83 "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
86 @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } )
87 public void testAddAutoRemove()
89 goToRepositoryScanningPage();
90 setFieldValue( "newpattern_1", "**/*.test" );
91 clickAddIcon( "newpattern_1" );
92 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table.3.0" ), "**/*.test" );
95 @Test( dependsOnMethods = { "testAddAutoRemove" } )
96 public void testDeleteAutoRemove()
98 goToRepositoryScanningPage();
99 String path = "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td/code";
100 assertElementPresent( path );
101 Assert.assertEquals( getSelenium().getText( path ), "**/*.test" );
102 clickDeleteIcon( "**/*.test" );
103 assertElementNotPresent( path );
106 @Test( dependsOnMethods = { "testDeleteAutoRemove" } )
107 public void testAddIgnoredArtifacts_NullValue()
109 goToRepositoryScanningPage();
110 setFieldValue( "newpattern_2", "" );
111 clickAddIcon( "newpattern_2" );
112 Assert.assertEquals( getErrorMessageText(),
113 "Unable to process blank pattern." );
116 @Test(enabled = false)
117 public void testAddIgnoredArtifacts_ExistingValue()
119 setFieldValue( "newpattern_2", "**/*.sh" );
120 clickAddIcon( "newpattern_2" );
122 Assert.assertEquals( getErrorMessageText(),
123 "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
127 public void testAddIgnoredArtifacts()
129 goToRepositoryScanningPage();
130 setFieldValue( "newpattern_2", "**/*.log" );
131 clickAddIcon( "newpattern_2" );
132 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table.6.0" ), "**/*.log" );
135 @Test( dependsOnMethods = { "testAddIgnoredArtifacts" } )
136 public void testDeleteIgnoredArtifacts()
138 goToRepositoryScanningPage();
139 String pattern = "**/*.log";
140 String path = "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td/code";
141 assertElementPresent( path );
142 Assert.assertEquals( getSelenium().getText( path ), pattern );
143 clickDeleteIcon( pattern );
144 assertElementNotPresent( path );
148 @Test( dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
149 public void testAddIndexableContent_NullValue()
151 goToRepositoryScanningPage();
152 setFieldValue( "newpattern_3", "" );
153 clickAddIcon( "newpattern_3" );
154 Assert.assertEquals( getErrorMessageText(),
155 "Unable to process blank pattern." );
158 @Test( enabled = false )
159 public void testAddIndexableContent_ExistingValue()
161 setFieldValue( "newpattern_3", "**/*.xml" );
162 clickAddIcon( "newpattern_3" );
164 Assert.assertEquals( getErrorMessageText(),
165 "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
169 public void testAddIndexableContent()
171 goToRepositoryScanningPage();
172 setFieldValue( "newpattern_3", "**/*.html" );
173 clickAddIcon( "newpattern_3" );
174 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table.9.0" ), "**/*.html" );
177 @Test( dependsOnMethods = { "testAddIndexableContent" } )
178 public void testDeleteIndexableContent()
180 goToRepositoryScanningPage();
181 String pattern = "**/*.html";
182 String path = "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td/code";
183 assertElementPresent( path );
184 Assert.assertEquals( getSelenium().getText( path ), pattern );
185 clickDeleteIcon( pattern );
186 assertElementNotPresent( path );
189 @Test( dependsOnMethods = { "testDeleteIndexableContent" } )
190 public void testUpdateConsumers()
192 goToRepositoryScanningPage();
193 checkField( "enabledKnownContentConsumers" );
194 checkField( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
195 clickButtonWithValue( "Update Consumers" );
196 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
199 @Test( dependsOnMethods = { "testUpdateConsumers" } )
200 public void testUpdateConsumers_UnsetAll()
202 goToRepositoryScanningPage();
203 getSelenium().uncheck( "enabledKnownContentConsumers" );
204 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
205 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='create-missing-checksums']" );
206 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='index-content']" );
207 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='metadata-updater']" );
208 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='repository-purge']" );
209 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" );
210 clickButtonWithValue( "Update Consumers" );
212 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
215 private void clickAddIcon( String fieldId )
217 String xPath = "//preceding::td/input[@id='" + fieldId + "']//following::td/a/img";
218 clickLinkWithLocator( xPath );
221 private void clickDeleteIcon( String pattern )
223 String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img";
224 clickLinkWithLocator( xPath );