continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r431371 - in /maven/continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/DefaultContinuum.java test/java/org/apache/maven/continuum/DefaultContinuumUnitTest.java
Date Mon, 14 Aug 2006 15:49:56 GMT
Author: carlos
Date: Mon Aug 14 08:49:56 2006
New Revision: 431371

URL: http://svn.apache.org/viewvc?rev=431371&view=rev
Log:
Don't wrap ContinuumException again

Added:
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumUnitTest.java
  (with props)
Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=431371&r1=431370&r2=431371&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Aug 14 08:49:56 2006
@@ -170,6 +170,16 @@
         } );
     }
 
+    public void setActionManager( ActionManager actionManager )
+    {
+        this.actionManager = actionManager;
+    }
+
+    public ActionManager getActionManager()
+    {
+        return actionManager;
+    }
+
     // ----------------------------------------------------------------------
     // Projects
     // ----------------------------------------------------------------------
@@ -2086,18 +2096,22 @@
     // Workflow
     // ----------------------------------------------------------------------
 
-    private void executeAction( String actionName, Map context )
+    protected void executeAction( String actionName, Map context )
         throws ContinuumException
     {
         try
         {
-            Action action = actionManager.lookup( actionName );
+            Action action = getActionManager().lookup( actionName );
 
             action.execute( context );
         }
         catch ( ActionNotFoundException e )
         {
             throw new ContinuumException( "Error while executing the action '" + actionName
+ "'.", e );
+        }
+        catch ( ContinuumException e )
+        {
+            throw e;
         }
         catch ( Exception e )
         {

Added: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumUnitTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumUnitTest.java?rev=431371&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumUnitTest.java
(added)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumUnitTest.java
Mon Aug 14 08:49:56 2006
@@ -0,0 +1,67 @@
+package org.apache.maven.continuum;
+
+/*
+ * 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.Collections;
+
+import org.codehaus.plexus.action.Action;
+import org.codehaus.plexus.action.ActionManager;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * Test for {@link DefaultContinuum}.
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class DefaultContinuumUnitTest
+    extends MockObjectTestCase
+{
+
+    public void testExecuteAction()
+        throws Exception
+    {
+        DefaultContinuum continuum = new DefaultContinuum();
+
+        Mock actionMock = new Mock( Action.class );
+
+        Mock actionManagerMock = new Mock( ActionManager.class );
+
+        actionManagerMock.expects( once() ).will( returnValue( (Action) actionMock.proxy()
) );
+
+        continuum.setActionManager( (ActionManager) actionManagerMock.proxy() );
+
+        actionMock.expects( once() ).will( throwException( new ContinuumException( "" ) )
);
+
+        String exceptionName = ContinuumException.class.getName();
+        try
+        {
+            continuum.executeAction( "", Collections.EMPTY_MAP );
+            fail( exceptionName + " must have been thrown" );
+        }
+        catch ( ContinuumException e )
+        {
+            //expected, check for twice wrapped exception
+            if ( e.getCause() != null )
+            {
+                assertFalse( exceptionName + " is wrapped in " + exceptionName, e.getCause().getClass()
+                    .equals( ContinuumException.class ) );
+            }
+        }
+    }
+}

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

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



Mime
View raw message