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." );
37 @Test( dependsOnMethods = { "testAddArtifactFileType_NullValue" } )
38 public void testAddArtifactFileType()
40 setFieldValue( "newpattern_0", "**/*.dll" );
41 clickAddIcon( "newpattern_0" );
42 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table.13.0" ), "**/*.dll" );
45 @Test( dependsOnMethods = { "testAddArtifactFileType" }, enabled = false )
46 public void testAddArtifactFileType_ExistingValue()
49 setFieldValue( "newpattern_0", "**/*.zip" );
50 clickAddIcon( "newpattern_0" );
51 Assert.assertEquals( getErrorMessageText(),
52 "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." );
55 @Test( dependsOnMethods = { "testAddArtifactFileType" } )
56 public void testDeleteArtifactFileType()
58 String path = "//div[@id='contentArea']/div/div/table/tbody/tr[14]/td/code";
59 assertElementPresent( path );
60 Assert.assertEquals( getSelenium().getText( path ), "**/*.dll" );
61 clickDeleteIcon( "**/*.dll" );
62 assertElementNotPresent( path );
65 @Test( dependsOnMethods = { "testDeleteArtifactFileType" } )
66 public void testAddAutoRemove_NullValue()
68 setFieldValue( "newpattern_1", "" );
69 clickAddIcon( "newpattern_1" );
70 assertTextPresent( "Unable to process blank pattern." );
73 @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" }, enabled = false )
74 public void testAddAutoRemove_ExistingValue()
76 setFieldValue( "newpattern_1", "**/*-" );
77 clickAddIcon( "newpattern_1" );
79 Assert.assertEquals( getErrorMessageText(),
80 "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
83 @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } )
84 public void testAddAutoRemove()
86 setFieldValue( "newpattern_1", "**/*.test" );
87 clickAddIcon( "newpattern_1" );
88 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table.3.0" ), "**/*.test" );
91 @Test( dependsOnMethods = { "testAddAutoRemove" } )
92 public void testDeleteAutoRemove()
94 String path = "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td/code";
95 assertElementPresent( path );
96 Assert.assertEquals( getSelenium().getText( path ), "**/*.test" );
97 clickDeleteIcon( "**/*.test" );
98 assertElementNotPresent( path );
101 @Test( dependsOnMethods = { "testDeleteAutoRemove" } )
102 public void testAddIgnoredArtifacts_NullValue()
104 setFieldValue( "newpattern_2", "" );
105 clickAddIcon( "newpattern_2" );
106 Assert.assertEquals( getErrorMessageText(),
107 "Unable to process blank pattern." );
110 @Test(enabled = false)
111 public void testAddIgnoredArtifacts_ExistingValue()
113 setFieldValue( "newpattern_2", "**/*.sh" );
114 clickAddIcon( "newpattern_2" );
116 Assert.assertEquals( getErrorMessageText(),
117 "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
121 public void testAddIgnoredArtifacts()
123 goToRepositoryScanningPage();
124 setFieldValue( "newpattern_2", "**/*.log" );
125 clickAddIcon( "newpattern_2" );
126 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table.6.0" ), "**/*.log" );
129 @Test( dependsOnMethods = { "testAddIgnoredArtifacts" } )
130 public void testDeleteIgnoredArtifacts()
132 String pattern = "**/*.log";
133 String path = "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td/code";
134 assertElementPresent( path );
135 Assert.assertEquals( getSelenium().getText( path ), pattern );
136 clickDeleteIcon( pattern );
137 assertElementNotPresent( path );
141 @Test( dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
142 public void testAddIndexableContent_NullValue()
144 setFieldValue( "newpattern_3", "" );
145 clickAddIcon( "newpattern_3" );
146 Assert.assertEquals( getErrorMessageText(),
147 "Unable to process blank pattern." );
150 @Test( enabled = false )
151 public void testAddIndexableContent_ExistingValue()
153 setFieldValue( "newpattern_3", "**/*.xml" );
154 clickAddIcon( "newpattern_3" );
156 Assert.assertEquals( getErrorMessageText(),
157 "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
161 public void testAddIndexableContent()
163 goToRepositoryScanningPage();
164 setFieldValue( "newpattern_3", "**/*.html" );
165 clickAddIcon( "newpattern_3" );
166 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table.9.0" ), "**/*.html" );
169 @Test( dependsOnMethods = { "testAddIndexableContent" } )
170 public void testDeleteIndexableContent()
172 String pattern = "**/*.html";
173 String path = "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td/code";
174 assertElementPresent( path );
175 Assert.assertEquals( getSelenium().getText( path ), pattern );
176 clickDeleteIcon( pattern );
177 assertElementNotPresent( path );
180 @Test( dependsOnMethods = { "testDeleteIndexableContent" } )
181 public void testUpdateConsumers()
183 checkField( "enabledKnownContentConsumers" );
184 checkField( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
185 clickButtonWithValue( "Update Consumers" );
186 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
189 @Test( dependsOnMethods = { "testUpdateConsumers" } )
190 public void testUpdateConsumers_UnsetAll()
192 getSelenium().uncheck( "enabledKnownContentConsumers" );
193 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
194 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='create-missing-checksums']" );
195 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='index-content']" );
196 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='metadata-updater']" );
197 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='repository-purge']" );
198 getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" );
199 clickButtonWithValue( "Update Consumers" );
201 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
204 private void clickAddIcon( String fieldId )
206 String xPath = "//preceding::td/input[@id='" + fieldId + "']//following::td/a/img";
207 clickLinkWithLocator( xPath );
210 private void clickDeleteIcon( String pattern )
212 String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img";
213 clickLinkWithLocator( xPath );