View Javadoc
1   package org.apache.archiva.webdav;
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  
23  import org.junit.After;
24  import org.junit.Before;
25  import org.junit.Test;
26  
27  /**
28   * RepositoryServlet Tests, Proxied, Get of Metadata, exists on remote repository only.
29   *
30   *
31   */
32  public class RepositoryServletProxiedMetadataRemoteOnlyTest
33      extends AbstractRepositoryServletProxiedMetadataTestCase
34  {
35  
36      @Before
37      public void setup()
38          throws Exception
39      {
40          super.setUp();
41      }
42  
43      @After
44      @Override
45      public void tearDown()
46          throws Exception
47      {
48          super.tearDown();
49      }
50  
51  
52      @Test
53      public void testGetProxiedSnapshotVersionMetadataRemoteOnly()
54          throws Exception
55      {
56          // --- Setup
57          setupSnapshotsRemoteRepo();
58          setupPrivateSnapshotsRemoteRepo();
59          setupCleanInternalRepo();
60  
61          String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
62          String version = "4.0-alpha-1-SNAPSHOT";
63          String timestamp = "20040305.112233";
64          String buildNumber = "2";
65          String lastUpdated = "20040305112233";
66          String expectedMetadata =
67              createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin", version, timestamp, buildNumber,
68                                     lastUpdated );
69  
70          populateRepo( remoteSnapshots, path, expectedMetadata );
71  
72          setupConnector( REPOID_INTERNAL, remoteSnapshots );
73          setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
74          saveConfiguration();
75  
76          // --- Execution
77          String actualMetadata = requestMetadataOK( path );
78  
79          // --- Verification
80          assertExpectedMetadata( expectedMetadata, actualMetadata );
81      }
82  
83      @Test
84      public void testGetProxiedPluginSnapshotVersionMetadataRemoteOnly()
85          throws Exception
86      {
87          // --- Setup
88          setupSnapshotsRemoteRepo();
89          setupPrivateSnapshotsRemoteRepo();
90          setupCleanInternalRepo();
91  
92          String path = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
93          String version = "2.2-beta-2-SNAPSHOT";
94          String timestamp = "20071017.162810";
95          String buildNumber = "20";
96          String lastUpdated = "20071017162810";
97          String expectedMetadata =
98              createVersionMetadata( "org.apache.maven.plugins", "maven-assembly-plugin", version, timestamp, buildNumber,
99                                     lastUpdated );
100 
101         populateRepo( remoteSnapshots, path, expectedMetadata );
102 
103         setupConnector( REPOID_INTERNAL, remoteSnapshots );
104         setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
105         saveConfiguration();
106 
107         // --- Execution
108         String actualMetadata = requestMetadataOK( path );
109 
110         // --- Verification
111         assertExpectedMetadata( expectedMetadata, actualMetadata );
112     }
113 
114     @Test
115     public void testGetProxiedVersionMetadataRemoteOnly()
116         throws Exception
117     {
118         // --- Setup
119         setupSnapshotsRemoteRepo();
120         setupPrivateSnapshotsRemoteRepo();
121         setupCleanInternalRepo();
122 
123         String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-2/maven-metadata.xml";
124         String expectedMetadata =
125             createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin", "4.0-alpha-2" );
126 
127         populateRepo( remoteSnapshots, path, expectedMetadata );
128 
129         setupConnector( REPOID_INTERNAL, remoteSnapshots );
130         setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
131         saveConfiguration();
132 
133         // --- Execution
134         String actualMetadata = requestMetadataOK( path );
135 
136         // --- Verification
137         assertExpectedMetadata( expectedMetadata, actualMetadata );
138     }
139 
140     @Test
141     public void testGetProxiedProjectMetadataRemoteOnly()
142         throws Exception
143     {
144         // --- Setup
145         setupSnapshotsRemoteRepo();
146         setupPrivateSnapshotsRemoteRepo();
147         setupCleanInternalRepo();
148 
149         String path = "org/apache/archiva/archivatest-maven-plugin/maven-metadata.xml";
150         String latest = "1.0-alpha-4";
151         String release = "1.0-alpha-4";
152         String expectedMetadata =
153             createProjectMetadata( "org.apache.archiva", "archivatest-maven-plugin", latest, release,
154                                    new String[]{ "1.0-alpha-4" } );
155 
156         populateRepo( remoteSnapshots, path, expectedMetadata );
157 
158         setupConnector( REPOID_INTERNAL, remoteSnapshots );
159         setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
160         saveConfiguration();
161 
162         // --- Execution
163         String actualMetadata = requestMetadataOK( path );
164 
165         // --- Verification
166         assertExpectedMetadata( expectedMetadata, actualMetadata );
167     }
168 
169     @Test
170     public void testGetProxiedGroupMetadataRemoteOnly()
171         throws Exception
172     {
173         // --- Setup
174         setupSnapshotsRemoteRepo();
175         setupPrivateSnapshotsRemoteRepo();
176         setupCleanInternalRepo();
177 
178         String path = "org/apache/archiva/maven-metadata.xml";
179         String expectedMetadata =
180             createGroupMetadata( "org.apache.archiva", new String[]{ "archivatest-maven-plugin" } );
181 
182         populateRepo( remoteSnapshots, path, expectedMetadata );
183 
184         setupConnector( REPOID_INTERNAL, remoteSnapshots );
185         setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
186         saveConfiguration();
187 
188         // --- Execution
189         String actualMetadata = requestMetadataOK( path );
190 
191         // --- Verification
192         assertExpectedMetadata( expectedMetadata, actualMetadata );
193     }
194 }