aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-06-12 19:15:17 +0000
committerOlivier Lamy <olamy@apache.org>2011-06-12 19:15:17 +0000
commit4ebc70a0e642ee90b30cedbf4f5550bfbe9beb67 (patch)
tree33c9faae5b0b0f1e27ba917bb102791cbc5cfc37 /archiva-modules
parent27b5c1a52b04a14aa6433c7964a2146538fe060f (diff)
downloadarchiva-4ebc70a0e642ee90b30cedbf4f5550bfbe9beb67.tar.gz
archiva-4ebc70a0e642ee90b30cedbf4f5550bfbe9beb67.zip
ensure we save the configuration for restarting applicationcontext with httpunit tests
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1134960 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java160
1 files changed, 85 insertions, 75 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
index 63e9b11bc..e508e4aad 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
@@ -34,6 +34,7 @@ import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
+import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -64,15 +65,98 @@ public abstract class AbstractRepositoryServletTestCase
private ServletRunner sr;
- @Inject
protected ArchivaConfiguration archivaConfiguration;
+ @Inject
+ protected ApplicationContext applicationContext;
+
+
protected void saveConfiguration()
throws Exception
{
saveConfiguration( archivaConfiguration );
}
+
+ @Before
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ String appserverBase = new File( "target/appserver-base" ).getAbsolutePath();
+ System.setProperty( "appserver.base", appserverBase );
+
+ 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 = applicationContext.getBean( 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();
+
+ if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_INTERNAL ) )
+ {
+ config.addManagedRepository(
+ createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) );
+ }
+ if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_LEGACY ) )
+ {
+ config.addManagedRepository(
+ createManagedRepository( REPOID_LEGACY, "Legacy Format Test Repo", repoRootLegacy, "legacy", true ) );
+ }
+
+ saveConfiguration( archivaConfiguration );
+
+ CacheManager.getInstance().clearAll();
+
+ HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
+
+ sr = new ServletRunner( new File( "src/test/resources/WEB-INF/web.xml" ) );
+
+ sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() );
+ sc = sr.newClient();
+ }
+
+ @Override
+ @After
+ public void tearDown()
+ throws Exception
+ {
+ if ( sc != null )
+ {
+ sc.clearContents();
+ }
+
+ if ( sr != null )
+ {
+ sr.shutDown();
+ }
+
+ if ( repoRootInternal.exists() )
+ {
+ FileUtils.deleteDirectory( repoRootInternal );
+ }
+
+ if ( repoRootLegacy.exists() )
+ {
+ FileUtils.deleteDirectory( repoRootLegacy );
+ }
+
+ super.tearDown();
+ }
+
+
+
protected void assertFileContents( String expectedContents, File repoRoot, String path )
throws IOException
{
@@ -164,80 +248,6 @@ public abstract class AbstractRepositoryServletTestCase
archivaConfiguration.save( archivaConfiguration.getConfiguration() );
}
- @Before
- public void setUp()
- throws Exception
- {
- super.setUp();
-
- String appserverBase = new File( "target/appserver-base" ).getAbsolutePath();
- System.setProperty( "appserver.base", appserverBase );
-
- 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 );
- repoRootInternal = new File( appserverBase, "data/repositories/internal" );
- repoRootLegacy = new File( appserverBase, "data/repositories/legacy" );
- Configuration config = archivaConfiguration.getConfiguration();
-
- 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().clearAll();
-
- HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
-
- sr = new ServletRunner( new File( "src/test/resources/WEB-INF/web.xml" ) );
-
- sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() );
- sc = sr.newClient();
- }
-
- @Override
- @After
- public void tearDown()
- throws Exception
- {
- if ( sc != null )
- {
- sc.clearContents();
- }
-
- if ( sr != null )
- {
- sr.shutDown();
- }
-
- if ( repoRootInternal.exists() )
- {
- FileUtils.deleteDirectory( repoRootInternal );
- }
-
- if ( repoRootLegacy.exists() )
- {
- FileUtils.deleteDirectory( repoRootLegacy );
- }
-
- super.tearDown();
- }
protected void setupCleanRepo( File repoRootDir )
throws IOException