123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585 |
- package org.apache.archiva.webdav;
-
- /*
- * 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.gargoylesoftware.htmlunit.WebRequest;
- import com.gargoylesoftware.htmlunit.WebResponse;
- import org.apache.archiva.configuration.ProxyConnectorConfiguration;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
- import org.springframework.mock.web.MockHttpServletRequest;
- import org.springframework.mock.web.MockHttpServletResponse;
-
- import javax.servlet.http.HttpServletResponse;
- import java.nio.charset.Charset;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.util.ArrayList;
-
- /**
- * RepositoryServletTest
- */
- public class RepositoryServletNoProxyTest
- extends AbstractRepositoryServletTestCase
- {
-
- @Before
- @Override
- public void setUp()
- throws Exception
- {
- super.setUp();
- archivaConfiguration.getConfiguration().setProxyConnectors( new ArrayList<ProxyConnectorConfiguration>() );
- startRepository();
- }
-
- @Override
- @After
- public void tearDown( ) throws Exception
- {
- super.tearDown( );
- }
-
- @Test
- public void testLastModifiedHeaderExists()
- throws Exception
- {
- String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";
-
- Path checksumFile = repoRootInternal.resolve( commonsLangSha1 );
- Files.createDirectories(checksumFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( checksumFile, Charset.defaultCharset(), "dummy-checksum" );
-
- //WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 );
- WebResponse response = getWebResponse( "/repository/internal/" + commonsLangSha1 );
- assertNotNull( response.getResponseHeaderValue( "Last-Modified" ) );
- }
-
- @Test
- public void testGetNoProxyChecksumDefaultLayout()
- throws Exception
- {
- String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";
-
- Path checksumFile = repoRootInternal.resolve(commonsLangSha1);
- Files.createDirectories(checksumFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( checksumFile, Charset.defaultCharset(), "dummy-checksum");
-
- //WebRequest request = new WebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 );
- WebResponse response = getWebResponse( "/repository/internal/" + commonsLangSha1 );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", "dummy-checksum", response.getContentAsString() );
- }
-
- @Test
- public void testGetNoProxyChecksumLegacyLayout()
- throws Exception
- {
- String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";
-
- Path checksumFile = repoRootInternal.resolve(commonsLangSha1);
- Files.createDirectories(checksumFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( checksumFile, Charset.defaultCharset() , "dummy-checksum");
-
- //WebRequest request = new GetMethodWebRequest(
- // "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar.sha1" );
- WebResponse response =
- getWebResponse( "/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar.sha1" );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyVersionedMetadataDefaultLayout()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
- String expectedMetadataContents = "dummy-versioned-metadata";
-
- Path metadataFile = repoRootInternal.resolve(commonsLangMetadata);
- Files.createDirectories(metadataFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( metadataFile, Charset.defaultCharset(), expectedMetadataContents );
-
- //WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
- WebResponse response = getWebResponse( "/repository/internal/" + commonsLangMetadata );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
- }
-
- @Test
- public void testGetNoProxyProjectMetadataDefaultLayout()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
- String expectedMetadataContents = "dummy-project-metadata";
-
- Path metadataFile = repoRootInternal.resolve(commonsLangMetadata);
- Files.createDirectories(metadataFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( metadataFile, Charset.defaultCharset(), expectedMetadataContents );
-
- //WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
- WebResponse response = getWebResponse( "/repository/internal/" + commonsLangMetadata );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
- }
-
- @Test
- public void testGetNoProxyGroupMetadataDefaultLayout()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/maven-metadata.xml";
- String expectedMetadataContents = "dummy-group-metadata";
-
- Path metadataFile = repoRootInternal.resolve(commonsLangMetadata);
- Files.createDirectories(metadataFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( metadataFile, Charset.defaultCharset(), expectedMetadataContents );
-
- //WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
- WebResponse response = getWebResponse( "/repository/internal/" + commonsLangMetadata );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
- }
-
- @Test
- public void testGetNoProxyArtifactDefaultLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
- String expectedArtifactContents = "dummy-commons-lang-artifact";
-
- Path artifactFile = repoRootInternal.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( artifactFile, Charset.defaultCharset(), expectedArtifactContents );
-
- //WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
- WebResponse response = getWebResponse( "/repository/internal/" + commonsLangJar );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedArtifactContents, response.getContentAsString() );
- }
-
- @Test
- public void testGetNoProxyArtifactLegacyLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
- String expectedArtifactContents = "dummy-commons-lang-artifact";
-
- Path artifactFile = repoRootInternal.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( artifactFile, Charset.defaultCharset(), expectedArtifactContents );
-
- //WebRequest request = new GetMethodWebRequest(
- // "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar" );
- WebResponse response = getWebResponse( "/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar" );
- assertResponseNotFound( response );
-
- }
-
- @Test
- public void testGetNoProxySnapshotArtifactDefaultLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- Path artifactFile = repoRootInternal.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( artifactFile, Charset.defaultCharset() , expectedArtifactContents);
-
- //WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
- WebResponse response = getWebResponse( "/repository/internal/" + commonsLangJar );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedArtifactContents, response.getContentAsString() );
- }
-
- @Test
- public void testGetNoProxySnapshotArtifactLegacyLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- Path artifactFile = repoRootInternal.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( artifactFile, Charset.defaultCharset() , expectedArtifactContents);
-
- //WebRequest request = new GetMethodWebRequest(
- // "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" );
- WebResponse response = getWebResponse( "/repository/internal/commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- Path artifactFile = repoRootInternal.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
-
- //WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
- WebResponse response = getWebResponse( "/repository/internal/" + commonsLangJar );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedArtifactContents, response.getContentAsString() );
- }
-
- @Test
- public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayout()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- Path artifactFile = repoRootInternal.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
-
- WebRequest request = new GetMethodWebRequest(
- "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar" );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- /**
- * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
- */
- @Test
- public void testGetNoProxyDualExtensionDefaultLayout()
- throws Exception
- {
- String expectedContents = "the-contents-of-the-dual-extension";
- String dualExtensionPath = "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip";
-
- Path checksumFile = repoRootInternal.resolve(dualExtensionPath);
- Files.createDirectories(checksumFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), expectedContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + dualExtensionPath );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseOK( response );
-
- assertEquals( "Expected file contents", expectedContents, response.getContentAsString() );
- }
-
- @Test
- public void testGetNoProxyDistributionLegacyLayout()
- throws Exception
- {
- String expectedContents = "the-contents-of-the-dual-extension";
- String dualExtensionPath = "org/project/example-presentation/3.2/example-presentation-3.2.zip";
-
- Path checksumFile = repoRootInternal.resolve(dualExtensionPath);
- Files.createDirectories(checksumFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), expectedContents);
-
- WebRequest request = new GetMethodWebRequest(
- "http://machine.com/repository/internal/" + "org.project/distributions/example-presentation-3.2.zip" );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
-
- }
-
- @Test
- public void testGetNoProxyChecksumDefaultLayoutManagedLegacy()
- throws Exception
- {
- String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";
-
- Path checksumFile = repoRootLegacy.resolve( "commons-lang/jars/commons-lang-2.1.jar.sha1" );
- Files.createDirectories(checksumFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( checksumFile, Charset.defaultCharset(), "dummy-checksum" );
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyChecksumLegacyLayoutManagedLegacy()
- throws Exception
- {
- String commonsLangSha1 = "commons-lang/jars/commons-lang-2.1.jar.sha1";
- Path checksumFile = repoRootLegacy.resolve(commonsLangSha1);
- Files.createDirectories(checksumFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), "dummy-checksum");
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyVersionedMetadataDefaultLayoutManagedLegacy()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
- String expectedMetadataContents = "dummy-versioned-metadata";
-
- // TODO: find out what this should be from maven-artifact
- Path metadataFile = repoRootLegacy.resolve(commonsLangMetadata);
- Files.createDirectories(metadataFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(metadataFile, Charset.defaultCharset(), expectedMetadataContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyProjectMetadataDefaultLayoutManagedLegacy()
- throws Exception
- {
- // TODO: find out what it is meant to be from maven-artifact
- String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
- String expectedMetadataContents = "dummy-project-metadata";
-
- Path metadataFile = repoRootLegacy.resolve(commonsLangMetadata);
- Files.createDirectories(metadataFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(metadataFile, Charset.defaultCharset(), expectedMetadataContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyGroupMetadataDefaultLayoutManagedLegacy()
- throws Exception
- {
- String commonsLangMetadata = "commons-lang/maven-metadata.xml";
- String expectedMetadataContents = "dummy-group-metadata";
-
- Path metadataFile = repoRootLegacy.resolve(commonsLangMetadata);
- Files.createDirectories(metadataFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(metadataFile, Charset.defaultCharset(), expectedMetadataContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyArtifactDefaultLayoutManagedLegacy()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
- String expectedArtifactContents = "dummy-commons-lang-artifact";
-
- Path artifactFile = repoRootLegacy.resolve("commons-lang/jars/commons-lang-2.1.jar" );
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyArtifactLegacyLayoutManagedLegacy()
- throws Exception
- {
- String commonsLangJar = "commons-lang/jars/commons-lang-2.1.jar";
- String expectedArtifactContents = "dummy-commons-lang-artifact";
-
- Path artifactFile = repoRootLegacy.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxySnapshotArtifactDefaultLayoutManagedLegacy()
- throws Exception
- {
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- Path artifactFile = repoRootLegacy.resolve( "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" );
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxySnapshotArtifactLegacyLayoutManagedLegacy()
- throws Exception
- {
- String commonsLangJar = "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- Path artifactFile = repoRootLegacy.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayoutManagedLegacy()
- throws Exception
- {
- String filename = "commons-lang-2.1-20050821.023400-1.jar";
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/" + filename;
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- Path artifactFile = repoRootLegacy.resolve( "commons-lang/jars/" + filename );
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayoutManagedLegacy()
- throws Exception
- {
- String commonsLangJar = "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- Path artifactFile = repoRootLegacy.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- /**
- * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
- */
- @Test
- public void testGetNoProxyDualExtensionDefaultLayoutManagedLegacy()
- throws Exception
- {
- String expectedContents = "the-contents-of-the-dual-extension";
- String dualExtensionPath = "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip";
-
- Path checksumFile = repoRootLegacy.resolve( "org.project/distributions/example-presentation-3.2.xml.zip" );
- Files.createDirectories(checksumFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), expectedContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxyDistributionLegacyLayoutManagedLegacy()
- throws Exception
- {
- String expectedContents = "the-contents-of-the-dual-extension";
- String dualExtensionPath = "org.project/distributions/example-presentation-3.2.zip";
-
- Path checksumFile = repoRootLegacy.resolve(dualExtensionPath);
- Files.createDirectories(checksumFile.getParent());
-
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(checksumFile, Charset.defaultCharset(), expectedContents);
-
- WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath );
- WebResponse response = getServletUnitClient().getResponse( request );
- assertResponseNotFound( response );
- }
-
- @Test
- public void testGetNoProxySnapshotRedirectToTimestampedSnapshot()
- throws Exception
- {
- String commonsLangQuery = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
- String commonsLangMetadata = "commons-lang/commons-lang/2.1-SNAPSHOT/maven-metadata.xml";
- String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
- String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";
-
- archivaConfiguration.getConfiguration().getWebapp().getUi().setApplicationUrl("http://localhost");
-
- Path artifactFile = repoRootInternal.resolve(commonsLangJar);
- Files.createDirectories(artifactFile.getParent());
- org.apache.archiva.common.utils.FileUtils.writeStringToFile(artifactFile, Charset.defaultCharset(), expectedArtifactContents);
-
- Path metadataFile = repoRootInternal.resolve(commonsLangMetadata);
- Files.createDirectories(metadataFile.getParent());
- org.apache.archiva.common.utils.FileUtils.writeStringToFile( metadataFile, Charset.defaultCharset(), createVersionMetadata("commons-lang", "commons-lang",
- "2.1-SNAPSHOT", "20050821.023400", "1", "20050821.023400"));
-
- WebRequest webRequest = new GetMethodWebRequest(
- "http://localhost/repository/internal/" + commonsLangQuery );
-
- MockHttpServletRequest request = new MockHttpServletRequest();
- request.setRequestURI( webRequest.getUrl().getPath() );
- request.addHeader( "User-Agent", "Apache Archiva unit test" );
- request.setMethod( webRequest.getHttpMethod().name() );
-
- final MockHttpServletResponse response = execute( request );
-
- assertEquals( HttpServletResponse.SC_MOVED_TEMPORARILY,
- response.getStatus() );
-
- assertEquals( "http://localhost/repository/internal/" + commonsLangJar,
- response.getHeader("Location") );
- }
-
- }
|