aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt <joakime@apache.org>2007-10-31 20:20:02 +0000
committerJoakim Erdfelt <joakime@apache.org>2007-10-31 20:20:02 +0000
commit3e55adbce6c2196b78b87b997e15d7a246572d19 (patch)
treec512b15199446e44cddedc633c2e48ac3ba6fc46
parent0561ccc53d6c8390f7ff4682aa6cda8dfd69d4dc (diff)
downloadarchiva-3e55adbce6c2196b78b87b997e15d7a246572d19.tar.gz
archiva-3e55adbce6c2196b78b87b997e15d7a246572d19.zip
[MRM-577] Metadata aren't generated by archiva.
Adding unit tests to replicate conditions around maven-metadata.xml requests presented in Jira ticket. Not able to reproduce bug (yet). git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@590808 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-web/archiva-webapp/pom.xml10
-rw-r--r--archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedMetadataTestCase.java226
-rw-r--r--archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedTestCase.java99
-rw-r--r--archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyMetadataTest.java93
-rw-r--r--archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataLocalOnlyTest.java98
-rw-r--r--archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataRemoteOnlyTest.java142
6 files changed, 588 insertions, 80 deletions
diff --git a/archiva-web/archiva-webapp/pom.xml b/archiva-web/archiva-webapp/pom.xml
index 159a41294..db05ca8fa 100644
--- a/archiva-web/archiva-webapp/pom.xml
+++ b/archiva-web/archiva-webapp/pom.xml
@@ -192,12 +192,6 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xwork-integration</artifactId>
</dependency>
- <!--
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </dependency>
- -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
@@ -227,6 +221,10 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.plexus.redback</groupId>
<artifactId>redback-keys-memory</artifactId>
<version>${redback.version}</version>
diff --git a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedMetadataTestCase.java b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedMetadataTestCase.java
new file mode 100644
index 000000000..1ad6e20fc
--- /dev/null
+++ b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedMetadataTestCase.java
@@ -0,0 +1,226 @@
+package org.apache.maven.archiva.web.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.custommonkey.xmlunit.DetailedDiff;
+import org.custommonkey.xmlunit.Diff;
+
+/**
+ * Abstract TestCase for RepositoryServlet Tests, Proxied, Get of Metadata.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractRepositoryServletProxiedMetadataTestCase
+ extends AbstractRepositoryServletProxiedTestCase
+{
+ protected RemoteRepoInfo remotePrivateSnapshots;
+
+ protected void assertExpectedMetadata( String expectedMetadata, String actualMetadata )
+ throws Exception
+ {
+ DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
+ if ( !detailedDiff.similar() )
+ {
+ // If it isn't similar, dump the difference.
+ assertEquals( expectedMetadata, actualMetadata );
+ }
+ // XMLAssert.assertXMLEqual( "Expected Metadata:", expectedMetadata, actualMetadata );
+ }
+
+ protected String requestMetadataOK( String path )
+ throws Exception
+ {
+ // process the response code later, not via an exception.
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+ return response.getText();
+ }
+
+ protected String createVersionMetadata( String groupId, String artifactId, String version )
+ {
+ return createVersionMetadata( groupId, artifactId, version, null, null, null );
+ }
+
+ protected String createVersionMetadata( String groupId, String artifactId, String version, String timestamp,
+ String buildNumber, String lastUpdated )
+ {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" );
+ buf.append( "<metadata>\n" );
+ buf.append( " <groupId>" ).append( groupId ).append( "</groupId>\n" );
+ buf.append( " <artifactId>" ).append( artifactId ).append( "</artifactId>\n" );
+ buf.append( " <version>" ).append( version ).append( "</version>\n" );
+
+ boolean hasSnapshot = StringUtils.isNotBlank( timestamp ) || StringUtils.isNotBlank( buildNumber );
+ boolean hasLastUpdated = StringUtils.isNotBlank( lastUpdated );
+
+ if ( hasSnapshot || hasLastUpdated )
+ {
+ buf.append( " <versioning>\n" );
+ if ( hasSnapshot )
+ {
+ buf.append( " <snapshot>\n" );
+ buf.append( " <buildNumber>" ).append( buildNumber ).append( "</buildNumber>\n" );
+ buf.append( " <timestamp>" ).append( timestamp ).append( "</timestamp>\n" );
+ buf.append( " </snapshot>\n" );
+ }
+ if ( hasLastUpdated )
+ {
+ buf.append( " <lastUpdated>" ).append( lastUpdated ).append( "</lastUpdated>\n" );
+ }
+ buf.append( " </versioning>\n" );
+ }
+ buf.append( "</metadata>" );
+
+ return buf.toString();
+ }
+
+ protected String createProjectMetadata( String groupId, String artifactId, String latest, String release,
+ String[] versions )
+ {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" );
+ buf.append( "<metadata>\n" );
+ buf.append( " <groupId>" ).append( groupId ).append( "</groupId>\n" );
+ buf.append( " <artifactId>" ).append( artifactId ).append( "</artifactId>\n" );
+
+ boolean hasLatest = StringUtils.isNotBlank( latest );
+ boolean hasRelease = StringUtils.isNotBlank( release );
+ boolean hasVersions = !ArrayUtils.isEmpty( versions );
+
+ if ( hasLatest || hasRelease || hasVersions )
+ {
+ buf.append( " <versioning>\n" );
+ if ( hasLatest )
+ {
+ buf.append( " <latest>" ).append( latest ).append( "</latest>\n" );
+ }
+ if ( hasRelease )
+ {
+ buf.append( " <release>" ).append( release ).append( "</release>\n" );
+ }
+ if ( hasVersions )
+ {
+ buf.append( " <versions>\n" );
+ for ( String availVersion : versions )
+ {
+ buf.append( " <version>" ).append( availVersion ).append( "</version>\n" );
+ }
+ buf.append( " </versions>\n" );
+ }
+ buf.append( " </versioning>\n" );
+ }
+ buf.append( "</metadata>" );
+
+ return buf.toString();
+ }
+
+ protected void setupPrivateSnapshotsRemoteRepo()
+ throws Exception
+ {
+ remotePrivateSnapshots = createServer( "private-snapshots" );
+
+ assertServerSetupCorrectly( remotePrivateSnapshots );
+ archivaConfiguration.getConfiguration().addRemoteRepository( remotePrivateSnapshots.config );
+ setupCleanRepo( remotePrivateSnapshots.root );
+ }
+
+// private void assertGetProxiedSnapshotMetadata( int expectation, boolean hasManagedCopy,
+// long deltaManagedToRemoteTimestamp )
+// throws Exception
+// {
+// // --- Setup
+// setupSnapshotsRemoteRepo();
+// setupCleanInternalRepo();
+//
+// String resourcePath = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
+// String expectedRemoteContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n"
+// + " <groupId>org.apache.maven.plugins</groupId>\n" + " <artifactId>maven-assembly-plugin</artifactId>\n"
+// + " <version>2.2-beta-2-SNAPSHOT</version>\n" + " <versioning>\n" + " <snapshot>\n"
+// + " <timestamp>20071017.162810</timestamp>\n" + " <buildNumber>20</buildNumber>\n"
+// + " </snapshot>\n" + " <lastUpdated>20071017162814</lastUpdated>\n" + " </versioning>\n"
+// + "</metadata>";
+// String expectedManagedContents = null;
+// File remoteFile = populateRepo( remoteSnapshots, resourcePath, expectedRemoteContents );
+//
+// if ( hasManagedCopy )
+// {
+// expectedManagedContents = "<metadata>\n" + " <groupId>org.apache.maven.plugins</groupId>\n"
+// + " <artifactId>maven-assembly-plugin</artifactId>\n" + " <version>2.2-beta-2-SNAPSHOT</version>\n"
+// + "</metadata>";
+//
+// File managedFile = populateRepo( repoRootInternal, resourcePath, expectedManagedContents );
+// managedFile.setLastModified( remoteFile.lastModified() + deltaManagedToRemoteTimestamp );
+// }
+//
+// setupConnector( REPOID_INTERNAL, remoteSnapshots );
+// saveConfiguration();
+//
+// // --- Execution
+// // process the response code later, not via an exception.
+// HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+//
+// WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
+// WebResponse response = sc.getResponse( request );
+//
+// // --- Verification
+//
+// switch ( expectation )
+// {
+// case EXPECT_MANAGED_CONTENTS:
+// assertResponseOK( response );
+// assertTrue( "Invalid Test Case: Can't expect managed contents with "
+// + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
+// String actualContents = response.getText();
+// XMLAssert.assertXMLEqual( expectedManagedContents, actualContents );
+// // assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
+// break;
+// case EXPECT_REMOTE_CONTENTS:
+// assertResponseOK( response );
+// assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
+// break;
+// case EXPECT_NOT_FOUND:
+// assertResponseNotFound( response );
+// assertManagedFileNotExists( repoRootInternal, resourcePath );
+// break;
+// }
+// }
+
+ protected void tearDown()
+ throws Exception
+ {
+ shutdownServer( remotePrivateSnapshots );
+
+ super.tearDown();
+ }
+}
diff --git a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedTestCase.java b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedTestCase.java
index af811ed48..067ba0e9e 100644
--- a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedTestCase.java
+++ b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/AbstractRepositoryServletProxiedTestCase.java
@@ -93,6 +93,8 @@ public abstract class AbstractRepositoryServletProxiedTestCase
protected RemoteRepoInfo remoteSnapshots;
+ protected RemoteRepoInfo remotePrivateSnapshots;
+
@Override
protected void setUp()
throws Exception
@@ -100,58 +102,57 @@ public abstract class AbstractRepositoryServletProxiedTestCase
super.setUp();
}
- public RemoteRepoInfo createSnapshotsRepo()
+ protected RemoteRepoInfo createServer( String id )
throws Exception
{
- RemoteRepoInfo snapshots = new RemoteRepoInfo();
- snapshots.id = "snapshots";
- snapshots.context = "/snapshots";
- snapshots.root = getTestFile( "target/remote-repos/snapshots/" );
+ RemoteRepoInfo repo = new RemoteRepoInfo();
+ repo.id = id;
+ repo.context = "/" + id;
+ repo.root = getTestFile( "target/remote-repos/" + id + "/" );
// Remove exising root contents.
- if ( snapshots.root.exists() )
+ if ( repo.root.exists() )
{
- FileUtils.deleteDirectory( snapshots.root );
+ FileUtils.deleteDirectory( repo.root );
}
// Establish root directory.
- if ( !snapshots.root.exists() )
+ if ( !repo.root.exists() )
{
- snapshots.root.mkdirs();
+ repo.root.mkdirs();
}
- snapshots.server = new Server();
+ repo.server = new Server();
ContextHandlerCollection contexts = new ContextHandlerCollection();
- snapshots.server.setHandler( contexts );
+ repo.server.setHandler( contexts );
SocketConnector connector = new SocketConnector();
connector.setPort( 0 ); // 0 means, choose and empty port. (we'll find out which, later)
- snapshots.server.setConnectors( new Connector[] { connector } );
+ repo.server.setConnectors( new Connector[] { connector } );
ContextHandler context = new ContextHandler();
- context.setContextPath( snapshots.context );
+ context.setContextPath( repo.context );
+ context.setResourceBase( repo.root.getAbsolutePath() );
context.setAttribute( "dirAllowed", true );
context.setAttribute( "maxCacheSize", 0 );
- context.setResourceBase( snapshots.root.getAbsolutePath() );
ServletHandler servlet = new ServletHandler();
servlet.addServletWithMapping( DefaultServlet.class.getName(), "/" );
context.setHandler( servlet );
contexts.addHandler( context );
- snapshots.server.start();
+ repo.server.start();
int port = connector.getLocalPort();
- snapshots.url = "http://localhost:" + port + snapshots.context;
- System.out.println( "Snapshot HTTP Server started on " + snapshots.url );
+ repo.url = "http://localhost:" + port + repo.context;
+ System.out.println( "Remote HTTP Server started on " + repo.url );
- snapshots.config = createRemoteRepository( snapshots.id, "Testable [" + snapshots.id + "] Remote Repo",
- snapshots.url );
+ repo.config = createRemoteRepository( repo.id, "Testable [" + repo.id + "] Remote Repo", repo.url );
- return snapshots;
+ return repo;
}
- private void assertServerSetupCorrectly( RemoteRepoInfo remoteRepo )
+ protected void assertServerSetupCorrectly( RemoteRepoInfo remoteRepo )
throws Exception
{
WebConversation wc = new WebConversation();
@@ -159,56 +160,6 @@ public abstract class AbstractRepositoryServletProxiedTestCase
assertResponseOK( response );
}
- private RemoteRepoInfo createCentralRepo()
- throws Exception
- {
- RemoteRepoInfo central = new RemoteRepoInfo();
- central.id = "central";
- central.context = "/central";
- central.root = getTestFile( "target/remote-repos/central/" );
-
- // Remove exising root contents.
- if ( central.root.exists() )
- {
- FileUtils.deleteDirectory( central.root );
- }
-
- // Establish root directory.
- if ( !central.root.exists() )
- {
- central.root.mkdirs();
- }
-
- central.server = new Server();
- ContextHandlerCollection contexts = new ContextHandlerCollection();
- central.server.setHandler( contexts );
-
- SocketConnector connector = new SocketConnector();
- connector.setPort( 0 ); // 0 means, choose and empty port. (we'll find out which, later)
-
- central.server.setConnectors( new Connector[] { connector } );
-
- ContextHandler context = new ContextHandler();
- context.setContextPath( central.context );
- context.setResourceBase( central.root.getAbsolutePath() );
- context.setAttribute( "dirAllowed", true );
- context.setAttribute( "maxCacheSize", 0 );
- ServletHandler servlet = new ServletHandler();
- servlet.addServletWithMapping( DefaultServlet.class.getName(), "/" );
- context.setHandler( servlet );
- contexts.addHandler( context );
-
- central.server.start();
-
- int port = connector.getLocalPort();
- central.url = "http://localhost:" + port + central.context;
- System.out.println( "Central HTTP Server started on " + central.url );
-
- central.config = createRemoteRepository( central.id, "Testable [" + central.id + "] Remote Repo", central.url );
-
- return central;
- }
-
private void setupConnector( String repoId, RemoteRepoInfo remoteRepo, String releasesPolicy, String snapshotsPolicy )
{
ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
@@ -222,7 +173,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase
archivaConfiguration.getConfiguration().addProxyConnector( connector );
}
- private void shutdownServer( RemoteRepoInfo remoteRepo )
+ protected void shutdownServer( RemoteRepoInfo remoteRepo )
{
if ( remoteRepo != null )
{
@@ -258,7 +209,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase
protected void setupCentralRemoteRepo()
throws Exception
{
- remoteCentral = createCentralRepo();
+ remoteCentral = createServer( "central" );
assertServerSetupCorrectly( remoteCentral );
archivaConfiguration.getConfiguration().addRemoteRepository( remoteCentral.config );
@@ -283,7 +234,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase
protected void setupSnapshotsRemoteRepo()
throws Exception
{
- remoteSnapshots = createSnapshotsRepo();
+ remoteSnapshots = createServer( "snapshots" );
assertServerSetupCorrectly( remoteSnapshots );
archivaConfiguration.getConfiguration().addRemoteRepository( remoteSnapshots.config );
diff --git a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyMetadataTest.java b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyMetadataTest.java
new file mode 100644
index 000000000..2db6fa32e
--- /dev/null
+++ b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletNoProxyMetadataTest.java
@@ -0,0 +1,93 @@
+package org.apache.maven.archiva.web.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+
+/**
+ * RepositoryServletTest
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletNoProxyMetadataTest
+ extends AbstractRepositoryServletTestCase
+{
+ public void testGetVersionMetadataDefaultLayout()
+ throws Exception
+ {
+ String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
+ String expectedMetadataContents = "metadata-for-commons-lang-version-2.1";
+
+ File checksumFile = new File( repoRootInternal, commonsLangMetadata );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+ public void testGetProjectMetadataDefaultLayout()
+ throws Exception
+ {
+ String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
+ String expectedMetadataContents = "metadata-for-commons-lang-version-for-project";
+
+ File checksumFile = new File( repoRootInternal, commonsLangMetadata );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+ public void testGetSnapshotVersionMetadataDefaultLayout()
+ throws Exception
+ {
+ String assemblyPluginMetadata = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
+ String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
+
+ File checksumFile = new File( repoRootInternal, assemblyPluginMetadata );
+ checksumFile.getParentFile().mkdirs();
+
+ FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+
+ assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
+ }
+
+}
diff --git a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataLocalOnlyTest.java b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataLocalOnlyTest.java
new file mode 100644
index 000000000..c04fbf0f8
--- /dev/null
+++ b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataLocalOnlyTest.java
@@ -0,0 +1,98 @@
+package org.apache.maven.archiva.web.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * RepositoryServlet Tests, Proxied, Get of Metadata, exists on local managed repository only.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletProxiedMetadataLocalOnlyTest
+ extends AbstractRepositoryServletProxiedMetadataTestCase
+{
+ public void testGetProxiedSnapshotVersionMetadataLocalOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
+ String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ "4.0-alpha-1-SNAPSHOT" );
+
+ populateRepo( repoRootInternal, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedVersionMetadataLocalOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-2/maven-metadata.xml";
+ String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ "4.0-alpha-2" );
+
+ populateRepo( repoRootInternal, path, expectedMetadata );
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedProjectMetadataLocalOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/maven-metadata.xml";
+ String version = "1.0-alpha-4";
+ String release = "1.0-alpha-4";
+ String expectedMetadata = createProjectMetadata( "org.apache.archiva", "archivatest-maven-plugin", version,
+ release, new String[] { "1.0-alpha-4" } );
+
+ populateRepo( repoRootInternal, path, expectedMetadata );
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+}
diff --git a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataRemoteOnlyTest.java b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataRemoteOnlyTest.java
new file mode 100644
index 000000000..63eaf2416
--- /dev/null
+++ b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletProxiedMetadataRemoteOnlyTest.java
@@ -0,0 +1,142 @@
+package org.apache.maven.archiva.web.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+/**
+ * RepositoryServlet Tests, Proxied, Get of Metadata, exists on remote repository only.
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryServletProxiedMetadataRemoteOnlyTest
+ extends AbstractRepositoryServletProxiedMetadataTestCase
+{
+ public void testGetProxiedSnapshotVersionMetadataRemoteOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-1-SNAPSHOT/maven-metadata.xml";
+ String version = "4.0-alpha-1-SNAPSHOT";
+ String timestamp = "20040305.112233";
+ String buildNumber = "2";
+ String lastUpdated = "20040305112233";
+ String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ version, timestamp, buildNumber, lastUpdated);
+
+ File metadataFile = populateRepo( remoteSnapshots, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+ saveConfiguration();
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedPluginSnapshotVersionMetadataRemoteOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
+ String version = "2.2-beta-2-SNAPSHOT";
+ String timestamp = "20071017.162810";
+ String buildNumber = "20";
+ String lastUpdated = "20071017162810";
+ String expectedMetadata = createVersionMetadata( "org.apache.maven.plugins", "maven-assembly-plugin", version,
+ timestamp, buildNumber, lastUpdated );
+
+ File metadataFile = populateRepo( remoteSnapshots, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+ saveConfiguration();
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedVersionMetadataRemoteOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/4.0-alpha-2/maven-metadata.xml";
+ String expectedMetadata = createVersionMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ "4.0-alpha-2" );
+
+ File managedFile = populateRepo( remoteSnapshots, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+ saveConfiguration();
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+
+ public void testGetProxiedProjectMetadataRemoteOnly()
+ throws Exception
+ {
+ // --- Setup
+ setupSnapshotsRemoteRepo();
+ setupPrivateSnapshotsRemoteRepo();
+ setupCleanInternalRepo();
+
+ String path = "org/apache/archiva/archivatest-maven-plugin/maven-metadata.xml";
+ String latest = "1.0-alpha-4";
+ String release = "1.0-alpha-4";
+ String expectedMetadata = createProjectMetadata( "org.apache.archiva", "archivatest-maven-plugin",
+ latest, release, new String[] { "1.0-alpha-4" } );
+
+ File managedFile = populateRepo( remoteSnapshots, path, expectedMetadata );
+
+ setupConnector( REPOID_INTERNAL, remoteSnapshots );
+ setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
+ saveConfiguration();
+
+ // --- Execution
+ String actualMetadata = requestMetadataOK( path );
+
+ // --- Verification
+ assertExpectedMetadata( expectedMetadata, actualMetadata );
+ }
+}