IOUtils.closeQuietly( reader );
}
}
+
+ public String getResource()
+ {
+ return resource;
+ }
+
+ public void setResource( String resource )
+ {
+ this.resource = resource;
+ }
}
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.
// }
// }
- protected void tearDown()
+ @Before
+ public void tearDown()
throws Exception
{
shutdownServer( remotePrivateSnapshots );
* 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;
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$
*/
protected RemoteRepoInfo remoteCentral;
protected RemoteRepoInfo remoteSnapshots;
-
+
protected RemoteRepoInfo remotePrivateSnapshots;
-
- @Override
- protected void setUp()
+
+ @Before
+ public void setUp()
throws Exception
{
super.setUp();
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() )
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 );
}
@Override
- protected void tearDown()
+ @After
+ public void tearDown()
throws Exception
{
shutdownServer( remoteCentral );
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";
private ServletRunner sr;
+ @Inject
protected ArchivaConfiguration archivaConfiguration;
protected void saveConfiguration()
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();
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 )
FileUtils.deleteDirectory( repoRootLegacy );
}
- release( archivaConfiguration );
-
super.tearDown();
}
* 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;
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";
private MockControl repoContentFactoryControl;
private RepositoryContentFactory repoFactory;
-
+
+ @Before
public void setUp()
throws Exception
{
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" ) );
return repoContent;
}
+ @After
public void tearDown()
throws Exception
{
}
// MRM-1232 - Unable to get artifacts from repositories which requires Repository Manager role using repository group
+ @Test
public void testRepositoryGroupFirstRepositoryRequiresAuthentication()
throws Exception
{
}
}
+ @Test
public void testRepositoryGroupLastRepositoryRequiresAuthentication()
throws Exception
{
}
}
+ @Test
public void testRepositoryGroupArtifactDoesNotExistInAnyOfTheReposAuthenticationDisabled()
throws Exception
{
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>();
}
// MRM-1239
+ @Test
public void testRequestArtifactMetadataThreePartsRepoHasDefaultLayout()
throws Exception
{
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
}
}
+ @Test
public void testRequestArtifactMetadataTwoPartsRepoHasDefaultLayout()
throws Exception
{
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
}
}
+ @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 =
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
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 )
{
/**
*/
-public class ArchivaDavResourceLocatorTest extends TestCase
+public class ArchivaDavResourceLocatorTest
+ extends TestCase
{
ArchivaDavLocatorFactory factory;
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()
{
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()
{
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()
{
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 );
}
}
* 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;
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
{
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()
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()
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()
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;
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 );
+ }
}
}
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
*
* @version $Id$
*
- * @plexus.component
+ * plexus.component
* role="org.codehaus.plexus.redback.system.SecuritySystem"
*/
+@Service("securitySystem#bypass")
public class BypassSecuritySystem
extends DefaultSecuritySystem
implements SecuritySystem
* 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;
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;
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() );
resource.addLockManager( lockManager );
}
- @Override
+ @After
protected void tearDown()
throws Exception
{
super.tearDown();
- release( mimeTypes );
FileUtils.deleteDirectory( baseDir );
}
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(), null );
}
+ @Test
public void testDeleteNonExistantResourceShould404()
throws Exception
{
}
}
+ @Test
public void testDeleteCollection()
throws Exception
{
}
}
+ @Test
public void testDeleteResource()
throws Exception
{
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
{
assertEquals( 1, resource.getLocks().length );
}
+ @Test
public void testLockIfResourceUnlockable()
throws Exception
{
assertEquals( 0, resource.getLocks().length );
}
+ @Test
public void testGetLock()
throws Exception
{
assertNull( resource.getLock( Type.WRITE, Scope.SHARED ) );
}
+ @Test
public void testRefreshLockThrowsExceptionIfNoLockIsPresent()
throws Exception
{
assertEquals( 0, resource.getLocks().length );
}
+ @Test
public void testRefreshLock()
throws Exception
{
assertEquals( 1, resource.getLocks().length );
}
+ @Test
public void testUnlock()
throws Exception
{
assertEquals( 0, resource.getLocks().length );
}
+ @Test
public void testUnlockThrowsDavExceptionIfNotLocked()
throws Exception
{
assertEquals( 1, resource.getLocks().length );
}
+ @Test
public void testUnlockThrowsDavExceptionIfResourceNotLocked()
throws Exception
{
* 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.
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;
extends AbstractRepositoryServletTestCase
{
@Override
- protected void setUp()
+ @Before
+ public void setUp()
throws Exception
{
super.setUp();
new File( repoRootInternal, "net/sourceforge" ).mkdirs();
new File( repoRootInternal, "commons-lang" ).mkdirs();
}
-
+
+ @Test
public void testBrowse()
throws Exception
{
String expectedLinks[] = new String[] { "commons-lang/", "net/", "org/" };
assertLinks(expectedLinks, response.getLinks());
}
-
+
+ @Test
public void testBrowseSubdirectory()
throws Exception
{
assertLinks(expectedLinks, response.getLinks());
}
+ @Test
public void testGetDirectoryWhichHasMatchingFile() //MRM-893
throws Exception
{
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.webdav.httpunit.MkColMethodWebRequest;
+import org.junit.Test;
/**
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
{
*
* @throws Exception
*/
+ @Test
public void testReleaseArtifactsRedeploymentValidPath()
throws Exception
{
response = sc.getResponse( request );
assertResponseConflictError( response );
}
-
+
+ @Test
public void testReleaseArtifactsRedeploymentIsAllowed()
throws Exception
{
response = sc.getResponse( request );
assertResponseNoContent( response );
}
-
+
+ @Test
public void testReleaseArtifactsRedeploymentInvalidPath()
throws Exception
{
response = sc.getResponse( request );
assertResponseNoContent( response );
}
-
+
+ @Test
public void testReleaseArtifactsRedeploymentArtifactIsSnapshot()
throws Exception
{
response = sc.getResponse( request );
assertResponseNoContent( response );
}
-
+
+ @Test
public void testMkColWithMissingParentCollectionFails()
throws Exception
{
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
import org.apache.commons.io.FileUtils;
+import org.junit.Test;
import java.io.File;
public class RepositoryServletNoProxyMetadataTest
extends AbstractRepositoryServletTestCase
{
+ @Test
public void testGetVersionMetadataDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
}
+ @Test
public void testGetProjectMetadataDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
}
+ @Test
public void testGetGroupMetadataDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
}
+ @Test
public void testGetSnapshotVersionMetadataDefaultLayout()
throws Exception
{
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
import org.apache.commons.io.FileUtils;
+import org.junit.Test;
import java.io.File;
public class RepositoryServletNoProxyTest
extends AbstractRepositoryServletTestCase
{
+ @Test
public void testLastModifiedHeaderExists()
throws Exception
{
assertNotNull( response.getHeaderField( "last-modified" ) );
}
+ @Test
public void testGetNoProxyChecksumDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
}
+ @Test
public void testGetNoProxyChecksumLegacyLayout()
throws Exception
{
assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
}
+ @Test
public void testGetNoProxyVersionedMetadataDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
}
+ @Test
public void testGetNoProxyProjectMetadataDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
}
+ @Test
public void testGetNoProxyGroupMetadataDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
}
+ @Test
public void testGetNoProxyArtifactDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxyArtifactLegacyLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxySnapshotArtifactDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxySnapshotArtifactLegacyLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayout()
throws Exception
{
/**
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
*/
+ @Test
public void testGetNoProxyDualExtensionDefaultLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedContents, response.getText() );
}
+ @Test
public void testGetNoProxyDistributionLegacyLayout()
throws Exception
{
assertEquals( "Expected file contents", expectedContents, response.getText() );
}
+ @Test
public void testGetNoProxyChecksumDefaultLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
}
+ @Test
public void testGetNoProxyChecksumLegacyLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", "dummy-checksum", response.getText() );
}
+ @Test
public void testGetNoProxyVersionedMetadataDefaultLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
}
+ @Test
public void testGetNoProxyProjectMetadataDefaultLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
}
+ @Test
public void testGetNoProxyGroupMetadataDefaultLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
}
+ @Test
public void testGetNoProxyArtifactDefaultLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxyArtifactLegacyLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxySnapshotArtifactDefaultLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxySnapshotArtifactLegacyLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", expectedArtifactContents, response.getText() );
}
+ @Test
public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayoutManagedLegacy()
throws Exception
{
/**
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
*/
+ @Test
public void testGetNoProxyDualExtensionDefaultLayoutManagedLegacy()
throws Exception
{
assertEquals( "Expected file contents", expectedContents, response.getText() );
}
+ @Test
public void testGetNoProxyDistributionLegacyLayoutManagedLegacy()
throws Exception
{
* under the License.
*/
+import org.junit.Test;
+
/**
* RepositoryServlet Tests, Proxied, Get of Metadata, exists on local managed repository only.
*
public class RepositoryServletProxiedMetadataLocalOnlyTest
extends AbstractRepositoryServletProxiedMetadataTestCase
{
+
+ @Test
public void testGetProxiedSnapshotVersionMetadataLocalOnly()
throws Exception
{
assertExpectedMetadata( expectedMetadata, actualMetadata );
}
+ @Test
public void testGetProxiedVersionMetadataLocalOnly()
throws Exception
{
assertExpectedMetadata( expectedMetadata, actualMetadata );
}
+ @Test
public void testGetProxiedProjectMetadataLocalOnly()
throws Exception
{
assertExpectedMetadata( expectedMetadata, actualMetadata );
}
+ @Test
public void testGetProxiedGroupMetadataLocalOnly()
throws Exception
{
*/
+import org.junit.Test;
+
/**
* RepositoryServlet Tests, Proxied, Get of Metadata, exists on remote repository only.
*
public class RepositoryServletProxiedMetadataRemoteOnlyTest
extends AbstractRepositoryServletProxiedMetadataTestCase
{
+ @Test
public void testGetProxiedSnapshotVersionMetadataRemoteOnly()
throws Exception
{
assertExpectedMetadata( expectedMetadata, actualMetadata );
}
+ @Test
public void testGetProxiedPluginSnapshotVersionMetadataRemoteOnly()
throws Exception
{
assertExpectedMetadata( expectedMetadata, actualMetadata );
}
+ @Test
public void testGetProxiedVersionMetadataRemoteOnly()
throws Exception
{
assertExpectedMetadata( expectedMetadata, actualMetadata );
}
+ @Test
public void testGetProxiedProjectMetadataRemoteOnly()
throws Exception
{
assertExpectedMetadata( expectedMetadata, actualMetadata );
}
+ @Test
public void testGetProxiedGroupMetadataRemoteOnly()
throws Exception
{
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.
private static final String PATH_ASC = "org/apache/archiva/test/1.0/test-1.0.jar.asc";
+ @Test
public void testGetProxiedManagedNewerSha1()
throws Exception
{
CONTENT_SHA1 );
}
+ @Test
public void testGetProxiedManagedOlderSha1()
throws Exception
{
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
{
CONTENT_ASC );
}
+ @Test
public void testGetProxiedManagedOlderAsc()
throws Exception
{
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
{
import com.meterware.httpunit.WebResponse;
import org.apache.maven.archiva.policies.SnapshotsPolicy;
+import org.junit.Test;
import java.io.File;
public class RepositoryServletProxiedPluginSnapshotPolicyTest
extends AbstractRepositoryServletProxiedTestCase
{
+
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
throws Exception
{
HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
throws Exception
{
( 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
{
( NEWER * ONE_MINUTE ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
throws Exception
{
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
throws Exception
{
( OLDER * OVER_ONE_DAY ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
throws Exception
{
HAS_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
throws Exception
{
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
throws Exception
{
HAS_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
throws Exception
{
( NEWER * ONE_MINUTE ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
throws Exception
{
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
throws Exception
{
( 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
{
import com.meterware.httpunit.WebResponse;
import org.apache.maven.archiva.policies.ReleasesPolicy;
+import org.junit.Test;
import java.io.File;
public class RepositoryServletProxiedReleasePolicyTest
extends AbstractRepositoryServletProxiedTestCase
{
+ @Test
public void testGetProxiedReleaseArtifactPolicyAlwaysManagedNewer()
throws Exception
{
( NEWER * OVER_ONE_DAY ) );
}
+ @Test
public void testGetProxiedReleaseArtifactPolicyAlwaysManagedOlder()
throws Exception
{
( 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
{
( NEWER * ONE_MINUTE ) );
}
+ @Test
public void testGetProxiedReleaseArtifactPolicyDailyNoManagedContent()
throws Exception
{
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.DAILY, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedReleaseArtifactPolicyDailyPass()
throws Exception
{
( 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
{
( NEWER * ONE_MINUTE ) );
}
+ @Test
public void testGetProxiedReleaseArtifactPolicyHourlyNoManagedContent()
throws Exception
{
assertGetProxiedReleaseArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, ReleasesPolicy.HOURLY, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedReleaseArtifactPolicyHourlyPass()
throws Exception
{
( 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
{
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.
public class RepositoryServletProxiedRelocatedTest
extends AbstractRepositoryServletProxiedTestCase
{
+
+ @Test
public void testGetProxiedReleaseArtifactPolicyOncePass()
throws Exception
{
import com.meterware.httpunit.WebResponse;
import org.apache.maven.archiva.policies.SnapshotsPolicy;
+import org.junit.Test;
import java.io.File;
public class RepositoryServletProxiedSnapshotPolicyTest
extends AbstractRepositoryServletProxiedTestCase
{
+
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
throws Exception
{
HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
throws Exception
{
( 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
{
( NEWER * ONE_MINUTE ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
throws Exception
{
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
throws Exception
{
( OLDER * OVER_ONE_DAY ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
throws Exception
{
HAS_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
throws Exception
{
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
throws Exception
{
HAS_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
throws Exception
{
( NEWER * ONE_MINUTE ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
throws Exception
{
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
throws Exception
{
( 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
{
import com.meterware.httpunit.WebResponse;
import org.apache.maven.archiva.policies.SnapshotsPolicy;
+import org.junit.Test;
import java.io.File;
public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
extends AbstractRepositoryServletProxiedTestCase
{
+
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer()
throws Exception
{
HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedOlder()
throws Exception
{
( 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
{
( NEWER * ONE_MINUTE ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyDailyNoManagedContent()
throws Exception
{
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.DAILY, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyDailyPass()
throws Exception
{
( OLDER * OVER_ONE_DAY ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyRejectFail()
throws Exception
{
HAS_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyRejectNoManagedContentFail()
throws Exception
{
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_NOT_FOUND, SnapshotsPolicy.NEVER, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyRejectPass()
throws Exception
{
HAS_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyHourlyFail()
throws Exception
{
( NEWER * ONE_MINUTE ) );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyHourlyNoManagedContent()
throws Exception
{
assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_REMOTE_CONTENTS, SnapshotsPolicy.HOURLY, NO_MANAGED_COPY );
}
+ @Test
public void testGetProxiedSnapshotsArtifactPolicyHourlyPass()
throws Exception
{
( 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
{
* 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;
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 )
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;
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
*
* @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";
private ServletRunner sr;
+ @Inject
protected ArchivaConfiguration archivaConfiguration;
private DavSessionProvider davSessionProvider;
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();
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();
}
@Override
- protected String getPlexusConfigLocation()
- {
- return "org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.xml";
- }
-
- @Override
+ @After
protected void tearDown()
throws Exception
{
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
+import org.junit.Test;
import java.io.File;
private static final String NEW_REPOSITORY_NAME = "New Repository";
+ @Test
public void testGetRepository()
throws Exception
{
assertRepositoryValid( servlet, REPOID_INTERNAL );
}
+ @Test
public void testGetRepositoryAfterDelete()
throws Exception
{
assertNull( repository );
}
+ @Test
public void testGetRepositoryAfterAdd()
throws Exception
{
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();
assertRepositoryValid( servlet, REPOID_INTERNAL );
}
+ @Test
public void testGetRepositoryInvalidPathPassthroughPresent()
throws Exception
{
assertEquals( "index file", response.getText() );
}
+ @Test
public void testGetRepositoryInvalidPathPassthroughMissing()
throws Exception
{
* 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" ) );
/**
*/
-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 ) );
}
--- /dev/null
+<?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>
\ No newline at end of file
</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>