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.gargoylesoftware.htmlunit.WebRequest;
23 import com.gargoylesoftware.htmlunit.WebResponse;
24 import org.apache.commons.io.FileUtils;
25 import org.junit.Test;
28 import java.nio.charset.Charset;
31 * RepositoryServletTest
33 public class RepositoryServletNoProxyMetadataTest
34 extends AbstractRepositoryServletTestCase
37 public void testGetVersionMetadataDefaultLayout()
40 String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
41 String expectedMetadataContents = "metadata-for-commons-lang-version-2.1";
43 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
44 checksumFile.getParentFile().mkdirs();
46 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, Charset.defaultCharset() );
48 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
49 WebResponse response = getServletUnitClient().getResponse( request );
50 assertResponseOK( response );
52 assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
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, Charset.defaultCharset() );
67 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
68 WebResponse response = getServletUnitClient().getResponse( request );
69 assertResponseOK( response );
71 assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
75 public void testGetGroupMetadataDefaultLayout()
78 String commonsLangMetadata = "commons-lang/maven-metadata.xml";
79 String expectedMetadataContents = "metadata-for-commons-lang-group";
81 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
82 checksumFile.getParentFile().mkdirs();
84 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, Charset.defaultCharset() );
86 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
87 WebResponse response = getServletUnitClient().getResponse( request );
88 assertResponseOK( response );
90 assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
94 public void testGetSnapshotVersionMetadataDefaultLayout()
97 String assemblyPluginMetadata =
98 "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
99 String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
101 File checksumFile = new File( repoRootInternal, assemblyPluginMetadata );
102 checksumFile.getParentFile().mkdirs();
104 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, Charset.defaultCharset() );
107 new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
108 WebResponse response = getServletUnitClient().getResponse( request );
109 assertResponseOK( response );
111 assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );