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.WebRequest;
24  import com.meterware.httpunit.WebResponse;
25  import org.apache.commons.io.FileUtils;
26  
27  import java.io.File;
28  
29  /**
30   * RepositoryServletTest 
31   *
32   * @version $Id: RepositoryServletNoProxyMetadataTest.java 718864 2008-11-19 06:33:35Z brett $
33   */
34  public class RepositoryServletNoProxyMetadataTest
35      extends AbstractRepositoryServletTestCase
36  {
37      public void testGetVersionMetadataDefaultLayout()
38          throws Exception
39      {
40          String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
41          String expectedMetadataContents = "metadata-for-commons-lang-version-2.1";
42  
43          File checksumFile = new File( repoRootInternal, commonsLangMetadata );
44          checksumFile.getParentFile().mkdirs();
45  
46          FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
47  
48          WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
49          WebResponse response = sc.getResponse( request );
50          assertResponseOK( response );
51  
52          assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
53      }
54  
55      public void testGetProjectMetadataDefaultLayout()
56          throws Exception
57      {
58          String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
59          String expectedMetadataContents = "metadata-for-commons-lang-version-for-project";
60  
61          File checksumFile = new File( repoRootInternal, commonsLangMetadata );
62          checksumFile.getParentFile().mkdirs();
63  
64          FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
65  
66          WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
67          WebResponse response = sc.getResponse( request );
68          assertResponseOK( response );
69  
70          assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
71      }
72  
73      public void testGetGroupMetadataDefaultLayout()
74          throws Exception
75      {
76          String commonsLangMetadata = "commons-lang/maven-metadata.xml";
77          String expectedMetadataContents = "metadata-for-commons-lang-group";
78  
79          File checksumFile = new File( repoRootInternal, commonsLangMetadata );
80          checksumFile.getParentFile().mkdirs();
81  
82          FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
83  
84          WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
85          WebResponse response = sc.getResponse( request );
86          assertResponseOK( response );
87  
88          assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
89      }
90  
91      public void testGetSnapshotVersionMetadataDefaultLayout()
92          throws Exception
93      {
94          String assemblyPluginMetadata = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
95          String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
96  
97          File checksumFile = new File( repoRootInternal, assemblyPluginMetadata );
98          checksumFile.getParentFile().mkdirs();
99  
100         FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
101 
102         WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
103         WebResponse response = sc.getResponse( request );
104         assertResponseOK( response );
105 
106         assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
107     }
108 
109 }