struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r474191 [3/4] - in /struts/struts2/trunk: apps/showcase/src/main/resources/ apps/showcase/src/main/webapp/WEB-INF/ core/src/main/java/org/apache/struts2/ core/src/main/java/org/apache/struts2/components/ core/src/main/java/org/apache/struts...
Date Mon, 13 Nov 2006 08:30:46 GMT
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java Mon Nov 13 00:30:40 2006
@@ -40,7 +40,6 @@
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsException;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.util.VelocityStrutsUtil;
 import org.apache.struts2.views.jsp.ui.OgnlTool;
 import org.apache.struts2.views.util.ContextUtil;
@@ -95,6 +94,7 @@
 import org.apache.velocity.tools.view.servlet.ServletToolboxManager;
 
 import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
 
 
@@ -133,14 +133,15 @@
 
     private Properties velocityProperties;
 
-    protected VelocityManager() {
-        init();
+    private String customConfigFile;
+    
+    public VelocityManager() {
     }
 
     /**
      * retrieve an instance to the current VelocityManager
      */
-    public synchronized static VelocityManager getInstance() {
+    /*public synchronized static VelocityManager getInstance() {
         if (instance == null) {
             String classname = VelocityManager.class.getName();
 
@@ -164,6 +165,7 @@
 
         return instance;
     }
+    */
 
     /**
      * @return a reference to the VelocityEngine used by <b>all</b> struts velocity thingies with the exception of
@@ -196,7 +198,7 @@
             Map.Entry entry = (Map.Entry) iterator.next();
             context.put((String) entry.getKey(), entry.getValue());
         }
-        context.put(STRUTS, new VelocityStrutsUtil(context, stack, req, res));
+        context.put(STRUTS, new VelocityStrutsUtil(velocityEngine, context, stack, req, res));
 
 
         ServletContext ctx = null;
@@ -299,8 +301,8 @@
          */
         String configfile;
 
-        if (Settings.isSet(StrutsConstants.STRUTS_VELOCITY_CONFIGFILE)) {
-            configfile = Settings.get(StrutsConstants.STRUTS_VELOCITY_CONFIGFILE);
+        if (customConfigFile != null) {
+            configfile = customConfigFile;
         } else {
             configfile = "velocity.properties";
         }
@@ -396,23 +398,40 @@
 
         return properties;
     }
-
+    
+    @Inject(StrutsConstants.STRUTS_VELOCITY_CONFIGFILE)
+    public void setCustomConfigFile(String val) {
+        this.customConfigFile = val;
+    }
+    
+    @Inject(StrutsConstants.STRUTS_VELOCITY_TOOLBOXLOCATION)
+    public void setToolBoxLocation(String toolboxLocation) {
+        this.toolBoxLocation = toolboxLocation;
+    }
+    
     /**
-     * performs one-time initializations
+     * allow users to specify via the struts.properties file a set of additional VelocityContexts to chain to the
+     * the StrutsVelocityContext.  The intent is to allow these contexts to store helper objects that the ui
+     * developer may want access to.  Examples of reasonable VelocityContexts would be an IoCVelocityContext, a
+     * SpringReferenceVelocityContext, and a ToolboxVelocityContext
      */
-    protected void init() {
-
-        // read in the names of contexts to add to each request
-        initChainedContexts();
-
+    @Inject(StrutsConstants.STRUTS_VELOCITY_CONTEXTS)
+    public void setChainedContexts(String contexts) {
+        // we expect contexts to be a comma separated list of classnames
+        StringTokenizer st = new StringTokenizer(contexts, ",");
+        List contextList = new ArrayList();
 
-        if (Settings.isSet(StrutsConstants.STRUTS_VELOCITY_TOOLBOXLOCATION)) {
-            toolBoxLocation = Settings.get(StrutsConstants.STRUTS_VELOCITY_TOOLBOXLOCATION).toString();
+        while (st.hasMoreTokens()) {
+            String classname = st.nextToken();
+            contextList.add(classname);
+        }
+        if (contextList.size() > 0) {
+            String[] chainedContexts = new String[contextList.size()];
+            contextList.toArray(chainedContexts);
+            this.chainedContextNames = chainedContexts;
         }
-
     }
 
-
     /**
      * Initializes the ServletToolboxManager for this servlet's
      * toolbox (if any).
@@ -427,34 +446,7 @@
     }
 
 
-    /**
-     * allow users to specify via the struts.properties file a set of additional VelocityContexts to chain to the
-     * the StrutsVelocityContext.  The intent is to allow these contexts to store helper objects that the ui
-     * developer may want access to.  Examples of reasonable VelocityContexts would be an IoCVelocityContext, a
-     * SpringReferenceVelocityContext, and a ToolboxVelocityContext
-     */
-    protected void initChainedContexts() {
-
-        if (Settings.isSet(StrutsConstants.STRUTS_VELOCITY_CONTEXTS)) {
-            // we expect contexts to be a comma separated list of classnames
-            String contexts = Settings.get(StrutsConstants.STRUTS_VELOCITY_CONTEXTS).toString();
-            StringTokenizer st = new StringTokenizer(contexts, ",");
-            List contextList = new ArrayList();
-
-            while (st.hasMoreTokens()) {
-                String classname = st.nextToken();
-                contextList.add(classname);
-            }
-            if (contextList.size() > 0) {
-                String[] chainedContexts = new String[contextList.size()];
-                contextList.toArray(chainedContexts);
-                this.chainedContextNames = chainedContexts;
-            }
-
-
-        }
-
-    }
+    
 
     /**
      * <p/>

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/components/AbstractDirective.java Mon Nov 13 00:30:40 2006
@@ -30,6 +30,7 @@
 
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.components.Component;
+import org.apache.struts2.dispatcher.Dispatcher;
 import org.apache.velocity.context.InternalContextAdapter;
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.ParseErrorException;
@@ -37,6 +38,7 @@
 import org.apache.velocity.runtime.directive.Directive;
 import org.apache.velocity.runtime.parser.node.Node;
 
+import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.util.ValueStack;
 
 public abstract class AbstractDirective extends Directive {
@@ -61,7 +63,8 @@
         HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST);
         HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE);
         Component bean = getBean(stack, req, res);
-
+        Container container = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getContainer();
+        container.inject(bean);
         // get the parameters
         Map params = createPropertyMap(ctx, node);
         bean.copyParams(params);

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java Mon Nov 13 00:30:40 2006
@@ -42,11 +42,12 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.config.Settings;
+import org.apache.struts2.StrutsConstants;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.Result;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.TextParseUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 
@@ -202,12 +203,16 @@
 
     public XSLTResult() {
         templatesCache = new HashMap<String, Templates>();
-        noCache = Settings.get("struts.xslt.nocache").trim().equalsIgnoreCase("true");
     }
 
     public XSLTResult(String stylesheetLocation) {
         this();
         setStylesheetLocation(stylesheetLocation);
+    }
+    
+    @Inject(StrutsConstants.STRUTS_XSLT_NOCACHE)
+    public void setNoCache(String val) {
+        noCache = "true".equals(val);
     }
 
     /**

Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties Mon Nov 13 00:30:40 2006
@@ -48,16 +48,7 @@
 # struts.custom.properties=application,org/apache/struts2/extension/custom
 
 ### How request URLs are mapped to and from actions
-struts.mapper.class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper
-### The above line is to be commented and following are to be uncommented to 
-### enable CompositeActionMapper
-### - With CompositeActionMapper one could specified many ActionMapper instance, where
-###   each of them will be chosen according to the order. Lower order number has
-###   higher precedence
-#struts.mapper.class=org.apache.struts2.dispatcher.mapper.CompositeActionMapper
-#struts.mapper.composite.1=org.apache.struts2.dispatcher.mapper.DefaultActionMapper
-#struts.mapper.composite.2=foo.bar.MyActionMapper
-#struts.mapper.composite.3=foo.bar.MyAnotherActionMapper
+#struts.mapper.class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper
 
 ### Used by the DefaultActionMapper
 ### You may provide a comma separated list, e.g. struts.action.extension=action,jnlp,do
@@ -128,10 +119,13 @@
 struts.configuration.xml.reload=false
 
 ### Location of velocity.properties file.  defaults to velocity.properties
-# struts.velocity.configfile = velocity.properties
+struts.velocity.configfile = velocity.properties
 
 ### Comma separated list of VelocityContext classnames to chain to the StrutsVelocityContext
-# struts.velocity.contexts =
+struts.velocity.contexts =
+
+### Location of the velocity toolbox
+struts.velocity.toolboxlocation=
 
 ### used to build URLs, such as the UrlTag
 struts.url.http.port = 80
@@ -160,5 +154,8 @@
 
 ### A list of configuration files automatically loaded by Struts
 struts.configuration.files=struts-default.xml,struts-plugin.xml,struts.xml
+
+### A list of template engines available
+struts.templateEngines=ftl,jsp,vm
 
 ### END SNIPPET: complete_file

Modified: struts/struts2/trunk/core/src/main/resources/struts-2.0.dtd
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/struts-2.0.dtd?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/struts-2.0.dtd (original)
+++ struts/struts2/trunk/core/src/main/resources/struts-2.0.dtd Mon Nov 13 00:30:40 2006
@@ -11,7 +11,7 @@
 	"http://struts.apache.org/dtds/struts-2.0.dtd">
 -->
 
-<!ELEMENT struts (package|include)*>
+<!ELEMENT struts (package|include|bean|constant)*>
 
 <!ELEMENT package (result-types?, interceptors?, default-interceptor-ref?, default-action-ref?, global-results?, global-exception-mappings?, action*)>
 <!ATTLIST package
@@ -98,6 +98,22 @@
 <!ELEMENT include (#PCDATA)>
 <!ATTLIST include
     file CDATA #REQUIRED
+>
+
+<!ELEMENT bean (#PCDATA)>
+<!ATTLIST bean
+    type CDATA #IMPLIED
+    name CDATA #IMPLIED
+    class CDATA #REQUIRED
+    scope CDATA #IMPLIED
+    static CDATA #IMPLIED
+    optional CDATA #IMPLIED
+>
+
+<!ELEMENT constant (#PCDATA)>
+<!ATTLIST constant
+    name CDATA #REQUIRED
+    value CDATA #REQUIRED    
 >
 
 <!-- END SNIPPET: strutsDtd -->

Modified: struts/struts2/trunk/core/src/main/resources/struts-default.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/struts-default.xml?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/struts-default.xml (original)
+++ struts/struts2/trunk/core/src/main/resources/struts-default.xml Mon Nov 13 00:30:40 2006
@@ -5,6 +5,41 @@
     "http://struts.apache.org/dtds/struts-2.0.dtd">
     
 <struts>
+	<bean class="com.opensymphony.xwork2.ObjectFactory" name="xwork" />
+	<bean type="com.opensymphony.xwork2.ObjectFactory" name="struts" class="org.apache.struts2.impl.StrutsObjectFactory" />
+	<bean type="com.opensymphony.xwork2.ObjectFactory" name="spring" class="org.apache.struts2.spring.StrutsSpringObjectFactory" optional="true"/>
+	
+	<bean type="com.opensymphony.xwork2.ActionProxyFactory" name="xwork" class="com.opensymphony.xwork2.DefaultActionProxyFactory"/>
+	<bean type="com.opensymphony.xwork2.ActionProxyFactory" name="struts" class="org.apache.struts2.impl.StrutsActionProxyFactory"/>
+	
+	<bean type="com.opensymphony.xwork2.util.ObjectTypeDeterminer" name="tiger" class="com.opensymphony.xwork2.util.GenericsObjectTypeDeterminer"/>
+	<bean type="com.opensymphony.xwork2.util.ObjectTypeDeterminer" name="notiger" class="com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer"/>
+	<bean type="com.opensymphony.xwork2.util.ObjectTypeDeterminer" name="struts" class="com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer"/>
+    
+    <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="struts" class="org.apache.struts2.dispatcher.mapper.DefaultActionMapper" />
+    <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="composite" class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper" />
+    <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="restful" class="org.apache.struts2.dispatcher.mapper.RestfulActionMapper" />
+    <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="restful2" class="org.apache.struts2.dispatcher.mapper.Restful2ActionMapper" />
+    
+    <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="struts" class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" scope="default"/>
+    <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakarta" class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" scope="default"/>
+    
+    <bean class="org.apache.struts2.views.freemarker.FreemarkerManager" name="struts" optional="true"/>
+    <bean class="org.apache.struts2.views.velocity.VelocityManager" name="struts" optional="true" />
+    
+    <bean class="org.apache.struts2.components.template.TemplateEngineManager" />
+    <bean type="org.apache.struts2.components.template.TemplateEngine" name="ftl" class="org.apache.struts2.components.template.FreemarkerTemplateEngine" />
+    <bean type="org.apache.struts2.components.template.TemplateEngine" name="vm" class="org.apache.struts2.components.template.VelocityTemplateEngine" />
+    <bean type="org.apache.struts2.components.template.TemplateEngine" name="jsp" class="org.apache.struts2.components.template.JspTemplateEngine" />
+    
+    <!--  Only have static constant injections -->
+    <bean class="com.opensymphony.xwork2.util.OgnlValueStack" static="true" />
+    <bean class="org.apache.struts2.dispatcher.Dispatcher" static="true" />
+    <bean class="org.apache.struts2.components.Include" static="true" />
+    <bean class="org.apache.struts2.dispatcher.FilterDispatcher" static="true" />
+    <bean class="org.apache.struts2.views.util.ContextUtil" static="true" />
+    <bean class="org.apache.struts2.views.util.UrlHelper" static="true" />
+	
     <package name="struts-default">
         <result-types>
             <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>

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?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- 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 Mon Nov 13 00:30:40 2006
@@ -24,6 +24,7 @@
 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;
@@ -31,12 +32,17 @@
 
 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;
 import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.config.entities.PackageConfig;
 import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
 import com.opensymphony.xwork2.mock.MockResult;
 
@@ -53,6 +59,7 @@
     public static final String TOKEN_SESSION_ACTION_NAME = "tokenSessionAction";
     public static final String TEST_NAMESPACE = "/testNamespace";
     public static final String TEST_NAMESPACE_ACTION = "testNamespaceAction";
+    private Configuration configuration;
 
 
     /**
@@ -60,11 +67,15 @@
      */
     public void destroy() {
     }
+    
+    public void init(Configuration config) {
+        this.configuration = config;
+    }
 
     /**
      * Initializes the configuration object.
      */
-    public void init(Configuration configurationManager) {
+    public void loadPackages() {
         PackageConfig defaultPackageConfig = new PackageConfig("");
 
         HashMap results = new HashMap();
@@ -125,7 +136,7 @@
         tokenSessionActionConfig.addResultConfig(new ResultConfig("success", MockResult.class.getName()));
         defaultPackageConfig.addActionConfig(TOKEN_SESSION_ACTION_NAME, tokenSessionActionConfig);
 
-        configurationManager.addPackageConfig("", defaultPackageConfig);
+        configuration.addPackageConfig("", defaultPackageConfig);
 
         Map testActionTagResults = new HashMap();
         testActionTagResults.put(Action.SUCCESS, new ResultConfig(Action.SUCCESS, TestActionTagResult.class.getName(), new HashMap()));
@@ -140,7 +151,7 @@
         ActionConfig namespaceAction = new ActionConfig(null, TestAction.class, null, null, null);
         namespacePackageConfig.addActionConfig(TEST_NAMESPACE_ACTION, namespaceAction);
 
-        configurationManager.addPackageConfig("namespacePackage", namespacePackageConfig);
+        configuration.addPackageConfig("namespacePackage", namespacePackageConfig);
     }
 
     /**
@@ -150,5 +161,14 @@
      */
     public boolean needsReload() {
         return false;
+    }
+
+    public void register(ContainerBuilder builder, Properties props) throws ConfigurationException {
+        if (!builder.contains(ObjectFactory.class)) {
+            builder.factory(ObjectFactory.class);
+        }
+        if (!builder.contains(ActionProxyFactory.class)) {
+            builder.factory(ActionProxyFactory.class, DefaultActionProxyFactory.class);
+        }
     }
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java Mon Nov 13 00:30:40 2006
@@ -49,6 +49,7 @@
         customPackage.setNamespace("/custom");
         config.addPackageConfig("custom-package", customPackage);
         provider.init(config);
+        provider.loadPackages();
     }
 
     public void testFoundRootPackages() {

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/SettingsTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/SettingsTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/SettingsTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/SettingsTest.java Mon Nov 13 00:30:40 2006
@@ -48,7 +48,7 @@
         assertEquals("de", locale.getLanguage());
 
         int count = getKeyCount();
-        assertEquals(32, count);
+        assertEquals(35, count);
     }
 
     public void testDefaultResourceBundlesLoaded() {

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ActionContextCleanUpTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ActionContextCleanUpTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ActionContextCleanUpTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ActionContextCleanUpTest.java Mon Nov 13 00:30:40 2006
@@ -21,6 +21,7 @@
 package org.apache.struts2.dispatcher;
 
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -110,20 +111,8 @@
             }
         };
 
-        cleanUp = new ActionContextCleanUp() {
-            @Override
-            protected Dispatcher createDispatcher() {
-                return _dispatcher;
-            }
-        };
-
-        cleanUp2 = new ActionContextCleanUp() {
-            @Override
-            protected Dispatcher createDispatcher() {
-                return _dispatcher2;
-            }
-        };
-
+        cleanUp = new ActionContextCleanUp();
+        cleanUp2 = new ActionContextCleanUp();
         filterChain2 = new MockFilterChain() {
             @Override
             public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
@@ -135,8 +124,6 @@
 
 
     public void testSingle() throws Exception {
-        assertFalse(_dispatcher.prepare);
-        assertFalse(_dispatcher.wrapRequest);
         assertNull(request.getAttribute("__cleanup_recursion_counter"));
 
         cleanUp.init(filterConfig);
@@ -146,16 +133,10 @@
         assertEquals(_tmpStore.size(), 1);
         assertEquals(_tmpStore.get("counter0"), new Integer(1));
 
-        assertTrue(_dispatcher.prepare);
-        assertTrue(_dispatcher.wrapRequest);
         assertEquals(request.getAttribute("__cleanup_recursion_counter"), new Integer("0"));
     }
 
     public void testMultiple() throws Exception {
-        assertFalse(_dispatcher.prepare);
-        assertFalse(_dispatcher.wrapRequest);
-        assertFalse(_dispatcher2.prepare);
-        assertFalse(_dispatcher2.wrapRequest);
         assertNull(request.getAttribute("__cleanup_recursion_counter"));
 
         cleanUp.init(filterConfig);
@@ -168,10 +149,6 @@
         assertEquals(_tmpStore.get("counter0"), new Integer(1));
         assertEquals(_tmpStore.get("counter1"), new Integer(2));
 
-        assertFalse(_dispatcher2.prepare);
-        assertFalse(_dispatcher2.wrapRequest);
-        assertTrue(_dispatcher.prepare);
-        assertTrue(_dispatcher.wrapRequest);
         assertEquals(request.getAttribute("__cleanup_recursion_counter"), new Integer("0"));
     }
 
@@ -182,7 +159,7 @@
         public boolean service = false;
 
         public InnerDispatcher(ServletContext servletContext) {
-            super(servletContext);
+            super(servletContext, new HashMap<String,String>());
         }
 
         @Override

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?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- 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 Mon Nov 13 00:30:40 2006
@@ -20,6 +20,7 @@
  */
 package org.apache.struts2.dispatcher;
 
+import java.util.HashMap;
 import java.util.Locale;
 
 import javax.servlet.http.HttpServletRequest;
@@ -27,7 +28,6 @@
 
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsTestCase;
-import org.apache.struts2.config.Settings;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 
@@ -58,10 +58,9 @@
         HttpServletRequest req = new MockHttpServletRequest();
         HttpServletResponse res = new MockHttpServletResponse();
 
-        Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
-
-
-        Dispatcher du = Dispatcher.getInstance();
+        Dispatcher du = initDispatcher(new HashMap() {{
+            put(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
+        }});
         du.prepare(req, res);
 
         assertEquals(req.getCharacterEncoding(), "utf-8");
@@ -72,12 +71,11 @@
         MockHttpServletResponse res = new MockHttpServletResponse();
 
         req.setContentType("multipart/form-data");
-        Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
-
-
-        Dispatcher du = Dispatcher.getInstance();
+        Dispatcher du = initDispatcher(new HashMap() {{
+            put(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
+        }});
         du.prepare(req, res);
 
-        assertEquals(req.getCharacterEncoding(), "utf-8");
+        assertEquals("utf-8", req.getCharacterEncoding());
     }
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java Mon Nov 13 00:30:40 2006
@@ -24,6 +24,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.servlet.FilterConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -31,12 +32,9 @@
 
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsTestCase;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.mapper.ActionMapper;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 import org.apache.struts2.util.ObjectFactoryDestroyable;
-import org.apache.struts2.util.ObjectFactoryInitializable;
-import org.apache.struts2.util.ObjectFactoryLifecycle;
 import org.springframework.mock.web.MockFilterConfig;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
@@ -93,119 +91,63 @@
         assertTrue(destroyedObjectFactory.destroyed);
     }
 
-
-    public void testObjectFactoryInitializable() throws Exception {
-
-        Map configMap = new HashMap();
-        configMap.put(StrutsConstants.STRUTS_OBJECTFACTORY, "org.apache.struts2.dispatcher.FilterDispatcherTest$InnerInitializableObjectFactory");
-        configMap.put(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "false");
-        Settings.setInstance(new InnerConfiguration(configMap));
-
+    public void testIfActionMapperIsNullDontServiceAction() throws Exception {
         MockServletContext servletContext = new MockServletContext();
         MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
+        MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
+        MockHttpServletResponse res = new MockHttpServletResponse();
+        MockFilterChain chain = new MockFilterChain();
+        final NoOpDispatcher _dispatcher = new NoOpDispatcher(servletContext);
+        Dispatcher.setInstance(_dispatcher);
+
+        ConfigurationManager confManager = new ConfigurationManager();
+        confManager.setConfiguration(new DefaultConfiguration());
+        _dispatcher.setConfigurationManager(confManager);
+
+
+        ObjectFactory.setObjectFactory(new InnerObjectFactory());
+
+        FilterDispatcher filter = new FilterDispatcher() {
+            protected Dispatcher createDispatcher() {
+                return _dispatcher;
+            }
+        };
+        filter.setActionMapper(null);
+        filter.init(filterConfig);
+        filter.doFilter(req, res, chain);
 
-
-        FilterDispatcher filterDispatcher = new FilterDispatcher();
-        filterDispatcher.init(filterConfig);
-
-        assertTrue(ObjectFactory.getObjectFactory() instanceof InnerInitializableObjectFactory);
-        assertTrue(((InnerInitializableObjectFactory) ObjectFactory.getObjectFactory()).initializable);
+        assertFalse(_dispatcher.serviceRequest);
     }
 
-    public void testObjectFactoryLifecycle() throws Exception {
-
-        Map configMap = new HashMap();
-        configMap.put(StrutsConstants.STRUTS_OBJECTFACTORY, "org.apache.struts2.dispatcher.FilterDispatcherTest$InnerInitailizableDestroyableObjectFactory");
-        configMap.put(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "false");
-        Settings.setInstance(new InnerConfiguration(configMap));
-
+    public void testCharacterEncodingSetBeforeRequestWrappingAndActionService() throws Exception {
         MockServletContext servletContext = new MockServletContext();
         MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
+        MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
+        MockHttpServletResponse res = new MockHttpServletResponse();
+        MockFilterChain chain = new MockFilterChain();
+        final InnerDispatcher _dispatcher = new InnerDispatcher(servletContext);
+        Dispatcher.setInstance(null);
+
+        ConfigurationManager confManager = new ConfigurationManager();
+        confManager.setConfiguration(new DefaultConfiguration());
+        _dispatcher.setConfigurationManager(confManager);
+
+
+        ObjectFactory.setObjectFactory(new InnerObjectFactory());
+
+        _dispatcher.setDefaultEncoding("UTF-16_DUMMY");
+
+        FilterDispatcher filter = new FilterDispatcher() {
+            protected Dispatcher createDispatcher(FilterConfig filterConfig) {
+                return _dispatcher;
+            }
+        };
+        filter.init(filterConfig);
+        filter.setActionMapper(new InnerActionMapper());
+        filter.doFilter(req, res, chain);
 
-
-        FilterDispatcher filterDispatcher = new FilterDispatcher();
-        filterDispatcher.init(filterConfig);
-
-        assertTrue(ObjectFactory.getObjectFactory() instanceof InnerInitailizableDestroyableObjectFactory);
-        assertTrue(((InnerInitailizableDestroyableObjectFactory) ObjectFactory.getObjectFactory()).initializable);
-
-        assertFalse(((InnerInitailizableDestroyableObjectFactory) ObjectFactory.getObjectFactory()).destroyable);
-        filterDispatcher.destroy();
-        assertTrue(((InnerInitailizableDestroyableObjectFactory) ObjectFactory.getObjectFactory()).destroyable);
-    }
-
-    public void testIfActionMapperIsNullDontServiceAction() throws Exception {
-        try {
-            MockServletContext servletContext = new MockServletContext();
-            MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
-            MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
-            MockHttpServletResponse res = new MockHttpServletResponse();
-            MockFilterChain chain = new MockFilterChain();
-            final NoOpDispatcher _dispatcher = new NoOpDispatcher(servletContext);
-            Dispatcher.setInstance(null);
-
-            ConfigurationManager confManager = new ConfigurationManager();
-            confManager.setConfiguration(new DefaultConfiguration());
-            _dispatcher.setConfigurationManager(confManager);
-
-
-            ObjectFactory.setObjectFactory(new InnerObjectFactory());
-
-            Map settings = new HashMap();
-            settings.put(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterDispatcherTest$NullActionMapper");
-            Settings.setInstance(new InnerConfiguration(settings));
-
-            FilterDispatcher filter = new FilterDispatcher() {
-                protected Dispatcher createDispatcher() {
-                    return _dispatcher;
-                }
-            };
-            filter.init(filterConfig);
-            filter.doFilter(req, res, chain);
-
-            assertFalse(_dispatcher.serviceRequest);
-        }
-        finally {
-            Settings.reset();
-        }
-    }
-
-    public void testCharacterEncodingSetBeforeRequestWrappingAndActionService() throws Exception {
-        try {
-            MockServletContext servletContext = new MockServletContext();
-            MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
-            MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
-            MockHttpServletResponse res = new MockHttpServletResponse();
-            MockFilterChain chain = new MockFilterChain();
-            final InnerDispatcher _dispatcher = new InnerDispatcher(servletContext);
-            Dispatcher.setInstance(null);
-
-            ConfigurationManager confManager = new ConfigurationManager();
-            confManager.setConfiguration(new DefaultConfiguration());
-            _dispatcher.setConfigurationManager(confManager);
-
-
-            ObjectFactory.setObjectFactory(new InnerObjectFactory());
-
-            Map settings = new HashMap();
-            settings.put(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-16_DUMMY");
-            settings.put(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterDispatcherTest$InnerActionMapper");
-            Settings.setInstance(new InnerConfiguration(settings));
-
-            FilterDispatcher filter = new FilterDispatcher() {
-                protected Dispatcher createDispatcher() {
-                    return _dispatcher;
-                }
-            };
-            filter.init(filterConfig);
-            filter.doFilter(req, res, chain);
-
-            assertTrue(_dispatcher.wrappedRequest);
-            assertTrue(_dispatcher.serviceRequest);
-        }
-        finally {
-            Settings.reset();
-        }
+        assertTrue(_dispatcher.wrappedRequest);
+        assertTrue(_dispatcher.serviceRequest);
     }
 
 
@@ -219,9 +161,10 @@
         protected boolean serviceRequest = false;
 
         public NoOpDispatcher(ServletContext servletContext) {
-            super(servletContext);
+            super(servletContext, new HashMap());
         }
 
+        @Override
         public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
             wrappedRequest = true;
             return request;
@@ -238,9 +181,10 @@
         protected boolean serviceRequest = false;
 
         public InnerDispatcher(ServletContext servletContext) {
-            super(servletContext);
+            super(servletContext, new HashMap());
         }
 
+        @Override
         public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
             wrappedRequest = true;
             // if we set the chracter encoding AFTER we do wrap request, we will get
@@ -282,28 +226,6 @@
     }
 
 
-    public static class InnerConfiguration extends Settings {
-        Map<String,String> m;
-
-        public InnerConfiguration(Map configMap) {
-            m = configMap;
-        }
-
-        public boolean isSetImpl(String name) {
-            if (!m.containsKey(name))
-                return super.isSetImpl(name);
-            else
-                return true;
-        }
-
-        public String getImpl(String aName) throws IllegalArgumentException {
-            if (!m.containsKey(aName))
-                return super.getImpl(aName);
-            else
-                return m.get(aName);
-        }
-    }
-
     public static class InnerDestroyableObjectFactory extends ObjectFactory implements ObjectFactoryDestroyable {
         public boolean destroyed = false;
 
@@ -311,27 +233,5 @@
             destroyed = true;
         }
     }
-
-    public static class InnerInitializableObjectFactory extends ObjectFactory implements ObjectFactoryInitializable {
-        public boolean initializable = false;
-
-        public void init(ServletContext servletContext) {
-            initializable = true;
-        }
-    }
-
-    public static class InnerInitailizableDestroyableObjectFactory extends ObjectFactory implements ObjectFactoryLifecycle {
-        public boolean initializable = false;
-        public boolean destroyable = false;
-
-        public void init(ServletContext servletContext) {
-            initializable = true;
-        }
-
-        public void destroy() {
-            destroyable = true;
-        }
-    }
-
 
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterTest.java Mon Nov 13 00:30:40 2006
@@ -21,7 +21,9 @@
 package org.apache.struts2.dispatcher;
 
 import java.io.IOException;
+import java.util.HashMap;
 
+import javax.servlet.FilterConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
@@ -32,7 +34,6 @@
 import junit.framework.TestCase;
 
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.mapper.ActionMapper;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 import org.springframework.mock.web.MockFilterConfig;
@@ -115,22 +116,11 @@
         };
 
 
-        cleanUp = new ActionContextCleanUp() {
-            @Override
-            protected Dispatcher createDispatcher() {
-                cleanUpFilterCreateDispatcherCount++;
-                return _dispatcher1;
-            }
-
-            @Override
-            public String toString() {
-                return "cleanUp";
-            }
-        };
+        cleanUp = new ActionContextCleanUp();
 
         filterDispatcher = new FilterDispatcher() {
             @Override
-            protected Dispatcher createDispatcher() {
+            protected Dispatcher createDispatcher(FilterConfig filterConfig) {
                 filterDispatcherCreateDispatcherCount++;
                 return _dispatcher2;
             }
@@ -147,7 +137,7 @@
         ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
         try {
             ObjectFactory.setObjectFactory(new InnerObjectFactory());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
+            filterDispatcher.setActionMapper(new FilterTest.InnerMapper());
 
             assertEquals(cleanUpFilterCreateDispatcherCount, 0);
             assertEquals(filterDispatcherCreateDispatcherCount, 0);
@@ -182,7 +172,7 @@
         ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
         try {
             ObjectFactory.setObjectFactory(new InnerObjectFactory());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
+            filterDispatcher.setActionMapper(new FilterTest.InnerMapper());
 
             assertEquals(cleanUpFilterCreateDispatcherCount, 0);
             assertEquals(filterDispatcherCreateDispatcherCount, 0);
@@ -214,11 +204,11 @@
         }
     }
 
-    public void testUsingCleanUpAndFilterDispatcher() throws Exception {
+    /*public void testUsingCleanUpAndFilterDispatcher() throws Exception {
         ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
         try {
             ObjectFactory.setObjectFactory(new InnerObjectFactory());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
+            filterDispatcher.setActionMapper(new FilterTest.InnerMapper());
 
             assertEquals(cleanUpFilterCreateDispatcherCount, 0);
             assertEquals(filterDispatcherCreateDispatcherCount, 0);
@@ -235,8 +225,8 @@
             filterDispatcher.destroy();
             cleanUp.destroy();
 
-            assertEquals(cleanUpFilterCreateDispatcherCount, 1);
-            assertEquals(filterDispatcherCreateDispatcherCount, 1);
+            assertEquals(1, cleanUpFilterCreateDispatcherCount);
+            assertEquals(1, filterDispatcherCreateDispatcherCount);
             assertTrue(_dispatcher1.prepare);
             assertTrue(_dispatcher1.wrapRequest);
             assertTrue(_dispatcher1.service);
@@ -255,7 +245,7 @@
         ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
         try {
             ObjectFactory.setObjectFactory(new InnerObjectFactory());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
+            filterDispatcher.setActionMapper(new FilterTest.InnerMapper());
 
             assertEquals(cleanUpFilterCreateDispatcherCount, 0);
             assertEquals(filterDispatcherCreateDispatcherCount, 0);
@@ -287,6 +277,7 @@
             ObjectFactory.setObjectFactory(oldObjecFactory);
         }
     }
+    */
 
 
     class InnerDispatcher extends Dispatcher {
@@ -295,7 +286,7 @@
         public boolean service = false;
 
         public InnerDispatcher(ServletContext servletContext) {
-            super(servletContext);
+            super(servletContext, new HashMap());
         }
 
         @Override

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletActionRedirectResultTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletActionRedirectResultTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletActionRedirectResultTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletActionRedirectResultTest.java Mon Nov 13 00:30:40 2006
@@ -25,6 +25,7 @@
 
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsTestCase;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
 import org.springframework.mock.web.MockHttpServletRequest;
@@ -99,7 +100,7 @@
         control.anyTimes();
 
         control.replay();
-
+        result.setActionMapper(container.getInstance(ActionMapper.class));
         result.execute(mockInvocation);
         assertEquals("/myNamespace/myAction.action?param2=value+2&param1=value+1&param3=value+3", res.getRedirectedUrl());
 
@@ -153,7 +154,7 @@
         control.andReturn(context);
 
         control.replay();
-
+        result.setActionMapper(container.getInstance(ActionMapper.class));
         result.execute(mockInvocation);
         assertEquals("/myNamespace/myAction.action?param2=value+2&param1=value+1&param3=value+3", res.getRedirectedUrl());
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java Mon Nov 13 00:30:40 2006
@@ -100,16 +100,12 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        Dispatcher du = new Dispatcher(new MockServletContext());
-        Dispatcher.setInstance(du);
-        ConfigurationManager cm = new ConfigurationManager();
-        cm.addConfigurationProvider(new StrutsXmlConfigurationProvider("struts.xml", false));
-        du.setConfigurationManager(cm);
-        du.getConfigurationManager().getConfiguration().
+        configurationManager.getConfiguration().
             addPackageConfig("foo", new PackageConfig("foo", "/namespace", false, null));
 
 
         view = new ServletRedirectResult();
+        container.inject(view);
 
         responseMock = new Mock(HttpServletResponse.class);
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapperTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapperTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapperTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/CompositeActionMapperTest.java Mon Nov 13 00:30:40 2006
@@ -28,11 +28,13 @@
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
-import org.apache.struts2.dispatcher.mapper.CompositeActionMapper.IndividualActionMapperEntry;
 import org.springframework.mock.web.MockHttpServletRequest;
 
+import com.mockobjects.dynamic.C;
+import com.mockobjects.dynamic.Mock;
 import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.Scope.Strategy;
 
 import junit.framework.TestCase;
 
@@ -42,253 +44,49 @@
  */
 public class CompositeActionMapperTest extends TestCase {
 
-    /**
-     * Test with empty settings (settings with no entries of interest)
-     *
-     * @throws Exception
-     */
-    public void testGetOrderActionMapperEntries1() throws Exception {
-        CompositeActionMapper compositeActionMapper = new CompositeActionMapper();
-        List<IndividualActionMapperEntry> result =
-            compositeActionMapper.getOrderedActionMapperEntries();
-
-        assertEquals(result.size(), 0);
-    }
-
-    /**
-     * Test with a normal settings.
-     *
-     * @throws Exception
-     */
-    public void testGetOrderActionMapperEntries2() throws Exception {
-        CompositeActionMapper compositeActionMapper = new CompositeActionMapper();
-
-        Settings old = Settings.getInstance();
-        try {
-            Settings.setInstance(new InnerSettings());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1", InnerActionMapper1.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"2", InnerActionMapper2.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"3", InnerActionMapper3.class.getName());
-
-            List<IndividualActionMapperEntry> result =
-                compositeActionMapper.getOrderedActionMapperEntries();
-
-            assertEquals(result.size(), 3);
-
-            IndividualActionMapperEntry e = null;
-            Iterator<IndividualActionMapperEntry> i = result.iterator();
-
-            // 1
-            e = i.next();
-
-            assertEquals(e.order, new Integer(1));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1");
-            assertEquals(e.propertyValue, InnerActionMapper1.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper1.class);
-
-            // 2
-            e = i.next();
-
-            assertEquals(e.order, new Integer(2));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"2");
-            assertEquals(e.propertyValue, InnerActionMapper2.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper2.class);
-
-            // 3
-            e = i.next();
-            assertEquals(e.order, new Integer(3));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"3");
-            assertEquals(e.propertyValue, InnerActionMapper3.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper3.class);
-        }
-        finally {
-            Settings.setInstance(old);
-        }
-    }
-
-    /**
-     * Test with settings where entries are out-of-order, it needs to be able to retrieve them
-     * back in proper order.
-     *
-     * @throws Exception
-     */
-    public void testGetOrderActionMapperEntries3() throws Exception {
-        CompositeActionMapper compositeActionMapper = new CompositeActionMapper();
-
-        Settings old = Settings.getInstance();
-        try {
-            Settings.setInstance(new InnerSettings());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"3", InnerActionMapper3.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"2", InnerActionMapper2.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1", InnerActionMapper1.class.getName());
-
-            List<IndividualActionMapperEntry> result =
-                compositeActionMapper.getOrderedActionMapperEntries();
-
-            assertEquals(result.size(), 3);
-
-            IndividualActionMapperEntry e = null;
-            Iterator<IndividualActionMapperEntry> i = result.iterator();
-
-            // 1
-            e = i.next();
-
-            assertEquals(e.order, new Integer(1));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1");
-            assertEquals(e.propertyValue, InnerActionMapper1.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper1.class);
-
-            // 2
-            e = i.next();
-
-            assertEquals(e.order, new Integer(2));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"2");
-            assertEquals(e.propertyValue, InnerActionMapper2.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper2.class);
-
-            // 3
-            e = i.next();
-            assertEquals(e.order, new Integer(3));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"3");
-            assertEquals(e.propertyValue, InnerActionMapper3.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper3.class);
-        }
-        finally {
-            Settings.setInstance(old);
-        }
+    CompositeActionMapper compositeActionMapper;
+    Mock mockContainer;
+    
+    public void setUp() throws Exception {
+        compositeActionMapper = new CompositeActionMapper();
+        mockContainer = new Mock(Container.class);
+        compositeActionMapper.setContainer((Container)mockContainer.proxy());
     }
-
-    /**
-     * Test with a bad entry
-     *
-     * @throws Exception
-     */
-    public void testGetOrderActionMapperEntries4() throws Exception {
-        CompositeActionMapper compositeActionMapper = new CompositeActionMapper();
-
-        Settings old = Settings.getInstance();
-        try {
-            Settings.setInstance(new InnerSettings());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1", InnerActionMapper1.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"NotANumber", InnerActionMapper2.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"3", InnerActionMapper3.class.getName());
-
-            List<IndividualActionMapperEntry> result =
-                compositeActionMapper.getOrderedActionMapperEntries();
-
-            assertEquals(result.size(), 2);
-
-            IndividualActionMapperEntry e = null;
-            Iterator<IndividualActionMapperEntry> i = result.iterator();
-
-            // 1
-            e = i.next();
-
-            assertEquals(e.order, new Integer(1));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1");
-            assertEquals(e.propertyValue, InnerActionMapper1.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper1.class);
-
-            // 2
-            e = i.next();
-            assertEquals(e.order, new Integer(3));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"3");
-            assertEquals(e.propertyValue, InnerActionMapper3.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper3.class);
-        }
-        finally {
-            Settings.setInstance(old);
-        }
-    }
-
-    /**
-     * Test with an entry where the action mapper class is bogus.
-     * @throws Exception
-     */
-    public void testGetOrderActionMapperEntries5() throws Exception {
-        CompositeActionMapper compositeActionMapper = new CompositeActionMapper();
-
-        Settings old = Settings.getInstance();
-        try {
-            Settings.setInstance(new InnerSettings());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1", InnerActionMapper1.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"2", "bogus.class.name");
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"3", InnerActionMapper3.class.getName());
-
-            List<IndividualActionMapperEntry> result =
-                compositeActionMapper.getOrderedActionMapperEntries();
-
-            assertEquals(result.size(), 2);
-
-            IndividualActionMapperEntry e = null;
-            Iterator<IndividualActionMapperEntry> i = result.iterator();
-
-            // 1
-            e = i.next();
-
-            assertEquals(e.order, new Integer(1));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1");
-            assertEquals(e.propertyValue, InnerActionMapper1.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper1.class);
-
-
-            // 2
-            e = i.next();
-            assertEquals(e.order, new Integer(3));
-            assertEquals(e.propertyName, StrutsConstants.STRUTS_MAPPER_COMPOSITE+"3");
-            assertEquals(e.propertyValue, InnerActionMapper3.class.getName());
-            assertEquals(e.actionMapper.getClass(), InnerActionMapper3.class);
-        }
-        finally {
-            Settings.setInstance(old);
-        }
-    }
-
-
+    
 
     public void testGetActionMappingAndUri1() throws Exception {
-        CompositeActionMapper compositeActionMapper = new CompositeActionMapper();
-
-        Settings old = Settings.getInstance();
-        try {
-            Settings.setInstance(new InnerSettings());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1", InnerActionMapper1.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"2", InnerActionMapper2.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"3", InnerActionMapper3.class.getName());
-
-
-            ActionMapping actionMapping = compositeActionMapper.getMapping(new MockHttpServletRequest(), new ConfigurationManager());
-            String uri = compositeActionMapper.getUriFromActionMapping(new ActionMapping());
-
-            assertNotNull(actionMapping);
-            assertNotNull(uri);
-            assertTrue(actionMapping == InnerActionMapper3.actionMapping);
-            assertTrue(uri == InnerActionMapper3.uri);
-        }
-        finally {
-            Settings.setInstance(old);
-        }
+        ActionMapper mapper1 = new InnerActionMapper1();
+        ActionMapper mapper2 = new InnerActionMapper2();
+        ActionMapper mapper3 = new InnerActionMapper3();
+        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper1")), mapper1);
+        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper2")), mapper3);
+        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper3")), mapper2);
+        compositeActionMapper.setActionMappers("mapper1,mapper2,mapper3");
+        
+        ActionMapping actionMapping = compositeActionMapper.getMapping(new MockHttpServletRequest(), new ConfigurationManager());
+        String uri = compositeActionMapper.getUriFromActionMapping(new ActionMapping());
+        mockContainer.verify();
+        
+        assertNotNull(actionMapping);
+        assertNotNull(uri);
+        assertTrue(actionMapping == InnerActionMapper3.actionMapping);
+        assertTrue(uri == InnerActionMapper3.uri);
+        
     }
 
     public void testGetActionMappingAndUri2() throws Exception {
-        CompositeActionMapper compositeActionMapper = new CompositeActionMapper();
-
-        Settings old = Settings.getInstance();
-        try {
-            Settings.setInstance(new InnerSettings());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"1", InnerActionMapper1.class.getName());
-            Settings.set(StrutsConstants.STRUTS_MAPPER_COMPOSITE+"2", InnerActionMapper2.class.getName());
+        ActionMapper mapper1 = new InnerActionMapper1();
+        ActionMapper mapper2 = new InnerActionMapper2();
+        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper1")), mapper1);
+        mockContainer.expectAndReturn("getInstance", C.args(C.eq(ActionMapper.class), C.eq("mapper2")), mapper2);
+        compositeActionMapper.setActionMappers("mapper1,mapper2");
+
+        ActionMapping actionMapping = compositeActionMapper.getMapping(new MockHttpServletRequest(), new ConfigurationManager());
+        String uri = compositeActionMapper.getUriFromActionMapping(new ActionMapping());
+        mockContainer.verify();
 
-
-            ActionMapping actionMapping = compositeActionMapper.getMapping(new MockHttpServletRequest(), new ConfigurationManager());
-            String uri = compositeActionMapper.getUriFromActionMapping(new ActionMapping());
-
-            assertNull(actionMapping);
-            assertNull(uri);
-        }
-        finally {
-            Settings.setInstance(old);
-        }
+        assertNull(actionMapping);
+        assertNull(uri);
     }
 
 
@@ -325,26 +123,4 @@
             return uri;
         }
     }
-
-    class InnerSettings extends Settings {
-        private Map<String, String> _impl = new LinkedHashMap<String, String>();
-
-        @Override
-        public boolean isSetImpl(String name) {
-            return _impl.containsKey(name);
-        }
-        @Override
-        public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException {
-            _impl.put(name, value);
-        }
-        @Override
-        public String getImpl(String name) throws IllegalArgumentException {
-            return (String) _impl.get(name);
-        }
-        @Override
-        public Iterator listImpl() {
-            return _impl.keySet().iterator();
-        }
-    }
-
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java Mon Nov 13 00:30:40 2006
@@ -25,7 +25,6 @@
 
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsTestCase;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.dispatcher.ServletRedirectResult;
 import org.apache.struts2.views.jsp.StrutsMockHttpServletRequest;
 
@@ -96,24 +95,18 @@
 
     public void testGetMappingWithSlashedName() throws Exception {
 
-        String old = Settings.get(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES);
-        Settings.set(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES, "true");
-        try {
-            req.setupGetRequestURI("/my/foo/actionName.action");
-            req.setupGetServletPath("/my/foo/actionName.action");
-            req.setupGetAttribute(null);
-            req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
-
-            DefaultActionMapper mapper = new DefaultActionMapper();
-            ActionMapping mapping = mapper.getMapping(req, configManager);
-
-            assertEquals("/my", mapping.getNamespace());
-            assertEquals("foo/actionName", mapping.getName());
-            assertNull(mapping.getMethod());        }
-        finally {
-            Settings.set(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES, old);
-        }
+        req.setupGetRequestURI("/my/foo/actionName.action");
+        req.setupGetServletPath("/my/foo/actionName.action");
+        req.setupGetAttribute(null);
+        req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
 
+        DefaultActionMapper mapper = new DefaultActionMapper();
+        mapper.setSlashesInActionNames("true");
+        ActionMapping mapping = mapper.getMapping(req, configManager);
+
+        assertEquals("/my", mapping.getNamespace());
+        assertEquals("foo/actionName", mapping.getName());
+        assertNull(mapping.getMethod());      
     }
 
     public void testGetMappingWithUnknownNamespace() throws Exception {
@@ -157,25 +150,19 @@
     }
 
     public void testGetMappingWithNoExtension() throws Exception {
-        String old = org.apache.struts2.config.Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION);
-        org.apache.struts2.config.Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "");
-        try {
-            req.setupGetParameterMap(new HashMap());
-            req.setupGetRequestURI("/my/namespace/actionName");
-            req.setupGetServletPath("/my/namespace/actionName");
-            req.setupGetAttribute(null);
-            req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
-
-            DefaultActionMapper mapper = new DefaultActionMapper();
-            ActionMapping mapping = mapper.getMapping(req, configManager);
-
-            assertEquals("/my/namespace", mapping.getNamespace());
-            assertEquals("actionName", mapping.getName());
-            assertNull(mapping.getMethod());
-        }
-        finally {
-            org.apache.struts2.config.Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, old);
-        }
+        req.setupGetParameterMap(new HashMap());
+        req.setupGetRequestURI("/my/namespace/actionName");
+        req.setupGetServletPath("/my/namespace/actionName");
+        req.setupGetAttribute(null);
+        req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
+
+        DefaultActionMapper mapper = new DefaultActionMapper();
+        mapper.setExtensions("");
+        ActionMapping mapping = mapper.getMapping(req, configManager);
+
+        assertEquals("/my/namespace", mapping.getNamespace());
+        assertEquals("actionName", mapping.getName());
+        assertNull(mapping.getMethod());
     }
 
     // =============================
@@ -213,37 +200,25 @@
     }
 
     public void testParseNameAndNamespace_NoSlashes() throws Exception {
-        String old = Settings.get(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES);
-        Settings.set(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES, "false");
-        try {
-            ActionMapping actionMapping = new ActionMapping();
-
-            DefaultActionMapper defaultActionMapper = new DefaultActionMapper();
-            defaultActionMapper.parseNameAndNamespace("/foo/someAction", actionMapping, config);
-
-            assertEquals(actionMapping.getName(), "someAction");
-            assertEquals(actionMapping.getNamespace(), "");
-        }
-        finally {
-            Settings.set(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES, old);
-        }
+        ActionMapping actionMapping = new ActionMapping();
+
+        DefaultActionMapper defaultActionMapper = new DefaultActionMapper();
+        defaultActionMapper.setSlashesInActionNames("false");
+        defaultActionMapper.parseNameAndNamespace("/foo/someAction", actionMapping, config);
+
+        assertEquals(actionMapping.getName(), "someAction");
+        assertEquals(actionMapping.getNamespace(), "");
     }
 
     public void testParseNameAndNamespace_AllowSlashes() throws Exception {
-        String old = Settings.get(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES);
-        Settings.set(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES, "true");
-        try {
-            ActionMapping actionMapping = new ActionMapping();
-
-            DefaultActionMapper defaultActionMapper = new DefaultActionMapper();
-            defaultActionMapper.parseNameAndNamespace("/foo/someAction", actionMapping, config);
-
-            assertEquals(actionMapping.getName(), "foo/someAction");
-            assertEquals(actionMapping.getNamespace(), "");
-        }
-        finally {
-            Settings.set(StrutsConstants.STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES, old);
-        }
+        ActionMapping actionMapping = new ActionMapping();
+
+        DefaultActionMapper defaultActionMapper = new DefaultActionMapper();
+        defaultActionMapper.setSlashesInActionNames("true");
+        defaultActionMapper.parseNameAndNamespace("/foo/someAction", actionMapping, config);
+
+        assertEquals(actionMapping.getName(), "foo/someAction");
+        assertEquals(actionMapping.getNamespace(), "");
     }
 
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java Mon Nov 13 00:30:40 2006
@@ -22,7 +22,6 @@
 
 import org.apache.struts2.StrutsTestCase;
 import org.apache.struts2.StrutsConstants;
-import org.apache.struts2.config.Settings;
 import com.mockobjects.servlet.MockHttpServletRequest;
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.Configuration;
@@ -33,6 +32,7 @@
 
 public class Restful2ActionMapperTest extends StrutsTestCase {
 
+    private Restful2ActionMapper mapper;
     private MockHttpServletRequest req;
     private ConfigurationManager configManager;
     private Configuration config;
@@ -40,7 +40,8 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "");
+        mapper = new Restful2ActionMapper();
+        mapper.setExtensions("");
         req = new MockHttpServletRequest();
         req.setupGetParameterMap(new HashMap());
         req.setupGetContextPath("/my/namespace");
@@ -56,7 +57,7 @@
             }
         };
     }
-
+    
     public void testGetIndex() throws Exception {
         req.setupGetRequestURI("/my/namespace/foo/");
         req.setupGetServletPath("/my/namespace/foo/");
@@ -64,7 +65,6 @@
         req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
         req.setupGetMethod("GET");
 
-        Restful2ActionMapper mapper = new Restful2ActionMapper();
         ActionMapping mapping = mapper.getMapping(req, configManager);
 
         assertEquals("/my/namespace", mapping.getNamespace());
@@ -79,7 +79,6 @@
         req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
         req.setupGetMethod("GET");
 
-        Restful2ActionMapper mapper = new Restful2ActionMapper();
         ActionMapping mapping = mapper.getMapping(req, configManager);
 
         assertEquals("/my/namespace", mapping.getNamespace());
@@ -96,7 +95,6 @@
         req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
         req.setupGetMethod("POST");
 
-        Restful2ActionMapper mapper = new Restful2ActionMapper();
         ActionMapping mapping = mapper.getMapping(req, configManager);
 
         assertEquals("/my/namespace", mapping.getNamespace());

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java Mon Nov 13 00:30:40 2006
@@ -24,6 +24,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import javax.servlet.http.HttpSession;
 
@@ -36,13 +37,17 @@
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.ActionProxyFactory;
+import com.opensymphony.xwork2.DefaultActionProxyFactory;
+import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationException;
+import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.config.entities.PackageConfig;
 import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
 import com.opensymphony.xwork2.mock.MockResult;
 
@@ -164,14 +169,15 @@
     }
 
     protected ActionProxy buildProxy(String actionName) throws Exception {
-        return ActionProxyFactory.getFactory().createActionProxy(
+        return container.getInstance(ActionProxyFactory.class).createActionProxy(
                 configurationManager.getConfiguration(), "", actionName, context);
     }
 
     protected void setUp() throws Exception {
-        configurationManager.clearConfigurationProviders();
+        configurationManager = new ConfigurationManager();
         configurationManager.addConfigurationProvider(new WaitConfigurationProvider());
         configurationManager.reload();
+        container = configurationManager.getConfiguration().getContainer();
 
         session = new HashMap();
         params = new HashMap();
@@ -194,6 +200,7 @@
 
     private class WaitConfigurationProvider implements ConfigurationProvider {
 
+        Configuration configuration;
         public void destroy() {
             waitInterceptor.destroy();
         }
@@ -201,8 +208,12 @@
         public boolean needsReload() {
             return false;
         }
-
+        
         public void init(Configuration configuration) throws ConfigurationException {
+            this.configuration = configuration;
+        }
+
+        public void loadPackages() throws ConfigurationException {
             PackageConfig wait = new PackageConfig("");
 
             Map results = new HashMap();
@@ -219,6 +230,11 @@
             wait.addActionConfig("action1", ac);
 
             configuration.addPackageConfig("", wait);
+        }
+
+        public void register(ContainerBuilder builder, Properties props) throws ConfigurationException {
+            builder.factory(ObjectFactory.class);
+            builder.factory(ActionProxyFactory.class, DefaultActionProxyFactory.class);
         }
 
     }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java Mon Nov 13 00:30:40 2006
@@ -33,6 +33,8 @@
 
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsTestCase;
+import org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest;
+import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
 import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
 import org.springframework.mock.web.MockHttpServletRequest;
 
@@ -226,7 +228,7 @@
     }
 
     private MultiPartRequestWrapper createMultipartRequest(HttpServletRequest req, int maxsize) throws IOException {
-       return new MultiPartRequestWrapper(req, tempDir.getAbsolutePath(), maxsize);
+       return new MultiPartRequestWrapper(new JakartaMultiPartRequest(), req, tempDir.getAbsolutePath());
     }
 
     protected void setUp() throws Exception {

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java Mon Nov 13 00:30:40 2006
@@ -37,6 +37,7 @@
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.ActionProxyFactory;
+import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 
@@ -106,9 +107,10 @@
     }
 
     protected void setUp() throws Exception {
-        configurationManager.clearConfigurationProviders();
+        configurationManager = new ConfigurationManager();
         configurationManager.addConfigurationProvider(new TestConfigurationProvider());
         configurationManager.reload();
+        container = configurationManager.getConfiguration().getContainer();
 
         session = new HashMap();
         params = new HashMap();
@@ -129,7 +131,7 @@
     }
 
     protected ActionProxy buildProxy(String actionName) throws Exception {
-        return ActionProxyFactory.getFactory().createActionProxy(
+        return container.getInstance(ActionProxyFactory.class).createActionProxy(
                 configurationManager.getConfiguration(), "", actionName, extraContext, true, true);
     }
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java Mon Nov 13 00:30:40 2006
@@ -85,6 +85,8 @@
         mockConfig.stubs().method("getPortletContext").will(returnValue(mockCtx.proxy()));
         mockCtx.stubs().method("getInitParameterNames").will(returnValue(Collections.enumeration(initParams.keySet())));
         setupStub(initParams, mockCtx, "getInitParameter");
+        mockConfig.stubs().method("getInitParameterNames").will(returnValue(Collections.enumeration(initParams.keySet())));
+        setupStub(initParams, mockConfig, "getInitParameter");
 
         mockConfig.stubs().method("getResourceBundle").will(returnValue(new ListResourceBundle() {
             protected Object[][] getContents() {

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java Mon Nov 13 00:30:40 2006
@@ -24,7 +24,6 @@
 
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsTestCase;
-import org.apache.struts2.config.Settings;
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.mock.web.MockServletContext;
 import org.springframework.web.context.ConfigurableWebApplicationContext;
@@ -41,7 +40,7 @@
         // to cover situations where there will be logged an error
         StrutsSpringObjectFactory fac = new StrutsSpringObjectFactory();
         ServletContext msc = (ServletContext) new MockServletContext();
-        fac.init(msc);
+        fac.setServletContext(msc);
 
         assertEquals(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, fac.getAutowireStrategy());
     }
@@ -50,7 +49,7 @@
         StrutsSpringObjectFactory fac = new StrutsSpringObjectFactory();
 
         // autowire by constructure, we try a non default setting in this unit test
-        Settings.set(StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE, "constructor");
+        fac.setAutoWire("constructor");
 
         ConfigurableWebApplicationContext ac = new XmlWebApplicationContext();
         ServletContext msc = (ServletContext) new MockServletContext();
@@ -59,7 +58,7 @@
         ac.setConfigLocations(new String[] {"org/apache/struts2/spring/StrutsSpringObjectFactoryTest-applicationContext.xml"});
         ac.refresh();
 
-        fac.init(msc);
+        fac.setServletContext(msc);
 
         assertEquals(AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, fac.getAutowireStrategy());
     }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java Mon Nov 13 00:30:40 2006
@@ -28,50 +28,59 @@
 import org.apache.struts2.components.template.TemplateEngine;
 import org.apache.struts2.components.template.TemplateEngineManager;
 import org.apache.struts2.components.template.VelocityTemplateEngine;
-import org.apache.struts2.config.Settings;
+import org.apache.struts2.dispatcher.mapper.CompositeActionMapper;
+
+import com.mockobjects.dynamic.C;
+import com.mockobjects.dynamic.Mock;
+import com.opensymphony.xwork2.inject.Container;
 
 /**
  * TemplateEngineManagerTest
  *
  */
 public class TemplateEngineManagerTest extends TestCase {
+    
+    TemplateEngineManager mgr;
+    Mock mockContainer;
+    
+    public void setUp() throws Exception {
+        mgr = new TemplateEngineManager();
+        mockContainer = new Mock(Container.class);
+        mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("jsp")), new JspTemplateEngine());
+        mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("vm")), new VelocityTemplateEngine());
+        mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("ftl")), new FreemarkerTemplateEngine());
+        
+        mgr.setContainer((Container)mockContainer.proxy());
+        mgr.setTemplateEngines("jsp,vm,ftl");
+        mgr.setDefaultTemplateType("jsp");
+    }
+    
     public void testTemplateTypeFromTemplateNameAndDefaults() {
-        Settings.setInstance(new Settings() {
-            public boolean isSetImpl(String name) {
-                return name.equals(TemplateEngineManager.DEFAULT_TEMPLATE_TYPE_CONFIG_KEY);
-            }
-
-            public String getImpl(String aName) throws IllegalArgumentException {
-                if (aName.equals(TemplateEngineManager.DEFAULT_TEMPLATE_TYPE_CONFIG_KEY)) {
-                    return "jsp";
-                }
-                return null;
-            }
-        });
-        TemplateEngine engine = TemplateEngineManager.getTemplateEngine(new Template("/template", "simple", "foo"), null);
+        
+        TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), null);
         assertTrue(engine instanceof JspTemplateEngine);
-        engine = TemplateEngineManager.getTemplateEngine(new Template("/template", "simple", "foo.vm"), null);
+        engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.vm"), null);
         assertTrue(engine instanceof VelocityTemplateEngine);
     }
 
     public void testTemplateTypeOverrides() {
-        TemplateEngine engine = TemplateEngineManager.getTemplateEngine(new Template("/template", "simple", "foo"), "ftl");
+        TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), "ftl");
         assertTrue(engine instanceof FreemarkerTemplateEngine);
-        engine = TemplateEngineManager.getTemplateEngine(new Template("/template", "simple", "foo.vm"), "ftl");
+        engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.vm"), "ftl");
         assertTrue(engine instanceof VelocityTemplateEngine);
-        engine = TemplateEngineManager.getTemplateEngine(new Template("/template", "simple", "foo.ftl"), "");
+        engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.ftl"), "");
         assertTrue(engine instanceof FreemarkerTemplateEngine);
     }
 
     public void testTemplateTypeUsesDefaultWhenNotSetInConfiguration() {
-        TemplateEngine engine = TemplateEngineManager.getTemplateEngine(new Template("/template", "simple", "foo"), null);
+        mgr.setDefaultTemplateType(null);
+        TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), null);
         Template template = new Template("/template", "simple", "foo." + TemplateEngineManager.DEFAULT_TEMPLATE_TYPE);
-        TemplateEngine defaultTemplateEngine = TemplateEngineManager.getTemplateEngine(template, null);
+        TemplateEngine defaultTemplateEngine = mgr.getTemplateEngine(template, null);
         assertTrue(engine.getClass().equals(defaultTemplateEngine.getClass()));
     }
 
     protected void tearDown() throws Exception {
         super.tearDown();
-        Settings.setInstance(null);
     }
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java?view=diff&rev=474191&r1=474190&r2=474191
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java Mon Nov 13 00:30:40 2006
@@ -22,7 +22,6 @@
 
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsTestCase;
-import org.apache.struts2.config.Settings;
 import org.apache.struts2.views.jsp.StrutsMockServletContext;
 
 /**
@@ -32,10 +31,11 @@
 public class FreemarkerManagerTest extends StrutsTestCase {
 
     public void testIfStrutsEncodingIsSetProperty() throws Exception {
-        Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8");
+        FreemarkerManager mgr = new FreemarkerManager();
+        mgr.setEncoding("UTF-8");
         StrutsMockServletContext servletContext = new StrutsMockServletContext();
         servletContext.setAttribute(FreemarkerManager.CONFIG_SERVLET_CONTEXT_KEY, null);
-        freemarker.template.Configuration conf = FreemarkerManager.getInstance().getConfiguration(servletContext);
+        freemarker.template.Configuration conf = mgr.getConfiguration(servletContext);
         assertEquals(conf.getDefaultEncoding(), "UTF-8");
     }
 }



Mime
View raw message