diff options
author | Olivier Lamy <olamy@apache.org> | 2013-11-13 06:33:14 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2013-11-13 06:33:14 +0000 |
commit | 402f10c84133ca2cfbfc612255551b7c88791e32 (patch) | |
tree | bcdd1531f49e19b7b6982b27eeb5ab9b5e04ddf1 /archiva-modules/archiva-base/archiva-configuration/src | |
parent | ab6f5bde33f4ab6899557733fac009497053952e (diff) | |
download | archiva-402f10c84133ca2cfbfc612255551b7c88791e32.tar.gz archiva-402f10c84133ca2cfbfc612255551b7c88791e32.zip |
code cleanup comment
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1541400 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-configuration/src')
-rw-r--r-- | archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java index e4604476b..b6a678e95 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java @@ -45,8 +45,8 @@ import static org.junit.Assert.*; /** * Test the configuration store. */ -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@RunWith(ArchivaSpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) public class ArchivaConfigurationTest { @@ -75,7 +75,7 @@ public class ArchivaConfigurationTest { ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-defaults" ); Configuration configuration = archivaConfiguration.getConfiguration(); - + assertConfiguration( configuration, 2, 1, 1 ); assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); @@ -88,7 +88,7 @@ public class ArchivaConfigurationTest assertEquals( "check managed repositories", "default", repository.getLayout() ); assertTrue( "check managed repositories", repository.isScanned() ); } - + @Test public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource() throws Exception @@ -217,20 +217,15 @@ public class ArchivaConfigurationTest configuration.getWebapp().getUi().setAppletFindEnabled( false ); // add a change listener - //MockControl control = createConfigurationListenerMockControl(); - ConfigurationListener listener = createMock( ConfigurationListener.class );// (ConfigurationListener) control.getMock(); + ConfigurationListener listener = createMock( ConfigurationListener.class ); archivaConfiguration.addListener( listener ); listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) ); - //control.setVoidCallable(); - - //control.replay(); replay( listener ); archivaConfiguration.save( configuration ); - //control.verify(); verify( listener ); assertTrue( "Check file exists", file.exists() ); @@ -265,7 +260,7 @@ public class ArchivaConfigurationTest assertFalse( userFile.exists() ); userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); @@ -306,23 +301,15 @@ public class ArchivaConfigurationTest configuration.getWebapp().getUi().setAppletFindEnabled( false ); // add a change listener - //MockControl control = createConfigurationListenerMockControl(); - //ConfigurationListener listener = (ConfigurationListener) control.getMock(); ConfigurationListener listener = createConfigurationListenerMockControl(); archivaConfiguration.addListener( listener ); listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) ); - //control.setVoidCallable( 1 ); - - //control.replay(); - replay( listener ); archivaConfiguration.save( configuration ); - //control.verify(); - verify( listener ); assertTrue( "Check file exists", userFile.exists() ); @@ -361,7 +348,7 @@ public class ArchivaConfigurationTest assertFalse( userFile.exists() ); baseFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user-fallback" ); @@ -396,13 +383,12 @@ public class ArchivaConfigurationTest assertFalse( userFile.exists() ); baseFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName( "UTF-8" ) ); userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName( "UTF-8" ) ); - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); + ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); archivaConfiguration.reload(); @@ -415,10 +401,10 @@ public class ArchivaConfigurationTest assertTrue( "Check file exists", baseFile.exists() ); assertEquals( "Check base file is unchanged", "<configuration/>", - FileUtils.readFileToString( baseFile, Charset.forName("UTF-8") ) ); + FileUtils.readFileToString( baseFile, Charset.forName( "UTF-8" ) ) ); assertTrue( "Check file exists", userFile.exists() ); assertFalse( "Check base file is changed", - "<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName("UTF-8") ) ) ); + "<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) ) ) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -441,10 +427,9 @@ public class ArchivaConfigurationTest FileUtils.copyFile( getTestFile( "src/test/conf/conf-user.xml" ), userFile ); baseFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName( "UTF-8" ) ); - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); + ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); archivaConfiguration.reload(); @@ -457,10 +442,10 @@ public class ArchivaConfigurationTest assertTrue( "Check file exists", baseFile.exists() ); assertEquals( "Check base file is unchanged", "<configuration/>", - FileUtils.readFileToString( baseFile, Charset.forName("UTF-8") ) ); + FileUtils.readFileToString( baseFile, Charset.forName( "UTF-8" ) ) ); assertTrue( "Check file exists", userFile.exists() ); assertFalse( "Check base file is changed", - "<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName("UTF-8") ) ) ); + "<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) ) ) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -483,10 +468,9 @@ public class ArchivaConfigurationTest FileUtils.copyFile( getTestFile( "src/test/conf/conf-base.xml" ), baseFile ); userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName( "UTF-8" ) ); - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); + ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); archivaConfiguration.reload(); @@ -636,9 +620,6 @@ public class ArchivaConfigurationTest // Save the file. archivaConfiguration.save( configuration ); - // Release existing - //release( archivaConfiguration ); - // Reload. archivaConfiguration = lookup( ArchivaConfiguration.class, "test-autodetect-v1" ); configuration = archivaConfiguration.getConfiguration(); @@ -650,7 +631,7 @@ public class ArchivaConfigurationTest assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() ); assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); - String actualXML = FileUtils.readFileToString( userFile, Charset.forName("UTF-8") ); + String actualXML = FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) ); XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML ); XMLAssert.assertXpathNotExists( "//configuration/repositories", actualXML ); } @@ -758,7 +739,7 @@ public class ArchivaConfigurationTest FileUtils.copyFile( getTestFile( "src/test/conf/conf-single-list-elements.xml" ), baseFile ); userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-remove-central" ); |