You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by jc...@apache.org on 2006/05/23 22:26:46 UTC
svn commit: r409001 [1/2] - in /struts/action2/trunk:
apps/showcase/src/main/java/org/apache/struts/action2/showcase/action/
core/src/main/java/org/apache/struts/action2/components/
core/src/main/java/org/apache/struts/action2/config_browser/ core/src/...
Author: jcarreira
Date: Tue May 23 13:26:45 2006
New Revision: 409001
URL: http://svn.apache.org/viewvc?rev=409001&view=rev
Log:
Moved static instance out of ConfigurationManager into new XWorkStatic and started doing 1.5 updates with generics and enhanced for-loops.
Modified:
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/action/EmployeeAction.java
struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Form.java
struts/action2/trunk/core/src/main/java/org/apache/struts/action2/config_browser/ConfigurationHelper.java
struts/action2/trunk/core/src/main/java/org/apache/struts/action2/sitegraph/XWorkConfigRetriever.java
struts/action2/trunk/core/src/main/java/org/apache/struts/action2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java
struts/action2/trunk/core/src/main/java/org/apache/struts/action2/util/ResolverSetupServletContextListener.java
struts/action2/trunk/core/src/test/java/org/apache/struts/action2/components/UIComponentTest.java
struts/action2/trunk/core/src/test/java/org/apache/struts/action2/dispatcher/AbstractServletDispatcherTestCase.java
struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/ExecuteAndWaitInterceptorTest.java
struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/TokenInterceptorTest.java
struts/action2/trunk/core/src/test/java/org/apache/struts/action2/views/jsp/ActionTagTest.java
struts/action2/trunk/core/src/test/java/org/apache/struts/action2/views/jsp/ui/FormTagTest.java
struts/action2/trunk/core/src/test/java/org/apache/struts/action2/views/jsp/ui/TooltipTest.java
Modified: struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/action/EmployeeAction.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/action/EmployeeAction.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/action/EmployeeAction.java (original)
+++ struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/action/EmployeeAction.java Tue May 23 13:26:45 2006
@@ -17,29 +17,28 @@
*/
package org.apache.struts.action2.showcase.action;
+import com.opensymphony.xwork.Preparable;
+import org.apache.log4j.Logger;
+import org.apache.struts.action2.showcase.application.TestDataProvider;
import org.apache.struts.action2.showcase.dao.Dao;
import org.apache.struts.action2.showcase.dao.EmployeeDao;
import org.apache.struts.action2.showcase.model.Employee;
import org.apache.struts.action2.showcase.model.Skill;
-import org.apache.struts.action2.showcase.application.TestDataProvider;
-import com.opensymphony.xwork.Preparable;
-import org.apache.log4j.Logger;
-import java.util.List;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
-import java.util.ArrayList;
+import java.util.List;
/**
* EmployeeAction.
- *
*/
public class EmployeeAction extends AbstractCRUDAction implements Preparable {
- private static final long serialVersionUID = 7047317819789938957L;
+ private static final long serialVersionUID = 7047317819789938957L;
- private static final Logger log = Logger.getLogger(EmployeeAction.class);
+ private static final Logger log = Logger.getLogger(EmployeeAction.class);
private Long empId;
protected EmployeeDao employeeDao;
@@ -102,7 +101,7 @@
}
public String execute() throws Exception {
- if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills()!=null) {
+ if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) {
setSelectedSkills(new ArrayList());
Iterator it = getCurrentEmployee().getOtherSkills().iterator();
while (it.hasNext()) {
Modified: struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Form.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Form.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Form.java (original)
+++ struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/Form.java Tue May 23 13:26:45 2006
@@ -17,80 +17,73 @@
*/
package org.apache.struts.action2.components;
-import org.apache.struts.action2.dispatcher.mapper.ActionMapperFactory;
-import org.apache.struts.action2.dispatcher.mapper.ActionMapping;
-import org.apache.struts.action2.dispatcher.DispatcherUtils;
-import org.apache.struts.action2.portlet.context.PortletActionContext;
-import org.apache.struts.action2.portlet.util.PortletUrlHelper;
-import org.apache.struts.action2.views.util.UrlHelper;
-import com.opensymphony.xwork.config.ConfigurationManager;
+import com.opensymphony.xwork.ActionContext;
+import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.ObjectFactory;
+import com.opensymphony.xwork.XWorkStatic;
import com.opensymphony.xwork.config.RuntimeConfiguration;
import com.opensymphony.xwork.config.entities.ActionConfig;
import com.opensymphony.xwork.config.entities.InterceptorMapping;
+import com.opensymphony.xwork.interceptor.MethodFilterInterceptorUtil;
import com.opensymphony.xwork.util.OgnlValueStack;
-import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.ObjectFactory;
+import com.opensymphony.xwork.validator.ActionValidatorManagerFactory;
+import com.opensymphony.xwork.validator.FieldValidator;
import com.opensymphony.xwork.validator.ValidationInterceptor;
import com.opensymphony.xwork.validator.Validator;
-import com.opensymphony.xwork.validator.FieldValidator;
-import com.opensymphony.xwork.validator.ActionValidatorManagerFactory;
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts.action2.dispatcher.DispatcherUtils;
+import org.apache.struts.action2.dispatcher.mapper.ActionMapperFactory;
+import org.apache.struts.action2.dispatcher.mapper.ActionMapping;
+import org.apache.struts.action2.portlet.context.PortletActionContext;
+import org.apache.struts.action2.portlet.util.PortletUrlHelper;
+import org.apache.struts.action2.views.util.UrlHelper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.lang.StringUtils;
-
-import com.opensymphony.xwork.interceptor.MethodFilterInterceptorUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Collections;
-import java.util.Iterator;
+import java.util.*;
import java.util.Set;
/**
* <!-- START SNIPPET: javadoc -->
- *
+ * <p/>
* Renders HTML an input form.<p/>
- *
+ * <p/>
* The remote form allows the form to be submitted without the page being refreshed. The results from the form
* can be inserted into any HTML element on the page.<p/>
- *
+ * <p/>
* NOTE:<p/>
* The order / logic in determining the posting url of the generated HTML form is as follows:-
* <ol>
- * <li>
- * If the action attribute is not specified, then the current request will be used to
- * determine the posting url
- * </li>
- * <li>
- * If the action is given, SAF will try to obtain an ActionConfig. This will be
- * successfull if the action attribute is a valid action alias defined xwork.xml.
- * </li>
- * <li>
- * If the action is given and is not an action alias defined in xwork.xmlm SAF
- * will used the action attribute as if it is the posting url, separting the namespace
- * from it and using UrlHelper to generate the final url.
- * </li>
+ * <li>
+ * If the action attribute is not specified, then the current request will be used to
+ * determine the posting url
+ * </li>
+ * <li>
+ * If the action is given, SAF will try to obtain an ActionConfig. This will be
+ * successfull if the action attribute is a valid action alias defined xwork.xml.
+ * </li>
+ * <li>
+ * If the action is given and is not an action alias defined in xwork.xmlm SAF
+ * will used the action attribute as if it is the posting url, separting the namespace
+ * from it and using UrlHelper to generate the final url.
+ * </li>
* </ol>
- *
+ * <p/>
* <!-- END SNIPPET: javadoc -->
- *
+ * <p/>
* <p/> <b>Examples</b>
- *
+ * <p/>
* <pre>
* <!-- START SNIPPET: example -->
- *
+ * <p/>
* <a:form ... />
- *
+ * <p/>
* <!-- END SNIPPET: example -->
* </pre>
*
- *
* @a2.tag name="form" tld-body-content="JSP" tld-tag-class="org.apache.struts.action2.views.jsp.ui.FormTag"
* description="Renders an input form"
- */
+ */
public class Form extends ClosingUIBean {
public static final String OPEN_TEMPLATE = "form";
public static final String TEMPLATE = "form-close";
@@ -135,7 +128,7 @@
if (validate != null) {
addParameter("validate", findValue(validate, Boolean.class));
}
-
+
// calculate the action and namespace
String action = null;
if (this.action != null) {
@@ -197,15 +190,15 @@
action = uri.substring(uri.lastIndexOf('/'));
}
}
-
+
String actionMethod = "";
if (action.indexOf("!") != -1) {
- int endIdx = action.lastIndexOf("!");
- actionMethod = action.substring(endIdx+1, action.length());
- action = action.substring(0, endIdx);
+ int endIdx = action.lastIndexOf("!");
+ actionMethod = action.substring(endIdx + 1, action.length());
+ action = action.substring(0, endIdx);
}
- final ActionConfig actionConfig = ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfig(namespace, action);
+ final ActionConfig actionConfig = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfig(namespace, action);
String actionName = action;
if (actionConfig != null) {
@@ -235,10 +228,10 @@
addParameter("id", action);
}
} else if (action != null) {
- // Since we can't find an action alias in the configuration, we just assume
- // the action attribute supplied is the path to be used as the uri this
- // form is submitting to.
-
+ // Since we can't find an action alias in the configuration, we just assume
+ // the action attribute supplied is the path to be used as the uri this
+ // form is submitting to.
+
String result = UrlHelper.buildUrl(action, request, response, null);
addParameter("action", result);
@@ -262,46 +255,47 @@
addParameter("id", escape(id));
}
}
-
+
// WW-1284
// evaluate if client-side js is to be enabled. (if validation interceptor
// does allow validation eg. method is not filtered out)
evaluateClientSideJsEnablement(actionName, namespace, actionMethod);
}
-
+
private void evaluateClientSideJsEnablement(String actionName, String namespace, String actionMethod) {
-
- // Only evaluate if Client-Side js is to be enable when validate=true
- Boolean validate = (Boolean) getParameters().get("validate");
- if (validate != null && validate.booleanValue()) {
-
- addParameter("performValidation", Boolean.FALSE);
-
- RuntimeConfiguration runtimeConfiguration = ConfigurationManager.getConfiguration().getRuntimeConfiguration();
- ActionConfig actionConfig = runtimeConfiguration.getActionConfig(namespace, actionName);
-
- if (actionConfig != null) {
- List interceptors = actionConfig.getInterceptors();
- for (Iterator i = interceptors.iterator(); i.hasNext(); ) {
- InterceptorMapping interceptorMapping = (InterceptorMapping) i.next();
- if (ValidationInterceptor.class.isInstance(interceptorMapping.getInterceptor())) {
- ValidationInterceptor validationInterceptor = (ValidationInterceptor) interceptorMapping.getInterceptor();
-
- Set excludeMethods = validationInterceptor.getExcludeMethodsSet();
- Set includeMethods = validationInterceptor.getIncludeMethodsSet();
-
- if (MethodFilterInterceptorUtil.applyMethod(excludeMethods, includeMethods, actionMethod)) {
- addParameter("performValidation", Boolean.TRUE);
- }
- return;
- }
- }
- }
- }
+
+ // Only evaluate if Client-Side js is to be enable when validate=true
+ Boolean validate = (Boolean) getParameters().get("validate");
+ if (validate != null && validate.booleanValue()) {
+
+ addParameter("performValidation", Boolean.FALSE);
+
+ RuntimeConfiguration runtimeConfiguration = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration();
+ ActionConfig actionConfig = runtimeConfiguration.getActionConfig(namespace, actionName);
+
+ if (actionConfig != null) {
+ List interceptors = actionConfig.getInterceptors();
+ for (Iterator i = interceptors.iterator(); i.hasNext();) {
+ InterceptorMapping interceptorMapping = (InterceptorMapping) i.next();
+ if (ValidationInterceptor.class.isInstance(interceptorMapping.getInterceptor())) {
+ ValidationInterceptor validationInterceptor = (ValidationInterceptor) interceptorMapping.getInterceptor();
+
+ Set excludeMethods = validationInterceptor.getExcludeMethodsSet();
+ Set includeMethods = validationInterceptor.getIncludeMethodsSet();
+
+ if (MethodFilterInterceptorUtil.applyMethod(excludeMethods, includeMethods, actionMethod)) {
+ addParameter("performValidation", Boolean.TRUE);
+ }
+ return;
+ }
+ }
+ }
+ }
}
/**
* Constructs the action url adapted to a portal environment.
+ *
* @param action The action to create the URL for.
*/
private void evaluateExtraParamsPortletRequest(String namespace, String action) {
@@ -359,7 +353,7 @@
if (validator instanceof FieldValidator) {
FieldValidator fieldValidator = (FieldValidator) validator;
if (fieldValidator.getFieldName().equals(name)) {
- validators.add(fieldValidator);
+ validators.add(fieldValidator);
}
}
}
@@ -370,6 +364,7 @@
/**
* HTML onsubmit attribute
+ *
* @a2.tagattribute required="false"
*/
public void setOnsubmit(String onsubmit) {
@@ -378,6 +373,7 @@
/**
* Set action nane to submit to, without .action suffix
+ *
* @a2.tagattribute required="false" default="current action"
*/
public void setAction(String action) {
@@ -386,6 +382,7 @@
/**
* HTML form target attribute
+ *
* @a2.tagattribute required="false"
*/
public void setTarget(String target) {
@@ -394,6 +391,7 @@
/**
* HTML form enctype attribute
+ *
* @a2.tagattribute required="false"
*/
public void setEnctype(String enctype) {
@@ -402,6 +400,7 @@
/**
* HTML form method attribute
+ *
* @a2.tagattribute required="false"
*/
public void setMethod(String method) {
@@ -410,6 +409,7 @@
/**
* namespace for action to submit to
+ *
* @a2.tagattribute required="false" default="current namespace"
*/
public void setNamespace(String namespace) {
@@ -418,6 +418,7 @@
/**
* Whether client side/remote validation should be performed. Only useful with theme xhtml/ajax
+ *
* @a2.tagattribute required="false" type="Boolean" default="false"
*/
public void setValidate(String validate) {
@@ -426,6 +427,7 @@
/**
* The portlet mode to display after the form submit
+ *
* @a2.tagattribute required="false"
*/
public void setPortletMode(String portletMode) {
@@ -434,6 +436,7 @@
/**
* The window state to display after the form submit
+ *
* @a2.tagattribute required="false"
*/
public void setWindowState(String windowState) {
@@ -442,6 +445,7 @@
/**
* The accepted charsets for this form. The values may be comma or blank delimited.
+ *
* @a2.tagattribute required="false"
*/
public void setAcceptcharset(String acceptcharset) {
Modified: struts/action2/trunk/core/src/main/java/org/apache/struts/action2/config_browser/ConfigurationHelper.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/config_browser/ConfigurationHelper.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/main/java/org/apache/struts/action2/config_browser/ConfigurationHelper.java (original)
+++ struts/action2/trunk/core/src/main/java/org/apache/struts/action2/config_browser/ConfigurationHelper.java Tue May 23 13:26:45 2006
@@ -17,7 +17,7 @@
*/
package org.apache.struts.action2.config_browser;
-import com.opensymphony.xwork.config.ConfigurationManager;
+import com.opensymphony.xwork.XWorkStatic;
import com.opensymphony.xwork.config.entities.ActionConfig;
import java.util.Collections;
@@ -26,13 +26,12 @@
/**
* ConfigurationHelper
- *
*/
public class ConfigurationHelper {
public static Set getNamespaces() {
Set namespaces = Collections.EMPTY_SET;
- Map allActionConfigs = ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfigs();
+ Map allActionConfigs = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
if (allActionConfigs != null) {
namespaces = allActionConfigs.keySet();
}
@@ -41,7 +40,7 @@
public static Set getActionNames(String namespace) {
Set actionNames = Collections.EMPTY_SET;
- Map allActionConfigs = ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfigs();
+ Map allActionConfigs = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
if (allActionConfigs != null) {
Map actionMappings = (Map) allActionConfigs.get(namespace);
if (actionMappings != null) {
@@ -53,7 +52,7 @@
public static ActionConfig getActionConfig(String namespace, String actionName) {
ActionConfig config = null;
- Map allActionConfigs = ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfigs();
+ Map allActionConfigs = XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
if (allActionConfigs != null) {
Map actionMappings = (Map) allActionConfigs.get(namespace);
if (actionMappings != null) {
Modified: struts/action2/trunk/core/src/main/java/org/apache/struts/action2/sitegraph/XWorkConfigRetriever.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/sitegraph/XWorkConfigRetriever.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/main/java/org/apache/struts/action2/sitegraph/XWorkConfigRetriever.java (original)
+++ struts/action2/trunk/core/src/main/java/org/apache/struts/action2/sitegraph/XWorkConfigRetriever.java Tue May 23 13:26:45 2006
@@ -3,21 +3,24 @@
*/
package org.apache.struts.action2.sitegraph;
-import org.apache.struts.action2.sitegraph.collectors.ArbitraryXMLConfigurationProvider;
-import org.apache.struts.action2.sitegraph.entities.FreeMarkerView;
-import org.apache.struts.action2.sitegraph.entities.JspView;
-import org.apache.struts.action2.sitegraph.entities.VelocityView;
-import org.apache.struts.action2.sitegraph.entities.View;
-import com.opensymphony.xwork.config.ConfigurationManager;
+import com.opensymphony.xwork.XWorkStatic;
import com.opensymphony.xwork.config.ConfigurationProvider;
import com.opensymphony.xwork.config.entities.ActionConfig;
import com.opensymphony.xwork.config.entities.ResultConfig;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action2.sitegraph.collectors.ArbitraryXMLConfigurationProvider;
+import org.apache.struts.action2.sitegraph.entities.FreeMarkerView;
+import org.apache.struts.action2.sitegraph.entities.JspView;
+import org.apache.struts.action2.sitegraph.entities.VelocityView;
+import org.apache.struts.action2.sitegraph.entities.View;
import java.io.File;
import java.io.IOException;
-import java.util.*;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
/**
* Initializes and retrieves XWork config elements
@@ -38,7 +41,7 @@
public static Map getActionConfigs() {
if (!isXWorkStarted)
initXWork();
- return ConfigurationManager.getConfiguration().getRuntimeConfiguration().getActionConfigs();
+ return XWorkStatic.getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
}
private static void initXWork() {
@@ -46,7 +49,7 @@
File configFile = new File(configFilePath);
try {
ConfigurationProvider configProvider = new ArbitraryXMLConfigurationProvider(configFile.getCanonicalPath());
- ConfigurationManager.addConfigurationProvider(configProvider);
+ XWorkStatic.getConfigurationManager().addConfigurationProvider(configProvider);
isXWorkStarted = true;
} catch (IOException e) {
LOG.error("IOException", e);
Modified: struts/action2/trunk/core/src/main/java/org/apache/struts/action2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/main/java/org/apache/struts/action2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java (original)
+++ struts/action2/trunk/core/src/main/java/org/apache/struts/action2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java Tue May 23 13:26:45 2006
@@ -17,8 +17,8 @@
*/
package org.apache.struts.action2.spring.lifecycle;
+import com.opensymphony.xwork.XWorkStatic;
import com.opensymphony.xwork.config.Configuration;
-import com.opensymphony.xwork.config.ConfigurationManager;
import com.opensymphony.xwork.config.ExternalReferenceResolver;
import com.opensymphony.xwork.config.entities.PackageConfig;
import org.springframework.context.ApplicationContext;
@@ -36,7 +36,6 @@
* framework. Relies on Spring's
* {@link org.springframework.web.context.ContextLoaderListener}having been
* called first.
- *
*/
public class SpringExternalReferenceResolverSetupListener implements
ServletContextListener {
@@ -44,7 +43,7 @@
ApplicationContext appContext = WebApplicationContextUtils
.getWebApplicationContext(event.getServletContext());
- Configuration xworkConfig = ConfigurationManager.getConfiguration();
+ Configuration xworkConfig = XWorkStatic.getConfigurationManager().getConfiguration();
Map packageConfigs = xworkConfig.getPackageConfigs();
Iterator i = packageConfigs.values().iterator();
@@ -52,7 +51,7 @@
PackageConfig packageConfig = (PackageConfig) i.next();
ExternalReferenceResolver resolver = packageConfig.getExternalRefResolver();
if (resolver == null || !(resolver instanceof ApplicationContextAware))
- continue;
+ continue;
ApplicationContextAware contextAware = (ApplicationContextAware) resolver;
contextAware.setApplicationContext(appContext);
}
Modified: struts/action2/trunk/core/src/main/java/org/apache/struts/action2/util/ResolverSetupServletContextListener.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/util/ResolverSetupServletContextListener.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/main/java/org/apache/struts/action2/util/ResolverSetupServletContextListener.java (original)
+++ struts/action2/trunk/core/src/main/java/org/apache/struts/action2/util/ResolverSetupServletContextListener.java Tue May 23 13:26:45 2006
@@ -17,8 +17,8 @@
*/
package org.apache.struts.action2.util;
+import com.opensymphony.xwork.XWorkStatic;
import com.opensymphony.xwork.config.Configuration;
-import com.opensymphony.xwork.config.ConfigurationManager;
import com.opensymphony.xwork.config.entities.PackageConfig;
import javax.servlet.ServletContextEvent;
@@ -33,7 +33,6 @@
* Spring framework uses a ContextServletListener to initialise it's IoC container, storing it's
* container context (ApplicationContext in Spring terms) in the Servlet context, the External
* Reference Resolver can get a reference to the container context from the servlet context.
- *
*/
public class ResolverSetupServletContextListener implements ServletContextListener {
@@ -41,7 +40,7 @@
}
public void contextInitialized(ServletContextEvent event) {
- Configuration config = ConfigurationManager.getConfiguration();
+ Configuration config = XWorkStatic.getConfigurationManager().getConfiguration();
String key;
PackageConfig packageConfig;
@@ -50,7 +49,7 @@
key = (String) iter.next();
packageConfig = config.getPackageConfig(key);
- if (packageConfig.getExternalRefResolver() instanceof ServletContextAware) {
+ if (packageConfig.getExternalRefResolver()instanceof ServletContextAware) {
((ServletContextAware) packageConfig.getExternalRefResolver()).setServletContext(event.getServletContext());
}
}
Modified: struts/action2/trunk/core/src/test/java/org/apache/struts/action2/components/UIComponentTest.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/test/java/org/apache/struts/action2/components/UIComponentTest.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/test/java/org/apache/struts/action2/components/UIComponentTest.java (original)
+++ struts/action2/trunk/core/src/test/java/org/apache/struts/action2/components/UIComponentTest.java Tue May 23 13:26:45 2006
@@ -17,525 +17,505 @@
*/
package org.apache.struts.action2.components;
+import com.opensymphony.xwork.ActionContext;
+import com.opensymphony.xwork.XWorkStatic;
import org.apache.struts.action2.TestConfigurationProvider;
import org.apache.struts.action2.views.jsp.AbstractUITagTest;
-import org.apache.struts.action2.views.jsp.ui.ActionErrorTag;
-import org.apache.struts.action2.views.jsp.ui.ActionMessageTag;
-import org.apache.struts.action2.views.jsp.ui.AnchorTag;
-import org.apache.struts.action2.views.jsp.ui.CheckboxTag;
-import org.apache.struts.action2.views.jsp.ui.ComboBoxTag;
-import org.apache.struts.action2.views.jsp.ui.DivTag;
-import org.apache.struts.action2.views.jsp.ui.DoubleSelectTag;
-import org.apache.struts.action2.views.jsp.ui.FieldErrorTag;
-import org.apache.struts.action2.views.jsp.ui.FileTag;
-import org.apache.struts.action2.views.jsp.ui.FormTag;
-import org.apache.struts.action2.views.jsp.ui.HiddenTag;
-import org.apache.struts.action2.views.jsp.ui.LabelTag;
-import org.apache.struts.action2.views.jsp.ui.OptionTransferSelectTag;
-import org.apache.struts.action2.views.jsp.ui.PasswordTag;
-import org.apache.struts.action2.views.jsp.ui.RadioTag;
-import org.apache.struts.action2.views.jsp.ui.SelectTag;
-import org.apache.struts.action2.views.jsp.ui.SubmitTag;
-import org.apache.struts.action2.views.jsp.ui.TextFieldTag;
-import org.apache.struts.action2.views.jsp.ui.TextareaTag;
-import org.apache.struts.action2.views.jsp.ui.TokenTag;
-import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.config.ConfigurationManager;
+import org.apache.struts.action2.views.jsp.ui.*;
/**
* Test case common for all UI component in general.
- *
*/
public class UIComponentTest extends AbstractUITagTest {
-
- // actionError
- public void testActionErrorComponentDisposeItselfFromComponentStack() throws Exception {
- ActionMessageTag t = new ActionMessageTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- ActionErrorTag tag = new ActionErrorTag();
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
-
- }
-
- // actionMessage
- public void testActionMessageDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- ActionMessageTag tag = new ActionMessageTag();
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // Anchor
- public void testAnchorComponentDisposeItselfFromComponentStack() throws Exception {
-
- TextFieldTag t = new TextFieldTag();
- t.setPageContext(pageContext);
- t.setName("textFieldName");
-
- AnchorTag tag = new AnchorTag();
- tag.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // checkbox
- public void testCheckboxDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- CheckboxTag tag = new CheckboxTag();
- tag.setName("name");
- tag.setLabel("label");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // combobox
- public void testComboboxDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- ComboBoxTag tag = new ComboBoxTag();
- tag.setName("name");
- tag.setLabel("label");
- tag.setList("{'aaa','bbb','ccc'}");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // div
- public void testDivComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- DivTag tag = new DivTag();
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // doubleselect
- public void testDoubleselectComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- DoubleSelectTag tag = new DoubleSelectTag();
- tag.setName("name");
- tag.setLabel("label");
- tag.setList("#{1:'one',2:'two'}");
- tag.setDoubleName("doubleName");
- tag.setDoubleList("1?({'aa','bb'}:{'cc','dd'}");
- tag.setFormName("formName");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // fieldError
- public void testFielderrorComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- FieldErrorTag tag = new FieldErrorTag();
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // file
- public void testFileDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- FileTag tag = new FileTag();
- tag.setName("name");
- tag.setLabel("label");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // form
- public void testFormComponentDisposeItselfFromComponentStack() throws Exception {
- ConfigurationManager.clearConfigurationProviders();
- ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
+
+ // actionError
+ public void testActionErrorComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionMessageTag t = new ActionMessageTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ ActionErrorTag tag = new ActionErrorTag();
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+
+ }
+
+ // actionMessage
+ public void testActionMessageDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ ActionMessageTag tag = new ActionMessageTag();
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // Anchor
+ public void testAnchorComponentDisposeItselfFromComponentStack() throws Exception {
+
+ TextFieldTag t = new TextFieldTag();
+ t.setPageContext(pageContext);
+ t.setName("textFieldName");
+
+ AnchorTag tag = new AnchorTag();
+ tag.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // checkbox
+ public void testCheckboxDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ CheckboxTag tag = new CheckboxTag();
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // combobox
+ public void testComboboxDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ ComboBoxTag tag = new ComboBoxTag();
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setList("{'aaa','bbb','ccc'}");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // div
+ public void testDivComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ DivTag tag = new DivTag();
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // doubleselect
+ public void testDoubleselectComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ DoubleSelectTag tag = new DoubleSelectTag();
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setList("#{1:'one',2:'two'}");
+ tag.setDoubleName("doubleName");
+ tag.setDoubleList("1?({'aa','bb'}:{'cc','dd'}");
+ tag.setFormName("formName");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // fieldError
+ public void testFielderrorComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ FieldErrorTag tag = new FieldErrorTag();
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // file
+ public void testFileDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ FileTag tag = new FileTag();
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // form
+ public void testFormComponentDisposeItselfFromComponentStack() throws Exception {
+ XWorkStatic.getConfigurationManager().clearConfigurationProviders();
+ XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
ActionContext.getContext().setValueStack(stack);
-
+
request.setupGetServletPath("/testAction");
-
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- FormTag tag = new FormTag();
- tag.setName("myForm");
- tag.setMethod("POST");
- tag.setAction("myAction");
- tag.setEnctype("myEncType");
- tag.setTitle("mytitle");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // hidden
- public void testHiddenComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- HiddenTag tag = new HiddenTag();
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // label
- public void testLabelComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- LabelTag tag = new LabelTag();
- tag.setName("name");
- tag.setLabel("label");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // optiontransferselect
- public void testOptiontransferselectComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- OptionTransferSelectTag tag = new OptionTransferSelectTag();
- tag.setId("myId");
- tag.setDoubleId("myDoubleId");
- tag.setName("name");
- tag.setLabel("label");
- tag.setList("{}");
- tag.setDoubleList("{}");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // password
- public void testPasswordComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- PasswordTag tag = new PasswordTag();
- tag.setName("name");
- tag.setLabel("label");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // radio
- public void testRadioComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- RadioTag tag = new RadioTag();
- tag.setList("{}");
- tag.setName("name");
- tag.setLabel("label");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // select
- public void testSelectComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- SelectTag tag = new SelectTag();
- tag.setList("{}");
- tag.setName("name");
- tag.setLabel("label");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
-
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // submit
- public void testSubmitDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- SubmitTag tag = new SubmitTag();
- tag.setName("name");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // textarea
- public void testTextareaComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- TextareaTag tag = new TextareaTag();
- tag.setName("name");
- tag.setLabel("label");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // textfield
- public void testTextfieldComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- TextFieldTag tag = new TextFieldTag();
- tag.setName("name");
- tag.setLabel("label");
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- // token
- public void testTokenComponentDisposeItselfFromComponentStack() throws Exception {
- ActionErrorTag t = new ActionErrorTag();
- t.setPageContext(pageContext);
-
- try {
- t.doStartTag();
- TokenTag tag = new TokenTag();
- tag.setPageContext(pageContext);
- tag.doStartTag();
- assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
- tag.doEndTag();
- assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
-
- t.doEndTag();
- }
- catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- }
+
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ FormTag tag = new FormTag();
+ tag.setName("myForm");
+ tag.setMethod("POST");
+ tag.setAction("myAction");
+ tag.setEnctype("myEncType");
+ tag.setTitle("mytitle");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // hidden
+ public void testHiddenComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ HiddenTag tag = new HiddenTag();
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // label
+ public void testLabelComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ LabelTag tag = new LabelTag();
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // optiontransferselect
+ public void testOptiontransferselectComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ OptionTransferSelectTag tag = new OptionTransferSelectTag();
+ tag.setId("myId");
+ tag.setDoubleId("myDoubleId");
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setList("{}");
+ tag.setDoubleList("{}");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // password
+ public void testPasswordComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ PasswordTag tag = new PasswordTag();
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // radio
+ public void testRadioComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ RadioTag tag = new RadioTag();
+ tag.setList("{}");
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // select
+ public void testSelectComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ SelectTag tag = new SelectTag();
+ tag.setList("{}");
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // submit
+ public void testSubmitDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ SubmitTag tag = new SubmitTag();
+ tag.setName("name");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // textarea
+ public void testTextareaComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ TextareaTag tag = new TextareaTag();
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // textfield
+ public void testTextfieldComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ TextFieldTag tag = new TextFieldTag();
+ tag.setName("name");
+ tag.setLabel("label");
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ // token
+ public void testTokenComponentDisposeItselfFromComponentStack() throws Exception {
+ ActionErrorTag t = new ActionErrorTag();
+ t.setPageContext(pageContext);
+
+ try {
+ t.doStartTag();
+ TokenTag tag = new TokenTag();
+ tag.setPageContext(pageContext);
+ tag.doStartTag();
+ assertEquals(tag.getComponent().getComponentStack().peek(), tag.getComponent());
+ tag.doEndTag();
+ assertEquals(t.getComponent().getComponentStack().peek(), t.getComponent());
+
+ t.doEndTag();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
}
Modified: struts/action2/trunk/core/src/test/java/org/apache/struts/action2/dispatcher/AbstractServletDispatcherTestCase.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/test/java/org/apache/struts/action2/dispatcher/AbstractServletDispatcherTestCase.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/test/java/org/apache/struts/action2/dispatcher/AbstractServletDispatcherTestCase.java (original)
+++ struts/action2/trunk/core/src/test/java/org/apache/struts/action2/dispatcher/AbstractServletDispatcherTestCase.java Tue May 23 13:26:45 2006
@@ -23,11 +23,11 @@
import com.mockobjects.servlet.MockHttpSession;
import com.mockobjects.servlet.MockServletConfig;
import com.mockobjects.servlet.MockServletOutputStream;
+import com.opensymphony.xwork.XWorkStatic;
+import com.opensymphony.xwork.config.providers.XmlConfigurationProvider;
import org.apache.struts.action2.StrutsTestCase;
import org.apache.struts.action2.views.jsp.StrutsMockHttpServletRequest;
import org.apache.struts.action2.views.jsp.StrutsMockHttpServletResponse;
-import com.opensymphony.xwork.config.ConfigurationManager;
-import com.opensymphony.xwork.config.providers.XmlConfigurationProvider;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
@@ -66,14 +66,14 @@
protected void loadConfig() {
XmlConfigurationProvider c = new XmlConfigurationProvider(getConfigFilename());
- ConfigurationManager.clearConfigurationProviders();
- ConfigurationManager.destroyConfiguration();
- ConfigurationManager.addConfigurationProvider(c);
- ConfigurationManager.getConfiguration();
+ XWorkStatic.getConfigurationManager().clearConfigurationProviders();
+ XWorkStatic.getConfigurationManager().destroyConfiguration();
+ XWorkStatic.getConfigurationManager().addConfigurationProvider(c);
+ XWorkStatic.getConfigurationManager().getConfiguration();
}
protected void tearDown() throws Exception {
- ConfigurationManager.destroyConfiguration();
+ XWorkStatic.getConfigurationManager().destroyConfiguration();
}
private void service(HttpServlet servlet) throws ServletException, IOException {
Modified: struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/ExecuteAndWaitInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/ExecuteAndWaitInterceptorTest.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/ExecuteAndWaitInterceptorTest.java (original)
+++ struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/ExecuteAndWaitInterceptorTest.java Tue May 23 13:26:45 2006
@@ -17,21 +17,20 @@
*/
package org.apache.struts.action2.interceptor;
-import org.apache.struts.action2.ServletActionContext;
-import org.apache.struts.action2.StrutsTestCase;
-import org.apache.struts.action2.views.jsp.StrutsMockHttpServletRequest;
-import org.apache.struts.action2.views.jsp.StrutsMockHttpSession;
import com.opensymphony.xwork.*;
-import com.opensymphony.xwork.mock.MockResult;
import com.opensymphony.xwork.config.Configuration;
import com.opensymphony.xwork.config.ConfigurationException;
-import com.opensymphony.xwork.config.ConfigurationManager;
import com.opensymphony.xwork.config.ConfigurationProvider;
import com.opensymphony.xwork.config.entities.ActionConfig;
+import com.opensymphony.xwork.config.entities.InterceptorMapping;
import com.opensymphony.xwork.config.entities.PackageConfig;
import com.opensymphony.xwork.config.entities.ResultConfig;
-import com.opensymphony.xwork.config.entities.InterceptorMapping;
import com.opensymphony.xwork.interceptor.ParametersInterceptor;
+import com.opensymphony.xwork.mock.MockResult;
+import org.apache.struts.action2.ServletActionContext;
+import org.apache.struts.action2.StrutsTestCase;
+import org.apache.struts.action2.views.jsp.StrutsMockHttpServletRequest;
+import org.apache.struts.action2.views.jsp.StrutsMockHttpSession;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
@@ -41,7 +40,6 @@
/**
* Test case for ExecuteAndWaitInterceptor.
- *
*/
public class ExecuteAndWaitInterceptorTest extends StrutsTestCase {
@@ -162,9 +160,9 @@
}
protected void setUp() throws Exception {
- ConfigurationManager.clearConfigurationProviders();
- ConfigurationManager.addConfigurationProvider(new WaitConfigurationProvider());
- ConfigurationManager.getConfiguration().reload();
+ XWorkStatic.getConfigurationManager().clearConfigurationProviders();
+ XWorkStatic.getConfigurationManager().addConfigurationProvider(new WaitConfigurationProvider());
+ XWorkStatic.getConfigurationManager().getConfiguration().reload();
session = new HashMap();
params = new HashMap();
@@ -180,8 +178,8 @@
}
protected void tearDown() throws Exception {
- ConfigurationManager.clearConfigurationProviders();
- ConfigurationManager.destroyConfiguration();
+ XWorkStatic.getConfigurationManager().clearConfigurationProviders();
+ XWorkStatic.getConfigurationManager().destroyConfiguration();
ActionContext.setContext(null);
}
Modified: struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/TokenInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/TokenInterceptorTest.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/TokenInterceptorTest.java (original)
+++ struts/action2/trunk/core/src/test/java/org/apache/struts/action2/interceptor/TokenInterceptorTest.java Tue May 23 13:26:45 2006
@@ -17,19 +17,14 @@
*/
package org.apache.struts.action2.interceptor;
+import com.opensymphony.xwork.*;
+import com.opensymphony.xwork.util.OgnlValueStack;
import org.apache.struts.action2.ServletActionContext;
-import org.apache.struts.action2.TestConfigurationProvider;
import org.apache.struts.action2.StrutsTestCase;
+import org.apache.struts.action2.TestConfigurationProvider;
import org.apache.struts.action2.util.TokenHelper;
import org.apache.struts.action2.views.jsp.StrutsMockHttpServletRequest;
import org.apache.struts.action2.views.jsp.StrutsMockHttpSession;
-import com.opensymphony.xwork.Action;
-import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.ActionProxy;
-import com.opensymphony.xwork.ActionProxyFactory;
-import com.opensymphony.xwork.config.ConfigurationManager;
-import com.opensymphony.xwork.util.OgnlValueStack;
-import junit.framework.TestCase;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -39,7 +34,6 @@
/**
* TokenInterceptorTest
- *
*/
public class TokenInterceptorTest extends StrutsTestCase {
@@ -103,9 +97,9 @@
}
protected void setUp() throws Exception {
- ConfigurationManager.clearConfigurationProviders();
- ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
- ConfigurationManager.getConfiguration().reload();
+ XWorkStatic.getConfigurationManager().clearConfigurationProviders();
+ XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
+ XWorkStatic.getConfigurationManager().getConfiguration().reload();
session = new HashMap();
params = new HashMap();
@@ -130,7 +124,7 @@
}
protected void tearDown() throws Exception {
- ConfigurationManager.destroyConfiguration();
+ XWorkStatic.getConfigurationManager().destroyConfiguration();
ActionContext.setContext(null);
}
}
Modified: struts/action2/trunk/core/src/test/java/org/apache/struts/action2/views/jsp/ActionTagTest.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/test/java/org/apache/struts/action2/views/jsp/ActionTagTest.java?rev=409001&r1=409000&r2=409001&view=diff
==============================================================================
--- struts/action2/trunk/core/src/test/java/org/apache/struts/action2/views/jsp/ActionTagTest.java (original)
+++ struts/action2/trunk/core/src/test/java/org/apache/struts/action2/views/jsp/ActionTagTest.java Tue May 23 13:26:45 2006
@@ -17,17 +17,13 @@
*/
package org.apache.struts.action2.views.jsp;
+import com.opensymphony.xwork.*;
+import com.opensymphony.xwork.util.OgnlValueStack;
import org.apache.struts.action2.ServletActionContext;
import org.apache.struts.action2.TestAction;
import org.apache.struts.action2.TestActionTagResult;
import org.apache.struts.action2.TestConfigurationProvider;
import org.apache.struts.action2.components.ActionComponent;
-import com.opensymphony.xwork.Action;
-import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.ActionProxy;
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.config.ConfigurationManager;
-import com.opensymphony.xwork.util.OgnlValueStack;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
@@ -35,7 +31,6 @@
/**
* Unit test for {@link ActionTag}.
- *
*/
public class ActionTagTest extends AbstractTagTest {
@@ -115,7 +110,7 @@
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
- assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
+ assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
assertTrue(result.isExecuted());
}
@@ -136,7 +131,7 @@
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
- assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
+ assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
assertNull(result); // result is never executed, hence never set into invocation
}
@@ -229,16 +224,16 @@
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
- assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
+ assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
assertTrue(result.isExecuted());
}
protected void setUp() throws Exception {
super.setUp();
- ConfigurationManager.clearConfigurationProviders();
- ConfigurationManager.addConfigurationProvider(new TestConfigurationProvider());
- ConfigurationManager.getConfiguration().reload();
+ XWorkStatic.getConfigurationManager().clearConfigurationProviders();
+ XWorkStatic.getConfigurationManager().addConfigurationProvider(new TestConfigurationProvider());
+ XWorkStatic.getConfigurationManager().getConfiguration().reload();
ActionContext actionContext = new ActionContext(context);
actionContext.setValueStack(stack);
@@ -246,7 +241,7 @@
}
protected void tearDown() throws Exception {
- ConfigurationManager.destroyConfiguration();
+ XWorkStatic.getConfigurationManager().destroyConfiguration();
OgnlValueStack stack = new OgnlValueStack();
ActionContext.setContext(new ActionContext(stack.getContext()));