1 package org.apache.maven.archiva.web.repository;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
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;
30 * RepositoryServletTest
32 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
35 public class RepositoryServletNoProxyMetadataTest
36 extends AbstractRepositoryServletTestCase
38 public void testGetVersionMetadataDefaultLayout()
41 String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
42 String expectedMetadataContents = "metadata-for-commons-lang-version-2.1";
44 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
45 checksumFile.getParentFile().mkdirs();
47 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
49 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
50 WebResponse response = sc.getResponse( request );
51 assertResponseOK( response );
53 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
56 public void testGetProjectMetadataDefaultLayout()
59 String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
60 String expectedMetadataContents = "metadata-for-commons-lang-version-for-project";
62 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
63 checksumFile.getParentFile().mkdirs();
65 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
67 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
68 WebResponse response = sc.getResponse( request );
69 assertResponseOK( response );
71 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
74 public void testGetGroupMetadataDefaultLayout()
77 String commonsLangMetadata = "commons-lang/maven-metadata.xml";
78 String expectedMetadataContents = "metadata-for-commons-lang-group";
80 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
81 checksumFile.getParentFile().mkdirs();
83 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
85 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
86 WebResponse response = sc.getResponse( request );
87 assertResponseOK( response );
89 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
92 public void testGetSnapshotVersionMetadataDefaultLayout()
95 String assemblyPluginMetadata = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
96 String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
98 File checksumFile = new File( repoRootInternal, assemblyPluginMetadata );
99 checksumFile.getParentFile().mkdirs();
101 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
103 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
104 WebResponse response = sc.getResponse( request );
105 assertResponseOK( response );
107 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );