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;
31 * RepositoryServletTest
35 public class RepositoryServletNoProxyMetadataTest
36 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 = getServletUnitClient().getResponse( request );
52 assertResponseOK( response );
54 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
58 public void testGetProjectMetadataDefaultLayout()
61 String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
62 String expectedMetadataContents = "metadata-for-commons-lang-version-for-project";
64 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
65 checksumFile.getParentFile().mkdirs();
67 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
69 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
70 WebResponse response = getServletUnitClient().getResponse( request );
71 assertResponseOK( response );
73 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
77 public void testGetGroupMetadataDefaultLayout()
80 String commonsLangMetadata = "commons-lang/maven-metadata.xml";
81 String expectedMetadataContents = "metadata-for-commons-lang-group";
83 File checksumFile = new File( repoRootInternal, commonsLangMetadata );
84 checksumFile.getParentFile().mkdirs();
86 FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
88 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
89 WebResponse response = getServletUnitClient().getResponse( request );
90 assertResponseOK( response );
92 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
96 public void testGetSnapshotVersionMetadataDefaultLayout()
99 String assemblyPluginMetadata = "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, null );
107 WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
108 WebResponse response = getServletUnitClient().getResponse( request );
109 assertResponseOK( response );
111 assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );