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;
26 import org.apache.commons.io.FileUtils;
31 * RepositoryServletTest
33 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
36 public class RepositoryServletNoProxyMetadataTest
37 extends AbstractRepositoryServletTestCase
39 public void testGetVersionMetadataDefaultLayout()
42 String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
43 String expectedMetadataContents = "metadata-for-commons-lang-version-2.1";
45 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
46 checksumFile.getParentFile().mkdirs();
48 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
50 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
51 WebResponse response = sc.getResponse( request );
52 assertResponseOK( response );
54 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
57 public void testGetProjectMetadataDefaultLayout()
60 String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
61 String expectedMetadataContents = "metadata-for-commons-lang-version-for-project";
63 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
64 checksumFile.getParentFile().mkdirs();
66 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
68 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
69 WebResponse response = sc.getResponse( request );
70 assertResponseOK( response );
72 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
75 public void testGetSnapshotVersionMetadataDefaultLayout()
78 String assemblyPluginMetadata = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
79 String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
81 File checksumFile = new File( repoRootInternal, assemblyPluginMetadata );
82 checksumFile.getParentFile().mkdirs();
84 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
86 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
87 WebResponse response = sc.getResponse( request );
88 assertResponseOK( response );
90 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );