mirror of https://github.com/apache/archiva.git
plexus-spring remove , fix test compilation in archiva-webdav
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1131428 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fa5bd3e98b
commit
dc25b2f5e6
|
@ -195,4 +195,14 @@ public class MimeTypes
|
|||
IOUtils.closeQuietly( reader );
|
||||
}
|
||||
}
|
||||
|
||||
public String getResource()
|
||||
{
|
||||
return resource;
|
||||
}
|
||||
|
||||
public void setResource( String resource )
|
||||
{
|
||||
this.resource = resource;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.lang.ArrayUtils;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.custommonkey.xmlunit.DetailedDiff;
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import org.junit.Before;
|
||||
|
||||
/**
|
||||
* Abstract TestCase for RepositoryServlet Tests, Proxied, Get of Metadata.
|
||||
|
@ -242,7 +243,8 @@ public abstract class AbstractRepositoryServletProxiedMetadataTestCase
|
|||
// }
|
||||
// }
|
||||
|
||||
protected void tearDown()
|
||||
@Before
|
||||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
shutdownServer( remotePrivateSnapshots );
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.apache.maven.archiva.webdav;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.meterware.httpunit.WebConversation;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
|
||||
|
@ -28,17 +28,18 @@ import org.apache.maven.archiva.policies.CachedFailuresPolicy;
|
|||
import org.apache.maven.archiva.policies.ChecksumPolicy;
|
||||
import org.apache.maven.archiva.policies.ReleasesPolicy;
|
||||
import org.apache.maven.archiva.policies.SnapshotsPolicy;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.ContextHandler;
|
||||
import org.mortbay.jetty.handler.ContextHandlerCollection;
|
||||
import org.mortbay.jetty.servlet.DefaultServlet;
|
||||
import org.mortbay.jetty.servlet.ServletHandler;
|
||||
|
||||
import com.meterware.httpunit.WebConversation;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* AbstractRepositoryServletProxiedTestCase
|
||||
* AbstractRepositoryServletProxiedTestCase
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -89,11 +90,11 @@ public abstract class AbstractRepositoryServletProxiedTestCase
|
|||
protected RemoteRepoInfo remoteCentral;
|
||||
|
||||
protected RemoteRepoInfo remoteSnapshots;
|
||||
|
||||
|
||||
protected RemoteRepoInfo remotePrivateSnapshots;
|
||||
|
||||
@Override
|
||||
protected void setUp()
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
@ -105,7 +106,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase
|
|||
RemoteRepoInfo repo = new RemoteRepoInfo();
|
||||
repo.id = id;
|
||||
repo.context = "/" + id;
|
||||
repo.root = getTestFile( "target/remote-repos/" + id + "/" );
|
||||
repo.root = new File( "target/remote-repos/" + id + "/" );
|
||||
|
||||
// Remove exising root contents.
|
||||
if ( repo.root.exists() )
|
||||
|
@ -152,7 +153,8 @@ public abstract class AbstractRepositoryServletProxiedTestCase
|
|||
assertResponseOK( response );
|
||||
}
|
||||
|
||||
private void setupConnector( String repoId, RemoteRepoInfo remoteRepo, String releasesPolicy, String snapshotsPolicy )
|
||||
private void setupConnector( String repoId, RemoteRepoInfo remoteRepo, String releasesPolicy,
|
||||
String snapshotsPolicy )
|
||||
{
|
||||
ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
|
||||
connector.setSourceRepoId( repoId );
|
||||
|
@ -234,7 +236,8 @@ public abstract class AbstractRepositoryServletProxiedTestCase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
@After
|
||||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
shutdownServer( remoteCentral );
|
||||
|
|
|
@ -24,25 +24,33 @@ import com.meterware.httpunit.WebResponse;
|
|||
import com.meterware.servletunit.ServletRunner;
|
||||
import com.meterware.servletunit.ServletUnitClient;
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* AbstractRepositoryServletTestCase
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
@RunWith( SpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
|
||||
public abstract class AbstractRepositoryServletTestCase
|
||||
extends PlexusInSpringTestCase
|
||||
extends TestCase
|
||||
{
|
||||
protected static final String REPOID_INTERNAL = "internal";
|
||||
|
||||
|
@ -56,6 +64,7 @@ public abstract class AbstractRepositoryServletTestCase
|
|||
|
||||
private ServletRunner sr;
|
||||
|
||||
@Inject
|
||||
protected ArchivaConfiguration archivaConfiguration;
|
||||
|
||||
protected void saveConfiguration()
|
||||
|
@ -155,19 +164,20 @@ public abstract class AbstractRepositoryServletTestCase
|
|||
archivaConfiguration.save( archivaConfiguration.getConfiguration() );
|
||||
}
|
||||
|
||||
protected void setUp()
|
||||
@Before
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
String appserverBase = getTestFile( "target/appserver-base" ).getAbsolutePath();
|
||||
String appserverBase = new File( "target/appserver-base" ).getAbsolutePath();
|
||||
System.setProperty( "appserver.base", appserverBase );
|
||||
|
||||
File testConf = getTestFile( "src/test/resources/repository-archiva.xml" );
|
||||
File testConf = new File( "src/test/resources/repository-archiva.xml" );
|
||||
File testConfDest = new File( appserverBase, "conf/archiva.xml" );
|
||||
FileUtils.copyFile( testConf, testConfDest );
|
||||
|
||||
archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
|
||||
//archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
|
||||
repoRootInternal = new File( appserverBase, "data/repositories/internal" );
|
||||
repoRootLegacy = new File( appserverBase, "data/repositories/legacy" );
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
|
@ -180,19 +190,14 @@ public abstract class AbstractRepositoryServletTestCase
|
|||
|
||||
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
|
||||
|
||||
sr = new ServletRunner( getTestFile( "src/test/resources/WEB-INF/web.xml" ) );
|
||||
sr = new ServletRunner( new File( "src/test/resources/WEB-INF/web.xml" ) );
|
||||
sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() );
|
||||
sc = sr.newClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPlexusConfigLocation()
|
||||
{
|
||||
return "org/apache/maven/archiva/webdav/RepositoryServletTest.xml";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
@After
|
||||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
if ( sc != null )
|
||||
|
@ -215,8 +220,6 @@ public abstract class AbstractRepositoryServletTestCase
|
|||
FileUtils.deleteDirectory( repoRootLegacy );
|
||||
}
|
||||
|
||||
release( archivaConfiguration );
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,7 @@ package org.apache.maven.archiva.webdav;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.jackrabbit.webdav.DavException;
|
||||
import org.apache.jackrabbit.webdav.DavResourceLocator;
|
||||
|
@ -36,17 +32,30 @@ import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
|
|||
import org.apache.maven.archiva.proxy.DefaultRepositoryProxyConnectors;
|
||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.maven.archiva.repository.content.LegacyPathParser;
|
||||
import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.content.RepositoryRequest;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
import org.easymock.MockControl;
|
||||
import org.easymock.classextension.MockClassControl;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ArchivaDavResourceFactoryTest
|
||||
*/
|
||||
@RunWith( SpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
|
||||
public class ArchivaDavResourceFactoryTest
|
||||
extends PlexusInSpringTestCase
|
||||
extends TestCase
|
||||
{
|
||||
private static final String RELEASES_REPO = "releases";
|
||||
|
||||
|
@ -81,7 +90,8 @@ public class ArchivaDavResourceFactoryTest
|
|||
private MockControl repoContentFactoryControl;
|
||||
|
||||
private RepositoryContentFactory repoFactory;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -98,12 +108,10 @@ public class ArchivaDavResourceFactoryTest
|
|||
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
|
||||
|
||||
config = new Configuration();
|
||||
config.addManagedRepository( createManagedRepository( RELEASES_REPO, new File( getBasedir(),
|
||||
"target/test-classes/" +
|
||||
config.addManagedRepository( createManagedRepository( RELEASES_REPO, new File( "target/test-classes/" +
|
||||
RELEASES_REPO ).getPath(),
|
||||
"default" ) );
|
||||
config.addManagedRepository( createManagedRepository( INTERNAL_REPO, new File( getBasedir(),
|
||||
"target/test-classes/" +
|
||||
config.addManagedRepository( createManagedRepository( INTERNAL_REPO, new File( "target/test-classes/" +
|
||||
INTERNAL_REPO ).getPath(),
|
||||
"default" ) );
|
||||
|
||||
|
@ -146,6 +154,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
return repoContent;
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -153,6 +162,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
}
|
||||
|
||||
// MRM-1232 - Unable to get artifacts from repositories which requires Repository Manager role using repository group
|
||||
@Test
|
||||
public void testRepositoryGroupFirstRepositoryRequiresAuthentication()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -210,6 +220,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRepositoryGroupLastRepositoryRequiresAuthentication()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -277,6 +288,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRepositoryGroupArtifactDoesNotExistInAnyOfTheReposAuthenticationDisabled()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -286,8 +298,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
new ArchivaDavLocatorFactory() );
|
||||
|
||||
config.addManagedRepository( createManagedRepository( LOCAL_MIRROR_REPO,
|
||||
new File( getBasedir(),
|
||||
"target/test-classes/local-mirror" ).getPath(),
|
||||
new File( "target/test-classes/local-mirror" ).getPath(),
|
||||
"default" ) );
|
||||
|
||||
List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
|
||||
|
@ -359,6 +370,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
}
|
||||
|
||||
// MRM-1239
|
||||
@Test
|
||||
public void testRequestArtifactMetadataThreePartsRepoHasDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -370,7 +382,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
|
||||
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
|
||||
RepositoryRequest repoRequest = (RepositoryRequest) lookup( RepositoryRequest.class );
|
||||
RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
|
||||
resourceFactory.setRepositoryRequest( repoRequest );
|
||||
|
||||
try
|
||||
|
@ -411,6 +423,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestArtifactMetadataTwoPartsRepoHasDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -422,7 +435,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
|
||||
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
|
||||
RepositoryRequest repoRequest = (RepositoryRequest) lookup( RepositoryRequest.class );
|
||||
RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
|
||||
resourceFactory.setRepositoryRequest( repoRequest );
|
||||
|
||||
try
|
||||
|
@ -452,11 +465,11 @@ public class ArchivaDavResourceFactoryTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestMetadataRepoIsLegacy()
|
||||
throws Exception
|
||||
{
|
||||
config.addManagedRepository( createManagedRepository( LEGACY_REPO, new File( getBasedir(),
|
||||
"target/test-classes/" +
|
||||
config.addManagedRepository( createManagedRepository( LEGACY_REPO, new File( "target/test-classes/" +
|
||||
LEGACY_REPO ).getPath(),
|
||||
"legacy" ) );
|
||||
DavResourceLocator locator =
|
||||
|
@ -466,7 +479,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
|
||||
|
||||
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
|
||||
RepositoryRequest repoRequest = (RepositoryRequest) lookup( RepositoryRequest.class );
|
||||
RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
|
||||
resourceFactory.setRepositoryRequest( repoRequest );
|
||||
|
||||
try
|
||||
|
@ -527,7 +540,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
File target = new File( repository.getRepoRoot(), logicalPath );
|
||||
try
|
||||
{
|
||||
FileUtils.copyFile( new File( getBasedir(), "target/test-classes/maven-metadata.xml" ), target );
|
||||
FileUtils.copyFile( new File( "target/test-classes/maven-metadata.xml" ), target );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -23,7 +23,8 @@ import junit.framework.TestCase;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class ArchivaDavResourceLocatorTest extends TestCase
|
||||
public class ArchivaDavResourceLocatorTest
|
||||
extends TestCase
|
||||
{
|
||||
ArchivaDavLocatorFactory factory;
|
||||
|
||||
|
@ -34,22 +35,22 @@ public class ArchivaDavResourceLocatorTest extends TestCase
|
|||
super.setUp();
|
||||
factory = new ArchivaDavLocatorFactory();
|
||||
}
|
||||
|
||||
|
||||
public void testAvoidDoubleSlashInHref()
|
||||
throws Exception
|
||||
{
|
||||
String prefix = "http://myproxy/";
|
||||
String href = "/repository/internal/";
|
||||
ArchivaDavResourceLocator locator = getLocator(prefix, href);
|
||||
ArchivaDavResourceLocator locator = getLocator( prefix, href );
|
||||
|
||||
assertEquals("internal", locator.getRepositoryId());
|
||||
assertEquals("", locator.getWorkspaceName());
|
||||
assertEquals("", locator.getWorkspacePath());
|
||||
assertEquals("http://myproxy/", locator.getPrefix());
|
||||
assertEquals("http://myproxy/repository/internal/", locator.getHref(false));
|
||||
assertEquals("http://myproxy/repository/internal/", locator.getHref(true));
|
||||
assertEquals("/repository/internal", locator.getResourcePath());
|
||||
assertEquals("/repository/internal", locator.getRepositoryPath());
|
||||
assertEquals( "internal", locator.getRepositoryId() );
|
||||
assertEquals( "", locator.getWorkspaceName() );
|
||||
assertEquals( "", locator.getWorkspacePath() );
|
||||
assertEquals( "http://myproxy/", locator.getPrefix() );
|
||||
assertEquals( "http://myproxy/repository/internal/", locator.getHref( false ) );
|
||||
assertEquals( "http://myproxy/repository/internal/", locator.getHref( true ) );
|
||||
assertEquals( "/repository/internal", locator.getResourcePath() );
|
||||
assertEquals( "/repository/internal", locator.getRepositoryPath() );
|
||||
}
|
||||
|
||||
public void testLocatorWithPrefixHref()
|
||||
|
@ -57,16 +58,16 @@ public class ArchivaDavResourceLocatorTest extends TestCase
|
|||
{
|
||||
String prefix = "http://myproxy/";
|
||||
String href = "/repository/internal";
|
||||
ArchivaDavResourceLocator locator = getLocator(prefix, href);
|
||||
ArchivaDavResourceLocator locator = getLocator( prefix, href );
|
||||
|
||||
assertEquals("internal", locator.getRepositoryId());
|
||||
assertEquals("", locator.getWorkspaceName());
|
||||
assertEquals("", locator.getWorkspacePath());
|
||||
assertEquals("http://myproxy/", locator.getPrefix());
|
||||
assertEquals("http://myproxy/repository/internal", locator.getHref(false));
|
||||
assertEquals("http://myproxy/repository/internal/", locator.getHref(true));
|
||||
assertEquals("/repository/internal", locator.getResourcePath());
|
||||
assertEquals("/repository/internal", locator.getRepositoryPath());
|
||||
assertEquals( "internal", locator.getRepositoryId() );
|
||||
assertEquals( "", locator.getWorkspaceName() );
|
||||
assertEquals( "", locator.getWorkspacePath() );
|
||||
assertEquals( "http://myproxy/", locator.getPrefix() );
|
||||
assertEquals( "http://myproxy/repository/internal", locator.getHref( false ) );
|
||||
assertEquals( "http://myproxy/repository/internal/", locator.getHref( true ) );
|
||||
assertEquals( "/repository/internal", locator.getResourcePath() );
|
||||
assertEquals( "/repository/internal", locator.getRepositoryPath() );
|
||||
}
|
||||
|
||||
public void testLocatorWithHrefThatContainsPrefix()
|
||||
|
@ -74,16 +75,16 @@ public class ArchivaDavResourceLocatorTest extends TestCase
|
|||
{
|
||||
String prefix = "http://myproxy/";
|
||||
String href = "http://myproxy/repository/internal";
|
||||
ArchivaDavResourceLocator locator = getLocator(prefix, href);
|
||||
ArchivaDavResourceLocator locator = getLocator( prefix, href );
|
||||
|
||||
assertEquals("internal", locator.getRepositoryId());
|
||||
assertEquals("", locator.getWorkspaceName());
|
||||
assertEquals("", locator.getWorkspacePath());
|
||||
assertEquals("http://myproxy/", locator.getPrefix());
|
||||
assertEquals("http://myproxy/repository/internal", locator.getHref(false));
|
||||
assertEquals("http://myproxy/repository/internal/", locator.getHref(true));
|
||||
assertEquals("/repository/internal", locator.getResourcePath());
|
||||
assertEquals("/repository/internal", locator.getRepositoryPath());
|
||||
assertEquals( "internal", locator.getRepositoryId() );
|
||||
assertEquals( "", locator.getWorkspaceName() );
|
||||
assertEquals( "", locator.getWorkspacePath() );
|
||||
assertEquals( "http://myproxy/", locator.getPrefix() );
|
||||
assertEquals( "http://myproxy/repository/internal", locator.getHref( false ) );
|
||||
assertEquals( "http://myproxy/repository/internal/", locator.getHref( true ) );
|
||||
assertEquals( "/repository/internal", locator.getResourcePath() );
|
||||
assertEquals( "/repository/internal", locator.getRepositoryPath() );
|
||||
}
|
||||
|
||||
public void testLocatorWithRootHref()
|
||||
|
@ -91,20 +92,20 @@ public class ArchivaDavResourceLocatorTest extends TestCase
|
|||
{
|
||||
String prefix = "http://myproxy/";
|
||||
String href = "/";
|
||||
ArchivaDavResourceLocator locator = getLocator(prefix, href);
|
||||
ArchivaDavResourceLocator locator = getLocator( prefix, href );
|
||||
|
||||
assertEquals("", locator.getRepositoryId());
|
||||
assertEquals("", locator.getWorkspaceName());
|
||||
assertEquals("", locator.getWorkspacePath());
|
||||
assertEquals("http://myproxy/", locator.getPrefix());
|
||||
assertEquals("http://myproxy/", locator.getHref(false));
|
||||
assertEquals("http://myproxy/", locator.getHref(true));
|
||||
assertEquals("/", locator.getResourcePath());
|
||||
assertEquals("/", locator.getRepositoryPath());
|
||||
assertEquals( "", locator.getRepositoryId() );
|
||||
assertEquals( "", locator.getWorkspaceName() );
|
||||
assertEquals( "", locator.getWorkspacePath() );
|
||||
assertEquals( "http://myproxy/", locator.getPrefix() );
|
||||
assertEquals( "http://myproxy/", locator.getHref( false ) );
|
||||
assertEquals( "http://myproxy/", locator.getHref( true ) );
|
||||
assertEquals( "/", locator.getResourcePath() );
|
||||
assertEquals( "/", locator.getRepositoryPath() );
|
||||
}
|
||||
|
||||
|
||||
private ArchivaDavResourceLocator getLocator( String prefix, String href )
|
||||
{
|
||||
return (ArchivaDavResourceLocator)factory.createResourceLocator(prefix, href);
|
||||
return (ArchivaDavResourceLocator) factory.createResourceLocator( prefix, href );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,23 +19,7 @@ package org.apache.maven.archiva.webdav;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.Principal;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.jackrabbit.webdav.DavSessionProvider;
|
||||
import org.apache.jackrabbit.webdav.WebdavRequest;
|
||||
import org.apache.jackrabbit.webdav.WebdavRequestImpl;
|
||||
|
@ -51,10 +35,25 @@ import org.codehaus.plexus.redback.system.SecuritySession;
|
|||
import org.codehaus.plexus.redback.users.User;
|
||||
import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator;
|
||||
|
||||
public class ArchivaDavSessionProviderTest extends TestCase
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.Principal;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class ArchivaDavSessionProviderTest
|
||||
extends TestCase
|
||||
{
|
||||
private DavSessionProvider sessionProvider;
|
||||
|
||||
|
||||
private WebdavRequest request;
|
||||
|
||||
@Override
|
||||
|
@ -63,131 +62,142 @@ public class ArchivaDavSessionProviderTest extends TestCase
|
|||
{
|
||||
super.setUp();
|
||||
sessionProvider = new ArchivaDavSessionProvider( new ServletAuthenticatorMock(), new HttpAuthenticatorMock() );
|
||||
request = new WebdavRequestImpl(new HttpServletRequestMock(), null);
|
||||
request = new WebdavRequestImpl( new HttpServletRequestMock(), null );
|
||||
}
|
||||
|
||||
|
||||
public void testAttachSession()
|
||||
throws Exception
|
||||
{
|
||||
assertNull(request.getDavSession());
|
||||
sessionProvider.attachSession(request);
|
||||
assertNotNull(request.getDavSession());
|
||||
assertNull( request.getDavSession() );
|
||||
sessionProvider.attachSession( request );
|
||||
assertNotNull( request.getDavSession() );
|
||||
}
|
||||
|
||||
|
||||
public void testReleaseSession()
|
||||
throws Exception
|
||||
{
|
||||
assertNull(request.getDavSession());
|
||||
sessionProvider.attachSession(request);
|
||||
assertNotNull(request.getDavSession());
|
||||
|
||||
sessionProvider.releaseSession(request);
|
||||
assertNull(request.getDavSession());
|
||||
assertNull( request.getDavSession() );
|
||||
sessionProvider.attachSession( request );
|
||||
assertNotNull( request.getDavSession() );
|
||||
|
||||
sessionProvider.releaseSession( request );
|
||||
assertNull( request.getDavSession() );
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private class HttpServletRequestMock implements HttpServletRequest
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
private class HttpServletRequestMock
|
||||
implements HttpServletRequest
|
||||
{
|
||||
public Object getAttribute(String arg0) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public Object getAttribute( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public Enumeration getAttributeNames() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public Enumeration getAttributeNames()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public String getCharacterEncoding()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public int getContentLength() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public int getContentLength()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public String getContentType()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public ServletInputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getLocalAddr() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public String getLocalAddr()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getLocalName() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public String getLocalName()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public int getLocalPort() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public int getLocalPort()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public Locale getLocale()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public Enumeration getLocales()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getParameter(String arg0)
|
||||
public String getParameter( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public Map getParameterMap()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public Enumeration getParameterNames()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String[] getParameterValues(String arg0)
|
||||
public String[] getParameterValues( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public String getProtocol()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public BufferedReader getReader()
|
||||
throws IOException
|
||||
throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getRealPath(String arg0)
|
||||
public String getRealPath( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getRemoteAddr()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getRemoteHost()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public int getRemotePort()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public RequestDispatcher getRequestDispatcher(String arg0)
|
||||
public RequestDispatcher getRequestDispatcher( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getScheme()
|
||||
|
@ -197,39 +207,39 @@ public class ArchivaDavSessionProviderTest extends TestCase
|
|||
|
||||
public String getServerName()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public int getServerPort()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public boolean isSecure()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public void removeAttribute(String arg0)
|
||||
public void removeAttribute( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public void setAttribute(String arg0, Object arg1)
|
||||
public void setAttribute( String arg0, Object arg1 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public void setCharacterEncoding(String arg0)
|
||||
public void setCharacterEncoding( String arg0 )
|
||||
throws UnsupportedEncodingException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getAuthType()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getContextPath()
|
||||
|
@ -239,56 +249,57 @@ public class ArchivaDavSessionProviderTest extends TestCase
|
|||
|
||||
public Cookie[] getCookies()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public long getDateHeader(String arg0)
|
||||
public long getDateHeader( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getHeader(String arg0) {
|
||||
public String getHeader( String arg0 )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public Enumeration getHeaderNames()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public Enumeration getHeaders(String arg0)
|
||||
public Enumeration getHeaders( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public int getIntHeader(String arg0)
|
||||
public int getIntHeader( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getMethod()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getPathInfo()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getPathTranslated()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getQueryString()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getRemoteUser()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getRequestURI()
|
||||
|
@ -296,65 +307,66 @@ public class ArchivaDavSessionProviderTest extends TestCase
|
|||
return "/";
|
||||
}
|
||||
|
||||
public StringBuffer getRequestURL()
|
||||
public StringBuffer getRequestURL()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getRequestedSessionId()
|
||||
public String getRequestedSessionId()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public String getServletPath()
|
||||
public String getServletPath()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public HttpSession getSession(boolean arg0)
|
||||
public HttpSession getSession( boolean arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public HttpSession getSession()
|
||||
public HttpSession getSession()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public Principal getUserPrincipal()
|
||||
public Principal getUserPrincipal()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public boolean isRequestedSessionIdFromCookie()
|
||||
public boolean isRequestedSessionIdFromCookie()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public boolean isRequestedSessionIdFromURL()
|
||||
public boolean isRequestedSessionIdFromURL()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public boolean isRequestedSessionIdFromUrl()
|
||||
public boolean isRequestedSessionIdFromUrl()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public boolean isRequestedSessionIdValid()
|
||||
public boolean isRequestedSessionIdValid()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
|
||||
public boolean isUserInRole(String arg0)
|
||||
public boolean isUserInRole( String arg0 )
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
}
|
||||
|
||||
private class ServletAuthenticatorMock implements ServletAuthenticator
|
||||
|
||||
private class ServletAuthenticatorMock
|
||||
implements ServletAuthenticator
|
||||
{
|
||||
public boolean isAuthenticated(HttpServletRequest arg0, AuthenticationResult arg1)
|
||||
public boolean isAuthenticated( HttpServletRequest arg0, AuthenticationResult arg1 )
|
||||
throws AuthenticationException, AccountLockedException, MustChangePasswordException
|
||||
{
|
||||
return true;
|
||||
|
@ -371,56 +383,58 @@ public class ArchivaDavSessionProviderTest extends TestCase
|
|||
throws UnauthorizedException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class HttpAuthenticatorMock extends HttpAuthenticator
|
||||
|
||||
private class HttpAuthenticatorMock
|
||||
extends HttpAuthenticator
|
||||
{
|
||||
@Override
|
||||
public void challenge(HttpServletRequest arg0, HttpServletResponse arg1, String arg2, AuthenticationException arg3)
|
||||
public void challenge( HttpServletRequest arg0, HttpServletResponse arg1, String arg2,
|
||||
AuthenticationException arg3 )
|
||||
throws IOException
|
||||
{
|
||||
//Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationResult getAuthenticationResult(HttpServletRequest arg0, HttpServletResponse arg1)
|
||||
public AuthenticationResult getAuthenticationResult( HttpServletRequest arg0, HttpServletResponse arg1 )
|
||||
throws AuthenticationException, AccountLockedException, MustChangePasswordException
|
||||
{
|
||||
return new AuthenticationResult();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public AuthenticationResult authenticate(AuthenticationDataSource arg0, HttpSession httpSession)
|
||||
public AuthenticationResult authenticate( AuthenticationDataSource arg0, HttpSession httpSession )
|
||||
throws AuthenticationException, AccountLockedException, MustChangePasswordException
|
||||
{
|
||||
return new AuthenticationResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authenticate(HttpServletRequest arg0, HttpServletResponse arg1)
|
||||
public void authenticate( HttpServletRequest arg0, HttpServletResponse arg1 )
|
||||
throws AuthenticationException
|
||||
{
|
||||
//Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecuritySession getSecuritySession(HttpSession httpSession)
|
||||
public SecuritySession getSecuritySession( HttpSession httpSession )
|
||||
{
|
||||
return super.getSecuritySession(httpSession);
|
||||
return super.getSecuritySession( httpSession );
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getSessionUser(HttpSession httpSession)
|
||||
public User getSessionUser( HttpSession httpSession )
|
||||
{
|
||||
return super.getSessionUser(httpSession);
|
||||
return super.getSessionUser( httpSession );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlreadyAuthenticated(HttpSession httpSession)
|
||||
public boolean isAlreadyAuthenticated( HttpSession httpSession )
|
||||
{
|
||||
return super.isAlreadyAuthenticated(httpSession);
|
||||
}
|
||||
return super.isAlreadyAuthenticated( httpSession );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.codehaus.plexus.redback.system.SecuritySystem;
|
|||
import org.codehaus.plexus.redback.users.UserManager;
|
||||
import org.codehaus.plexus.redback.users.UserNotFoundException;
|
||||
import org.codehaus.plexus.redback.users.memory.MemoryUserManager;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* BypassSecuritySystem - used to bypass the security system for testing reasons and allow
|
||||
|
@ -43,9 +44,10 @@ import org.codehaus.plexus.redback.users.memory.MemoryUserManager;
|
|||
*
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component
|
||||
* plexus.component
|
||||
* role="org.codehaus.plexus.redback.system.SecuritySystem"
|
||||
*/
|
||||
@Service("securitySystem#bypass")
|
||||
public class BypassSecuritySystem
|
||||
extends DefaultSecuritySystem
|
||||
implements SecuritySystem
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.archiva.webdav;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.archiva.audit.AuditListener;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.jackrabbit.webdav.DavException;
|
||||
|
@ -36,17 +37,25 @@ import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
|
|||
import org.apache.jackrabbit.webdav.lock.Type;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.webdav.util.MimeTypes;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
import org.codehaus.plexus.spring.PlexusToSpringUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
@RunWith( SpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
|
||||
public class DavResourceTest
|
||||
extends PlexusInSpringTestCase
|
||||
extends TestCase
|
||||
{
|
||||
private DavSession session;
|
||||
|
||||
@Inject
|
||||
private MimeTypes mimeTypes;
|
||||
|
||||
private ArchivaDavResourceLocator resourceLocator;
|
||||
|
@ -66,13 +75,13 @@ public class DavResourceTest
|
|||
private ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
|
||||
|
||||
@Override
|
||||
protected void setUp()
|
||||
@Before
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
session = new ArchivaDavSession();
|
||||
mimeTypes = (MimeTypes) getApplicationContext().getBean( PlexusToSpringUtils.buildSpringId( MimeTypes.class ) );
|
||||
baseDir = getTestFile( "target/DavResourceTest" );
|
||||
baseDir = new File( "target/DavResourceTest" );
|
||||
baseDir.mkdirs();
|
||||
myResource = new File( baseDir, "myresource.jar" );
|
||||
assertTrue( "Could not create " + myResource.getAbsolutePath(), myResource.createNewFile() );
|
||||
|
@ -85,12 +94,11 @@ public class DavResourceTest
|
|||
resource.addLockManager( lockManager );
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
release( mimeTypes );
|
||||
FileUtils.deleteDirectory( baseDir );
|
||||
}
|
||||
|
||||
|
@ -100,6 +108,7 @@ public class DavResourceTest
|
|||
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(), null );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteNonExistantResourceShould404()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -116,6 +125,7 @@ public class DavResourceTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCollection()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -133,6 +143,7 @@ public class DavResourceTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteResource()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -141,12 +152,14 @@ public class DavResourceTest
|
|||
assertFalse( myResource.exists() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsLockable()
|
||||
{
|
||||
assertTrue( resource.isLockable( Type.WRITE, Scope.EXCLUSIVE ) );
|
||||
assertFalse( resource.isLockable( Type.WRITE, Scope.SHARED ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLock()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -158,6 +171,7 @@ public class DavResourceTest
|
|||
assertEquals( 1, resource.getLocks().length );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLockIfResourceUnlockable()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -176,6 +190,7 @@ public class DavResourceTest
|
|||
assertEquals( 0, resource.getLocks().length );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLock()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -191,6 +206,7 @@ public class DavResourceTest
|
|||
assertNull( resource.getLock( Type.WRITE, Scope.SHARED ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshLockThrowsExceptionIfNoLockIsPresent()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -211,6 +227,7 @@ public class DavResourceTest
|
|||
assertEquals( 0, resource.getLocks().length );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshLock()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -229,6 +246,7 @@ public class DavResourceTest
|
|||
assertEquals( 1, resource.getLocks().length );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnlock()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -247,6 +265,7 @@ public class DavResourceTest
|
|||
assertEquals( 0, resource.getLocks().length );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnlockThrowsDavExceptionIfNotLocked()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -271,6 +290,7 @@ public class DavResourceTest
|
|||
assertEquals( 1, resource.getLocks().length );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnlockThrowsDavExceptionIfResourceNotLocked()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -19,22 +19,33 @@ package org.apache.maven.archiva.webdav;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.maven.archiva.webdav.util.MimeTypes;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* ArchivaMimeTypesTest
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
@RunWith( SpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
|
||||
public class MimeTypesLoaderTest
|
||||
extends PlexusInSpringTestCase
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
@Inject
|
||||
MimeTypes mimeTypes;
|
||||
|
||||
@Test
|
||||
public void testArchivaTypes()
|
||||
throws Exception
|
||||
{
|
||||
lookup( MimeTypes.class );
|
||||
MimeTypes mimeTypes = (MimeTypes) lookup( MimeTypes.class );
|
||||
assertNotNull( mimeTypes );
|
||||
|
||||
// Test for some added types.
|
||||
|
|
|
@ -23,6 +23,8 @@ import com.meterware.httpunit.GetMethodWebRequest;
|
|||
import com.meterware.httpunit.WebLink;
|
||||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -37,7 +39,8 @@ public class RepositoryServletBrowseTest
|
|||
extends AbstractRepositoryServletTestCase
|
||||
{
|
||||
@Override
|
||||
protected void setUp()
|
||||
@Before
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
@ -47,7 +50,8 @@ public class RepositoryServletBrowseTest
|
|||
new File( repoRootInternal, "net/sourceforge" ).mkdirs();
|
||||
new File( repoRootInternal, "commons-lang" ).mkdirs();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBrowse()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -60,7 +64,8 @@ public class RepositoryServletBrowseTest
|
|||
String expectedLinks[] = new String[] { "commons-lang/", "net/", "org/" };
|
||||
assertLinks(expectedLinks, response.getLinks());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBrowseSubdirectory()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -72,6 +77,7 @@ public class RepositoryServletBrowseTest
|
|||
assertLinks(expectedLinks, response.getLinks());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDirectoryWhichHasMatchingFile() //MRM-893
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.webdav.httpunit.MkColMethodWebRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -41,7 +42,8 @@ public class RepositoryServletDeployTest
|
|||
extends AbstractRepositoryServletTestCase
|
||||
{
|
||||
private static final String ARTIFACT_DEFAULT_LAYOUT = "/path/to/artifact/1.0.0/artifact-1.0.0.jar";
|
||||
|
||||
|
||||
@Test
|
||||
public void testPutWithMissingParentCollection()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -65,6 +67,7 @@ public class RepositoryServletDeployTest
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testReleaseArtifactsRedeploymentValidPath()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -99,7 +102,8 @@ public class RepositoryServletDeployTest
|
|||
response = sc.getResponse( request );
|
||||
assertResponseConflictError( response );
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReleaseArtifactsRedeploymentIsAllowed()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -139,7 +143,8 @@ public class RepositoryServletDeployTest
|
|||
response = sc.getResponse( request );
|
||||
assertResponseNoContent( response );
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReleaseArtifactsRedeploymentInvalidPath()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -174,7 +179,8 @@ public class RepositoryServletDeployTest
|
|||
response = sc.getResponse( request );
|
||||
assertResponseNoContent( response );
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReleaseArtifactsRedeploymentArtifactIsSnapshot()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -209,7 +215,8 @@ public class RepositoryServletDeployTest
|
|||
response = sc.getResponse( request );
|
||||
assertResponseNoContent( response );
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMkColWithMissingParentCollectionFails()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.meterware.httpunit.GetMethodWebRequest;
|
|||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -34,6 +35,7 @@ import java.io.File;
|
|||
public class RepositoryServletNoProxyMetadataTest
|
||||
extends AbstractRepositoryServletTestCase
|
||||
{
|
||||
@Test
|
||||
public void testGetVersionMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -52,6 +54,7 @@ public class RepositoryServletNoProxyMetadataTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProjectMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -70,6 +73,7 @@ public class RepositoryServletNoProxyMetadataTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGroupMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -88,6 +92,7 @@ public class RepositoryServletNoProxyMetadataTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSnapshotVersionMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.meterware.httpunit.GetMethodWebRequest;
|
|||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -34,6 +35,7 @@ import java.io.File;
|
|||
public class RepositoryServletNoProxyTest
|
||||
extends AbstractRepositoryServletTestCase
|
||||
{
|
||||
@Test
|
||||
public void testLastModifiedHeaderExists()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -50,6 +52,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertNotNull( response.getHeaderField( "last-modified" ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyChecksumDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -67,6 +70,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyChecksumLegacyLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -85,6 +89,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyVersionedMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -103,6 +108,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyProjectMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -121,6 +127,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyGroupMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -139,6 +146,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyArtifactDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -157,6 +165,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyArtifactLegacyLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -176,6 +185,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxySnapshotArtifactDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -194,6 +204,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxySnapshotArtifactLegacyLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -213,6 +224,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -231,6 +243,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -253,6 +266,7 @@ public class RepositoryServletNoProxyTest
|
|||
/**
|
||||
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
|
||||
*/
|
||||
@Test
|
||||
public void testGetNoProxyDualExtensionDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -271,6 +285,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyDistributionLegacyLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -290,6 +305,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyChecksumDefaultLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -307,6 +323,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyChecksumLegacyLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -323,6 +340,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyVersionedMetadataDefaultLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -342,6 +360,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyProjectMetadataDefaultLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -361,6 +380,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyGroupMetadataDefaultLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -379,6 +399,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyArtifactDefaultLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -397,6 +418,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyArtifactLegacyLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -415,6 +437,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxySnapshotArtifactDefaultLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -433,6 +456,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxySnapshotArtifactLegacyLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -451,6 +475,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -470,6 +495,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -491,6 +517,7 @@ public class RepositoryServletNoProxyTest
|
|||
/**
|
||||
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
|
||||
*/
|
||||
@Test
|
||||
public void testGetNoProxyDualExtensionDefaultLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -509,6 +536,7 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedContents, response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoProxyDistributionLegacyLayoutManagedLegacy()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.maven.archiva.webdav;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* RepositoryServlet Tests, Proxied, Get of Metadata, exists on local managed repository only.
|
||||
*
|
||||
|
@ -27,6 +29,8 @@ package org.apache.maven.archiva.webdav;
|
|||
public class RepositoryServletProxiedMetadataLocalOnlyTest
|
||||
extends AbstractRepositoryServletProxiedMetadataTestCase
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotVersionMetadataLocalOnly()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -51,6 +55,7 @@ public class RepositoryServletProxiedMetadataLocalOnlyTest
|
|||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedVersionMetadataLocalOnly()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -72,6 +77,7 @@ public class RepositoryServletProxiedMetadataLocalOnlyTest
|
|||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedProjectMetadataLocalOnly()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -95,6 +101,7 @@ public class RepositoryServletProxiedMetadataLocalOnlyTest
|
|||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedGroupMetadataLocalOnly()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.apache.maven.archiva.webdav;
|
|||
*/
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* RepositoryServlet Tests, Proxied, Get of Metadata, exists on remote repository only.
|
||||
*
|
||||
|
@ -28,6 +30,7 @@ package org.apache.maven.archiva.webdav;
|
|||
public class RepositoryServletProxiedMetadataRemoteOnlyTest
|
||||
extends AbstractRepositoryServletProxiedMetadataTestCase
|
||||
{
|
||||
@Test
|
||||
public void testGetProxiedSnapshotVersionMetadataRemoteOnly()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -57,6 +60,7 @@ public class RepositoryServletProxiedMetadataRemoteOnlyTest
|
|||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedPluginSnapshotVersionMetadataRemoteOnly()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -86,6 +90,7 @@ public class RepositoryServletProxiedMetadataRemoteOnlyTest
|
|||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedVersionMetadataRemoteOnly()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -111,6 +116,7 @@ public class RepositoryServletProxiedMetadataRemoteOnlyTest
|
|||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedProjectMetadataRemoteOnly()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -138,6 +144,7 @@ public class RepositoryServletProxiedMetadataRemoteOnlyTest
|
|||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedGroupMetadataRemoteOnly()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.meterware.httpunit.GetMethodWebRequest;
|
|||
import com.meterware.httpunit.HttpUnitOptions;
|
||||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* RepositoryServlet Tests, Proxied, Get of resources that are not artifacts or metadata, with varying policy settings.
|
||||
|
@ -45,6 +46,7 @@ public class RepositoryServletProxiedPassthroughTest
|
|||
|
||||
private static final String PATH_ASC = "org/apache/archiva/test/1.0/test-1.0.jar.asc";
|
||||
|
||||
@Test
|
||||
public void testGetProxiedManagedNewerSha1()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -52,6 +54,7 @@ public class RepositoryServletProxiedPassthroughTest
|
|||
CONTENT_SHA1 );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedManagedOlderSha1()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -59,18 +62,21 @@ public class RepositoryServletProxiedPassthroughTest
|
|||
CONTENT_SHA1 );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedNoManagedContentSha1()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedResource( EXPECT_REMOTE_CONTENTS, NO_MANAGED_COPY, PATH_SHA1, CONTENT_SHA1 );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedEqualSha1()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedResource( EXPECT_MANAGED_CONTENTS, HAS_MANAGED_COPY, PATH_SHA1, CONTENT_SHA1 );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedManagedNewerAsc()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -78,6 +84,7 @@ public class RepositoryServletProxiedPassthroughTest
|
|||
CONTENT_ASC );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedManagedOlderAsc()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -85,12 +92,14 @@ public class RepositoryServletProxiedPassthroughTest
|
|||
CONTENT_ASC );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedNoManagedContentAsc()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedResource( EXPECT_REMOTE_CONTENTS, NO_MANAGED_COPY, PATH_ASC, CONTENT_ASC );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedEqualAsc()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.meterware.httpunit.WebRequest;
|
|||
import com.meterware.httpunit.WebResponse;
|
||||
|
||||
import org.apache.maven.archiva.policies.SnapshotsPolicy;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -36,6 +37,8 @@ import java.io.File;
|
|||
public class RepositoryServletProxiedPluginSnapshotPolicyTest
|
||||
extends AbstractRepositoryServletProxiedTestCase
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -43,6 +46,7 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest
|
|||
HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -50,12 +54,14 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest
|
|||
( OLDER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyAlwaysNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyDailyFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -63,12 +69,14 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest
|
|||
( NEWER * ONE_MINUTE ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -76,6 +84,7 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest
|
|||
( OLDER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -83,12 +92,14 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest
|
|||
HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -96,6 +107,7 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest
|
|||
HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -103,12 +115,14 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest
|
|||
( NEWER * ONE_MINUTE ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -116,18 +130,21 @@ public class RepositoryServletProxiedPluginSnapshotPolicyTest
|
|||
( OLDER * OVER_ONE_HOUR ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyOnceFail()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ONCE, HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyOnceNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyOncePass()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.meterware.httpunit.WebRequest;
|
|||
import com.meterware.httpunit.WebResponse;
|
||||
|
||||
import org.apache.maven.archiva.policies.ReleasesPolicy;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -36,6 +37,7 @@ import java.io.File;
|
|||
public class RepositoryServletProxiedReleasePolicyTest
|
||||
extends AbstractRepositoryServletProxiedTestCase
|
||||
{
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyAlwaysManagedNewer()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -43,6 +45,7 @@ public class RepositoryServletProxiedReleasePolicyTest
|
|||
( NEWER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyAlwaysManagedOlder()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -50,12 +53,14 @@ public class RepositoryServletProxiedReleasePolicyTest
|
|||
( OLDER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyAlwaysNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ALWAYS, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyDailyFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -63,12 +68,14 @@ public class RepositoryServletProxiedReleasePolicyTest
|
|||
( NEWER * ONE_MINUTE ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyDailyNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.DAILY, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyDailyPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -76,24 +83,28 @@ public class RepositoryServletProxiedReleasePolicyTest
|
|||
( OLDER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyRejectFail()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.NEVER, HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyRejectNoManagedContentFail()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_NOT_FOUND, ReleasesPolicy.NEVER, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyRejectPass()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.NEVER, HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyHourlyFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -101,12 +112,14 @@ public class RepositoryServletProxiedReleasePolicyTest
|
|||
( NEWER * ONE_MINUTE ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyHourlyNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.HOURLY, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyHourlyPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -114,18 +127,21 @@ public class RepositoryServletProxiedReleasePolicyTest
|
|||
( OLDER * OVER_ONE_HOUR ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyOnceFail()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, ReleasesPolicy.ONCE, HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyOnceNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.ONCE, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyOncePass()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.meterware.httpunit.WebRequest;
|
|||
import com.meterware.httpunit.WebResponse;
|
||||
|
||||
import org.apache.maven.archiva.policies.ReleasesPolicy;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* RepositoryServlet Tests, Proxied, Get of Release Artifacts, with varying policy settings.
|
||||
|
@ -34,6 +35,8 @@ import org.apache.maven.archiva.policies.ReleasesPolicy;
|
|||
public class RepositoryServletProxiedRelocatedTest
|
||||
extends AbstractRepositoryServletProxiedTestCase
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testGetProxiedReleaseArtifactPolicyOncePass()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.meterware.httpunit.WebRequest;
|
|||
import com.meterware.httpunit.WebResponse;
|
||||
|
||||
import org.apache.maven.archiva.policies.SnapshotsPolicy;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -36,6 +37,8 @@ import java.io.File;
|
|||
public class RepositoryServletProxiedSnapshotPolicyTest
|
||||
extends AbstractRepositoryServletProxiedTestCase
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -43,6 +46,7 @@ public class RepositoryServletProxiedSnapshotPolicyTest
|
|||
HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -50,12 +54,14 @@ public class RepositoryServletProxiedSnapshotPolicyTest
|
|||
( OLDER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyAlwaysNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyDailyFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -63,12 +69,14 @@ public class RepositoryServletProxiedSnapshotPolicyTest
|
|||
( NEWER * ONE_MINUTE ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -76,6 +84,7 @@ public class RepositoryServletProxiedSnapshotPolicyTest
|
|||
( OLDER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -83,12 +92,14 @@ public class RepositoryServletProxiedSnapshotPolicyTest
|
|||
HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -96,6 +107,7 @@ public class RepositoryServletProxiedSnapshotPolicyTest
|
|||
HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -103,12 +115,14 @@ public class RepositoryServletProxiedSnapshotPolicyTest
|
|||
( NEWER * ONE_MINUTE ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -116,18 +130,21 @@ public class RepositoryServletProxiedSnapshotPolicyTest
|
|||
( OLDER * OVER_ONE_HOUR ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyOnceFail()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ONCE, HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyOnceNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyOncePass()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.meterware.httpunit.WebRequest;
|
|||
import com.meterware.httpunit.WebResponse;
|
||||
|
||||
import org.apache.maven.archiva.policies.SnapshotsPolicy;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -36,6 +37,8 @@ import java.io.File;
|
|||
public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
|
||||
extends AbstractRepositoryServletProxiedTestCase
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -43,6 +46,7 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
|
|||
HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -50,12 +54,14 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
|
|||
( OLDER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyAlwaysNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ALWAYS, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyDailyFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -63,12 +69,14 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
|
|||
( NEWER * ONE_MINUTE ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -76,6 +84,7 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
|
|||
( OLDER * OVER_ONE_DAY ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -83,12 +92,14 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
|
|||
HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -96,6 +107,7 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
|
|||
HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -103,12 +115,14 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
|
|||
( NEWER * ONE_MINUTE ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -116,18 +130,21 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
|
|||
( OLDER * OVER_ONE_HOUR ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyOnceFail()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ONCE, HAS_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyOnceNoManagedContent()
|
||||
throws Exception
|
||||
{
|
||||
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.ONCE, NO_MANAGED_COPY );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProxiedSnapshotsArtifactPolicyOncePass()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -19,13 +19,10 @@ package org.apache.maven.archiva.webdav;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.meterware.httpunit.GetMethodWebRequest;
|
||||
import com.meterware.httpunit.PutMethodWebRequest;
|
||||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
|
@ -33,282 +30,299 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
|||
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
|
||||
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import com.meterware.httpunit.GetMethodWebRequest;
|
||||
import com.meterware.httpunit.PutMethodWebRequest;
|
||||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* RepositoryServletRepositoryGroupTest
|
||||
*
|
||||
* <p/>
|
||||
* Test Case 1. Accessing a valid repository group root url (e.g. http://machine.com/repository/repository-group/) returns a Bad Request (HTTP 400)
|
||||
* Test Case 2. Accessing an invalid repository group root url is forwarded to managed repository checking (this is not covered here)
|
||||
* Test Case 3. Accessing an artifact in a valid repository group will iterate over the managed repositories in the repository group
|
||||
* Test Case 3.a. If an invalid managed repository is encountered (managed repository doesn't exist),
|
||||
* a Not Found (HTTP 404) is returned and the iteration is broken
|
||||
* Test Case 3.b. If an artifact is not found in a valid managed repository (after proxying, etc.),
|
||||
* a Not Found (HTTP 404) is set but not returned yet, the iteration continues to the next managed repository.
|
||||
* The Not Found (HTTP 404) is returned after exhausting all valid managed repositories
|
||||
* Test Case 3.c. If an artifact is found in a valid managed repository,
|
||||
* the artifact is returned, the iteration is broken and any Not Found (HTTP 404) is disregarded
|
||||
* Test Case 3.a. If an invalid managed repository is encountered (managed repository doesn't exist),
|
||||
* a Not Found (HTTP 404) is returned and the iteration is broken
|
||||
* Test Case 3.b. If an artifact is not found in a valid managed repository (after proxying, etc.),
|
||||
* a Not Found (HTTP 404) is set but not returned yet, the iteration continues to the next managed repository.
|
||||
* The Not Found (HTTP 404) is returned after exhausting all valid managed repositories
|
||||
* Test Case 3.c. If an artifact is found in a valid managed repository,
|
||||
* the artifact is returned, the iteration is broken and any Not Found (HTTP 404) is disregarded
|
||||
* Test Case 4. Accessing a valid repository group with any http write method returns a Bad Request (HTTP 400)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class RepositoryServletRepositoryGroupTest
|
||||
extends AbstractRepositoryServletTestCase
|
||||
{
|
||||
protected File repoRootFirst;
|
||||
|
||||
|
||||
protected File repoRootLast;
|
||||
|
||||
|
||||
protected File repoRootInvalid;
|
||||
|
||||
|
||||
protected static final String MANAGED_REPO_FIRST = "first";
|
||||
|
||||
|
||||
protected static final String MANAGED_REPO_LAST = "last";
|
||||
|
||||
|
||||
protected static final String MANAGED_REPO_INVALID = "invalid";
|
||||
|
||||
|
||||
protected static final String REPO_GROUP_WITH_VALID_REPOS = "group-with-valid-repos";
|
||||
|
||||
protected static final String REPO_GROUP_WITH_INVALID_REPOS = "group-with-invalid-repos";
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp()
|
||||
@Before
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
|
||||
String appserverBase = System.getProperty( "appserver.base" );
|
||||
|
||||
|
||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
||||
|
||||
|
||||
repoRootFirst = new File( appserverBase, "data/repositories/" + MANAGED_REPO_FIRST );
|
||||
repoRootLast = new File( appserverBase, "data/repositories/" + MANAGED_REPO_LAST );
|
||||
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true ) );
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true ) );
|
||||
|
||||
|
||||
configuration.addManagedRepository(
|
||||
createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true ) );
|
||||
configuration.addManagedRepository(
|
||||
createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true ) );
|
||||
|
||||
List<String> managedRepoIds = new ArrayList<String>();
|
||||
managedRepoIds.add( MANAGED_REPO_FIRST );
|
||||
managedRepoIds.add( MANAGED_REPO_LAST );
|
||||
|
||||
|
||||
configuration.addRepositoryGroup( createRepositoryGroup( REPO_GROUP_WITH_VALID_REPOS, managedRepoIds ) );
|
||||
|
||||
|
||||
// Create the repository group with an invalid managed repository
|
||||
repoRootInvalid = new File( appserverBase, "data/repositories/" + MANAGED_REPO_INVALID );
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository( MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid, true );
|
||||
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true ) );
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration =
|
||||
createManagedRepository( MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid, true );
|
||||
|
||||
configuration.addManagedRepository(
|
||||
createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true ) );
|
||||
configuration.addManagedRepository( managedRepositoryConfiguration );
|
||||
configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true ) );
|
||||
|
||||
configuration.addManagedRepository(
|
||||
createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true ) );
|
||||
|
||||
List<String> invalidManagedRepoIds = new ArrayList<String>();
|
||||
invalidManagedRepoIds.add( MANAGED_REPO_FIRST );
|
||||
invalidManagedRepoIds.add( MANAGED_REPO_INVALID );
|
||||
invalidManagedRepoIds.add( MANAGED_REPO_LAST );
|
||||
|
||||
configuration.addRepositoryGroup( createRepositoryGroup( REPO_GROUP_WITH_INVALID_REPOS, invalidManagedRepoIds ) );
|
||||
|
||||
|
||||
configuration.addRepositoryGroup(
|
||||
createRepositoryGroup( REPO_GROUP_WITH_INVALID_REPOS, invalidManagedRepoIds ) );
|
||||
|
||||
configuration.removeManagedRepository( managedRepositoryConfiguration );
|
||||
FileUtils.deleteDirectory( repoRootInvalid );
|
||||
|
||||
|
||||
saveConfiguration( archivaConfiguration );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
@After
|
||||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
setupCleanRepo( repoRootFirst );
|
||||
setupCleanRepo( repoRootLast );
|
||||
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test Case 3.c
|
||||
*/
|
||||
* Test Case 3.c
|
||||
*/
|
||||
public void testGetFromFirstManagedRepositoryReturnOk()
|
||||
throws Exception
|
||||
{
|
||||
String resourceName = "dummy/dummy-first-resource/1.0/dummy-first-resource-1.0.txt";
|
||||
|
||||
|
||||
File dummyInternalResourceFile = new File( repoRootFirst, resourceName );
|
||||
dummyInternalResourceFile.getParentFile().mkdirs();
|
||||
FileUtils.writeStringToFile( dummyInternalResourceFile, "first", null );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest(
|
||||
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
|
||||
WebResponse response = sc.getResponse( request );
|
||||
|
||||
|
||||
assertResponseOK( response );
|
||||
assertEquals( "Expected file contents", "first", response.getText() );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test Case 3.c
|
||||
*/
|
||||
* Test Case 3.c
|
||||
*/
|
||||
public void testGetFromLastManagedRepositoryReturnOk()
|
||||
throws Exception
|
||||
{
|
||||
{
|
||||
String resourceName = "dummy/dummy-last-resource/1.0/dummy-last-resource-1.0.txt";
|
||||
|
||||
|
||||
File dummyReleasesResourceFile = new File( repoRootLast, resourceName );
|
||||
dummyReleasesResourceFile.getParentFile().mkdirs();
|
||||
FileUtils.writeStringToFile( dummyReleasesResourceFile, "last", null );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest(
|
||||
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
|
||||
WebResponse response = sc.getResponse( request );
|
||||
|
||||
|
||||
assertResponseOK( response );
|
||||
assertEquals( "Expected file contents", "last", response.getText() );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test Case 3.b
|
||||
*/
|
||||
* Test Case 3.b
|
||||
*/
|
||||
public void testGetFromValidRepositoryGroupReturnNotFound()
|
||||
throws Exception
|
||||
{
|
||||
String resourceName = "dummy/dummy-no-resource/1.0/dummy-no-resource-1.0.txt";
|
||||
|
||||
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest(
|
||||
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
|
||||
WebResponse response = sc.getResponse( request );
|
||||
|
||||
|
||||
assertResponseNotFound( response );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Test Case 3.a
|
||||
*/
|
||||
* Test Case 3.a
|
||||
*/
|
||||
public void testGetInvalidManagedRepositoryInGroupReturnNotFound()
|
||||
throws Exception
|
||||
{
|
||||
String resourceName = "dummy/dummy-no-resource/1.0/dummy-no-resource-1.0.txt";
|
||||
|
||||
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_INVALID_REPOS + "/" + resourceName );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest(
|
||||
"http://machine.com/repository/" + REPO_GROUP_WITH_INVALID_REPOS + "/" + resourceName );
|
||||
WebResponse response = sc.getResponse( request );
|
||||
|
||||
|
||||
assertResponseInternalServerError( response );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test Case 4
|
||||
*/
|
||||
* Test Case 4
|
||||
*/
|
||||
public void testPutValidRepositoryGroupReturnBadRequest()
|
||||
throws Exception
|
||||
{
|
||||
String resourceName = "dummy/dummy-put-resource/1.0/dummy-put-resource-1.0.txt";
|
||||
String putUrl = "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName;
|
||||
InputStream is = getClass().getResourceAsStream( "/artifact.jar" );
|
||||
|
||||
|
||||
WebRequest request = new PutMethodWebRequest( putUrl, is, "text/plain" );
|
||||
WebResponse response = sc.getResponse( request );
|
||||
|
||||
|
||||
assertResponseMethodNotAllowed( response );
|
||||
}
|
||||
|
||||
|
||||
// MRM-872
|
||||
public void testGetMergedMetadata()
|
||||
throws Exception
|
||||
{
|
||||
{
|
||||
// first metadata file
|
||||
String resourceName = "dummy/dummy-merged-metadata-resource/maven-metadata.xml";
|
||||
|
||||
String resourceName = "dummy/dummy-merged-metadata-resource/maven-metadata.xml";
|
||||
|
||||
File dummyInternalResourceFile = new File( repoRootFirst, resourceName );
|
||||
dummyInternalResourceFile.getParentFile().mkdirs();
|
||||
FileUtils.writeStringToFile( dummyInternalResourceFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<metadata>\n<groupId>dummy</groupId>\n<artifactId>dummy-merged-metadata-resource</artifactId>\n" +
|
||||
"<versioning>\n<latest>1.0</latest>\n<release>1.0</release>\n<versions>\n<version>1.0</version>\n" +
|
||||
"<version>2.5</version>\n</versions>\n<lastUpdated>20080708095554</lastUpdated>\n</versioning>\n</metadata>", null );
|
||||
|
||||
FileUtils.writeStringToFile( dummyInternalResourceFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
+ "<metadata>\n<groupId>dummy</groupId>\n<artifactId>dummy-merged-metadata-resource</artifactId>\n"
|
||||
+ "<versioning>\n<latest>1.0</latest>\n<release>1.0</release>\n<versions>\n<version>1.0</version>\n"
|
||||
+ "<version>2.5</version>\n</versions>\n<lastUpdated>20080708095554</lastUpdated>\n</versioning>\n</metadata>",
|
||||
null );
|
||||
|
||||
//second metadata file
|
||||
resourceName = "dummy/dummy-merged-metadata-resource/maven-metadata.xml";
|
||||
resourceName = "dummy/dummy-merged-metadata-resource/maven-metadata.xml";
|
||||
dummyInternalResourceFile = new File( repoRootLast, resourceName );
|
||||
dummyInternalResourceFile.getParentFile().mkdirs();
|
||||
FileUtils.writeStringToFile( dummyInternalResourceFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<metadata><groupId>dummy</groupId><artifactId>dummy-merged-metadata-resource</artifactId>" +
|
||||
"<versioning><latest>2.0</latest><release>2.0</release><versions><version>1.0</version>" +
|
||||
"<version>1.5</version><version>2.0</version></versions><lastUpdated>20080709095554</lastUpdated>" +
|
||||
"</versioning></metadata>", null );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" +
|
||||
"dummy-merged-metadata-resource/maven-metadata.xml" );
|
||||
WebResponse response = sc.getResource( request );
|
||||
|
||||
File returnedMetadata = new File( getBasedir(), "/target/test-classes/retrievedMetadataFile.xml");
|
||||
FileUtils.writeStringToFile( dummyInternalResourceFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
+ "<metadata><groupId>dummy</groupId><artifactId>dummy-merged-metadata-resource</artifactId>"
|
||||
+ "<versioning><latest>2.0</latest><release>2.0</release><versions><version>1.0</version>"
|
||||
+ "<version>1.5</version><version>2.0</version></versions><lastUpdated>20080709095554</lastUpdated>"
|
||||
+ "</versioning></metadata>", null );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest(
|
||||
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/"
|
||||
+ "dummy-merged-metadata-resource/maven-metadata.xml" );
|
||||
WebResponse response = sc.getResource( request );
|
||||
|
||||
File returnedMetadata = new File( "target/test-classes/retrievedMetadataFile.xml" );
|
||||
FileUtils.writeStringToFile( returnedMetadata, response.getText() );
|
||||
ArchivaRepositoryMetadata metadata = RepositoryMetadataReader.read( returnedMetadata );
|
||||
|
||||
ArchivaRepositoryMetadata metadata = RepositoryMetadataReader.read( returnedMetadata );
|
||||
|
||||
assertResponseOK( response );
|
||||
assertEquals( "Versions list size", 4, metadata.getAvailableVersions().size() );
|
||||
assertTrue( "Versions list contains version 1.0", metadata.getAvailableVersions().contains( "1.0" ) );
|
||||
assertTrue( "Versions list contains version 1.5", metadata.getAvailableVersions().contains( "1.5" ) );
|
||||
assertTrue( "Versions list contains version 2.0", metadata.getAvailableVersions().contains( "2.0" ) );
|
||||
assertTrue( "Versions list contains version 2.5", metadata.getAvailableVersions().contains( "2.5" ) );
|
||||
|
||||
|
||||
//check if the checksum files were generated
|
||||
File checksumFileSha1 = new File( repoRootFirst, resourceName + ".sha1" );
|
||||
checksumFileSha1.getParentFile().mkdirs();
|
||||
FileUtils.writeStringToFile( checksumFileSha1, "3290853214d3687134", null );
|
||||
|
||||
|
||||
File checksumFileMd5 = new File( repoRootFirst, resourceName + ".md5" );
|
||||
checksumFileMd5.getParentFile().mkdirs();
|
||||
FileUtils.writeStringToFile( checksumFileMd5, "98745897234eda12836423", null );
|
||||
|
||||
|
||||
// request the sha1 checksum of the metadata
|
||||
request =
|
||||
new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" +
|
||||
"dummy-merged-metadata-resource/maven-metadata.xml.sha1" );
|
||||
request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/"
|
||||
+ "dummy-merged-metadata-resource/maven-metadata.xml.sha1" );
|
||||
response = sc.getResource( request );
|
||||
|
||||
|
||||
assertResponseOK( response );
|
||||
assertEquals( "add113b0d7f8c6adb92a5015a7a3701081edf998 maven-metadata-group-with-valid-repos.xml", response.getText() );
|
||||
|
||||
assertEquals( "add113b0d7f8c6adb92a5015a7a3701081edf998 maven-metadata-group-with-valid-repos.xml",
|
||||
response.getText() );
|
||||
|
||||
// request the md5 checksum of the metadata
|
||||
request =
|
||||
new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/" +
|
||||
"dummy-merged-metadata-resource/maven-metadata.xml.md5" );
|
||||
request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/"
|
||||
+ "dummy-merged-metadata-resource/maven-metadata.xml.md5" );
|
||||
response = sc.getResource( request );
|
||||
|
||||
|
||||
assertResponseOK( response );
|
||||
assertEquals( "5b85ea4aa5f52bb76760041a52f98de8 maven-metadata-group-with-valid-repos.xml", response.getText().trim() );
|
||||
assertEquals( "5b85ea4aa5f52bb76760041a52f98de8 maven-metadata-group-with-valid-repos.xml",
|
||||
response.getText().trim() );
|
||||
}
|
||||
|
||||
|
||||
// MRM-901
|
||||
public void testBrowseWithTwoArtifactsWithSameGroupIdInRepos()
|
||||
throws Exception
|
||||
{
|
||||
String resourceName = "dummy/dummy-artifact/1.0/dummy-artifact-1.0.txt";
|
||||
|
||||
|
||||
File dummyInternalResourceFile = new File( repoRootFirst, resourceName );
|
||||
dummyInternalResourceFile.getParentFile().mkdirs();
|
||||
FileUtils.writeStringToFile( dummyInternalResourceFile, "first", null );
|
||||
|
||||
|
||||
resourceName = "dummy/dummy-artifact/2.0/dummy-artifact-2.0.txt";
|
||||
|
||||
|
||||
File dummyReleasesResourceFile = new File( repoRootLast, resourceName );
|
||||
dummyReleasesResourceFile.getParentFile().mkdirs();
|
||||
FileUtils.writeStringToFile( dummyReleasesResourceFile, "last", null );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/dummy-artifact/" );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest(
|
||||
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/dummy-artifact/" );
|
||||
WebResponse response = sc.getResource( request );
|
||||
|
||||
|
||||
assertResponseOK( response );
|
||||
assertTrue( StringUtils.contains( response.getText(), "Collection" ) );
|
||||
assertTrue( StringUtils.contains( response.getText(), "dummy/dummy-artifact" ) );
|
||||
assertTrue( StringUtils.contains( response.getText(), "1.0" ) );
|
||||
assertTrue( StringUtils.contains( response.getText(), "2.0" ) );
|
||||
}
|
||||
|
||||
|
||||
protected void assertResponseMethodNotAllowed( WebResponse response )
|
||||
{
|
||||
assertNotNull( "Should have recieved a response", response );
|
||||
assertEquals( "Should have been an 405/Method Not Allowed response code.", HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getResponseCode() );
|
||||
assertEquals( "Should have been an 405/Method Not Allowed response code.",
|
||||
HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getResponseCode() );
|
||||
}
|
||||
|
||||
protected RepositoryGroupConfiguration createRepositoryGroup( String id, List<String> repositories )
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.meterware.httpunit.WebResponse;
|
|||
import com.meterware.servletunit.InvocationContext;
|
||||
import com.meterware.servletunit.ServletRunner;
|
||||
import com.meterware.servletunit.ServletUnitClient;
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.archiva.repository.audit.TestAuditListener;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
@ -43,16 +44,21 @@ import org.codehaus.plexus.redback.system.DefaultSecuritySession;
|
|||
import org.codehaus.plexus.redback.system.SecuritySession;
|
||||
import org.codehaus.plexus.redback.users.User;
|
||||
import org.codehaus.plexus.redback.users.memory.SimpleUser;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator;
|
||||
import org.codehaus.redback.integration.filter.authentication.basic.HttpBasicAuthentication;
|
||||
import org.easymock.MockControl;
|
||||
import org.easymock.classextension.MockClassControl;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* RepositoryServletSecurityTest Test the flow of the authentication and authorization checks. This does not necessarily
|
||||
|
@ -60,8 +66,10 @@ import javax.servlet.http.HttpServletResponse;
|
|||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
@RunWith( SpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
|
||||
public class RepositoryServletSecurityTest
|
||||
extends PlexusInSpringTestCase
|
||||
extends TestCase
|
||||
{
|
||||
protected static final String REPOID_INTERNAL = "internal";
|
||||
|
||||
|
@ -71,6 +79,7 @@ public class RepositoryServletSecurityTest
|
|||
|
||||
private ServletRunner sr;
|
||||
|
||||
@Inject
|
||||
protected ArchivaConfiguration archivaConfiguration;
|
||||
|
||||
private DavSessionProvider davSessionProvider;
|
||||
|
@ -85,19 +94,19 @@ public class RepositoryServletSecurityTest
|
|||
|
||||
private RepositoryServlet servlet;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
String appserverBase = getTestFile( "target/appserver-base" ).getAbsolutePath();
|
||||
String appserverBase = new File( "target/appserver-base" ).getAbsolutePath();
|
||||
System.setProperty( "appserver.base", appserverBase );
|
||||
|
||||
File testConf = getTestFile( "src/test/resources/repository-archiva.xml" );
|
||||
File testConf = new File( "src/test/resources/repository-archiva.xml" );
|
||||
File testConfDest = new File( appserverBase, "conf/archiva.xml" );
|
||||
FileUtils.copyFile( testConf, testConfDest );
|
||||
|
||||
archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
|
||||
repoRootInternal = new File( appserverBase, "data/repositories/internal" );
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
|
||||
|
@ -108,7 +117,7 @@ public class RepositoryServletSecurityTest
|
|||
|
||||
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
|
||||
|
||||
sr = new ServletRunner( getTestFile( "src/test/resources/WEB-INF/repository-servlet-security-test/web.xml" ) );
|
||||
sr = new ServletRunner( new File( "src/test/resources/WEB-INF/repository-servlet-security-test/web.xml" ) );
|
||||
sr.registerServlet( "/repository/*", RepositoryServlet.class.getName() );
|
||||
sc = sr.newClient();
|
||||
|
||||
|
@ -156,12 +165,7 @@ public class RepositoryServletSecurityTest
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getPlexusConfigLocation()
|
||||
{
|
||||
return "org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.xml";
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.maven.archiva.webdav.RepositoryServlet;
|
|||
import com.meterware.httpunit.GetMethodWebRequest;
|
||||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -44,6 +45,7 @@ public class RepositoryServletTest
|
|||
|
||||
private static final String NEW_REPOSITORY_NAME = "New Repository";
|
||||
|
||||
@Test
|
||||
public void testGetRepository()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -53,6 +55,7 @@ public class RepositoryServletTest
|
|||
assertRepositoryValid( servlet, REPOID_INTERNAL );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRepositoryAfterDelete()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -68,6 +71,7 @@ public class RepositoryServletTest
|
|||
assertNull( repository );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRepositoryAfterAdd()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -79,7 +83,7 @@ public class RepositoryServletTest
|
|||
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
|
||||
repo.setId( NEW_REPOSITORY_ID );
|
||||
repo.setName( NEW_REPOSITORY_NAME );
|
||||
File repoRoot = new File( getBasedir(), "target/test-repository-root" );
|
||||
File repoRoot = new File( "target/test-repository-root" );
|
||||
if ( !repoRoot.exists() )
|
||||
{
|
||||
repoRoot.mkdirs();
|
||||
|
@ -96,6 +100,7 @@ public class RepositoryServletTest
|
|||
assertRepositoryValid( servlet, REPOID_INTERNAL );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRepositoryInvalidPathPassthroughPresent()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -109,6 +114,7 @@ public class RepositoryServletTest
|
|||
assertEquals( "index file", response.getText() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRepositoryInvalidPathPassthroughMissing()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -19,18 +19,31 @@ package org.apache.maven.archiva.webdav.util;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* MimeTypesTest
|
||||
* MimeTypesTest
|
||||
*
|
||||
* @version $Id: MimeTypesTest.java 6556 2007-06-20 20:44:46Z joakime $
|
||||
*/
|
||||
public class MimeTypesTest extends PlexusInSpringTestCase
|
||||
@RunWith( SpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
|
||||
public class MimeTypesTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testGetMimeType() throws Exception
|
||||
@Inject
|
||||
MimeTypes mime;
|
||||
|
||||
@Test
|
||||
public void testGetMimeType()
|
||||
throws Exception
|
||||
{
|
||||
MimeTypes mime = (MimeTypes) lookup( MimeTypes.class );
|
||||
assertNotNull( "MimeTypes should not be null.", mime );
|
||||
|
||||
assertEquals( "application/pdf", mime.getMimeType( "big-book.pdf" ) );
|
||||
|
|
|
@ -23,28 +23,29 @@ import junit.framework.TestCase;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class RepositoryPathUtilTest extends TestCase
|
||||
public class RepositoryPathUtilTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testGetRepositoryId()
|
||||
{
|
||||
String href = "/path/to/my/resource";
|
||||
assertEquals("to", RepositoryPathUtil.getRepositoryName(href));
|
||||
assertEquals( "to", RepositoryPathUtil.getRepositoryName( href ) );
|
||||
|
||||
href = "path/to/my/resource";
|
||||
assertEquals("to", RepositoryPathUtil.getRepositoryName(href));
|
||||
assertEquals( "to", RepositoryPathUtil.getRepositoryName( href ) );
|
||||
|
||||
href = "mypath";
|
||||
assertEquals("/", RepositoryPathUtil.getLogicalResource(href));
|
||||
assertEquals( "/", RepositoryPathUtil.getLogicalResource( href ) );
|
||||
}
|
||||
|
||||
public void testGetLogicalPath()
|
||||
{
|
||||
String href = "/repository/internal/org/apache/maven/someartifact.jar";
|
||||
assertEquals("/org/apache/maven/someartifact.jar", RepositoryPathUtil.getLogicalResource(href));
|
||||
assertEquals( "/org/apache/maven/someartifact.jar", RepositoryPathUtil.getLogicalResource( href ) );
|
||||
|
||||
href = "repository/internal/org/apache/maven/someartifact.jar";
|
||||
assertEquals("/org/apache/maven/someartifact.jar", RepositoryPathUtil.getLogicalResource(href));
|
||||
|
||||
assertEquals( "/org/apache/maven/someartifact.jar", RepositoryPathUtil.getLogicalResource( href ) );
|
||||
|
||||
href = "repository/internal/org/apache/maven/";
|
||||
assertEquals( "/org/apache/maven/", RepositoryPathUtil.getLogicalResource( href ) );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
|
||||
default-lazy-init="true">
|
||||
|
||||
<context:annotation-config/>
|
||||
<context:component-scan base-package="org.apache.maven.archiva.webdav"/>
|
||||
|
||||
</beans>
|
|
@ -29,14 +29,10 @@
|
|||
</listener>
|
||||
|
||||
<context-param>
|
||||
<param-name>contextClass</param-name>
|
||||
<param-value>org.codehaus.plexus.spring.PlexusWebApplicationContext</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>
|
||||
classpath*:/META-INF/plexus/components.xml
|
||||
classpath*:/META-INF/spring-context.xml,
|
||||
classpath*:spring-context.xml
|
||||
</param-value>
|
||||
</context-param>
|
||||
|
||||
|
|
Loading…
Reference in New Issue