]> source.dussan.org Git - archiva.git/blob
f37a158be1ac5393d90d555453f93be5da3f89cd
[archiva.git] /
1 package org.apache.archiva.web.test;
2
3 /*
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
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
23 import org.testng.Assert;
24 import org.testng.annotations.Test;
25
26 @Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
27 public class RepositoryScanningTest
28     extends AbstractRepositoryTest
29 {
30     public void testAddArtifactFileType_NullValue()
31     {
32         goToRepositoryScanningPage();
33         clickAddIcon( "newpattern_0" );
34         assertTextPresent( "Unable to process blank pattern." );
35     }
36
37     @Test
38     public void testAddArtifactFileType()
39     {
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" );
44     }
45
46     @Test( dependsOnMethods = { "testAddArtifactFileType" } )
47     public void testAddArtifactFileType_ExistingValue()
48     {
49         goToRepositoryScanningPage();
50         setFieldValue( "newpattern_0", "**/*.zip" );
51         clickAddIcon( "newpattern_0" );
52         Assert.assertEquals( getErrorMessageText(), "File type [artifacts] already contains pattern [**/*.zip]" );
53     }
54
55     @Test( dependsOnMethods = { "testAddArtifactFileType" } )
56     public void testDeleteArtifactFileType()
57     {
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 );
64     }
65
66     @Test( dependsOnMethods = { "testDeleteArtifactFileType" } )
67     public void testAddAutoRemove_NullValue()
68     {
69         goToRepositoryScanningPage();
70         setFieldValue( "newpattern_1", "" );
71         clickAddIcon( "newpattern_1" );
72         assertTextPresent( "Unable to process blank pattern." );
73     }
74
75     @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } )
76     public void testAddAutoRemove_ExistingValue()
77     {
78         goToRepositoryScanningPage();
79         setFieldValue( "newpattern_1", "**/*-" );
80         clickAddIcon( "newpattern_1" );
81         Assert.assertEquals( getErrorMessageText(), "File type [auto-remove] already contains pattern [**/*-]" );
82     }
83
84     @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } )
85     public void testAddAutoRemove()
86     {
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" );
91     }
92
93     @Test( dependsOnMethods = { "testAddAutoRemove" } )
94     public void testDeleteAutoRemove()
95     {
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 );
102     }
103
104     @Test( dependsOnMethods = { "testDeleteAutoRemove" } )
105     public void testAddIgnoredArtifacts_NullValue()
106     {
107         goToRepositoryScanningPage();
108         setFieldValue( "newpattern_2", "" );
109         clickAddIcon( "newpattern_2" );
110         Assert.assertEquals( getErrorMessageText(),
111                              "Unable to process blank pattern." );
112     }
113
114     @Test
115     public void testAddIgnoredArtifacts_ExistingValue()
116     {
117         goToRepositoryScanningPage();
118         setFieldValue( "newpattern_2", "**/*.sh" );
119         clickAddIcon( "newpattern_2" );
120         Assert.assertEquals( getErrorMessageText(), "File type [ignored] already contains pattern [**/*.sh]" );
121     }
122
123     @Test
124     public void testAddIgnoredArtifacts()
125     {
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" );
130     }
131
132     @Test( dependsOnMethods = { "testAddIgnoredArtifacts" } )
133     public void testDeleteIgnoredArtifacts()
134     {
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 );
142     }
143
144     //
145     @Test( dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
146     public void testAddIndexableContent_NullValue()
147     {
148         goToRepositoryScanningPage();
149         setFieldValue( "newpattern_3", "" );
150         clickAddIcon( "newpattern_3" );
151         Assert.assertEquals( getErrorMessageText(),
152                              "Unable to process blank pattern." );
153     }
154
155     @Test
156     public void testAddIndexableContent_ExistingValue()
157     {
158         goToRepositoryScanningPage();
159         setFieldValue( "newpattern_3", "**/*.xml" );
160         clickAddIcon( "newpattern_3" );
161         Assert.assertEquals( getErrorMessageText(),
162                              "File type [indexable-content] already contains pattern [**/*.xml]" );
163     }
164
165     @Test
166     public void testAddIndexableContent()
167     {
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" );
172     }
173
174     @Test( dependsOnMethods = { "testAddIndexableContent" } )
175     public void testDeleteIndexableContent()
176     {
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 );
184     }
185
186     @Test( dependsOnMethods = { "testDeleteIndexableContent" } )
187     public void testUpdateConsumers()
188     {
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" );
194     }
195
196     @Test( dependsOnMethods = { "testUpdateConsumers" } )
197     public void testUpdateConsumers_UnsetAll()
198     {
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" );
208
209         assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
210     }
211     
212     private void clickAddIcon( String fieldId )
213     {
214         String xPath = "//preceding::td/input[@id='" + fieldId + "']//following::td/a/img";
215         clickLinkWithLocator( xPath );
216     }
217
218     private void clickDeleteIcon( String pattern )
219     {
220         String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img";
221         clickLinkWithLocator( xPath );
222     }
223
224 }