continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r432090 - in /maven/continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/core/action/ main/java/org/apache/maven/continuum/project/builder/maven/ test/java/org/apache/maven/continuum/core/action/
Date Thu, 17 Aug 2006 00:57:10 GMT
Author: carlos
Date: Wed Aug 16 17:57:09 2006
New Revision: 432090

URL: http://svn.apache.org/viewvc?rev=432090&view=rev
Log:
[CONTINUUM-776] More error handling

Added:
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
  (with props)
Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java?rev=432090&r1=432089&r2=432090&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java
Wed Aug 16 17:57:09 2006
@@ -15,6 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilderException;
@@ -42,6 +43,16 @@
 
     public static final String KEY_PROJECT_BUILDING_RESULT = "projectBuildingResult";
 
+    public void setProjectBuilderManager( ContinuumProjectBuilderManager projectBuilderManager
)
+    {
+        this.projectBuilderManager = projectBuilderManager;
+    }
+
+    public ContinuumProjectBuilderManager getProjectBuilderManager()
+    {
+        return projectBuilderManager;
+    }
+
     public void execute( Map context )
         throws ContinuumException, ContinuumProjectBuilderManagerException, ContinuumProjectBuilderException
     {
@@ -51,7 +62,7 @@
 
         URL url;
 
-        ContinuumProjectBuilder projectBuilder = projectBuilderManager.getProjectBuilder(
projectBuilderId );
+        ContinuumProjectBuilder projectBuilder = getProjectBuilderManager().getProjectBuilder(
projectBuilderId );
 
         ContinuumProjectBuildingResult result;
 
@@ -77,7 +88,7 @@
                 else
                 {
                     result = new ContinuumProjectBuildingResult();
-
+                    getLogger().info( "Malformed URL (MungedHttpsURL is not valid): " + u
);
                     result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL );
                 }
             }
@@ -85,8 +96,8 @@
         }
         catch ( MalformedURLException e )
         {
+            getLogger().info( "Malformed URL: " + u, e );
             result = new ContinuumProjectBuildingResult();
-
             result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL );
         }
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?rev=432090&r1=432089&r2=432090&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
Wed Aug 16 17:57:09 2006
@@ -195,8 +195,8 @@
             }
             catch ( MalformedURLException e )
             {
+                getLogger().debug( "Error adding project module: Malformed URL " + urlString,
e );
                 result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL, urlString
);
-
                 continue;
             }
 

Added: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java?rev=432090&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
(added)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
Wed Aug 16 17:57:09 2006
@@ -0,0 +1,69 @@
+package org.apache.maven.continuum.core.action;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.apache.maven.continuum.project.builder.manager.ContinuumProjectBuilderManager;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+public class CreateProjectsFromMetadataTest
+    extends MockObjectTestCase
+{
+
+    private CreateProjectsFromMetadata action;
+
+    private Mock projectBuilderManagerMock, projectBuilder;
+
+    protected void setUp()
+        throws Exception
+    {
+        action = new CreateProjectsFromMetadata();
+        action.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "" ) );
+        projectBuilderManagerMock = mock( ContinuumProjectBuilderManager.class );
+        action.setProjectBuilderManager( (ContinuumProjectBuilderManager) projectBuilderManagerMock.proxy()
);
+
+        projectBuilder = mock( ContinuumProjectBuilder.class );
+
+        projectBuilderManagerMock.expects( once() ).method( "getProjectBuilder" )
+            .will(returnValue( projectBuilder.proxy() ) );
+        projectBuilder.expects( once() ).method( "buildProjectsFromMetadata" )
+            .will( returnValue( new ContinuumProjectBuildingResult() ) );
+    }
+
+    public void testExecute()
+        throws Exception
+    {
+        Map context = new HashMap();
+        context.put( CreateProjectsFromMetadata.KEY_URL, "http://svn.apache.org/repos/asf/maven/continuum/trunk/pom.xml"
);
+        context.put( CreateProjectsFromMetadata.KEY_PROJECT_BUILDER_ID, "id" );
+
+        action.execute( context );
+
+        ContinuumProjectBuildingResult result = (ContinuumProjectBuildingResult) context
+            .get( CreateProjectsFromMetadata.KEY_PROJECT_BUILDING_RESULT );
+
+        assertFalse( "Should not have errors", result.hasErrors() );
+    }
+
+}

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message