]> source.dussan.org Git - archiva.git/blob
7624dc7d864fa70983e991a7db6f49c8ad01dfaf
[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( dependsOnMethods = { "testAddArtifactFileType_NullValue" } )
38     public void testAddArtifactFileType()
39     {
40         setFieldValue( "newpattern_0", "**/*.dll" );
41         clickAddIcon( "newpattern_0" );
42         Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table.13.0" ), "**/*.dll" );
43     }
44
45     @Test( dependsOnMethods = { "testAddArtifactFileType" }, enabled = false )
46     public void testAddArtifactFileType_ExistingValue()
47     {
48         // FIXME: broken
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." );
53     }
54
55     @Test( dependsOnMethods = { "testAddArtifactFileType" } )
56     public void testDeleteArtifactFileType()
57     {
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 );
63     }
64
65     @Test( dependsOnMethods = { "testDeleteArtifactFileType" } )
66     public void testAddAutoRemove_NullValue()
67     {
68         setFieldValue( "newpattern_1", "" );
69         clickAddIcon( "newpattern_1" );
70         assertTextPresent( "Unable to process blank pattern." );
71     }
72
73     @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" }, enabled = false )
74     public void testAddAutoRemove_ExistingValue()
75     {
76         setFieldValue( "newpattern_1", "**/*-" );
77         clickAddIcon( "newpattern_1" );
78         // FIXME: broken
79         Assert.assertEquals( getErrorMessageText(),
80                              "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
81     }
82
83     @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } )
84     public void testAddAutoRemove()
85     {
86         setFieldValue( "newpattern_1", "**/*.test" );
87         clickAddIcon( "newpattern_1" );
88         Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table.3.0" ), "**/*.test" );
89     }
90
91     @Test( dependsOnMethods = { "testAddAutoRemove" } )
92     public void testDeleteAutoRemove()
93     {
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 );
99     }
100
101     @Test( dependsOnMethods = { "testDeleteAutoRemove" } )
102     public void testAddIgnoredArtifacts_NullValue()
103     {
104         setFieldValue( "newpattern_2", "" );
105         clickAddIcon( "newpattern_2" );
106         Assert.assertEquals( getErrorMessageText(),
107                              "Unable to process blank pattern." );
108     }
109
110     @Test(enabled = false)
111     public void testAddIgnoredArtifacts_ExistingValue()
112     {
113         setFieldValue( "newpattern_2", "**/*.sh" );
114         clickAddIcon( "newpattern_2" );
115         // FIXME: broken
116         Assert.assertEquals( getErrorMessageText(),
117                              "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
118     }
119
120     @Test
121     public void testAddIgnoredArtifacts()
122     {
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" );
127     }
128
129     @Test( dependsOnMethods = { "testAddIgnoredArtifacts" } )
130     public void testDeleteIgnoredArtifacts()
131     {
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 );
138     }
139
140     //
141     @Test( dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
142     public void testAddIndexableContent_NullValue()
143     {
144         setFieldValue( "newpattern_3", "" );
145         clickAddIcon( "newpattern_3" );
146         Assert.assertEquals( getErrorMessageText(),
147                              "Unable to process blank pattern." );
148     }
149
150     @Test( enabled = false )
151     public void testAddIndexableContent_ExistingValue()
152     {
153         setFieldValue( "newpattern_3", "**/*.xml" );
154         clickAddIcon( "newpattern_3" );
155         // FIXME: broken
156         Assert.assertEquals( getErrorMessageText(),
157                              "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
158     }
159
160     @Test
161     public void testAddIndexableContent()
162     {
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" );
167     }
168
169     @Test( dependsOnMethods = { "testAddIndexableContent" } )
170     public void testDeleteIndexableContent()
171     {
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 );
178     }
179
180     @Test( dependsOnMethods = { "testDeleteIndexableContent" } )
181     public void testUpdateConsumers()
182     {
183         checkField( "enabledKnownContentConsumers" );
184         checkField( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
185         clickButtonWithValue( "Update Consumers" );
186         assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
187     }
188
189     @Test( dependsOnMethods = { "testUpdateConsumers" } )
190     public void testUpdateConsumers_UnsetAll()
191     {
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" );
200
201         assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
202     }
203     
204     private void clickAddIcon( String fieldId )
205     {
206         String xPath = "//preceding::td/input[@id='" + fieldId + "']//following::td/a/img";
207         clickLinkWithLocator( xPath );
208     }
209
210     private void clickDeleteIcon( String pattern )
211     {
212         String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img";
213         clickLinkWithLocator( xPath );
214     }
215
216 }