]> source.dussan.org Git - archiva.git/commitdiff
[MRM-430] revert configuration if it failed to save
authorBrett Porter <brett@apache.org>
Fri, 3 Aug 2007 14:48:18 +0000 (14:48 +0000)
committerBrett Porter <brett@apache.org>
Fri, 3 Aug 2007 14:48:18 +0000 (14:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@562488 13f79535-47bb-0310-9956-ffa450edef68

archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java

index 6cf53bd0a0ca0d45a8cf9498d39480c0b60ca3d0..540a8653919a280644830403e93adff784b77629 100644 (file)
@@ -28,7 +28,6 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce
 import org.codehaus.plexus.registry.Registry;
 import org.codehaus.plexus.registry.RegistryException;
 import org.codehaus.plexus.registry.RegistryListener;
-import org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
@@ -148,6 +147,8 @@ public class DefaultArchivaConfiguration
         }
         else if ( registry.getSection( KEY + ".base" ) != null )
         {
+            this.configuration = null;
+
             throw new IndeterminateConfigurationException(
                 "Configuration can not be saved when it is loaded from two sources" );
         }
@@ -174,7 +175,7 @@ public class DefaultArchivaConfiguration
 
         try
         {
-            ( (CommonsConfigurationRegistry) registry ).initialize();
+            ( (Initializable) registry ).initialize();
         }
         catch ( InitializationException e )
         {
index 6145832bc2183a7427ef56778237867d9b9444e6..7c6dd36c3c3e0efc6e95ae5ea55a87651a963f75 100644 (file)
@@ -308,9 +308,9 @@ public class ArchivaConfigurationTest
         ArchivaConfiguration archivaConfiguration =
             (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" );
 
-        Configuration configuration = new Configuration();
-        configuration.setWebapp( new WebappConfiguration() );
-        configuration.getWebapp().setUi( new UserInterfaceOptions() );
+        Configuration configuration = archivaConfiguration.getConfiguration();
+        assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
+
         configuration.getWebapp().getUi().setAppletFindEnabled( false );
 
         try
@@ -320,7 +320,9 @@ public class ArchivaConfigurationTest
         }
         catch ( IndeterminateConfigurationException e )
         {
-            assertTrue( true );
+            // check it was reverted
+            configuration = archivaConfiguration.getConfiguration();
+            assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
         }
     }