You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by tv...@apache.org on 2015/10/02 16:47:53 UTC

svn commit: r1706425 - in /turbine/core/trunk: conf/test/ src/java/org/apache/turbine/ src/java/org/apache/turbine/modules/ src/java/org/apache/turbine/modules/actions/ src/java/org/apache/turbine/om/ src/java/org/apache/turbine/services/pull/ src/java...

Author: tv
Date: Fri Oct  2 14:47:51 2015
New Revision: 1706425

URL: http://svn.apache.org/viewvc?rev=1706425&view=rev
Log:
Add tests for OMTool and VelocitySecureAction

Added:
    turbine/core/trunk/src/test/org/apache/turbine/modules/actions/VelocitySecureActionDoesNothing.java   (with props)
    turbine/core/trunk/src/test/org/apache/turbine/om/
    turbine/core/trunk/src/test/org/apache/turbine/om/MockRetrieverFactory.java   (with props)
    turbine/core/trunk/src/test/org/apache/turbine/om/OMToolTest.java   (with props)
Modified:
    turbine/core/trunk/conf/test/CompleteTurbineResources.properties
    turbine/core/trunk/src/java/org/apache/turbine/Turbine.java
    turbine/core/trunk/src/java/org/apache/turbine/modules/ActionEvent.java
    turbine/core/trunk/src/java/org/apache/turbine/modules/actions/DefaultAction.java
    turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocityAction.java
    turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocitySecureAction.java
    turbine/core/trunk/src/java/org/apache/turbine/om/OMTool.java
    turbine/core/trunk/src/java/org/apache/turbine/om/Retrievable.java
    turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java
    turbine/core/trunk/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java
    turbine/core/trunk/src/test/org/apache/turbine/pipeline/ExecutePageValveTest.java

Modified: turbine/core/trunk/conf/test/CompleteTurbineResources.properties
URL: http://svn.apache.org/viewvc/turbine/core/trunk/conf/test/CompleteTurbineResources.properties?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/conf/test/CompleteTurbineResources.properties (original)
+++ turbine/core/trunk/conf/test/CompleteTurbineResources.properties Fri Oct  2 14:47:51 2015
@@ -512,6 +512,9 @@ tool.content.want.encoding = false
 tool.content.want.relative = false
 tool.link.want.relative = false
 
+# Set the retriever factory for OMTool
+tool.om.factory=org.apache.turbine.om.MockRetrieverFactory
+
 # -------------------------------------------------------------------
 #
 #  V E L O C I T Y  S E R V I C E

Modified: turbine/core/trunk/src/java/org/apache/turbine/Turbine.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/Turbine.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/Turbine.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/Turbine.java Fri Oct  2 14:47:51 2015
@@ -123,7 +123,7 @@ public class Turbine
 
     /**
      * In certain situations the init() method is called more than once,
-     * somtimes even concurrently. This causes bad things to happen,
+     * sometimes even concurrently. This causes bad things to happen,
      * so we use this flag to prevent it.
      */
     private static boolean firstInit = true;

Modified: turbine/core/trunk/src/java/org/apache/turbine/modules/ActionEvent.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/modules/ActionEvent.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/modules/ActionEvent.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/modules/ActionEvent.java Fri Oct  2 14:47:51 2015
@@ -186,7 +186,7 @@ public abstract class ActionEvent extend
 	}
 
 	/**
-	 * This overrides the default Action.perform() to execute the
+	 * This overrides the default Action.doPerform() to execute the
 	 * doEvent() method. If that fails, then it will execute the
 	 * doPerform() method instead.
 	 *
@@ -194,7 +194,7 @@ public abstract class ActionEvent extend
 	 * @exception Exception a generic exception.
 	 */
 	@Override
-    protected void perform(PipelineData pipelineData)
+    public void doPerform(PipelineData pipelineData)
 			throws Exception
 	{
 	    ParameterParser pp = pipelineData.get(Turbine.class, ParameterParser.class);
@@ -210,7 +210,7 @@ public abstract class ActionEvent extend
 	 *
 	 * @exception Exception a generic exception.
 	 */
-	public void executeEvents(ParameterParser pp, Class<?>[] signature, Object[] parameters)
+	protected void executeEvents(ParameterParser pp, Class<?>[] signature, Object[] parameters)
 			throws Exception
 	{
 		// Name of the button.

Modified: turbine/core/trunk/src/java/org/apache/turbine/modules/actions/DefaultAction.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/modules/actions/DefaultAction.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/modules/actions/DefaultAction.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/modules/actions/DefaultAction.java Fri Oct  2 14:47:51 2015
@@ -46,7 +46,7 @@ public class DefaultAction extends Actio
             throws Exception
     {
         RunData data = getRunData(pipelineData);
-        data.setMessage(data.getScreen() + " has been executed!");
+        data.setMessage(data.getAction() + " has been executed!");
     }
 
 }

Modified: turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocityAction.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocityAction.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocityAction.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocityAction.java Fri Oct  2 14:47:51 2015
@@ -19,10 +19,8 @@ package org.apache.turbine.modules.actio
  * under the License.
  */
 
-import org.apache.turbine.annotation.TurbineService;
 import org.apache.turbine.modules.screens.TemplateScreen;
 import org.apache.turbine.pipeline.PipelineData;
-import org.apache.turbine.services.velocity.VelocityService;
 import org.apache.turbine.util.velocity.VelocityActionEvent;
 import org.apache.velocity.context.Context;
 
@@ -37,22 +35,6 @@ import org.apache.velocity.context.Conte
  */
 public abstract class VelocityAction extends VelocityActionEvent
 {
-    /** Injected service instance */
-    @TurbineService
-    private VelocityService velocity;
-
-    /**
-     * You SHOULD NOT override this method and implement it in your action.
-     *
-     * @param pipelineData Turbine information.
-     * @throws Exception a generic exception.
-     */
-    @Override
-    public void doPerform(PipelineData pipelineData) throws Exception
-    {
-        doPerform(pipelineData, getContext(pipelineData));
-    }
-
     /**
      * Initialize the module.
      *
@@ -90,13 +72,13 @@ public abstract class VelocityAction ext
         try
         {
             super.perform(pipelineData);
-        } catch (Exception e)
+        }
+        catch (Exception e)
         {
             if (bubbleUpException)
             {
                 throw e;
             }
-
         }
     }
 
@@ -111,15 +93,4 @@ public abstract class VelocityAction ext
     {
         TemplateScreen.setTemplate(pipelineData, template);
     }
-
-    /**
-     * Return the Context needed by Velocity.
-     *
-     * @param pipelineData Turbine information.
-     * @return Context, a context for web pages.
-     */
-    protected Context getContext(PipelineData pipelineData)
-    {
-        return velocity.getContext(pipelineData);
-    }
 }

Modified: turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocitySecureAction.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocitySecureAction.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocitySecureAction.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/modules/actions/VelocitySecureAction.java Fri Oct  2 14:47:51 2015
@@ -21,8 +21,6 @@ package org.apache.turbine.modules.actio
 
 
 import org.apache.turbine.pipeline.PipelineData;
-import org.apache.turbine.util.RunData;
-import org.apache.velocity.context.Context;
 
 /**
  * VelocitySecure action.
@@ -44,22 +42,7 @@ import org.apache.velocity.context.Conte
 public abstract class VelocitySecureAction extends VelocityAction
 {
     /**
-     * Implement this to add information to the context.
-     * Should revert to abstract when RunData has gone.
-     * @param pipelineData Turbine information.
-     * @param context Context for web pages.
-     * @throws Exception a generic exception.
-     */
-    @Override
-    public void doPerform(PipelineData pipelineData, Context context)
-            throws Exception
-    {
-        RunData data = getRunData(pipelineData);
-        doPerform(data, context);
-    }
-
-    /**
-     * This method overrides the method in WebMacroSiteAction to
+     * This method overrides the method in VelocityAction to
      * perform a security check first.
      *
      * @param pipelineData Turbine information.

Modified: turbine/core/trunk/src/java/org/apache/turbine/om/OMTool.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/om/OMTool.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/om/OMTool.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/om/OMTool.java Fri Oct  2 14:47:51 2015
@@ -124,7 +124,13 @@ public class OMTool implements Applicati
      */
     public PullHelper get(String omName) throws Exception
     {
-        return pullMap.putIfAbsent(omName, new OMTool.PullHelper(omName));
+        PullHelper ph = pullMap.putIfAbsent(omName, new OMTool.PullHelper(omName));
+        if (ph == null)
+        {
+            return pullMap.get(omName);
+        }
+
+        return ph;
     }
 
     /**

Modified: turbine/core/trunk/src/java/org/apache/turbine/om/Retrievable.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/om/Retrievable.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/om/Retrievable.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/om/Retrievable.java Fri Oct  2 14:47:51 2015
@@ -43,7 +43,7 @@ public interface Retrievable
      *
      * @param key The new id value
      *
-     * @throws Exception A problem occured while setting the id.
+     * @throws Exception A problem occurred while setting the id.
      */
     void setQueryKey(String key)
         throws Exception;

Modified: turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java Fri Oct  2 14:47:51 2015
@@ -29,8 +29,8 @@ import org.apache.turbine.pipeline.Pipel
  *
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
  */
-public interface PipelineDataApplicationTool {
-
+public interface PipelineDataApplicationTool
+{
     /**
      * Initialize the application tool. The data parameter holds a different
      * type depending on how the tool is being instantiated:
@@ -63,6 +63,4 @@ public interface PipelineDataApplication
      * @param data The current PipelineData Object
      */
     public void refresh(PipelineData data);
-
-
 }

Modified: turbine/core/trunk/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java Fri Oct  2 14:47:51 2015
@@ -61,7 +61,7 @@ public abstract class VelocityActionEven
         throws Exception;
 
     /**
-     * This overrides the default Action.perform() to execute the
+     * This overrides the default Action.doPerform() to execute the
      * doEvent() method.  If that fails, then it will execute the
      * doPerform() method instead.
      *
@@ -69,7 +69,7 @@ public abstract class VelocityActionEven
      * @exception Exception a generic exception.
      */
     @Override
-    protected void perform(PipelineData pipelineData)
+    public void doPerform(PipelineData pipelineData)
             throws Exception
     {
         if (!initialized)

Added: turbine/core/trunk/src/test/org/apache/turbine/modules/actions/VelocitySecureActionDoesNothing.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/modules/actions/VelocitySecureActionDoesNothing.java?rev=1706425&view=auto
==============================================================================
--- turbine/core/trunk/src/test/org/apache/turbine/modules/actions/VelocitySecureActionDoesNothing.java (added)
+++ turbine/core/trunk/src/test/org/apache/turbine/modules/actions/VelocitySecureActionDoesNothing.java Fri Oct  2 14:47:51 2015
@@ -0,0 +1,69 @@
+package org.apache.turbine.modules.actions;
+
+/*
+ * 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 static org.junit.Assert.assertNotNull;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.turbine.pipeline.PipelineData;
+import org.apache.turbine.util.RunData;
+import org.apache.velocity.context.Context;
+/**
+ * This action is used to test the secure action methods.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ */
+public class VelocitySecureActionDoesNothing extends VelocitySecureAction
+{
+    private static Log log = LogFactory.getLog(VelocitySecureActionDoesNothing.class);
+    public static int numberOfCalls;
+    public static int pipelineDataCalls;
+    public static int isAuthorizedCalls;
+
+    /**
+     *  Default action is throw an exception.
+     *
+     * @param  pipelineData           Current RunData information
+     * @param  context        Context to populate
+     * @exception  Exception  Thrown on error
+     */
+    @Override
+    public void doPerform(PipelineData pipelineData, Context context) throws Exception
+    {
+        log.debug("Calling doPerform(PipelineData)");
+		VelocitySecureActionDoesNothing.numberOfCalls++;
+        RunData rd = (RunData)pipelineData;
+		assertNotNull("PipelineData object was Null.", rd);
+		VelocitySecureActionDoesNothing.pipelineDataCalls++;
+    }
+
+    /**
+     * @see org.apache.turbine.modules.actions.VelocitySecureAction#isAuthorized(org.apache.turbine.pipeline.PipelineData)
+     */
+    @Override
+    protected boolean isAuthorized(PipelineData pipelineData) throws Exception
+    {
+        log.debug("Calling isAuthorized(PipelineData)");
+        VelocitySecureActionDoesNothing.isAuthorizedCalls++;
+        return true;
+    }
+}

Propchange: turbine/core/trunk/src/test/org/apache/turbine/modules/actions/VelocitySecureActionDoesNothing.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: turbine/core/trunk/src/test/org/apache/turbine/om/MockRetrieverFactory.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/om/MockRetrieverFactory.java?rev=1706425&view=auto
==============================================================================
--- turbine/core/trunk/src/test/org/apache/turbine/om/MockRetrieverFactory.java (added)
+++ turbine/core/trunk/src/test/org/apache/turbine/om/MockRetrieverFactory.java Fri Oct  2 14:47:51 2015
@@ -0,0 +1,46 @@
+package org.apache.turbine.om;
+
+/*
+ * 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.
+ */
+
+/**
+ * This mocks a {@link RetrieverFactory}.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ */
+public class MockRetrieverFactory implements RetrieverFactory
+{
+
+    /**
+     * @see org.apache.turbine.om.RetrieverFactory#getInstance(java.lang.String)
+     */
+    @Override
+    public Retriever getInstance(String className) throws Exception
+    {
+        return new Retriever()
+        {
+            @Override
+            public Object retrieve(String key) throws Exception
+            {
+                return new String(key);
+            }
+        };
+    }
+
+}

Propchange: turbine/core/trunk/src/test/org/apache/turbine/om/MockRetrieverFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: turbine/core/trunk/src/test/org/apache/turbine/om/OMToolTest.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/om/OMToolTest.java?rev=1706425&view=auto
==============================================================================
--- turbine/core/trunk/src/test/org/apache/turbine/om/OMToolTest.java (added)
+++ turbine/core/trunk/src/test/org/apache/turbine/om/OMToolTest.java Fri Oct  2 14:47:51 2015
@@ -0,0 +1,89 @@
+package org.apache.turbine.om;
+
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.turbine.util.TurbineConfig;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This class tests the {@link OMTool} functionality.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ */
+public class OMToolTest
+{
+    private static TurbineConfig tc = null;
+    private OMTool om;
+
+    @BeforeClass
+    public static void init() {
+        tc = new TurbineConfig(
+                            ".",
+                            "/conf/test/CompleteTurbineResources.properties");
+        tc.initialize();
+    }
+
+    @Before
+    public void setUpBefore() throws Exception
+    {
+        om = new OMTool();
+    }
+
+    @Test
+    public void testGetString() throws Exception
+    {
+        assertNotNull("RetrieverFactory should not be null", om.omFactory);
+        OMTool.PullHelper ph1 = om.get("test1");
+        assertNotNull("PullHelper should not be null", ph1);
+        OMTool.PullHelper ph2 = om.get("test2");
+        assertNotNull("PullHelper should not be null", ph2);
+        assertNotSame("Should not be same instance", ph1, ph2);
+        OMTool.PullHelper ph3 = om.get("test2");
+        assertNotNull("PullHelper should not be null", ph3);
+        assertSame("Should be same instance", ph3, ph2);
+    }
+
+    @Test
+    public void testGetStringString() throws Exception
+    {
+        Object testString1 = om.get("test1", "testString");
+        assertNotNull("Object should not be null", testString1);
+        assertTrue("Object should be a string", testString1 instanceof String);
+        assertEquals("Object should be a string", "testString", testString1);
+        Object testString2 = om.get("test1", "testString");
+        assertNotNull("Object should not be null", testString2);
+        assertSame("Should be same instance", testString1, testString2);
+    }
+
+    @AfterClass
+    public static void destroy()
+    {
+        tc.dispose();
+    }
+}

Propchange: turbine/core/trunk/src/test/org/apache/turbine/om/OMToolTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: turbine/core/trunk/src/test/org/apache/turbine/pipeline/ExecutePageValveTest.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/pipeline/ExecutePageValveTest.java?rev=1706425&r1=1706424&r2=1706425&view=diff
==============================================================================
--- turbine/core/trunk/src/test/org/apache/turbine/pipeline/ExecutePageValveTest.java (original)
+++ turbine/core/trunk/src/test/org/apache/turbine/pipeline/ExecutePageValveTest.java Fri Oct  2 14:47:51 2015
@@ -21,12 +21,17 @@ package org.apache.turbine.pipeline;
  */
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.util.Vector;
 
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.fulcrum.security.model.turbine.entity.impl.TurbineUserImpl;
 import org.apache.turbine.modules.actions.VelocityActionDoesNothing;
+import org.apache.turbine.modules.actions.VelocitySecureActionDoesNothing;
 import org.apache.turbine.om.security.DefaultUserImpl;
 import org.apache.turbine.om.security.User;
 import org.apache.turbine.test.BaseTestCase;
@@ -43,8 +48,6 @@ import org.junit.Test;
 
 import com.mockobjects.servlet.MockServletConfig;
 
-import static org.junit.Assert.*;
-
 /**
  * Tests ExecutePageValve.
  *
@@ -68,7 +71,7 @@ public class ExecutePageValveTest extend
                             "/conf/test/CompleteTurbineResources.properties");
         tc.initialize();
     }
-    
+
     @Before
     public void setUpBefore() throws Exception
     {
@@ -126,9 +129,47 @@ public class ExecutePageValveTest extend
         assertEquals("username", user.getName());
         assertTrue(user.hasLoggedIn());
     }
-    
+
+    @Test public void testValveWithSecureAction() throws Exception
+    {
+        Vector<String> v = new Vector<String>();
+        v.add(URIConstants.CGI_TEMPLATE_PARAM);
+        request.setupGetParameterNames(v.elements());
+        String nulls[] = new String[1];
+        nulls[0]="Index.vm";
+        request.setupAddParameter(URIConstants.CGI_TEMPLATE_PARAM, nulls);
+
+        RunData runData = getRunData(request, response, config);
+        runData.setScreenTemplate("ExistPageWithLayout.vm");
+        User tu = new DefaultUserImpl(new TurbineUserImpl());
+        tu.setName("username");
+        tu.setHasLoggedIn(Boolean.TRUE);
+        String actionName = VelocitySecureActionDoesNothing.class.getName();
+        actionName = actionName.substring(actionName.lastIndexOf(".")+1);
+        runData.setAction(actionName);
+        runData.setUser(tu);
+
+        Pipeline pipeline = new TurbinePipeline();
+
+        PipelineData pipelineData = runData;
+        ExecutePageValve valve = new ExecutePageValve();
+        pipeline.addValve(valve);
+        pipeline.initialize();
+
+        int numberOfCalls = VelocitySecureActionDoesNothing.numberOfCalls;
+        int isAuthorizedCalls = VelocitySecureActionDoesNothing.isAuthorizedCalls;
+        pipeline.invoke(pipelineData);
+        assertEquals("Assert action was called",numberOfCalls +1,VelocitySecureActionDoesNothing.numberOfCalls);
+        assertEquals("Assert authorization was called",isAuthorizedCalls +1,VelocitySecureActionDoesNothing.isAuthorizedCalls);
+        User user = runData.getUser();
+        assertNotNull(user);
+        assertEquals("username", user.getName());
+        assertTrue(user.hasLoggedIn());
+    }
+
     @AfterClass
-    public static void destroy() {
+    public static void destroy()
+    {
         tc.dispose();
     }
 }