View Javadoc

1   package org.apache.maven.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  import com.meterware.httpunit.GetMethodWebRequest;
23  import com.meterware.httpunit.HttpUnitOptions;
24  import com.meterware.httpunit.WebRequest;
25  import com.meterware.httpunit.WebResponse;
26  
27  import org.apache.maven.archiva.policies.ReleasesPolicy;
28  
29  /**
30   * RepositoryServlet Tests, Proxied, Get of Release Artifacts, with varying policy settings.
31   *
32   * @version $Id: RepositoryServletProxiedReleasePolicyTest.java 590908 2007-11-01 06:21:26Z joakime $
33   */
34  public class RepositoryServletProxiedRelocatedTest
35      extends AbstractRepositoryServletProxiedTestCase
36  {
37      public void testGetProxiedReleaseArtifactPolicyOncePass()
38          throws Exception
39      {
40          // --- Setup
41          setupCentralRemoteRepo();
42          setupCleanInternalRepo();
43  
44          String resourcePath = "org/apache/archiva/test/1.0/test-1.0.jar";
45          String expectedRemoteContents = "archiva-test-1.0|jar-remote-contents";
46          populateRepo( remoteCentral, resourcePath, expectedRemoteContents );
47  
48          resourcePath = "archiva/test/1.0/test-1.0.pom";
49          String pom = "<project>" +
50                  "<modelVersion>4.0.0</modelVersion>" +
51                  "<groupId>archiva</groupId>" +
52                  "<artifactId>test</artifactId>" +
53                  "<version>1.0</version>" +
54                  "<distributionManagement>" +
55                  "<relocation>" +
56                  "<groupId>org.apache.archiva</groupId>" +
57                  "</relocation>" +
58                  "</distributionManagement>" +
59                  "</project>";
60          populateRepo( remoteCentral, resourcePath, pom );
61  
62          resourcePath = "archiva/jars/test-1.0.jar";
63  
64          setupReleaseConnector( REPOID_INTERNAL, remoteCentral, ReleasesPolicy.ONCE );
65          saveConfiguration();
66  
67          // --- Execution
68          // process the response code later, not via an exception.
69          HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
70  
71          WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
72          WebResponse response = sc.getResponse( request );
73  
74          // --- Verification
75          assertResponseOK( response );
76          assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
77      }
78  }