continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r677275 - in /continuum/trunk/continuum-base/continuum-configuration/src: main/java/org/apache/continuum/configuration/ main/resources/META-INF/ test/java/org/apache/continuum/configuration/ test/resources/META-INF/ test/resources/META-INF/...
Date Wed, 16 Jul 2008 13:03:24 GMT
Author: evenisse
Date: Wed Jul 16 06:03:23 2008
New Revision: 677275

URL: http://svn.apache.org/viewvc?rev=677275&view=rev
Log:
Add more test + format

Added:
    continuum/trunk/continuum-base/continuum-configuration/src/main/resources/META-INF/
    continuum/trunk/continuum-base/continuum-configuration/src/main/resources/META-INF/spring-context.xml
      - copied unchanged from r676793, continuum/trunk/continuum-base/continuum-configuration/src/test/resources/META-INF/spring-context.xml
Removed:
    continuum/trunk/continuum-base/continuum-configuration/src/test/resources/META-INF/spring-context.xml
Modified:
    continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java
    continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfigurationException.java
    continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
    continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java
    continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java
    continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
    continuum/trunk/continuum-base/continuum-configuration/src/test/resources/META-INF/continuum/continuum-configuration.xml
    continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml

Modified: continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java?rev=677275&r1=677274&r2=677275&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java
(original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java
Wed Jul 16 06:03:23 2008
@@ -21,17 +21,17 @@
 
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 17 juin 2008
  * @version $Id$
+ * @since 17 juin 2008
  */
 public interface ContinuumConfiguration
 {
     GeneralConfiguration getGeneralConfiguration()
         throws ContinuumConfigurationException;
 
-     void setGeneralConfiguration( GeneralConfiguration generalConfiguration )
+    void setGeneralConfiguration( GeneralConfiguration generalConfiguration )
         throws ContinuumConfigurationException;
-    
+
     void save()
         throws ContinuumConfigurationException;
 

Modified: continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfigurationException.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfigurationException.java?rev=677275&r1=677274&r2=677275&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfigurationException.java
(original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ContinuumConfigurationException.java
Wed Jul 16 06:03:23 2008
@@ -21,8 +21,8 @@
 
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 30 Jun 08
  * @version $Id$
+ * @since 30 Jun 08
  */
 public class ContinuumConfigurationException
     extends Exception

Modified: continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java?rev=677275&r1=677274&r2=677275&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
(original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
Wed Jul 16 06:03:23 2008
@@ -19,9 +19,6 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-
 import org.apache.commons.configuration.CombinedConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
@@ -30,39 +27,40 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.core.io.ClassPathResource;
 
+import java.io.File;
+import java.io.IOException;
+
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 17 juin 2008
  * @version $Id$
+ * @since 17 juin 2008
  */
 public class DefaultContinuumConfiguration
     implements ContinuumConfiguration
 {
-
     private Logger log = LoggerFactory.getLogger( getClass() );
 
     private ClassPathResource classPathResource;
-    
+
     private Configuration configuration;
-    
+
     private GeneralConfiguration generalConfiguration;
-    
+
     public static final String BASE_URL_KEY = "continuum.baseUrl";
-    
+
     public static final String BUILDOUTPUT_DIR_KEY = "continuum.buildOutputDirectory";
-    
+
     public static final String DEPLOYMENT_REPOSITORY_DIR_KEY = "continuum.deploymentRepositoryDirectory";
-    
+
     public static final String WORKING_DIR_KEY = "continuum.workingDirectory";
-    
+
     public static final String PROXY_HOST_KEY = "continuum.proxyHost";
-    
+
     public static final String PROXY_PORT_KEY = "continuum.proxyPort";
-    
+
     public static final String PROXY_USER_KEY = "continuum.proxyUser";
-    
-    public static final String PROXY_PASSWORD_KEY = "continuum.proxyPassword";
 
+    public static final String PROXY_PASSWORD_KEY = "continuum.proxyPassword";
 
     //----------------------------------------------------
     //  Initialize method configured in the Spring xml 
@@ -77,52 +75,63 @@
 
         try
         {
-            DefaultConfigurationBuilder defaultConfigurationBuilder = new DefaultConfigurationBuilder(classPathResource.getURL());
+            DefaultConfigurationBuilder defaultConfigurationBuilder =
+                new DefaultConfigurationBuilder( classPathResource.getURL() );
             defaultConfigurationBuilder.load( classPathResource.getInputStream() );
-             
+
             CombinedConfiguration combinedConfiguration = defaultConfigurationBuilder.getConfiguration(
false );
             configuration = combinedConfiguration.getConfiguration( "org.apache.continuum"
);
-            
-            
+
             this.generalConfiguration = new GeneralConfiguration();
-            this.generalConfiguration.setBaseUrl( configuration.getString( BASE_URL_KEY )
);
+            this.generalConfiguration.setBaseUrl( getConfigurationString( BASE_URL_KEY )
);
+            log.info( "BaseUrl=" +this.generalConfiguration.getBaseUrl() );
             // TODO check if files exists ?
-            String buildOutputDirectory = configuration.getString( BUILDOUTPUT_DIR_KEY );
+            String buildOutputDirectory = getConfigurationString( BUILDOUTPUT_DIR_KEY );
             if ( buildOutputDirectory != null )
             {
                 this.generalConfiguration.setBuildOutputDirectory( new File( buildOutputDirectory
) );
             }
-            String deploymentRepositoryDirectory = configuration.getString( DEPLOYMENT_REPOSITORY_DIR_KEY
);
+            String deploymentRepositoryDirectory = getConfigurationString( DEPLOYMENT_REPOSITORY_DIR_KEY
);
             if ( deploymentRepositoryDirectory != null )
             {
                 this.generalConfiguration.setDeploymentRepositoryDirectory( new File( deploymentRepositoryDirectory
) );
             }
-            String workingDirectory = configuration.getString( WORKING_DIR_KEY );
+            String workingDirectory = getConfigurationString( WORKING_DIR_KEY );
             if ( workingDirectory != null )
             {
                 this.generalConfiguration.setWorkingDirectory( new File( workingDirectory
) );
             }
-            
+
             this.generalConfiguration.setProxyConfiguration( new ProxyConfiguration() );
-            this.generalConfiguration.getProxyConfiguration().setProxyHost( configuration.getString(
PROXY_HOST_KEY ) );
-            this.generalConfiguration.getProxyConfiguration().setProxyPort( configuration.getInt(
PROXY_PORT_KEY, 0 ) );
-            this.generalConfiguration.getProxyConfiguration().setProxyUser( configuration.getString(
PROXY_USER_KEY ) );
-            this.generalConfiguration.getProxyConfiguration().setProxyPassword(
-                                                                                configuration
-                                                                                    .getString(
PROXY_PASSWORD_KEY ) );
+            this.generalConfiguration.getProxyConfiguration().setProxyHost( getConfigurationString(
PROXY_HOST_KEY ) );
+            this.generalConfiguration.getProxyConfiguration().setProxyPort(
+                getConfigurationValue( PROXY_PORT_KEY, 0 ) );
+            this.generalConfiguration.getProxyConfiguration().setProxyUser( getConfigurationString(
PROXY_USER_KEY ) );
+            this.generalConfiguration.getProxyConfiguration().setProxyPassword( configuration
+                .getString( PROXY_PASSWORD_KEY ) );
         }
         catch ( org.apache.commons.configuration.ConfigurationException e )
         {
             log.error( e.getMessage(), e );
             throw new RuntimeException( e.getMessage(), e );
-        }catch (IOException e)
+        }
+        catch ( IOException e )
         {
             log.error( e.getMessage(), e );
             throw new RuntimeException( e.getMessage(), e );
         }
+    }
 
+    private String getConfigurationString( String key )
+    {
+        log.info( "Configuration=" + configuration );
+        return configuration.getString( key );
     }
 
+    private int getConfigurationValue( String key, int defaultValue )
+    {
+        return configuration.getInt( key, defaultValue );
+    }
 
     public void reload()
         throws ContinuumConfigurationException
@@ -144,18 +153,15 @@
         }
     }
 
-
-
-
-    /** 
-     * @see org.apache.maven.continuum.configuration.ContinuumConfiguration#getGeneralConfiguration()
+    /**
+     * @see org.apache.continuum.configuration.ContinuumConfiguration#getGeneralConfiguration()
      */
     public GeneralConfiguration getGeneralConfiguration()
         throws ContinuumConfigurationException
     {
         return this.generalConfiguration;
     }
-    
+
     public void setGeneralConfiguration( GeneralConfiguration generalConfiguration )
         throws ContinuumConfigurationException
     {
@@ -188,7 +194,7 @@
     // ----------------------------------------
     //  Spring injection
     // ----------------------------------------
-    
+
     public ClassPathResource getClassPathResource()
     {
         return classPathResource;
@@ -198,6 +204,6 @@
     public void setClassPathResource( ClassPathResource classPathResource )
     {
         this.classPathResource = classPathResource;
-    }    
-    
+    }
+
 }

Modified: continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java?rev=677275&r1=677274&r2=677275&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java
(original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java
Wed Jul 16 06:03:23 2008
@@ -19,35 +19,32 @@
  * under the License.
  */
 
-import java.io.File;
-
 import org.apache.commons.lang.builder.ReflectionToStringBuilder;
 
-
+import java.io.File;
 
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 17 juin 2008
  * @version $Id$
+ * @since 17 juin 2008
  */
 public class GeneralConfiguration
 {
-
     private File workingDirectory;
 
     private File buildOutputDirectory;
-    
+
     private File deploymentRepositoryDirectory;
-    
-    private String baseUrl;    
-    
+
+    private String baseUrl;
+
     private ProxyConfiguration proxyConfiguration;
-    
+
     public GeneralConfiguration()
     {
         // nothing here
     }
-    
+
     public File getWorkingDirectory()
     {
         return workingDirectory;
@@ -104,5 +101,5 @@
         return ReflectionToStringBuilder.toString( this );
     }
 
-    
+
 }

Modified: continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java?rev=677275&r1=677274&r2=677275&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java
(original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java
Wed Jul 16 06:03:23 2008
@@ -1,7 +1,5 @@
 package org.apache.continuum.configuration;
 
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -21,21 +19,23 @@
  * under the License.
  */
 
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 24 juin 2008
  * @version $Id$
+ * @since 24 juin 2008
  */
 public class ProxyConfiguration
 {
     private String proxyHost;
 
     private int proxyPort;
-    
+
     private String proxyUser;
-    
+
     private String proxyPassword;
-    
+
     public ProxyConfiguration()
     {
         // nothing here
@@ -80,10 +80,10 @@
     {
         this.proxyPassword = proxyPassword;
     }
-    
+
     @Override
     public String toString()
     {
         return ReflectionToStringBuilder.toString( this );
-    }    
+    }
 }

Modified: continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java?rev=677275&r1=677274&r2=677275&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
(original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
Wed Jul 16 06:03:23 2008
@@ -19,34 +19,32 @@
  * under the License.
  */
 
-import java.io.File;
-
-import org.apache.continuum.configuration.ContinuumConfiguration;
-import org.apache.continuum.configuration.GeneralConfiguration;
-import org.apache.continuum.configuration.ProxyConfiguration;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.codehaus.plexus.util.FileUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 17 juin 2008
  * @version $Id$
+ * @since 17 juin 2008
  */
 public class TestDefaultContinuumConfiguration
     extends PlexusInSpringTestCase
 {
-
     private Logger log = LoggerFactory.getLogger( getClass() );
-    
+
+    private String confFile = "target/test-classes/conf/continuum.xml";
+
     @Override
     protected void setUp()
         throws Exception
     {
         File originalConf = new File( getBasedir(), "src/test/resources/conf/continuum.xml"
);
 
-        File confUsed = new File( getBasedir(), "target/test-classes/conf/continuum.xml"
);
+        File confUsed = new File( getBasedir(), confFile );
         if ( confUsed.exists() )
         {
             confUsed.delete();
@@ -58,23 +56,26 @@
     public void testLoad()
         throws Exception
     {
-        ContinuumConfiguration configuration = (ContinuumConfiguration) lookup( ContinuumConfiguration.class,
"default" );
+        ContinuumConfiguration configuration =
+            (ContinuumConfiguration) lookup( ContinuumConfiguration.class, "default" );
         assertNotNull( configuration );
         GeneralConfiguration generalConfiguration = configuration.getGeneralConfiguration();
         assertNotNull( generalConfiguration );
         assertNotNull( generalConfiguration.getBaseUrl() );
         assertEquals( "http://test", generalConfiguration.getBaseUrl() );
+        assertEquals( new File( "myBuildOutputDir" ), generalConfiguration.getBuildOutputDirectory()
);
     }
-    
+
     public void testDefaultConfiguration()
         throws Exception
     {
-        File conf = new File( getBasedir(), "target/test-classes/conf/continuum.xml" );
+        File conf = new File( getBasedir(), confFile );
         if ( conf.exists() )
         {
             conf.delete();
         }
-        ContinuumConfiguration configuration = (ContinuumConfiguration) lookup( ContinuumConfiguration.class,
"default" );
+        ContinuumConfiguration configuration =
+            (ContinuumConfiguration) lookup( ContinuumConfiguration.class, "default" );
         assertNotNull( configuration );
         GeneralConfiguration generalConfiguration = new GeneralConfiguration();
         generalConfiguration.setBaseUrl( "http://test/zloug" );
@@ -84,11 +85,15 @@
         configuration.setGeneralConfiguration( generalConfiguration );
         configuration.save();
 
+        String contents = FileUtils.fileRead( conf );
+        assertTrue( contents.indexOf( "http://test/zloug" ) > 0 );
+        assertTrue( contents.indexOf( "localhost" ) > 0 );
+        assertTrue( contents.indexOf( "8080" ) > 0 );
+
         configuration.reload();
         assertEquals( "http://test/zloug", configuration.getGeneralConfiguration().getBaseUrl()
);
         assertEquals( "localhost", configuration.getGeneralConfiguration().getProxyConfiguration().getProxyHost()
);
         assertEquals( 8080, configuration.getGeneralConfiguration().getProxyConfiguration().getProxyPort()
);
         log.info( "generalConfiguration " + configuration.getGeneralConfiguration().toString()
);
     }
-   
 }

Modified: continuum/trunk/continuum-base/continuum-configuration/src/test/resources/META-INF/continuum/continuum-configuration.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/test/resources/META-INF/continuum/continuum-configuration.xml?rev=677275&r1=677274&r2=677275&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/test/resources/META-INF/continuum/continuum-configuration.xml
(original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/test/resources/META-INF/continuum/continuum-configuration.xml
Wed Jul 16 06:03:23 2008
@@ -26,4 +26,4 @@
        config-forceCreate="true" config-name="org.apache.continuum"/>
   <xml fileName="${user.home}/.m2/continuum.xml" config-optional="true"
        config-forceCreate="true" config-name="org.apache.continuum.user"/>  
-</configuration>
\ No newline at end of file
+</configuration>

Modified: continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml?rev=677275&r1=677274&r2=677275&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml
(original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml
Wed Jul 16 06:03:23 2008
@@ -2,5 +2,6 @@
 <configuration>
   <continuum>
     <baseUrl>http://test</baseUrl>
+    <buildOutputDirectory>myBuildOutputDir</buildOutputDirectory>
   </continuum>
 </configuration>
\ No newline at end of file



Mime
View raw message