]> source.dussan.org Git - archiva.git/blob
72ee92e5244db54fcfcda0d743b19204e0f44845
[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" }, enabled = false )
47     public void testAddArtifactFileType_ExistingValue()
48     {
49         // FIXME: broken
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." );
54     }
55
56     @Test( dependsOnMethods = { "testAddArtifactFileType" } )
57     public void testDeleteArtifactFileType()
58     {
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 );
65     }
66
67     @Test( dependsOnMethods = { "testDeleteArtifactFileType" } )
68     public void testAddAutoRemove_NullValue()
69     {
70         goToRepositoryScanningPage();
71         setFieldValue( "newpattern_1", "" );
72         clickAddIcon( "newpattern_1" );
73         assertTextPresent( "Unable to process blank pattern." );
74     }
75
76     @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" }, enabled = false )
77     public void testAddAutoRemove_ExistingValue()
78     {
79         setFieldValue( "newpattern_1", "**/*-" );
80         clickAddIcon( "newpattern_1" );
81         // FIXME: broken
82         Assert.assertEquals( getErrorMessageText(),
83                              "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
84     }
85
86     @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } )
87     public void testAddAutoRemove()
88     {
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" );
93     }
94
95     @Test( dependsOnMethods = { "testAddAutoRemove" } )
96     public void testDeleteAutoRemove()
97     {
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 );
104     }
105
106     @Test( dependsOnMethods = { "testDeleteAutoRemove" } )
107     public void testAddIgnoredArtifacts_NullValue()
108     {
109         goToRepositoryScanningPage();
110         setFieldValue( "newpattern_2", "" );
111         clickAddIcon( "newpattern_2" );
112         Assert.assertEquals( getErrorMessageText(),
113                              "Unable to process blank pattern." );
114     }
115
116     @Test(enabled = false)
117     public void testAddIgnoredArtifacts_ExistingValue()
118     {
119         setFieldValue( "newpattern_2", "**/*.sh" );
120         clickAddIcon( "newpattern_2" );
121         // FIXME: broken
122         Assert.assertEquals( getErrorMessageText(),
123                              "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
124     }
125
126     @Test
127     public void testAddIgnoredArtifacts()
128     {
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" );
133     }
134
135     @Test( dependsOnMethods = { "testAddIgnoredArtifacts" } )
136     public void testDeleteIgnoredArtifacts()
137     {
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 );
145     }
146
147     //
148     @Test( dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
149     public void testAddIndexableContent_NullValue()
150     {
151         goToRepositoryScanningPage();
152         setFieldValue( "newpattern_3", "" );
153         clickAddIcon( "newpattern_3" );
154         Assert.assertEquals( getErrorMessageText(),
155                              "Unable to process blank pattern." );
156     }
157
158     @Test( enabled = false )
159     public void testAddIndexableContent_ExistingValue()
160     {
161         setFieldValue( "newpattern_3", "**/*.xml" );
162         clickAddIcon( "newpattern_3" );
163         // FIXME: broken
164         Assert.assertEquals( getErrorMessageText(),
165                              "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
166     }
167
168     @Test
169     public void testAddIndexableContent()
170     {
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" );
175     }
176
177     @Test( dependsOnMethods = { "testAddIndexableContent" } )
178     public void testDeleteIndexableContent()
179     {
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 );
187     }
188
189     @Test( dependsOnMethods = { "testDeleteIndexableContent" } )
190     public void testUpdateConsumers()
191     {
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" );
197     }
198
199     @Test( dependsOnMethods = { "testUpdateConsumers" } )
200     public void testUpdateConsumers_UnsetAll()
201     {
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" );
211
212         assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
213     }
214     
215     private void clickAddIcon( String fieldId )
216     {
217         String xPath = "//preceding::td/input[@id='" + fieldId + "']//following::td/a/img";
218         clickLinkWithLocator( xPath );
219     }
220
221     private void clickDeleteIcon( String pattern )
222     {
223         String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img";
224         clickLinkWithLocator( xPath );
225     }
226
227 }