[MRM-546] re-enable tests that are passing

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@587070 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2007-10-22 12:36:50 +00:00
parent d2ceac7b0b
commit 858f0283d1
1 changed files with 23 additions and 33 deletions

View File

@ -20,9 +20,9 @@ package org.apache.maven.archiva.configuration;
*/ */
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryException; import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
import org.custommonkey.xmlunit.XMLAssert;
import org.easymock.MockControl; import org.easymock.MockControl;
import java.io.File; import java.io.File;
@ -37,17 +37,6 @@ import java.util.Map;
public class ArchivaConfigurationTest public class ArchivaConfigurationTest
extends PlexusTestCase extends PlexusTestCase
{ {
@SuppressWarnings("unused")
private Registry registry;
protected void setUp()
throws Exception
{
super.setUp();
registry = (Registry) lookup( Registry.ROLE, "commons-configuration" );
}
public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource() public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource()
throws Exception throws Exception
{ {
@ -195,7 +184,7 @@ public class ArchivaConfigurationTest
MockControl control = createConfigurationListenerMockControl(); MockControl control = createConfigurationListenerMockControl();
ConfigurationListener listener = (ConfigurationListener) control.getMock(); ConfigurationListener listener = (ConfigurationListener) control.getMock();
archivaConfiguration.addListener( listener ); archivaConfiguration.addListener( listener );
listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) ); listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) );
control.setVoidCallable(); control.setVoidCallable();
@ -220,8 +209,7 @@ public class ArchivaConfigurationTest
private static MockControl createConfigurationListenerMockControl() private static MockControl createConfigurationListenerMockControl()
{ {
MockControl control = MockControl.createControl( ConfigurationListener.class ); return MockControl.createControl( ConfigurationListener.class );
return control;
} }
public void testStoreConfigurationUser() public void testStoreConfigurationUser()
@ -303,7 +291,7 @@ public class ArchivaConfigurationTest
{ {
DefaultArchivaConfiguration archivaConfiguration = DefaultArchivaConfiguration archivaConfiguration =
(DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class.getName() ); (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class.getName() );
assertEquals( System.getProperty( "user.home" ) + "/.m2/archiva.xml", assertEquals( System.getProperty( "user.home" ) + "/.m2/archiva.xml",
archivaConfiguration.getUserConfigFilename() ); archivaConfiguration.getUserConfigFilename() );
assertEquals( System.getProperty( "appserver.base", "${appserver.base}" ) + "/conf/archiva.xml", assertEquals( System.getProperty( "appserver.base", "${appserver.base}" ) + "/conf/archiva.xml",
@ -457,13 +445,14 @@ public class ArchivaConfigurationTest
assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
} }
} }
public void testLoadConfigurationFromInvalidBothLocationsOnDisk() throws Exception public void testLoadConfigurationFromInvalidBothLocationsOnDisk()
throws Exception
{ {
ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), ArchivaConfiguration archivaConfiguration =
"test-not-allowed-to-write-to-both" ); (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-not-allowed-to-write-to-both" );
Configuration config = archivaConfiguration.getConfiguration(); Configuration config = archivaConfiguration.getConfiguration();
try try
{ {
archivaConfiguration.save( config ); archivaConfiguration.save( config );
@ -474,14 +463,15 @@ public class ArchivaConfigurationTest
/* expected exception */ /* expected exception */
} }
} }
public void testLoadConfigurationFromInvalidUserLocationOnDisk() throws Exception public void testLoadConfigurationFromInvalidUserLocationOnDisk()
throws Exception
{ {
File testConfDir = getTestFile( "target/test-appserver-base/conf/" ); File testConfDir = getTestFile( "target/test-appserver-base/conf/" );
testConfDir.mkdirs(); testConfDir.mkdirs();
ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), ArchivaConfiguration archivaConfiguration =
"test-not-allowed-to-write-to-user" ); (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-not-allowed-to-write-to-user" );
Configuration config = archivaConfiguration.getConfiguration(); Configuration config = archivaConfiguration.getConfiguration();
archivaConfiguration.save( config ); archivaConfiguration.save( config );
// No Exception == test passes. // No Exception == test passes.
@ -538,34 +528,33 @@ public class ArchivaConfigurationTest
assertEquals( "check managed repositories", "internal", repository.getId() ); assertEquals( "check managed repositories", "internal", repository.getId() );
assertEquals( "check managed repositories", "default", repository.getLayout() ); assertEquals( "check managed repositories", "default", repository.getLayout() );
assertTrue( "check managed repositories", repository.isScanned() ); assertTrue( "check managed repositories", repository.isScanned() );
// Test that only 1 set of repositories exist. // Test that only 1 set of repositories exist.
assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() ); assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() );
assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() ); assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() );
assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() );
// Save the file. // Save the file.
archivaConfiguration.save( configuration ); archivaConfiguration.save( configuration );
// Release existing // Release existing
release( archivaConfiguration ); release( archivaConfiguration );
// Reload. // Reload.
archivaConfiguration = archivaConfiguration =
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-autodetect-v1" ); (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-autodetect-v1" );
configuration = archivaConfiguration.getConfiguration();
// Test that only 1 set of repositories exist. // Test that only 1 set of repositories exist.
assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() ); assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() );
assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositoriesAsMap().size() ); assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositoriesAsMap().size() );
assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() ); assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() );
assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() ); assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() );
assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() );
/* FIXME: can't get rid of old v1 <repositories> section programatically.
String actualXML = FileUtils.fileRead( userFile ); String actualXML = FileUtils.fileRead( userFile );
XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML ); XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML );
XMLAssert.assertXpathNotExists( "//configuration/repositories", actualXML ); XMLAssert.assertXpathNotExists( "//configuration/repositories", actualXML );
*/
} }
public void testArchivaV1() public void testArchivaV1()
@ -579,6 +568,7 @@ public class ArchivaConfigurationTest
assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
assertEquals( "check managed repositories", 2, configuration.getManagedRepositories().size() ); assertEquals( "check managed repositories", 2, configuration.getManagedRepositories().size() );
assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() );
Map<String, ManagedRepositoryConfiguration> map = configuration.getManagedRepositoriesAsMap(); Map<String, ManagedRepositoryConfiguration> map = configuration.getManagedRepositoriesAsMap();