maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r793342 - in /maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder: ./ project/ validation/
Date Sun, 12 Jul 2009 12:59:21 GMT
Author: bentmann
Date: Sun Jul 12 12:59:21 2009
New Revision: 793342

URL: http://svn.apache.org/viewvc?rev=793342&view=rev
Log:
o Made embedder tests respect maven.repo.local

Added:
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/SimpleConfiguration.java
  (with props)
Modified:
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderTestCase.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderAligningBasedirTest.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/TestComponentOverride.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/BadModuleNotRecursiveTest.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/validation/MavenEmbedderCrappySettingsConfigurationTest.java

Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderTestCase.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderTestCase.java?rev=793342&r1=793341&r2=793342&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderTestCase.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderTestCase.java
Sun Jul 12 12:59:21 2009
@@ -46,10 +46,7 @@
     {
         super.setUp();
 
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
-        Configuration configuration = new DefaultConfiguration().setClassLoader( classLoader
).setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
-        configuration.setUserSettingsFile( MavenEmbedder.DEFAULT_USER_SETTINGS_FILE );
+        Configuration configuration = new SimpleConfiguration();
 
         maven = new MavenEmbedder( configuration );
         

Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderAligningBasedirTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderAligningBasedirTest.java?rev=793342&r1=793341&r2=793342&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderAligningBasedirTest.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderAligningBasedirTest.java
Sun Jul 12 12:59:21 2009
@@ -21,7 +21,6 @@
 
 import java.io.File;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -52,12 +51,7 @@
             basedir = new File( "." ).getCanonicalPath();
         }
 
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
-        Configuration configuration = new DefaultConfiguration()
-            .setClassLoader( classLoader )
-            .setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
-        configuration.setUserSettingsFile( MavenEmbedder.DEFAULT_USER_SETTINGS_FILE );
+        Configuration configuration = new SimpleConfiguration();
 
         mavenEmbedder = new MavenEmbedder( configuration );
     }
@@ -70,7 +64,7 @@
 
     protected void assertNoExceptions( MavenExecutionResult result )
     {
-        List exceptions = result.getExceptions();
+        List<Exception> exceptions = result.getExceptions();
         if ( ( exceptions == null ) || exceptions.isEmpty() )
         {
             // everything is a-ok.
@@ -78,10 +72,8 @@
         }
 
         System.err.println( "Encountered " + exceptions.size() + " exception(s)." );
-        Iterator it = exceptions.iterator();
-        while ( it.hasNext() )
+        for ( Exception exception : exceptions )
         {
-            Exception exception = (Exception) it.next();
             exception.printStackTrace( System.err );
         }
 

Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java?rev=793342&r1=793341&r2=793342&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java
Sun Jul 12 12:59:21 2009
@@ -81,9 +81,7 @@
         public ExtendableMavenEmbedder( ClassLoader classLoader )
             throws MavenEmbedderException
         {
-            super( new DefaultConfiguration()
-                .setClassLoader( classLoader )
-                .setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() ) );
+            super( new SimpleConfiguration().setClassLoader( classLoader ) );
         }
 
         protected Map<String, ArtifactHandler> getPluginExtensionComponents( Plugin
plugin )

Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java?rev=793342&r1=793341&r2=793342&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
Sun Jul 12 12:59:21 2009
@@ -25,7 +25,6 @@
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -71,12 +70,7 @@
             basedir = new File( "." ).getCanonicalPath();
         }
 
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
-        Configuration configuration = new DefaultConfiguration()
-            .setClassLoader( classLoader )
-            .setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
-        configuration.setUserSettingsFile( MavenEmbedder.DEFAULT_USER_SETTINGS_FILE );
+        Configuration configuration = new SimpleConfiguration();
 
         mavenEmbedder = new MavenEmbedder( configuration );
 
@@ -92,7 +86,7 @@
 
     protected void assertNoExceptions( MavenExecutionResult result )
     {
-        List exceptions = result.getExceptions();
+        List<Exception> exceptions = result.getExceptions();
         if ( ( exceptions == null ) || exceptions.isEmpty() )
         {
             // everything is a-ok.
@@ -100,10 +94,8 @@
         }
 
         System.err.println( "Encountered " + exceptions.size() + " exception(s)." );
-        Iterator it = exceptions.iterator();
-        while ( it.hasNext() )
+        for (Exception exception : exceptions)
         {
-            Exception exception = (Exception) it.next();
             exception.printStackTrace( System.err );
         }
 
@@ -181,11 +173,10 @@
             .setGoals( Arrays.asList( new String[]{"validate"} ) );
 
         MavenExecutionResult result = mavenEmbedder.execute( request );
-        List exceptions = result.getExceptions();
+        List<Exception> exceptions = result.getExceptions();
         assertEquals("Incorrect number of exceptions", 1, exceptions.size());
 
-        Iterator it = exceptions.iterator();
-        if( (it.next() instanceof NullPointerException))
+        if ( ( exceptions.get( 0 ) instanceof NullPointerException ) )
         {
             fail("Null Pointer on Exception");
         }
@@ -306,7 +297,7 @@
 
         MavenProject project = result.getProject();
 
-        Artifact p = (Artifact) project.getPluginArtifactMap().get( plugin.getKey() );
+        Artifact p = project.getPluginArtifactMap().get( plugin.getKey() );
         assertEquals( "2.4.2", p.getVersion() );
 
         /* Add the surefire plugin 2.3 to the pom */
@@ -324,7 +315,7 @@
 
         project = result.getProject();
 
-        p = (Artifact) project.getPluginArtifactMap().get( plugin.getKey() );
+        p = project.getPluginArtifactMap().get( plugin.getKey() );
         assertEquals( "2.4.3", p.getVersion() );
     }
 
@@ -365,7 +356,7 @@
 
         assertEquals( "org.apache.maven", result.getProject().getGroupId() );
 
-        Set artifacts = result.getProject().getArtifacts();
+        Set<Artifact> artifacts = result.getProject().getArtifacts();
 
         assertEquals( 1, artifacts.size() );
 

Added: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/SimpleConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/SimpleConfiguration.java?rev=793342&view=auto
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/SimpleConfiguration.java
(added)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/SimpleConfiguration.java
Sun Jul 12 12:59:21 2009
@@ -0,0 +1,49 @@
+package org.apache.maven.embedder;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+/**
+ * A configuration to be used for unit testing of the embedder. This basically sets some
default values.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class SimpleConfiguration
+    extends DefaultConfiguration
+{
+
+    public SimpleConfiguration()
+    {
+        String localRepo = System.getProperty( "maven.repo.local", "" );
+
+        if ( localRepo.length() > 0 )
+        {
+            setLocalRepository( new File( localRepo ).getAbsoluteFile() );
+        }
+
+        setClassLoader( Thread.currentThread().getContextClassLoader() );
+
+        setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
+
+        setUserSettingsFile( MavenEmbedder.DEFAULT_USER_SETTINGS_FILE );
+    }
+
+}

Propchange: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/SimpleConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/SimpleConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/TestComponentOverride.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/TestComponentOverride.java?rev=793342&r1=793341&r2=793342&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/TestComponentOverride.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/TestComponentOverride.java
Sun Jul 12 12:59:21 2009
@@ -37,13 +37,7 @@
     protected void setUp()
         throws Exception
     {
-        ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
-        Configuration request = new DefaultConfiguration();
-
-        request.setClassLoader( loader );
-
-        request.setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
+        Configuration request = new SimpleConfiguration();
 
         File extensions = new File( getBasedir(), "src/test/extensions" );
         

Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/BadModuleNotRecursiveTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/BadModuleNotRecursiveTest.java?rev=793342&r1=793341&r2=793342&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/BadModuleNotRecursiveTest.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/BadModuleNotRecursiveTest.java
Sun Jul 12 12:59:21 2009
@@ -1,14 +1,12 @@
 package org.apache.maven.embedder.project;
 
 import java.io.File;
-import java.util.Iterator;
 
 import junit.framework.TestCase;
 
 import org.apache.maven.embedder.Configuration;
-import org.apache.maven.embedder.DefaultConfiguration;
 import org.apache.maven.embedder.MavenEmbedder;
-import org.apache.maven.embedder.MavenEmbedderConsoleLogger;
+import org.apache.maven.embedder.SimpleConfiguration;
 import org.apache.maven.execution.DefaultMavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionResult;
 import org.apache.maven.project.MavenProject;
@@ -19,8 +17,7 @@
     public void test()
         throws Exception
     {
-        Configuration configuration = new DefaultConfiguration();
-        configuration.setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
+        Configuration configuration = new SimpleConfiguration();
         MavenEmbedder embedder = new MavenEmbedder( configuration );
 
         File pom = new File( "src/test/projects/bad-module-non-recursive/pom.xml" ).getCanonicalFile();
@@ -39,10 +36,9 @@
 
         if ( result.hasExceptions() )
         {
-            for ( Iterator it = result.getExceptions().iterator(); it.hasNext(); )
+            for ( Exception e : result.getExceptions() )
             {
-                Exception ex = (Exception) it.next();
-                ex.printStackTrace();
+                e.printStackTrace();
             }
         }
 

Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/validation/MavenEmbedderCrappySettingsConfigurationTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/validation/MavenEmbedderCrappySettingsConfigurationTest.java?rev=793342&r1=793341&r2=793342&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/validation/MavenEmbedderCrappySettingsConfigurationTest.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/validation/MavenEmbedderCrappySettingsConfigurationTest.java
Sun Jul 12 12:59:21 2009
@@ -21,12 +21,11 @@
 
 import java.io.File;
 import java.util.Arrays;
-import java.util.Iterator;
 
 import org.apache.maven.embedder.Configuration;
 import org.apache.maven.embedder.ConfigurationValidationResult;
-import org.apache.maven.embedder.DefaultConfiguration;
 import org.apache.maven.embedder.MavenEmbedder;
+import org.apache.maven.embedder.SimpleConfiguration;
 import org.apache.maven.execution.DefaultMavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionResult;
@@ -45,9 +44,8 @@
 
         File user = new File( projectDirectory, "invalid-settings.xml" );
 
-        Configuration configuration = new DefaultConfiguration()
-            .setUserSettingsFile( user )
-            .setClassLoader( Thread.currentThread().getContextClassLoader() );
+        Configuration configuration = new SimpleConfiguration()
+            .setUserSettingsFile( user );
 
         ConfigurationValidationResult validationResult = MavenEmbedder.validateConfiguration(
configuration );
 
@@ -63,9 +61,8 @@
 
         MavenExecutionResult result = embedder.execute( request );
         
-        for ( Iterator i = result.getExceptions().iterator(); i.hasNext(); )
+        for ( Exception e : result.getExceptions() )
         {
-            Exception e = (Exception) i.next();
             e.printStackTrace();
         }
         



Mime
View raw message