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" } )
47 public void testAddArtifactFileType_ExistingValue()
49 goToRepositoryScanningPage();
50 setFieldValue( "newpattern_0", "**/*.zip" );
51 clickAddIcon( "newpattern_0" );
52 Assert.assertEquals( getErrorMessageText(), "File type [artifacts] already contains pattern [**/*.zip]" );
55 @Test( dependsOnMethods = { "testAddArtifactFileType" } )
56 public void testDeleteArtifactFileType()
58 goToRepositoryScanningPage();
59 String path = "//div[@id='contentArea']/div/div/table/tbody/tr[14]/td/code";
60 assertElementPresent( path );
61 Assert.assertEquals( getSelenium().getText( path ), "**/*.dll" );
62 clickDeleteIcon( "**/*.dll" );
63 assertElementNotPresent( path );
66 @Test( dependsOnMethods = { "testDeleteArtifactFileType" } )
67 public void testAddAutoRemove_NullValue()
69 goToRepositoryScanningPage();
70 setFieldValue( "newpattern_1", "" );
71 clickAddIcon( "newpattern_1" );
72 assertTextPresent( "Unable to process blank pattern." );
75 @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } )
76 public void testAddAutoRemove_ExistingValue()
78 goToRepositoryScanningPage();
79 setFieldValue( "newpattern_1", "**/*-" );
80 clickAddIcon( "newpattern_1" );
81 Assert.assertEquals( getErrorMessageText(), "File type [auto-remove] already contains pattern [**/*-]" );
84 @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } )
85 public void testAddAutoRemove()
87 goToRepositoryScanningPage();
88 setFieldValue( "newpattern_1", "**/*.test" );
89 clickAddIcon( "newpattern_1" );
90 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table.3.0" ), "**/*.test" );
93 @Test( dependsOnMethods = { "testAddAutoRemove" } )
94 public void testDeleteAutoRemove()
96 goToRepositoryScanningPage();
97 String path = "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td/code";
98 assertElementPresent( path );
99 Assert.assertEquals( getSelenium().getText( path ), "**/*.test" );
100 clickDeleteIcon( "**/*.test" );
101 assertElementNotPresent( path );
104 @Test( dependsOnMethods = { "testDeleteAutoRemove" } )
105 public void testAddIgnoredArtifacts_NullValue()
107 goToRepositoryScanningPage();
108 setFieldValue( "newpattern_2", "" );
109 clickAddIcon( "newpattern_2" );
110 Assert.assertEquals( getErrorMessageText(),
111 "Unable to process blank pattern." );
115 public void testAddIgnoredArtifacts_ExistingValue()
117 goToRepositoryScanningPage();
118 setFieldValue( "newpattern_2", "**/*.sh" );
119 clickAddIcon( "newpattern_2" );
120 Assert.assertEquals( getErrorMessageText(), "File type [ignored] already contains pattern [**/*.sh]" );
124 public void testAddIgnoredArtifacts()
126 goToRepositoryScanningPage();
127 setFieldValue( "newpattern_2", "**/*.log" );
128 clickAddIcon( "newpattern_2" );
129 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table.6.0" ), "**/*.log" );
132 @Test( dependsOnMethods = { "testAddIgnoredArtifacts" } )
133 public void testDeleteIgnoredArtifacts()
135 goToRepositoryScanningPage();
136 String pattern = "**/*.log";
137 String path = "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td/code";
138 assertElementPresent( path );
139 Assert.assertEquals( getSelenium().getText( path ), pattern );
140 clickDeleteIcon( pattern );
141 assertElementNotPresent( path );
145 @Test( dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
146 public void testAddIndexableContent_NullValue()
148 goToRepositoryScanningPage();
149 setFieldValue( "newpattern_3", "" );
150 clickAddIcon( "newpattern_3" );
151 Assert.assertEquals( getErrorMessageText(),
152 "Unable to process blank pattern." );
156 public void testAddIndexableContent_ExistingValue()
158 goToRepositoryScanningPage();
159 setFieldValue( "newpattern_3", "**/*.xml" );
160 clickAddIcon( "newpattern_3" );
161 Assert.assertEquals( getErrorMessageText(),
162 "File type [indexable-content] already contains pattern [**/*.xml]" );
166 public void testAddIndexableContent()
168 goToRepositoryScanningPage();
169 setFieldValue( "newpattern_3", "**/*.html" );
170 clickAddIcon( "newpattern_3" );
171 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table.9.0" ), "**/*.html" );
174 @Test( dependsOnMethods = { "testAddIndexableContent" } )
175 public void testDeleteIndexableContent()
177 goToRepositoryScanningPage();
178 String pattern = "**/*.html";
179 String path = "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td/code";
180 assertElementPresent( path );
181 Assert.assertEquals( getSelenium().getText( path ), pattern );
182 clickDeleteIcon( pattern );
183 assertElementNotPresent( path );
186 @Test( dependsOnMethods = { "testDeleteIndexableContent" } )
187 public void testUpdateConsumers()
189 goToRepositoryScanningPage();
190 checkField( "enabledKnownContentConsumers" );
191 checkField( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
192 clickButtonWithValue( "Update Consumers" );
193 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
196 @Test( dependsOnMethods = { "testUpdateConsumers" } )
197 public void testUpdateConsumers_UnsetAll()
199 goToRepositoryScanningPage();
200 getSelenium().uncheck( "enabledKnownContentConsumers" );
201 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
202 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='create-missing-checksums']" );
203 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='index-content']" );
204 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='metadata-updater']" );
205 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='repository-purge']" );
206 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" );
207 clickButtonWithValue( "Update Consumers" );
209 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
212 private void clickAddIcon( String fieldId )
214 String xPath = "//preceding::td/input[@id='" + fieldId + "']//following::td/a/img";
215 clickLinkWithLocator( xPath );
218 private void clickDeleteIcon( String pattern )
220 String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img";
221 clickLinkWithLocator( xPath );