struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1549067 - in /struts/struts2/trunk: core/src/main/java/org/apache/struts2/dispatcher/ core/src/main/java/org/apache/struts2/util/ core/src/main/java/org/apache/struts2/views/jsp/ core/src/test/java/org/apache/struts2/ core/src/test/java/or...
Date Sun, 08 Dec 2013 17:12:02 GMT
Author: lukaszlenart
Date: Sun Dec  8 17:12:01 2013
New Revision: 1549067

URL: http://svn.apache.org/r1549067
Log:
WW-4252 Uses TagUtils instead directly calling Dispatcher.getInstance()

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ComponentTagSupport.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/ClassInstantiationTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/PlainTextResultTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TooltipTest.java
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-11.txt
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-13.txt
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-2.txt
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-22.txt
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-24.txt
    struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
    struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
    struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
    struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java Sun Dec  8 17:12:01 2013
@@ -442,14 +442,11 @@ public class Dispatcher {
     }
 
     private Container init_PreloadConfiguration() {
-        Configuration config = configurationManager.getConfiguration();
-        Container container = config.getContainer();
+        Container container = getContainer();
 
         boolean reloadi18n = Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_I18N_RELOAD));
         LocalizedTextUtil.setReloadBundles(reloadi18n);
 
-        ContainerHolder.store(container);
-
         return container;
     }
 
@@ -548,8 +545,7 @@ public class Dispatcher {
             String name = mapping.getName();
             String method = mapping.getMethod();
 
-            Configuration config = configurationManager.getConfiguration();
-            ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy(
+            ActionProxy proxy = getContainer().getInstance(ActionProxyFactory.class).createActionProxy(
                     namespace, name, method, extraContext, true, false);
 
             request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack());
@@ -664,7 +660,6 @@ public class Dispatcher {
         }
 
         extraContext.put(ActionContext.LOCALE, locale);
-        //extraContext.put(ActionContext.DEV_MODE, Boolean.valueOf(devMode));
 
         extraContext.put(StrutsStatics.HTTP_REQUEST, request);
         extraContext.put(StrutsStatics.HTTP_RESPONSE, response);

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java Sun Dec  8 17:12:01 2013
@@ -24,6 +24,7 @@ package org.apache.struts2.util;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.opensymphony.xwork2.inject.Container;
 import org.apache.struts2.dispatcher.Dispatcher;
 
 import com.opensymphony.xwork2.ActionContext;
@@ -53,10 +54,11 @@ public class StrutsTestCaseHelper {
         Dispatcher du = new Dispatcher(ctx, params);
         du.init();
         Dispatcher.setInstance(du);
-        
+
         // Reset the value stack
-        ValueStack stack = du.getContainer().getInstance(ValueStackFactory.class).createValueStack();
-        stack.getContext().put(ActionContext.CONTAINER, du.getContainer());
+        Container container = du.getContainer();
+        ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
+        stack.getContext().put(ActionContext.CONTAINER, container);
         ActionContext.setContext(new ActionContext(stack.getContext()));
         
         return du;

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ComponentTagSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ComponentTagSupport.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ComponentTagSupport.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ComponentTagSupport.java Sun Dec  8 17:12:01 2013
@@ -25,8 +25,8 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.JspException;
 
+import com.opensymphony.xwork2.ActionContext;
 import org.apache.struts2.components.Component;
-import org.apache.struts2.dispatcher.Dispatcher;
 
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.util.ValueStack;
@@ -45,8 +45,9 @@ public abstract class ComponentTagSuppor
     }
 
     public int doStartTag() throws JspException {
-        component = getBean(getStack(), (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
-        Container container = Dispatcher.getInstance().getContainer();
+        ValueStack stack = getStack();
+        component = getBean(stack, (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
+        Container container = (Container) stack.getContext().get(ActionContext.CONTAINER);
         container.inject(component);
         
         populateParams();

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/ClassInstantiationTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/ClassInstantiationTest.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/ClassInstantiationTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/ClassInstantiationTest.java Sun Dec  8 17:12:01 2013
@@ -13,11 +13,10 @@ public class ClassInstantiationTest exte
 
     public void testCompositeActionMapperInstantiationWithList() throws Exception {
         // given
-        Dispatcher du = initDispatcher(new HashMap<String, String>() {{
+        initDispatcher(new HashMap<String, String>() {{
             put(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
             put(StrutsConstants.STRUTS_MAPPER_COMPOSITE, "struts,restful");
         }});
-        Container container = du.getContainer();
 
         // when
         ActionMapper instance = container.getInstance(ActionMapper.class, "composite");
@@ -28,10 +27,9 @@ public class ClassInstantiationTest exte
 
     public void testCompositeActionMapperInstantiationWithoutList() throws Exception {
         // given
-        Dispatcher du = initDispatcher(new HashMap<String, String>() {{
+        initDispatcher(new HashMap<String, String>() {{
             put(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
         }});
-        Container container = du.getContainer();
 
         // when
         try {

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/StrutsInternalTestCase.java Sun Dec  8 17:12:01 2013
@@ -21,7 +21,10 @@
 
 package org.apache.struts2;
 
+import com.opensymphony.xwork2.ActionProxyFactory;
 import com.opensymphony.xwork2.XWorkTestCase;
+import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.util.XWorkTestCaseHelper;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import com.opensymphony.xwork2.util.logging.jdk.JdkLoggerFactory;
 import org.apache.struts2.dispatcher.Dispatcher;
@@ -71,7 +74,9 @@ public abstract class StrutsInternalTest
         logger.setLevel(Level.WARNING);
         LoggerFactory.setLoggerFactory(new JdkLoggerFactory());
     }
-    
+
+    protected Dispatcher dispatcher;
+
     /**
      * Sets up the configuration settings, XWork configuration, and
      * message resources
@@ -82,11 +87,12 @@ public abstract class StrutsInternalTest
     }
     
     protected Dispatcher initDispatcher(Map<String,String> params) {
-        Dispatcher du = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params);
-        configurationManager = du.getConfigurationManager();
+        dispatcher = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params);
+        configurationManager = dispatcher.getConfigurationManager();
         configuration = configurationManager.getConfiguration();
         container = configuration.getContainer();
-        return du;
+        container.inject(dispatcher);
+        return dispatcher;
     }
 
     /**
@@ -104,6 +110,11 @@ public abstract class StrutsInternalTest
 
     protected void tearDown() throws Exception {
         super.tearDown();
+        // maybe someone else already destroyed Dispatcher
+        if (dispatcher != null && dispatcher.getConfigurationManager() != null) {
+            dispatcher.cleanup();
+            dispatcher = null;
+        }
         StrutsTestCaseHelper.tearDown();
     }
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java Sun Dec  8 17:12:01 2013
@@ -21,18 +21,7 @@
 
 package org.apache.struts2;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.struts2.dispatcher.ServletDispatcherResult;
-import org.apache.struts2.interceptor.TokenInterceptor;
-import org.apache.struts2.interceptor.TokenSessionStoreInterceptor;
-
 import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionChainResult;
 import com.opensymphony.xwork2.ActionProxyFactory;
 import com.opensymphony.xwork2.DefaultActionProxyFactory;
 import com.opensymphony.xwork2.ObjectFactory;
@@ -47,6 +36,13 @@ import com.opensymphony.xwork2.inject.Co
 import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
 import com.opensymphony.xwork2.mock.MockResult;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
+import com.opensymphony.xwork2.validator.ValidationInterceptor;
+import org.apache.struts2.dispatcher.ServletDispatcherResult;
+import org.apache.struts2.interceptor.TokenInterceptor;
+import org.apache.struts2.interceptor.TokenSessionStoreInterceptor;
+import org.apache.struts2.views.jsp.ui.DoubleValidationAction;
+
+import java.util.HashMap;
 
 
 /**
@@ -89,6 +85,15 @@ public class TestConfigurationProvider i
                 .build())
             .build();
 
+        ValidationInterceptor validationInterceptor = new ValidationInterceptor();
+        validationInterceptor.setIncludeMethods("*");
+
+        ActionConfig doubleValidationActionConfig = new ActionConfig.Builder("", "doubleValidationAction", DoubleValidationAction.class.getName())
+            .addResultConfig(new ResultConfig.Builder(Action.SUCCESS, ServletDispatcherResult.class.getName())
+                    .addParam("location", "success.jsp")
+                    .build())
+            .addInterceptor(new InterceptorMapping("validation", validationInterceptor))
+            .build();
 
         ActionConfig testActionConfig = new ActionConfig.Builder("", "", TestAction.class.getName())
             .addResultConfig(new ResultConfig.Builder(Action.SUCCESS, ServletDispatcherResult.class.getName())
@@ -97,7 +102,6 @@ public class TestConfigurationProvider i
             .addInterceptor(new InterceptorMapping("params", new ParametersInterceptor()))
             .build();
 
-
         ActionConfig tokenActionConfig = new ActionConfig.Builder("", "", TestAction.class.getName())
             .addInterceptor(new InterceptorMapping("token", new TokenInterceptor()))
             .addResultConfig(new ResultConfig.Builder("invalid.token", MockResult.class.getName()).build())
@@ -115,6 +119,7 @@ public class TestConfigurationProvider i
         PackageConfig defaultPackageConfig = new PackageConfig.Builder("")
             .addActionConfig(EXECUTION_COUNT_ACTION_NAME, executionCountActionConfig)
             .addActionConfig(TEST_ACTION_NAME, testActionConfig)
+            .addActionConfig("doubleValidationAction", doubleValidationActionConfig)
             .addActionConfig(TOKEN_ACTION_NAME, tokenActionConfig)
             .addActionConfig(TOKEN_SESSION_ACTION_NAME, tokenSessionActionConfig)
             .addActionConfig("testActionTagAction", new ActionConfig.Builder("", "", TestAction.class.getName())
@@ -132,6 +137,15 @@ public class TestConfigurationProvider i
             .build();
 
         configuration.addPackageConfig("namespacePackage", namespacePackageConfig);
+
+        PackageConfig testActionWithNamespacePackageConfig = new PackageConfig.Builder("testActionNamespacePackages")
+            .namespace(TEST_NAMESPACE)
+            .addParent(defaultPackageConfig)
+            .addActionConfig(TEST_ACTION_NAME, new ActionConfig.Builder("", "", TestAction.class.getName()).build())
+            .build();
+
+        configuration.addPackageConfig("testActionNamespacePackages", testActionWithNamespacePackageConfig);
+
     }
 
     /**

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java Sun Dec  8 17:12:01 2013
@@ -172,7 +172,7 @@ public class DispatcherTest extends Stru
     	assertTrue(state.isInitialized);
     	
     	du.cleanup();
-    	
+
     	assertTrue(state.isDestroyed);
     }
     

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/PlainTextResultTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/PlainTextResultTest.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/PlainTextResultTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/PlainTextResultTest.java Sun Dec  8 17:12:01 2013
@@ -165,7 +165,6 @@ public class PlainTextResultTest extends
 
 
     protected void tearDown() throws Exception {
-        super.tearDown();
         stack = null;
         invocation = null;
         context = null;

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java Sun Dec  8 17:12:01 2013
@@ -81,9 +81,7 @@ public class FreeMarkerResultTest extend
 
 
         request.setRequestURI("/tutorial/test2.action");
-        Dispatcher dispatcher = Dispatcher.getInstance();
-        ActionMapping mapping = dispatcher.getContainer().getInstance(ActionMapper.class).getMapping(
-                    request, dispatcher.getConfigurationManager());
+        ActionMapping mapping = container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
         dispatcher.serviceAction(request, response, servletContext, mapping);
         assertEquals("beforenestedafter", stringWriter.toString());
     }
@@ -107,9 +105,7 @@ public class FreeMarkerResultTest extend
 
 
         request.setRequestURI("/tutorial/test5.action");
-        Dispatcher dispatcher = Dispatcher.getInstance();
-        ActionMapping mapping = dispatcher.getContainer().getInstance(ActionMapper.class).getMapping(
-                    request, dispatcher.getConfigurationManager());
+        ActionMapping mapping = container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
         dispatcher.serviceAction(request, response, servletContext, mapping);
         assertEquals("beforenestedafter", stringWriter.toString());
     }
@@ -218,8 +214,7 @@ public class FreeMarkerResultTest extend
 
 
         request.setRequestURI("/tutorial/test6.action");
-        Dispatcher dispatcher = Dispatcher.getInstance();
-        ActionMapping mapping = dispatcher.getContainer().getInstance(ActionMapper.class).getMapping(request, dispatcher.getConfigurationManager());
+        ActionMapping mapping = container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
         dispatcher.serviceAction(request, response, servletContext, mapping);
 
         // TODO lukaszlenart: remove expectedJDK15 and if() after switching to Java 1.6
@@ -279,8 +274,7 @@ public class FreeMarkerResultTest extend
 
 
         request.setRequestURI("/tutorial/test7.action");
-        Dispatcher dispatcher = Dispatcher.getInstance();
-        ActionMapping mapping = dispatcher.getContainer().getInstance(ActionMapper.class).getMapping(request, dispatcher.getConfigurationManager());
+        ActionMapping mapping = container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
         dispatcher.serviceAction(request, response, servletContext, mapping);
         String expected = "<input type=\"radio\" name=\"client\" id=\"client_foo\" value=\"foo\"/><label for=\"client_foo\">foo</label>\n"
                 + "<input type=\"radio\" name=\"client\" id=\"client_bar\" value=\"bar\"/><label for=\"client_bar\">bar</label>\n"
@@ -310,8 +304,7 @@ public class FreeMarkerResultTest extend
         ServletActionContext.setServletContext(servletContext);
 
         request.setRequestURI("/tutorial/test8.action");
-        Dispatcher dispatcher = Dispatcher.getInstance();
-        ActionMapping mapping = dispatcher.getContainer().getInstance(ActionMapper.class).getMapping(request, dispatcher.getConfigurationManager());
+        ActionMapping mapping = container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
         dispatcher.serviceAction(request, response, servletContext, mapping);
         String expected = "<input type=\"text\"autofocus=\"autofocus\"/>";
         assertEquals(expected, stringWriter.toString());
@@ -321,12 +314,15 @@ public class FreeMarkerResultTest extend
         super.setUp();
         mgr = new FreemarkerManager();
         mgr.setEncoding("UTF-8");
+
         DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
         container.inject(factory);
         mgr.setFileManagerFactory(factory);
+
         FreemarkerThemeTemplateLoader themeLoader = new FreemarkerThemeTemplateLoader();
         container.inject(themeLoader);
         mgr.setThemeTemplateLoader(themeLoader);
+
         stringWriter = new StringWriter();
         writer = new PrintWriter(stringWriter);
         response = new StrutsMockHttpServletResponse();
@@ -334,14 +330,17 @@ public class FreeMarkerResultTest extend
         request = new MockHttpServletRequest();
         servletContext = new StrutsMockServletContext();
         stack = ActionContext.getContext().getValueStack();
+
         context = new ActionContext(stack.getContext());
         context.put(StrutsStatics.HTTP_RESPONSE, response);
         context.put(StrutsStatics.HTTP_REQUEST, request);
         context.put(StrutsStatics.SERVLET_CONTEXT, servletContext);
+
         ServletActionContext.setServletContext(servletContext);
         ServletActionContext.setRequest(request);
         ServletActionContext.setResponse(response);
         servletContext.setAttribute(FreemarkerManager.CONFIG_SERVLET_CONTEXT_KEY, null);
+
         invocation = new MockActionInvocation();
         invocation.setStack(stack);
         invocation.setInvocationContext(context);
@@ -360,4 +359,5 @@ public class FreeMarkerResultTest extend
 
         super.tearDown();
     }
+
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java Sun Dec  8 17:12:01 2013
@@ -77,10 +77,13 @@ public abstract class AbstractTagTest ex
 
     protected void setUp() throws Exception {
         super.setUp();
-
         /**
          * create our standard mock objects
          */
+        createMocks();
+    }
+
+    protected void createMocks() {
         action = this.getAction();
         stack = ActionContext.getContext().getValueStack();
         context = stack.getContext();

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java Sun Dec  8 17:12:01 2013
@@ -300,12 +300,8 @@ public class ActionTagTest extends Abstr
 
     protected void setUp() throws Exception {
         super.setUp();
-
-        initDispatcher(new HashMap() {{ put("configProviders", TestConfigurationProvider.class.getName()); }});
-
-        ActionContext actionContext = new ActionContext(context);
-        actionContext.setValueStack(stack);
-        ActionContext.setContext(actionContext);
+        initDispatcher(new HashMap<String, String>() {{ put("configProviders", TestConfigurationProvider.class.getName()); }});
+        createMocks();
     }
 
     protected void tearDown() throws Exception {

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java Sun Dec  8 17:12:01 2013
@@ -21,12 +21,7 @@
 
 package org.apache.struts2.views.jsp.ui;
 
-import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.ActionProxy;
-import com.opensymphony.xwork2.ActionSupport;
-import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.*;
 import com.opensymphony.xwork2.config.RuntimeConfiguration;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
@@ -89,7 +84,7 @@ public class FormTagTest extends Abstrac
     }
 
     public void testFormWithContext() throws Exception {
-        request.setupGetContext("/somecontext");
+        request.setupGetContext("/testNamespace");
 
         FormTag tag = new FormTag();
         tag.setTheme("xhtml");
@@ -205,63 +200,13 @@ public class FormTagTest extends Abstrac
      */
     public void testFormWithCustomOnsubmitEnabledWithValidateEnabled1() throws Exception {
 
-        final Container cont = container;
-        // used to determined if the form action needs js validation
-        configurationManager.setConfiguration(new com.opensymphony.xwork2.config.impl.DefaultConfiguration() {
-            private DefaultConfiguration self = this;
-            public Container getContainer() {
-                return new Container() {
-                    public <T> T inject(Class<T> implementation) {return null;}
-                    public void removeScopeStrategy() {}
-                    public void setScopeStrategy(Strategy scopeStrategy) {}
-                    public <T> T getInstance(Class<T> type, String name) {return null;}
-                    public <T> T getInstance(Class<T> type) {return cont.getInstance(type);}
-                    public Set<String> getInstanceNames(Class<?> type) {return null;}
-
-                    public void inject(Object o) {
-                        cont.inject(o);
-                        if (o instanceof Form) {
-                            ((Form)o).setConfiguration(self);
-                        }
-                    }
-                };
-            }
-            public RuntimeConfiguration getRuntimeConfiguration() {
-                return new RuntimeConfiguration() {
-                    public ActionConfig getActionConfig(String namespace, String name) {
-                        ActionConfig actionConfig = new ActionConfig("", name, "") {
-                            public List getInterceptors() {
-                                List interceptors = new ArrayList();
-
-                                ValidationInterceptor validationInterceptor = new ValidationInterceptor();
-                                validationInterceptor.setIncludeMethods("*");
-
-                                InterceptorMapping interceptorMapping = new InterceptorMapping("validation", validationInterceptor);
-                                interceptors.add(interceptorMapping);
-
-                                return interceptors;
-                            }
-                            public String getClassName() {
-                                return ActionSupport.class.getName();
-                            }
-                        };
-                        return actionConfig;
-                    }
-
-                    public Map getActionConfigs() {
-                        return null;
-                    }
-                };
-            }
-        });
-
-        Dispatcher.getInstance().setConfigurationManager(configurationManager);
+        prepareMockInvocation();
 
         FormTag tag = new FormTag();
         tag.setPageContext(pageContext);
         tag.setName("myForm");
         tag.setMethod("post");
-        tag.setAction("myAction");
+        tag.setAction("doubleValidationAction");
         tag.setAcceptcharset("UTF-8");
         tag.setEnctype("myEncType");
         tag.setTitle("mytitle");
@@ -289,90 +234,31 @@ public class FormTagTest extends Abstrac
      * "excludes" all methods.
      */
     public void testFormWithCustomOnsubmitEnabledWithValidateEnabled2() throws Exception {
+        prepareMockInvocation();
 
-        com.opensymphony.xwork2.config.Configuration originalConfiguration = configurationManager.getConfiguration();
-        ObjectFactory originalObjectFactory = ObjectFactory.getObjectFactory();
+        FormTag tag = new FormTag();
+        tag.setPageContext(pageContext);
+        tag.setName("myForm");
+        tag.setMethod("post");
+        tag.setAction("testAction");
+        tag.setAcceptcharset("UTF-8");
+        tag.setEnctype("myEncType");
+        tag.setTitle("mytitle");
+        tag.setOnsubmit("submitMe()");
+        tag.setValidate("true");
+        tag.setNamespace("");
 
-        final Container cont = container;
-        try {
-            // used to determined if the form action needs js validation
-            configurationManager.setConfiguration(new DefaultConfiguration() {
-                private DefaultConfiguration self = this;
-                public Container getContainer() {
-                    return new Container() {
-                        public <T> T inject(Class<T> implementation) {return null;}
-                        public void removeScopeStrategy() {}
-                        public void setScopeStrategy(Strategy scopeStrategy) {}
-                        public <T> T getInstance(Class<T> type, String name) {return null;}
-                        public <T> T getInstance(Class<T> type) {return cont.getInstance(type);}
-                        public Set<String> getInstanceNames(Class<?> type) {return null;}
-
-                        public void inject(Object o) {
-                            cont.inject(o);
-                            if (o instanceof Form) {
-                                ((Form)o).setConfiguration(self);
-                            }
-                        }
-                    };
-                }
-                public RuntimeConfiguration getRuntimeConfiguration() {
-                    return new RuntimeConfiguration() {
-                        public ActionConfig getActionConfig(String namespace, String name) {
-                            ActionConfig actionConfig = new ActionConfig("", name, "") {
-                                public List getInterceptors() {
-                                    List interceptors = new ArrayList();
-
-                                    ValidationInterceptor validationInterceptor = new ValidationInterceptor();
-                                    validationInterceptor.setExcludeMethods("*");
-
-                                    InterceptorMapping interceptorMapping = new InterceptorMapping("validation", validationInterceptor);
-                                    interceptors.add(interceptorMapping);
-
-                                    return interceptors;
-                                }
-                                public String getClassName() {
-                                    return ActionSupport.class.getName();
-                                }
-                            };
-                            return actionConfig;
-                        }
-
-                        public Map getActionConfigs() {
-                            return null;
-                        }
-                    };
-                }
-            });
-
-            Dispatcher.getInstance().setConfigurationManager(configurationManager);
-
-            FormTag tag = new FormTag();
-            tag.setPageContext(pageContext);
-            tag.setName("myForm");
-            tag.setMethod("post");
-            tag.setAction("myAction");
-            tag.setAcceptcharset("UTF-8");
-            tag.setEnctype("myEncType");
-            tag.setTitle("mytitle");
-            tag.setOnsubmit("submitMe()");
-            tag.setValidate("true");
-            tag.setNamespace("");
-
-            UpDownSelectTag t = new UpDownSelectTag();
-            t.setPageContext(pageContext);
-            t.setName("myUpDownSelectTag");
-            t.setList("{}");
-
-            tag.doStartTag();
-            t.doStartTag();
-            t.doEndTag();
-            tag.doEndTag();
-
-            verify(FormTag.class.getResource("Formtag-11.txt"));
-        }
-        finally {
-            configurationManager.setConfiguration(originalConfiguration);
-        }
+        UpDownSelectTag t = new UpDownSelectTag();
+        t.setPageContext(pageContext);
+        t.setName("myUpDownSelectTag");
+        t.setList("{}");
+
+        tag.doStartTag();
+        t.doStartTag();
+        t.doEndTag();
+        tag.doEndTag();
+
+        verify(FormTag.class.getResource("Formtag-11.txt"));
     }
 
     /**
@@ -380,63 +266,12 @@ public class FormTagTest extends Abstrac
      */
     public void testFormWithCustomOnsubmitEnabledWithValidateEnabled3() throws Exception {
 
-        final Container cont = container;
-        // used to determined if the form action needs js validation
-        configurationManager.setConfiguration(new com.opensymphony.xwork2.config.impl.DefaultConfiguration() {
-            private DefaultConfiguration self = this;
-            public Container getContainer() {
-                return new Container() {
-                    public <T> T inject(Class<T> implementation) {return null;}
-                    public void removeScopeStrategy() {}
-                    public void setScopeStrategy(Strategy scopeStrategy) {}
-                    public <T> T getInstance(Class<T> type, String name) {return null;}
-                    public <T> T getInstance(Class<T> type) {return cont.getInstance(type);}
-                    public Set<String> getInstanceNames(Class<?> type) {return null;}
-
-                    public void inject(Object o) {
-                        cont.inject(o);
-                        if (o instanceof Form) {
-                            ((Form)o).setConfiguration(self);
-                        }
-                    }
-                };
-            }
-            public RuntimeConfiguration getRuntimeConfiguration() {
-                return new RuntimeConfiguration() {
-                    public ActionConfig getActionConfig(String namespace, String name) {
-                        ActionConfig actionConfig = new ActionConfig("", name, IntValidationAction.class.getName()) {
-                            public List getInterceptors() {
-                                List interceptors = new ArrayList();
-
-                                ValidationInterceptor validationInterceptor = new ValidationInterceptor();
-                                validationInterceptor.setIncludeMethods("*");
-
-                                InterceptorMapping interceptorMapping = new InterceptorMapping("validation", validationInterceptor);
-                                interceptors.add(interceptorMapping);
-
-                                return interceptors;
-                            }
-                            public String getClassName() {
-                                return IntValidationAction.class.getName();
-                            }
-                        };
-                        return actionConfig;
-                    }
-
-                    public Map getActionConfigs() {
-                        return null;
-                    }
-                };
-            }
-        });
-
-        Dispatcher.getInstance().setConfigurationManager(configurationManager);
-
+        prepareMockInvocation();
         FormTag tag = new FormTag();
         tag.setPageContext(pageContext);
         tag.setName("myForm");
         tag.setMethod("post");
-        tag.setAction("myAction");
+        tag.setAction("doubleValidationAction");
         tag.setAcceptcharset("UTF-8");
         tag.setEnctype("myEncType");
         tag.setTitle("mytitle");
@@ -462,64 +297,13 @@ public class FormTagTest extends Abstrac
      * Tests the numbers are formatted correctly to not break the javascript, using doubles
      */
     public void testFormWithCustomOnsubmitEnabledWithValidateEnabled4() throws Exception {
-
-        final Container cont = container;
-        // used to determined if the form action needs js validation
-        configurationManager.setConfiguration(new com.opensymphony.xwork2.config.impl.DefaultConfiguration() {
-            private DefaultConfiguration self = this;
-            public Container getContainer() {
-                return new Container() {
-                    public <T> T inject(Class<T> implementation) {return null;}
-                    public void removeScopeStrategy() {}
-                    public void setScopeStrategy(Strategy scopeStrategy) {}
-                    public <T> T getInstance(Class<T> type, String name) {return null;}
-                    public <T> T getInstance(Class<T> type) {return cont.getInstance(type);}
-                    public Set<String> getInstanceNames(Class<?> type) {return null;}
-
-                    public void inject(Object o) {
-                        cont.inject(o);
-                        if (o instanceof Form) {
-                            ((Form)o).setConfiguration(self);
-                        }
-                    }
-                };
-            }
-            public RuntimeConfiguration getRuntimeConfiguration() {
-                return new RuntimeConfiguration() {
-                    public ActionConfig getActionConfig(String namespace, String name) {
-                        ActionConfig actionConfig = new ActionConfig("", name, DoubleValidationAction.class.getName()) {
-                            public List getInterceptors() {
-                                List interceptors = new ArrayList();
-
-                                ValidationInterceptor validationInterceptor = new ValidationInterceptor();
-                                validationInterceptor.setIncludeMethods("*");
-
-                                InterceptorMapping interceptorMapping = new InterceptorMapping("validation", validationInterceptor);
-                                interceptors.add(interceptorMapping);
-
-                                return interceptors;
-                            }
-                            public String getClassName() {
-                                return DoubleValidationAction.class.getName();
-                            }
-                        };
-                        return actionConfig;
-                    }
-
-                    public Map getActionConfigs() {
-                        return null;
-                    }
-                };
-            }
-        });
-
-        Dispatcher.getInstance().setConfigurationManager(configurationManager);
+        prepareMockInvocation();
 
         FormTag tag = new FormTag();
         tag.setPageContext(pageContext);
         tag.setName("myForm");
         tag.setMethod("post");
-        tag.setAction("myAction");
+        tag.setAction("doubleValidationAction");
         tag.setAcceptcharset("UTF-8");
         tag.setEnctype("myEncType");
         tag.setTitle("mytitle");
@@ -541,6 +325,24 @@ public class FormTagTest extends Abstrac
         verify(FormTag.class.getResource("Formtag-24.txt"));
     }
 
+    private void prepareMockInvocation() throws Exception {
+        ActionContext.getContext().setValueStack(stack);
+
+        ActionConfig config = new ActionConfig.Builder("", "name", "").build();
+        ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
+        ActionProxy proxy = EasyMock.createNiceMock(ActionProxy.class);
+
+        EasyMock.expect(invocation.getProxy()).andReturn(proxy).anyTimes();
+        EasyMock.expect(invocation.getAction()).andReturn(null).anyTimes();
+        EasyMock.expect(invocation.invoke()).andReturn(Action.SUCCESS).anyTimes();
+        EasyMock.expect(proxy.getMethod()).andReturn("execute").anyTimes();
+        EasyMock.expect(proxy.getConfig()).andReturn(config).anyTimes();
+
+        EasyMock.replay(invocation);
+        EasyMock.replay(proxy);
+
+        ActionContext.getContext().setActionInvocation(invocation);
+    }
 
     /**
      * This test with form tag validation disabled.
@@ -582,6 +384,7 @@ public class FormTagTest extends Abstrac
             put(StrutsConstants.STRUTS_ACTION_EXTENSION, "jspa");
             put("configProviders", TestConfigurationProvider.class.getName());
         }});
+        createMocks();
         request.setupGetServletPath("/testNamespace/testNamespaceAction");
 
         FormTag tag = new FormTag();
@@ -637,7 +440,7 @@ public class FormTagTest extends Abstrac
     }
 
     public void testFormTagForStackOverflowException1() throws Exception {
-        request.setRequestURI("/requestUri");
+        request.setRequestURI("/testAction");
 
         FormTag form1 = new FormTag();
         form1.setPageContext(pageContext);
@@ -804,25 +607,9 @@ public class FormTagTest extends Abstrac
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        initDispatcher(new HashMap<String,String>(){{ 
+        initDispatcher(new HashMap<String, String>() {{
             put("configProviders", TestConfigurationProvider.class.getName());
         }});
-        ActionContext.getContext().setValueStack(stack);
-
-        ActionConfig config = new ActionConfig.Builder("", "name", "").build();
-        ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
-        ActionProxy proxy = EasyMock.createNiceMock(ActionProxy.class);
-
-        EasyMock.expect(invocation.getProxy()).andReturn(proxy).anyTimes();
-        EasyMock.expect(invocation.getAction()).andReturn(null).anyTimes();
-        EasyMock.expect(invocation.invoke()).andReturn(Action.SUCCESS).anyTimes();
-        EasyMock.expect(proxy.getMethod()).andReturn("execute").anyTimes();
-        EasyMock.expect(proxy.getConfig()).andReturn(config).anyTimes();
-
-
-        EasyMock.replay(invocation);
-        EasyMock.replay(proxy);
-
-        ActionContext.getContext().setActionInvocation(invocation);
+        createMocks();
     }
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TooltipTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TooltipTest.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TooltipTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/TooltipTest.java Sun Dec  8 17:12:01 2013
@@ -379,5 +379,6 @@ public class TooltipTest extends Abstrac
         initDispatcher(new HashMap<String,String>(){{ 
             put("configProviders", TestConfigurationProvider.class.getName());
         }});
+        createMocks();
     }
 }

Modified: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-11.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-11.txt?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-11.txt (original)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-11.txt Sun Dec  8 17:12:01 2013
@@ -1,19 +1,19 @@
 <script type="text/javascript" src="/struts/xhtml/validation.js"></script>
 <script type="text/javascript" src="/struts/utils.js"></script>
-<form id="myAction" name="myForm" onsubmit="submitMe(); return validateForm_myAction();" action="/myAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
+<form id="testAction" name="myForm" onsubmit="submitMe(); return validateForm_testAction();" action="/testAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
 <table class="wwFormTable"> <tr>
     <td class="tdLabel"></td>
     <td>	<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
 <table>
 <tr><td>
-<select name="myUpDownSelectTag" size="5" id="myAction_myUpDownSelectTag" multiple="multiple">
+<select name="myUpDownSelectTag" size="5" id="testAction_myUpDownSelectTag" multiple="multiple">
 </select>
-<input type="hidden" id="__multiselect_myAction_myUpDownSelectTag" name="__multiselect_myUpDownSelectTag"value=""/>
+<input type="hidden" id="__multiselect_testAction_myUpDownSelectTag" name="__multiselect_myUpDownSelectTag"value=""/>
 </td></tr>
 <tr><td>
-		&nbsp;<input type="button" value="^" onclick="moveOptionUp(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
-		&nbsp;<input type="button" value="v" onclick="moveOptionDown(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
-		&nbsp;<input type="button" value="*" onclick="selectAllOptions(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="^" onclick="moveOptionUp(document.getElementById('testAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="v" onclick="moveOptionDown(document.getElementById('testAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="*" onclick="selectAllOptions(document.getElementById('testAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
 </td></tr>
 </table>
 </td>
@@ -23,10 +23,10 @@
 
 
 <script type="text/javascript">
-	var containingForm = document.getElementById("myAction");
+	var containingForm = document.getElementById("testAction");
 	StrutsUtils.addEventListener(containingForm, "submit",
 			function(evt) {
-				var updownselectObj = document.getElementById("myAction_myUpDownSelectTag");
+				var updownselectObj = document.getElementById("testAction_myUpDownSelectTag");
 				selectAllOptionsExceptSome(updownselectObj, "key", "");
 			}, true);
 </script>

Modified: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-13.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-13.txt?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-13.txt (original)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-13.txt Sun Dec  8 17:12:01 2013
@@ -1,4 +1,4 @@
-<form id="testAction" name="testAction" action="/somecontext/testAction.action" method="post">
+<form id="testAction" name="testAction" action="/testNamespace/testAction.action" method="post">
 <table class="wwFormTable">
 </table>
 </form>
\ No newline at end of file

Modified: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-2.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-2.txt?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-2.txt (original)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-2.txt Sun Dec  8 17:12:01 2013
@@ -1,19 +1,19 @@
 <script type="text/javascript" src="/struts/xhtml/validation.js"></script>
 <script type="text/javascript "src="/struts/utils.js"></script>
-<form id="myAction" name="myForm" onsubmit="submitMe(); return validateForm_myAction();" action="/myAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
+<form id="doubleValidationAction" name="myForm" onsubmit="submitMe(); return validateForm_doubleValidationAction();" action="/doubleValidationAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
 <table class="wwFormTable"> <tr>
     <td class="tdLabel"></td>
     <td>	<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
 <table>
 <tr><td>
-<select name="myUpDownSelectTag" size="5" id="myAction_myUpDownSelectTag" multiple="multiple">
+<select name="myUpDownSelectTag" size="5" id="doubleValidationAction_myUpDownSelectTag" multiple="multiple">
 </select>
-<input type="hidden" id="__multiselect_myAction_myUpDownSelectTag" name="__multiselect_myUpDownSelectTag"value=""/>
+<input type="hidden" id="__multiselect_doubleValidationAction_myUpDownSelectTag" name="__multiselect_myUpDownSelectTag"value=""/>
 </td></tr>
 <tr><td>
-		&nbsp;<input type="button" value="^" onclick="moveOptionUp(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
-		&nbsp;<input type="button" value="v" onclick="moveOptionDown(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
-		&nbsp;<input type="button" value="*" onclick="selectAllOptions(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="^" onclick="moveOptionUp(document.getElementById('doubleValidationAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="v" onclick="moveOptionDown(document.getElementById('doubleValidationAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="*" onclick="selectAllOptions(document.getElementById('doubleValidationAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
 </td></tr>
 </table>
 </td>
@@ -23,17 +23,17 @@
 
 
 <script type="text/javascript">
-	var containingForm = document.getElementById("myAction");
+	var containingForm = document.getElementById("doubleValidationAction");
 	StrutsUtils.addEventListener(containingForm, "submit",
 			function(evt) {
-				var updownselectObj = document.getElementById("myAction_myUpDownSelectTag");
+				var updownselectObj = document.getElementById("doubleValidationAction_myUpDownSelectTag");
 				selectAllOptionsExceptSome(updownselectObj, "key", "");
 			}, true);
 </script>
 
 <script type="text/javascript">
 
-    function validateForm_myAction() {
+    function validateForm_doubleValidationAction() {
         var getFieldValue = function(field) {
             var type = field.type ? field.type : field[0].type;
             if(type == 'select-one' || type == 'select-multiple') {
@@ -51,11 +51,25 @@
             }
             return field.value;
         }
-        form = document.getElementById("myAction");
+        form = document.getElementById("doubleValidationAction");
         clearErrorMessages(form);
         clearErrorLabels(form);
         var errors = false;
         var continueValidation=true;
+        //field name: myUpDownSelectTag
+        //validator name: double
+        if(form.elements['myUpDownSelectTag']) {
+            field = form.elements['myUpDownSelectTag'];
+            var error = "bar must be between 6000.1 and 10000.1.";
+            var fieldValue=getFieldValue(field);
+            if(continueValidation && fieldValue != null) {
+                var value = parseFloat(fieldValue);
+                if(value < 6000.1 || value>10000.1 || false || false){
+                    addError(field, error);
+                    errors=true;
+                }
+            }
+        }
         return !errors;
     }
 

Modified: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-22.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-22.txt?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-22.txt (original)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-22.txt Sun Dec  8 17:12:01 2013
@@ -1,19 +1,19 @@
 <script type="text/javascript" src="/struts/xhtml/validation.js"></script>
 <script type="text/javascript "src="/struts/utils.js"></script>
-<form id="myAction" name="myForm" onsubmit="submitMe(); return validateForm_myAction();" action="/myAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
+<form id="doubleValidationAction" name="myForm" onsubmit="submitMe(); return validateForm_doubleValidationAction();" action="/doubleValidationAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
 <table class="wwFormTable"> <tr>
     <td class="tdLabel"></td>
     <td>	<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
 <table>
 <tr><td>
-<select name="myUpDownSelectTag" size="5" id="myAction_myUpDownSelectTag" multiple="multiple">
+<select name="myUpDownSelectTag" size="5" id="doubleValidationAction_myUpDownSelectTag" multiple="multiple">
 </select>
-<input type="hidden" id="__multiselect_myAction_myUpDownSelectTag" name="__multiselect_myUpDownSelectTag"value=""/>
+<input type="hidden" id="__multiselect_doubleValidationAction_myUpDownSelectTag" name="__multiselect_myUpDownSelectTag"value=""/>
 </td></tr>
 <tr><td>
-		&nbsp;<input type="button" value="^" onclick="moveOptionUp(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
-		&nbsp;<input type="button" value="v" onclick="moveOptionDown(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
-		&nbsp;<input type="button" value="*" onclick="selectAllOptions(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="^" onclick="moveOptionUp(document.getElementById('doubleValidationAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="v" onclick="moveOptionDown(document.getElementById('doubleValidationAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="*" onclick="selectAllOptions(document.getElementById('doubleValidationAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
 </td></tr>
 </table>
 </td>
@@ -23,16 +23,16 @@
 
 
 <script type="text/javascript">
-	var containingForm = document.getElementById("myAction");
+	var containingForm = document.getElementById("doubleValidationAction");
 	StrutsUtils.addEventListener(containingForm, "submit",
 			function(evt) {
-				var updownselectObj = document.getElementById("myAction_myUpDownSelectTag");
+				var updownselectObj = document.getElementById("doubleValidationAction_myUpDownSelectTag");
 				selectAllOptionsExceptSome(updownselectObj, "key", "");
 			}, true);
 </script>
 
 <script type="text/javascript">
-    function validateForm_myAction() {
+    function validateForm_doubleValidationAction() {
         var getFieldValue = function(field) {
             var type = field.type ? field.type : field[0].type;
             if(type == 'select-one' || type == 'select-multiple') {
@@ -50,21 +50,22 @@
             }
             return field.value;
         }
-        form = document.getElementById("myAction");
+        form = document.getElementById("doubleValidationAction");
         clearErrorMessages(form);
         clearErrorLabels(form);
         var errors = false;
         var continueValidation = true;
-        //fieldname:myUpDownSelectTag
-        //validatorname:int
+        //field name: myUpDownSelectTag
+        //validator name: double
         if(form.elements['myUpDownSelectTag']) {
             field = form.elements['myUpDownSelectTag'];
-            var error = "bar must be between 6000 and 10000.";
-            var fieldValue = getFieldValue(field);
+            var error = "bar must be between 6000.1 and 10000.1.";
+            var fieldValue=getFieldValue(field);
             if(continueValidation && fieldValue != null) {
-                if(parseInt(fieldValue) < 6000 || parseInt(fieldValue) > 10000) {
+                var value = parseFloat(fieldValue);
+                if(value < 6000.1 || value>10000.1 || false || false){
                     addError(field, error);
-                    errors = true;
+                    errors=true;
                 }
             }
         }

Modified: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-24.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-24.txt?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-24.txt (original)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-24.txt Sun Dec  8 17:12:01 2013
@@ -1,19 +1,19 @@
 <script type="text/javascript" src="/struts/xhtml/validation.js"></script>
 <script type="text/javascript "src="/struts/utils.js"></script>
-<form id="myAction" name="myForm" onsubmit="submitMe(); return validateForm_myAction();" action="/myAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
+<form id="doubleValidationAction" name="myForm" onsubmit="submitMe(); return validateForm_doubleValidationAction();" action="/doubleValidationAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
 <table class="wwFormTable"> <tr>
     <td class="tdLabel"></td>
     <td>	<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
 <table>
 <tr><td>
-<select name="myUpDownSelectTag" size="5" id="myAction_myUpDownSelectTag" multiple="multiple">
+<select name="myUpDownSelectTag" size="5" id="doubleValidationAction_myUpDownSelectTag" multiple="multiple">
 </select>
-<input type="hidden" id="__multiselect_myAction_myUpDownSelectTag" name="__multiselect_myUpDownSelectTag"value=""/>
+<input type="hidden" id="__multiselect_doubleValidationAction_myUpDownSelectTag" name="__multiselect_myUpDownSelectTag"value=""/>
 </td></tr>
 <tr><td>
-		&nbsp;<input type="button" value="^" onclick="moveOptionUp(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
-		&nbsp;<input type="button" value="v" onclick="moveOptionDown(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
-		&nbsp;<input type="button" value="*" onclick="selectAllOptions(document.getElementById('myAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="^" onclick="moveOptionUp(document.getElementById('doubleValidationAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="v" onclick="moveOptionDown(document.getElementById('doubleValidationAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
+		&nbsp;<input type="button" value="*" onclick="selectAllOptions(document.getElementById('doubleValidationAction_myUpDownSelectTag'), 'key', '');" />&nbsp;
 </td></tr>
 </table>
 </td>
@@ -23,16 +23,16 @@
 
 
 <script type="text/javascript">
-	var containingForm = document.getElementById("myAction");
+	var containingForm = document.getElementById("doubleValidationAction");
 	StrutsUtils.addEventListener(containingForm, "submit",
 			function(evt) {
-				var updownselectObj = document.getElementById("myAction_myUpDownSelectTag");
+				var updownselectObj = document.getElementById("doubleValidationAction_myUpDownSelectTag");
 				selectAllOptionsExceptSome(updownselectObj, "key", "");
 			}, true);
 </script>
 
 <script type="text/javascript">
-    function validateForm_myAction() {
+    function validateForm_doubleValidationAction() {
         var getFieldValue = function(field) {
             var type = field.type ? field.type : field[0].type;
             if(type == 'select-one' || type == 'select-multiple') {
@@ -50,13 +50,13 @@
             }
             return field.value;
         }
-        form = document.getElementById("myAction");
+        form = document.getElementById("doubleValidationAction");
         clearErrorMessages(form);
         clearErrorLabels(form);
         var errors = false;
         var continueValidation = true;
-        //fieldname:myUpDownSelectTag
-        //validatorname:double
+        //field name: myUpDownSelectTag
+        //validator name: double
         if(form.elements['myUpDownSelectTag']) {
             field = form.elements['myUpDownSelectTag'];
             var error = "bar must be between 6000.1 and 10000.1.";

Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java (original)
+++ struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java Sun Dec  8 17:12:01 2013
@@ -62,11 +62,13 @@ import static org.junit.Assert.assertNot
 
 
 public abstract class StrutsJUnit4TestCase<T> extends XWorkJUnit4TestCase {
+
     protected MockHttpServletResponse response;
     protected MockHttpServletRequest request;
     protected MockPageContext pageContext;
     protected MockServletContext servletContext;
     protected Map<String, String> dispatcherInitParams;
+    protected Dispatcher dispatcher;
 
     protected DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
 
@@ -178,8 +180,7 @@ public abstract class StrutsJUnit4TestCa
      * Finds an ActionMapping for a given request
      */
     protected ActionMapping getActionMapping(HttpServletRequest request) {
-        return Dispatcher.getInstance().getContainer().getInstance(ActionMapper.class).getMapping(request,
-                Dispatcher.getInstance().getConfigurationManager());
+        return container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
     }
 
     /**
@@ -195,10 +196,9 @@ public abstract class StrutsJUnit4TestCa
      * Injects dependencies on an Object using Struts internal IoC container
      */
     protected void injectStrutsDependencies(Object object) {
-        Dispatcher.getInstance().getContainer().inject(object);
+        container.inject(object);
     }
 
-
     protected void setupBeforeInitDispatcher() throws Exception {
     }
 
@@ -232,7 +232,6 @@ public abstract class StrutsJUnit4TestCa
      */
     @Before
     public void setUp() throws Exception {
-
         super.setUp();
         initServletMockObjects();
         setupBeforeInitDispatcher();
@@ -248,11 +247,12 @@ public abstract class StrutsJUnit4TestCa
     }
 
     protected Dispatcher initDispatcher(Map<String, String> params) {
-        Dispatcher du = StrutsTestCaseHelper.initDispatcher(servletContext, params);
-        configurationManager = du.getConfigurationManager();
+        dispatcher = StrutsTestCaseHelper.initDispatcher(servletContext, params);
+        configurationManager = dispatcher.getConfigurationManager();
         configuration = configurationManager.getConfiguration();
         container = configuration.getContainer();
-        return du;
+        container.inject(dispatcher);
+        return dispatcher;
     }
 
     /**
@@ -267,8 +267,11 @@ public abstract class StrutsJUnit4TestCa
 
     @After
     public void tearDown() throws Exception {
-
         super.tearDown();
+        if (dispatcher != null && dispatcher.getConfigurationManager() != null) {
+            dispatcher.cleanup();
+            dispatcher = null;
+        }
         StrutsTestCaseHelper.tearDown();
     }
 

Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java (original)
+++ struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java Sun Dec  8 17:12:01 2013
@@ -62,6 +62,7 @@ public abstract class StrutsTestCase ext
     protected MockPageContext pageContext;
     protected MockServletContext servletContext;
     protected Map<String, String> dispatcherInitParams;
+    protected Dispatcher dispatcher;
 
     protected DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
 
@@ -177,8 +178,7 @@ public abstract class StrutsTestCase ext
      * Finds an ActionMapping for a given request
      */
     protected ActionMapping getActionMapping(HttpServletRequest request) {
-        return Dispatcher.getInstance().getContainer().getInstance(ActionMapper.class).getMapping(request,
-                Dispatcher.getInstance().getConfigurationManager());
+        return container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
     }
 
     /**
@@ -194,10 +194,9 @@ public abstract class StrutsTestCase ext
      * Injects dependencies on an Object using Struts internal IoC container
      */
     protected void injectStrutsDependencies(Object object) {
-        Dispatcher.getInstance().getContainer().inject(object);
+        container.inject(object);
     }
 
-
     /**
      * Sets up the configuration settings, XWork configuration, and
      * message resources
@@ -206,7 +205,7 @@ public abstract class StrutsTestCase ext
         super.setUp();
         initServletMockObjects();
         setupBeforeInitDispatcher();
-        Dispatcher dispatcher = initDispatcher(dispatcherInitParams);
+        dispatcher = initDispatcher(dispatcherInitParams);
         setupAfterInitDispatcher(dispatcher);
     }
 
@@ -235,6 +234,11 @@ public abstract class StrutsTestCase ext
 
     protected void tearDown() throws Exception {
         super.tearDown();
+        // maybe someone else already destroyed Dispatcher
+        if (dispatcher != null && dispatcher.getConfigurationManager() != null) {
+            dispatcher.cleanup();
+            dispatcher = null;
+        }
         StrutsTestCaseHelper.tearDown();
     }
 

Modified: struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java (original)
+++ struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java Sun Dec  8 17:12:01 2013
@@ -206,7 +206,7 @@ public class Jsr168Dispatcher extends Ge
 
         // For testability
         if (factory == null) {
-            factory = dispatcherUtils.getConfigurationManager().getConfiguration().getContainer().getInstance(ActionProxyFactory.class);
+            factory = dispatcherUtils.getContainer().getInstance(ActionProxyFactory.class);
         }
         portletNamespace = cfg.getInitParameter("portletNamespace");
         if (LOG.isDebugEnabled()) {
@@ -374,7 +374,7 @@ public class Jsr168Dispatcher extends Ge
         extraContext.put(ActionContext.SESSION, sessionMap);
         extraContext.put(ActionContext.APPLICATION, applicationMap);
 
-        String defaultLocale = dispatcherUtils.getContainer().getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
+        String defaultLocale = container.getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
         Locale locale;
         if (defaultLocale != null) {
             locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());

Modified: struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java?rev=1549067&r1=1549066&r2=1549067&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java (original)
+++ struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java Sun Dec  8 17:12:01 2013
@@ -82,6 +82,8 @@ public class PortletUrlTagTest extends M
 
 	Mock mockActionInvocation = null;
 
+    private Dispatcher dispatcher;
+
     public static void main(String[] args) {
         TestRunner.run(PortletUrlTagTest.class);
     }
@@ -90,12 +92,12 @@ public class PortletUrlTagTest extends M
     public void setUp() throws Exception {
         super.setUp();
 
-        Dispatcher du = new Dispatcher(null, new HashMap());
-        du.init();
-        Dispatcher.setInstance(du);
+        dispatcher = new Dispatcher(null, new HashMap());
+        dispatcher.init();
+        Dispatcher.setInstance(dispatcher);
 
-        stack = du.getContainer().getInstance(ValueStackFactory.class).createValueStack();
-        stack.getContext().put(ActionContext.CONTAINER, du.getContainer());
+        stack = dispatcher.getContainer().getInstance(ValueStackFactory.class).createValueStack();
+        stack.getContext().put(ActionContext.CONTAINER, dispatcher.getContainer());
         ActionContext context = new ActionContext(stack.getContext());
         ActionContext.setContext(context);
         
@@ -166,6 +168,14 @@ public class PortletUrlTagTest extends M
         
     }
 
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (dispatcher != null && dispatcher.getConfigurationManager() != null) {
+            dispatcher.cleanup();
+            dispatcher = null;
+        }
+    }
+
     public void testEnsureParamsAreStringArrays() {
         Map params = new HashMap();
         params.put("param1", "Test1");



Mime
View raw message