import java.io.IOException;
/**
- * AbstractRepositoryServletTestCase
+ * AbstractRepositoryServletTestCase
*
* @version $Id$
*/
assertTrue( "File <" + actualFile.getAbsolutePath() + "> should exist.", actualFile.exists() );
assertTrue( "File <" + actualFile.getAbsolutePath() + "> should be a file (not a dir/link/device/etc).",
actualFile.isFile() );
-
+
String actualContents = FileUtils.readFileToString( actualFile, null );
assertEquals( "File Contents of <" + actualFile.getAbsolutePath() + ">", expectedContents, actualContents );
}
ManagedRepositoryConfiguration repository = servlet.getRepository( repoId );
assertNotNull( "Archiva Managed Repository id:<" + repoId + "> should exist.", repository );
File repoRoot = new File( repository.getLocation() );
- assertTrue( "Archiva Managed Repository id:<" + repoId + "> should have a valid location on disk.", repoRoot
- .exists()
- && repoRoot.isDirectory() );
+ assertTrue( "Archiva Managed Repository id:<" + repoId + "> should have a valid location on disk.",
+ repoRoot.exists() && repoRoot.isDirectory() );
}
protected void assertResponseOK( WebResponse response )
Assert.assertEquals( "Should have been an OK response code for path: " + path, HttpServletResponse.SC_OK,
response.getResponseCode() );
}
-
+
protected void assertResponseNotFound( WebResponse response )
{
assertNotNull( "Should have recieved a response", response );
- Assert.assertEquals( "Should have been an 404/Not Found response code.", HttpServletResponse.SC_NOT_FOUND, response
- .getResponseCode() );
+ Assert.assertEquals( "Should have been an 404/Not Found response code.", HttpServletResponse.SC_NOT_FOUND,
+ response.getResponseCode() );
}
protected void assertResponseInternalServerError( WebResponse response )
{
assertNotNull( "Should have recieved a response", response );
- Assert.assertEquals( "Should have been an 500/Internal Server Error response code.", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, response
- .getResponseCode() );
+ Assert.assertEquals( "Should have been an 500/Internal Server Error response code.",
+ HttpServletResponse.SC_INTERNAL_SERVER_ERROR, response.getResponseCode() );
}
-
+
protected void assertResponseConflictError( WebResponse response )
{
assertNotNull( "Should have received a response", response );
response.getResponseCode() );
}
- protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location, boolean blockRedeployments )
+ protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location,
+ boolean blockRedeployments )
{
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
repo.setId( id );
repo.setName( name );
repo.setLocation( location.getAbsolutePath() );
repo.setBlockRedeployments( blockRedeployments );
-
+
return repo;
}
File testConf = new File( "src/test/resources/repository-archiva.xml" );
File testConfDest = new File( appserverBase, "conf/archiva.xml" );
+ if ( testConfDest.exists() )
+ {
+ FileUtils.deleteQuietly( testConfDest );
+ }
FileUtils.copyFile( testConf, testConfDest );
//archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
repoRootLegacy = new File( appserverBase, "data/repositories/legacy" );
Configuration config = archivaConfiguration.getConfiguration();
- config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) );
- config.addManagedRepository( createManagedRepository( REPOID_LEGACY, "Legacy Format Test Repo", repoRootLegacy, "legacy", true ) );
- saveConfiguration( archivaConfiguration );
+ if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_INTERNAL ) )
+ {
+ config.addManagedRepository(
+ createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) );
+ saveConfiguration( archivaConfiguration );
+ }
+ if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_LEGACY ) )
+ {
+ config.addManagedRepository(
+ createManagedRepository( REPOID_LEGACY, "Legacy Format Test Repo", repoRootLegacy, "legacy", true ) );
+ saveConfiguration( archivaConfiguration );
+ }
+
- CacheManager.getInstance().removeCache( "url-failures-cache" );
+ //CacheManager.getInstance().removeCache( "url-failures-cache" );
+ CacheManager.getInstance().clearAll();
- HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
sr = new ServletRunner( new File( "src/test/resources/WEB-INF/web.xml" ) );
+
sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() );
sc = sr.newClient();
}
protected void assertManagedFileNotExists( File repoRootInternal, String resourcePath )
{
File repoFile = new File( repoRootInternal, resourcePath );
- assertFalse( "Managed Repository File <" + repoFile.getAbsolutePath() + "> should not exist.", repoFile
- .exists() );
+ assertFalse( "Managed Repository File <" + repoFile.getAbsolutePath() + "> should not exist.",
+ repoFile.exists() );
}
protected void setupCleanInternalRepo()
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ 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.
- -->
-
-<component-set>
- <components>
- <!-- Components that are common for all test cases -->
- <component>
- <role>org.apache.maven.archiva.webdav.util.MimeTypes</role>
- <implementation>org.apache.maven.archiva.webdav.util.MimeTypes</implementation>
- <description>MimeTypes</description>
- <configuration>
- <resource>archiva-mime-types.txt</resource>
- </configuration>
- </component>
-
- <component>
- <role>org.apache.archiva.metadata.repository.MetadataRepository</role>
- <implementation>org.apache.archiva.metadata.repository.TestMetadataRepository</implementation>
- </component>
- <component>
- <role>org.apache.archiva.metadata.repository.RepositorySessionFactory</role>
- <implementation>org.apache.archiva.metadata.repository.TestRepositorySessionFactory</implementation>
- </component>
- </components>
-</component-set>
\ No newline at end of file