1 package org.apache.archiva.webdav;
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;
26 import org.junit.Test;
29 import java.nio.charset.Charset;
32 * RepositoryServletTest
34 public class RepositoryServletNoProxyMetadataTest
35 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, Charset.defaultCharset() );
49 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
50 WebResponse response = getServletUnitClient().getResponse( request );
51 assertResponseOK( response );
53 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, Charset.defaultCharset() );
68 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
69 WebResponse response = getServletUnitClient().getResponse( request );
70 assertResponseOK( response );
72 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
76 public void testGetGroupMetadataDefaultLayout()
79 String commonsLangMetadata = "commons-lang/maven-metadata.xml";
80 String expectedMetadataContents = "metadata-for-commons-lang-group";
82 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
83 checksumFile.getParentFile().mkdirs();
85 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, Charset.defaultCharset() );
87 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
88 WebResponse response = getServletUnitClient().getResponse( request );
89 assertResponseOK( response );
91 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
95 public void testGetSnapshotVersionMetadataDefaultLayout()
98 String assemblyPluginMetadata =
99 "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
100 String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
102 File checksumFile = new File( repoRootInternal, assemblyPluginMetadata );
103 checksumFile.getParentFile().mkdirs();
105 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, Charset.defaultCharset() );
108 new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
109 WebResponse response = getServletUnitClient().getResponse( request );
110 assertResponseOK( response );
112 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );