mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
WW-4518 Drops deprecated API from ActionProxyFactory
This commit is contained in:
@@ -29,20 +29,6 @@ import java.util.Map;
|
||||
*/
|
||||
public interface ActionProxyFactory {
|
||||
|
||||
/**
|
||||
* Creates an {@link ActionProxy} for the given namespace and action name by looking up the configuration.The ActionProxy
|
||||
* should be fully initialized when it is returned, including having an {@link ActionInvocation} instance associated.
|
||||
* <p/>
|
||||
* <b>Note:</b> This is the most used create method.
|
||||
*
|
||||
* @param namespace the namespace of the action, can be <tt>null</tt>
|
||||
* @param actionName the name of the action
|
||||
* @param extraContext a Map of extra parameters to be provided to the ActionProxy, can be <tt>null</tt>
|
||||
* @return ActionProxy the created action proxy
|
||||
* @deprecated Since 2.1.1, use {@link #createActionProxy(String,String,String,Map) instead}
|
||||
*/
|
||||
@Deprecated public ActionProxy createActionProxy(String namespace, String actionName, Map<String, Object> extraContext);
|
||||
|
||||
/**
|
||||
* Creates an {@link ActionProxy} for the given namespace and action name by looking up the configuration.The ActionProxy
|
||||
* should be fully initialized when it is returned, including having an {@link ActionInvocation} instance associated.
|
||||
@@ -56,21 +42,7 @@ public interface ActionProxyFactory {
|
||||
* @return ActionProxy the created action proxy
|
||||
* @since 2.1.1
|
||||
*/
|
||||
public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext);
|
||||
|
||||
/**
|
||||
* Creates an {@link ActionProxy} for the given namespace and action name by looking up the configuration.The ActionProxy
|
||||
* should be fully initialized when it is returned, including having an {@link ActionInvocation} instance associated.
|
||||
*
|
||||
* @param namespace the namespace of the action, can be <tt>null</tt>
|
||||
* @param actionName the name of the action
|
||||
* @param extraContext a Map of extra parameters to be provided to the ActionProxy, can be <tt>null</tt>
|
||||
* @param executeResult flag which tells whether the result should be executed after the action
|
||||
* @param cleanupContext flag which tells whether the original context should be preserved during execution of the proxy.
|
||||
* @return ActionProxy the created action proxy
|
||||
* @deprecated Since 2.1.1, use {@link #createActionProxy(String,String,String,Map,boolean,boolean)} instead
|
||||
*/
|
||||
@Deprecated public ActionProxy createActionProxy(String namespace, String actionName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext);
|
||||
ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext);
|
||||
|
||||
/**
|
||||
* Creates an {@link ActionProxy} for the given namespace and action name by looking up the configuration.The ActionProxy
|
||||
@@ -85,7 +57,7 @@ public interface ActionProxyFactory {
|
||||
* @return ActionProxy the created action proxy
|
||||
* @since 2.1.1
|
||||
*/
|
||||
public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext);
|
||||
ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext);
|
||||
|
||||
|
||||
/**
|
||||
@@ -101,7 +73,7 @@ public interface ActionProxyFactory {
|
||||
* @return ActionProxy the created action proxy
|
||||
* @since 2.1.1
|
||||
*/
|
||||
public ActionProxy createActionProxy(ActionInvocation actionInvocation, String namespace, String actionName, String methodName,
|
||||
ActionProxy createActionProxy(ActionInvocation actionInvocation, String namespace, String actionName, String methodName,
|
||||
boolean executeResult, boolean cleanupContext);
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ActionNestingTest extends XWorkTestCase {
|
||||
|
||||
public void testNestedContext() throws Exception {
|
||||
assertEquals(context, ActionContext.getContext());
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(NAMESPACE, SIMPLE_ACTION_NAME, null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(NAMESPACE, SIMPLE_ACTION_NAME, null, null);
|
||||
proxy.execute();
|
||||
assertEquals(context, ActionContext.getContext());
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class ActionNestingTest extends XWorkTestCase {
|
||||
ValueStack stack = ActionContext.getContext().getValueStack();
|
||||
assertEquals(VALUE, stack.findValue(KEY));
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(NAMESPACE, NO_STACK_ACTION_NAME, null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(NAMESPACE, NO_STACK_ACTION_NAME, null, null);
|
||||
proxy.execute();
|
||||
stack = ActionContext.getContext().getValueStack();
|
||||
assertEquals(stack.findValue(KEY), VALUE);
|
||||
@@ -90,7 +90,7 @@ public class ActionNestingTest extends XWorkTestCase {
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.VALUE_STACK, stack);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(NAMESPACE, STACK_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(NAMESPACE, STACK_ACTION_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
assertEquals(context, ActionContext.getContext());
|
||||
assertEquals(stack, ActionContext.getContext().getValueStack());
|
||||
|
||||
@@ -76,12 +76,13 @@ public class ChainResultTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testRecursiveChain() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "InfiniteRecursionChain", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "InfiniteRecursionChain", null, null);
|
||||
|
||||
try {
|
||||
proxy.execute();
|
||||
fail("did not detected repeated chain to an action");
|
||||
} catch (XWorkException e) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,23 +37,23 @@ public class DefaultClasstTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testWildCardEvaluation() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("Abstract-crud", "edit", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("Abstract-crud", "edit", null, null);
|
||||
assertEquals("com.opensymphony.xwork2.SimpleAction", proxy.getConfig().getClassName());
|
||||
|
||||
proxy = actionProxyFactory.createActionProxy("/example", "edit", null);
|
||||
proxy = actionProxyFactory.createActionProxy("/example", "edit", null, null);
|
||||
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
|
||||
|
||||
|
||||
proxy = actionProxyFactory.createActionProxy("/example2", "override", null);
|
||||
proxy = actionProxyFactory.createActionProxy("/example2", "override", null, null);
|
||||
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
|
||||
|
||||
proxy = actionProxyFactory.createActionProxy("/example2/subItem", "save", null);
|
||||
proxy = actionProxyFactory.createActionProxy("/example2/subItem", "save", null, null);
|
||||
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
|
||||
|
||||
proxy = actionProxyFactory.createActionProxy("/example2", "list", null);
|
||||
proxy = actionProxyFactory.createActionProxy("/example2", "list", null, null);
|
||||
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
|
||||
|
||||
proxy = actionProxyFactory.createActionProxy("/example3", "list", null);
|
||||
proxy = actionProxyFactory.createActionProxy("/example3", "list", null, null);
|
||||
assertEquals("com.opensymphony.xwork2.SimpleAction", proxy.getConfig().getClassName());
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class LocaleAwareTest extends XWorkTestCase {
|
||||
|
||||
public void testGetText() {
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.FOO_ACTION_NAME, null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.FOO_ACTION_NAME, null, null);
|
||||
ActionContext.getContext().setLocale(Locale.US);
|
||||
|
||||
TextProvider localeAware = (TextProvider) proxy.getAction();
|
||||
@@ -46,7 +46,7 @@ public class LocaleAwareTest extends XWorkTestCase {
|
||||
|
||||
public void testLocaleGetText() {
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.FOO_ACTION_NAME, null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.FOO_ACTION_NAME, null, null);
|
||||
ActionContext.getContext().setLocale(Locale.GERMANY);
|
||||
|
||||
TextProvider localeAware = (TextProvider) proxy.getAction();
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ProxyInvocationTest extends XWorkTestCase {
|
||||
public void testProxyInvocation() throws Exception {
|
||||
|
||||
ActionProxy proxy = actionProxyFactory
|
||||
.createActionProxy("", "ProxyInvocation", createDummyContext());
|
||||
.createActionProxy("", "ProxyInvocation", null, createDummyContext());
|
||||
ActionInvocation invocation = proxy.getInvocation();
|
||||
|
||||
String result = invocation.invokeActionOnly();
|
||||
|
||||
@@ -39,17 +39,17 @@ public class WildCardResultTest extends XWorkTestCase {
|
||||
|
||||
public void testWildCardEvaluation() throws Exception {
|
||||
ActionContext.setContext(null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "WildCard", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "WildCard", null, null);
|
||||
assertEquals("success", proxy.execute());
|
||||
assertEquals(VoidResult.class, proxy.getInvocation().getResult().getClass());
|
||||
|
||||
ActionContext.setContext(null);
|
||||
proxy = actionProxyFactory.createActionProxy(null, "WildCardInput", null);
|
||||
proxy = actionProxyFactory.createActionProxy(null, "WildCardInput", null, null);
|
||||
assertEquals("input", proxy.execute());
|
||||
assertEquals(MockResult.class, proxy.getInvocation().getResult().getClass());
|
||||
|
||||
ActionContext.setContext(null);
|
||||
proxy = actionProxyFactory.createActionProxy(null, "WildCardError", null);
|
||||
proxy = actionProxyFactory.createActionProxy(null, "WildCardError", null, null);
|
||||
assertEquals("error", proxy.execute());
|
||||
assertEquals(MockResult.class, proxy.getInvocation().getResult().getClass());
|
||||
}
|
||||
|
||||
@@ -44,14 +44,14 @@ public class ConfigurationTest extends XWorkTestCase {
|
||||
|
||||
public void testAbstract() {
|
||||
try {
|
||||
actionProxyFactory.createActionProxy("/abstract", "test", null);
|
||||
actionProxyFactory.createActionProxy("/abstract", "test", null, null);
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
// this is what we expected
|
||||
}
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/nonAbstract", "test", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/nonAbstract", "test", null, null);
|
||||
assertTrue(proxy.getActionName().equals("test"));
|
||||
assertTrue(proxy.getConfig().getClassName().equals(SimpleAction.class.getName()));
|
||||
} catch (Exception e) {
|
||||
@@ -68,7 +68,7 @@ public class ConfigurationTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/does/not/exist", "Foo", extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/does/not/exist", "Foo", null, extraContext);
|
||||
proxy.execute();
|
||||
assertEquals("this is blah", proxy.getInvocation().getStack().findValue("[1].blah"));
|
||||
} catch (Exception e) {
|
||||
@@ -118,7 +118,7 @@ public class ConfigurationTest extends XWorkTestCase {
|
||||
|
||||
public void testGlobalResults() {
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "Foo", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "Foo", null, null);
|
||||
assertNotNull(proxy.getConfig().getResults().get("login"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -128,7 +128,7 @@ public class ConfigurationTest extends XWorkTestCase {
|
||||
|
||||
public void testInterceptorParamInehritanceOverride() {
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "TestInterceptorParamInehritanceOverride", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "TestInterceptorParamInehritanceOverride", null, null);
|
||||
assertEquals(1, proxy.getConfig().getInterceptors().size());
|
||||
|
||||
MockInterceptor testInterceptor = (MockInterceptor) proxy.getConfig().getInterceptors().get(0).getInterceptor();
|
||||
@@ -143,7 +143,7 @@ public class ConfigurationTest extends XWorkTestCase {
|
||||
|
||||
public void testInterceptorParamInheritance() {
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "TestInterceptorParamInheritance", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "TestInterceptorParamInheritance", null, null);
|
||||
assertEquals(1, proxy.getConfig().getInterceptors().size());
|
||||
|
||||
MockInterceptor testInterceptor = (MockInterceptor) proxy.getConfig().getInterceptors().get(0).getInterceptor();
|
||||
@@ -158,7 +158,7 @@ public class ConfigurationTest extends XWorkTestCase {
|
||||
|
||||
public void testInterceptorParamOverride() {
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "TestInterceptorParamOverride", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "TestInterceptorParamOverride", null, null);
|
||||
assertEquals(1, proxy.getConfig().getInterceptors().size());
|
||||
|
||||
MockInterceptor testInterceptor = (MockInterceptor) proxy.getConfig().getInterceptors().get(0).getInterceptor();
|
||||
@@ -173,7 +173,7 @@ public class ConfigurationTest extends XWorkTestCase {
|
||||
|
||||
public void testInterceptorParams() {
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "TestInterceptorParam", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "TestInterceptorParam", null, null);
|
||||
assertEquals(1, proxy.getConfig().getInterceptors().size());
|
||||
|
||||
MockInterceptor testInterceptor = (MockInterceptor) proxy.getConfig().getInterceptors().get(0).getInterceptor();
|
||||
@@ -277,11 +277,11 @@ public class ConfigurationTest extends XWorkTestCase {
|
||||
public void testMultipleInheritance() {
|
||||
try {
|
||||
ActionProxy proxy;
|
||||
proxy = actionProxyFactory.createActionProxy("multipleInheritance", "test", null);
|
||||
proxy = actionProxyFactory.createActionProxy("multipleInheritance", "test", null, null);
|
||||
assertNotNull(proxy);
|
||||
proxy = actionProxyFactory.createActionProxy("multipleInheritance", "Foo", null);
|
||||
proxy = actionProxyFactory.createActionProxy("multipleInheritance", "Foo", null, null);
|
||||
assertNotNull(proxy);
|
||||
proxy = actionProxyFactory.createActionProxy("multipleInheritance", "testMultipleInheritance", null);
|
||||
proxy = actionProxyFactory.createActionProxy("multipleInheritance", "testMultipleInheritance", null, null);
|
||||
assertNotNull(proxy);
|
||||
assertEquals(5, proxy.getConfig().getInterceptors().size());
|
||||
assertEquals(2, proxy.getConfig().getResults().size());
|
||||
@@ -293,7 +293,7 @@ public class ConfigurationTest extends XWorkTestCase {
|
||||
|
||||
public void testPackageExtension() {
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "Bar", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "Bar", null, null);
|
||||
assertEquals(5, proxy.getConfig().getInterceptors().size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -49,7 +49,7 @@ public class AliasInterceptorTest extends XWorkTestCase {
|
||||
XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml");
|
||||
container.inject(provider);
|
||||
loadConfigurationProviders(provider);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "aliasTest", params);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "aliasTest", null, params);
|
||||
SimpleAction actionOne = (SimpleAction) proxy.getAction();
|
||||
actionOne.setAliasSource("name to be copied");
|
||||
actionOne.setFoo(17);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PreResultListenerTest extends XWorkTestCase {
|
||||
|
||||
|
||||
public void testPreResultListenersAreCalled() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("package", "action", new HashMap<String, Object>(), false, true);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("package", "action", null, new HashMap<String, Object>(), false, true);
|
||||
ActionInvocation invocation = proxy.getInvocation();
|
||||
Mock preResultListenerMock1 = new Mock(PreResultListener.class);
|
||||
preResultListenerMock1.expect("beforeResult", C.args(C.eq(invocation), C.eq(Action.SUCCESS)));
|
||||
@@ -51,7 +51,7 @@ public class PreResultListenerTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testPreResultListenersAreCalledInOrder() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("package", "action", new HashMap<String, Object>(), false, true);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("package", "action", null, new HashMap<String, Object>(), false, true);
|
||||
ActionInvocation invocation = proxy.getInvocation();
|
||||
CountPreResultListener listener1 = new CountPreResultListener();
|
||||
CountPreResultListener listener2 = new CountPreResultListener();
|
||||
@@ -84,8 +84,6 @@ public class PreResultListenerTest extends XWorkTestCase {
|
||||
|
||||
/**
|
||||
* Tells whether the ConfigurationProvider should reload its configuration
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean needsReload() {
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -48,14 +48,14 @@ public class AnnotationWorkflowInterceptorTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testInterceptsBeforeAndAfter() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", ANNOTATED_ACTION, null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", ANNOTATED_ACTION, null, null);
|
||||
assertEquals(Action.SUCCESS, proxy.execute());
|
||||
AnnotatedAction action = (AnnotatedAction)proxy.getInvocation().getAction();
|
||||
assertEquals("baseBefore-before-execute-beforeResult-after", action.log);
|
||||
}
|
||||
|
||||
public void testInterceptsShortcircuitedAction() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", SHORTCIRCUITED_ACTION, null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", SHORTCIRCUITED_ACTION, null, null);
|
||||
assertEquals("shortcircuit", proxy.execute());
|
||||
ShortcircuitedAction action = (ShortcircuitedAction)proxy.getInvocation().getAction();
|
||||
assertEquals("baseBefore-before", action.log);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ActionsFromSpringTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testLoadSimpleAction() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "simpleAction", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "simpleAction", null, null);
|
||||
Object action = proxy.getAction();
|
||||
|
||||
Action expected = (Action) appContext.getBean("simple-action");
|
||||
@@ -35,19 +35,19 @@ public class ActionsFromSpringTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testLoadActionWithDependencies() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "dependencyAction", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "dependencyAction", null, null);
|
||||
SimpleAction action = (SimpleAction) proxy.getAction();
|
||||
|
||||
assertEquals("injected", action.getBlah());
|
||||
}
|
||||
|
||||
public void testProxiedActionIsNotStateful() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "proxiedAction", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "proxiedAction", null, null);
|
||||
SimpleAction action = (SimpleAction) proxy.getAction();
|
||||
|
||||
action.setBlah("Hello World");
|
||||
|
||||
proxy = actionProxyFactory.createActionProxy(null, "proxiedAction", null);
|
||||
proxy = actionProxyFactory.createActionProxy(null, "proxiedAction", null, null);
|
||||
action = (SimpleAction) proxy.getAction();
|
||||
|
||||
// If the action is a singleton, this test will fail
|
||||
@@ -60,7 +60,7 @@ public class ActionsFromSpringTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testAutoProxiedAction() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "autoProxiedAction", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "autoProxiedAction", null, null);
|
||||
|
||||
SimpleAction action = (SimpleAction) proxy.getAction();
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ActionsFromSpringTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testActionWithSpringResult() throws Exception {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "simpleActionSpringResult", null);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "simpleActionSpringResult", null, null);
|
||||
|
||||
proxy.execute();
|
||||
|
||||
|
||||
@@ -20,7 +20,12 @@ import com.opensymphony.xwork2.*;
|
||||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
|
||||
import com.opensymphony.xwork2.test.ModelDrivenAction2;
|
||||
import com.opensymphony.xwork2.test.TestBean2;
|
||||
import org.apache.struts2.util.DateFormatter;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.swing.text.Style;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
@@ -113,7 +118,7 @@ public class LocalizedTextUtilTest extends XWorkTestCase {
|
||||
|
||||
public void testAddDefaultResourceBundle() {
|
||||
String text = LocalizedTextUtil.findDefaultText("foo.range", Locale.getDefault());
|
||||
assertNull("Found message when it should not be available.", null);
|
||||
assertNull("Found message when it should not be available.", text);
|
||||
|
||||
LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/xwork2/SimpleAction");
|
||||
|
||||
@@ -124,7 +129,7 @@ public class LocalizedTextUtilTest extends XWorkTestCase {
|
||||
public void testAddDefaultResourceBundle2() throws Exception {
|
||||
LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/xwork2/SimpleAction");
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/", "packagelessAction", new HashMap<String, Object>(), false, true);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("/", "packagelessAction", null, new HashMap<String, Object>(), false, true);
|
||||
proxy.execute();
|
||||
}
|
||||
|
||||
@@ -191,12 +196,14 @@ public class LocalizedTextUtilTest extends XWorkTestCase {
|
||||
assertEquals("There is no Action mapped for namespace blah and action name AddUser.", message);
|
||||
}
|
||||
|
||||
public void testLocalizedDateFormatIsUsed() {
|
||||
public void testLocalizedDateFormatIsUsed() throws ParseException {
|
||||
LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/xwork2/util/LocalizedTextUtilTest");
|
||||
Object[] params = new Object[]{new Date()};
|
||||
Date date = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US).parse("01/01/2015");
|
||||
Object[] params = new Object[]{ date };
|
||||
String usDate = LocalizedTextUtil.findDefaultText("test.format.date", Locale.US, params);
|
||||
String germanDate = LocalizedTextUtil.findDefaultText("test.format.date", Locale.GERMANY, params);
|
||||
assertFalse(usDate.equals(germanDate));
|
||||
assertEquals(usDate, "1/1/15");
|
||||
assertEquals(germanDate, "01.01.15");
|
||||
}
|
||||
|
||||
public void testXW377() {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class MyBeanActionTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "MyBean", extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "MyBean", null, extraContext);
|
||||
proxy.execute();
|
||||
assertEquals(2, Integer.parseInt(proxy.getInvocation().getStack().findValue("beanList.size").toString()));
|
||||
assertEquals(MyBean.class.getName(), proxy.getInvocation().getStack().findValue("beanList.get(0)").getClass().getName());
|
||||
@@ -67,13 +67,12 @@ public class MyBeanActionTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "MyBean", extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "MyBean", null, extraContext);
|
||||
proxy.execute();
|
||||
MyBeanAction action = (MyBeanAction) proxy.getInvocation().getAction();
|
||||
|
||||
assertEquals(2, Integer.parseInt(proxy.getInvocation().getStack().findValue("beanMap.size").toString()));
|
||||
|
||||
Map map = (Map) proxy.getInvocation().getStack().findValue("beanMap");
|
||||
assertEquals(true, action.getBeanMap().containsKey(1234567890L));
|
||||
assertEquals(true, action.getBeanMap().containsKey(1234567891L));
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DateRangeValidatorTest extends XWorkTestCase {
|
||||
params.put("date", date.getTime());
|
||||
context.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, context);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, context);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class DoubleRangeValidatorTest extends XWorkTestCase {
|
||||
params.put("percentage", 100.0123d);
|
||||
context.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, context);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, context);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
@@ -50,13 +50,11 @@ public class DoubleRangeValidatorTest extends XWorkTestCase {
|
||||
params.put("percentage", 1.234567d);
|
||||
context.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "percentage", context);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "percentage", null, context);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
Map<String, List<String>> errors = ((ValidationAware) proxy.getAction()).getFieldErrors();
|
||||
Iterator it = errors.entrySet().iterator();
|
||||
|
||||
List<String> errorMessages = errors.get("percentage");
|
||||
assertNull("Expected no double range validation error message.", errorMessages);
|
||||
}
|
||||
@@ -187,7 +185,7 @@ public class DoubleRangeValidatorTest extends XWorkTestCase {
|
||||
params.put("percentage", 100.0123d);
|
||||
context.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.EXPRESSION_VALIDATION_ACTION, context);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.EXPRESSION_VALIDATION_ACTION, null, context);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ExpressionValidatorTest extends XWorkTestCase {
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasActionErrors());
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ExpressionValidatorTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testExpressionValidatorSuccess() throws Exception {
|
||||
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
|
||||
//make it not fail
|
||||
params.put("date", "12/23/2002");
|
||||
@@ -91,12 +91,12 @@ public class ExpressionValidatorTest extends XWorkTestCase {
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
assertFalse(((ValidationAware) proxy.getAction()).hasActionErrors());
|
||||
}
|
||||
|
||||
public void testGetSetExpresion() {
|
||||
public void testGetSetExpression() {
|
||||
ExpressionValidator ev = new ExpressionValidator();
|
||||
ev.setExpression("{top}");
|
||||
assertEquals("{top}", ev.getExpression());
|
||||
@@ -110,7 +110,7 @@ public class ExpressionValidatorTest extends XWorkTestCase {
|
||||
ev.setValidatorContext(new DelegatingValidatorContext(mock.proxy()));
|
||||
ev.setExpression("{top}");
|
||||
ev.setValueStack(ActionContext.getContext().getValueStack());
|
||||
ev.validate("Hello"); // {top} will evalute to Hello that is not a Boolean
|
||||
ev.validate("Hello"); // {top} will evaluate to Hello that is not a Boolean
|
||||
mock.verify();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class IntRangeValidatorTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class LongRangeValidatorTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ModelDrivenValidationTest extends XWorkTestCase {
|
||||
XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml");
|
||||
container.inject(provider);
|
||||
loadConfigurationProviders(provider);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "TestModelDrivenValidation", context);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy(null, "TestModelDrivenValidation", null, context);
|
||||
assertEquals(Action.SUCCESS, proxy.execute());
|
||||
|
||||
ModelDrivenAction action = (ModelDrivenAction) proxy.getAction();
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ShortRangeValidatorTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
|
||||
+7
-7
@@ -43,11 +43,11 @@ public class SimpleActionValidationTest extends XWorkTestCase {
|
||||
params.put("date", "12/23/2002");
|
||||
params.put("percentage", "1.23456789");
|
||||
|
||||
HashMap<String, Object> extraContext = new HashMap<String, Object>();
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
|
||||
ValidationAware validationAware = (ValidationAware) proxy.getAction();
|
||||
@@ -56,7 +56,7 @@ public class SimpleActionValidationTest extends XWorkTestCase {
|
||||
// put in an out-of-range value to see if the old validators still work
|
||||
ActionContext.setContext(new ActionContext(new HashMap<String, Object>()));
|
||||
params.put("bar", "42");
|
||||
proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ALIAS_NAME, extraContext);
|
||||
proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ALIAS_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
validationAware = (ValidationAware) proxy.getAction();
|
||||
assertTrue(validationAware.hasFieldErrors());
|
||||
@@ -94,7 +94,7 @@ public class SimpleActionValidationTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
@@ -119,7 +119,7 @@ public class SimpleActionValidationTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, extraContext);
|
||||
ValueStack stack = ActionContext.getContext().getValueStack();
|
||||
ActionContext.setContext(new ActionContext(stack.getContext()));
|
||||
ActionContext.getContext().setLocale(Locale.US);
|
||||
@@ -168,7 +168,7 @@ public class SimpleActionValidationTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
@@ -203,7 +203,7 @@ public class SimpleActionValidationTest extends XWorkTestCase {
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
try {
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_SUBPROPERTY_NAME, extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_SUBPROPERTY_NAME, null, extraContext);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ValidatorAnnotationTest extends XWorkTestCase {
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "notAnnotatedMethod", extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "notAnnotatedMethod", null, extraContext);
|
||||
proxy.execute();
|
||||
assertFalse(((ValidationAware) proxy.getAction()).hasActionErrors());
|
||||
|
||||
@@ -34,12 +34,11 @@ public class ValidatorAnnotationTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testNotAnnotatedMethodSuccess2() throws Exception {
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
extraContext.put(ActionContext.PARAMETERS, new HashMap<String, Object>());
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "notAnnotatedMethod", extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "notAnnotatedMethod", null, extraContext);
|
||||
proxy.execute();
|
||||
assertFalse(((ValidationAware) proxy.getAction()).hasActionErrors());
|
||||
|
||||
@@ -48,12 +47,11 @@ public class ValidatorAnnotationTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testAnnotatedMethodFailure() throws Exception {
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
extraContext.put(ActionContext.PARAMETERS, new HashMap<String, Object>());
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "annotatedMethod", extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "annotatedMethod", null, extraContext);
|
||||
proxy.execute();
|
||||
assertTrue(((ValidationAware) proxy.getAction()).hasActionErrors());
|
||||
Collection errors = ((ValidationAware) proxy.getAction()).getActionErrors();
|
||||
@@ -73,7 +71,7 @@ public class ValidatorAnnotationTest extends XWorkTestCase {
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "annotatedMethod", extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "annotatedMethod", null, extraContext);
|
||||
proxy.execute();
|
||||
assertFalse(((ValidationAware) proxy.getAction()).hasActionErrors());
|
||||
}
|
||||
@@ -87,7 +85,7 @@ public class ValidatorAnnotationTest extends XWorkTestCase {
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "annotatedMethod", extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "annotatedMethod", null, extraContext);
|
||||
proxy.execute();
|
||||
assertFalse(((ValidationAware) proxy.getAction()).hasActionErrors());
|
||||
}
|
||||
@@ -101,7 +99,7 @@ public class ValidatorAnnotationTest extends XWorkTestCase {
|
||||
HashMap<String, Object> extraContext = new HashMap<>();
|
||||
extraContext.put(ActionContext.PARAMETERS, params);
|
||||
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "annotatedMethod", extraContext);
|
||||
ActionProxy proxy = actionProxyFactory.createActionProxy("", "annotatedMethod", null, extraContext);
|
||||
proxy.execute();
|
||||
assertFalse(((ValidationAware) proxy.getAction()).hasActionErrors());
|
||||
}
|
||||
|
||||
@@ -126,6 +126,6 @@ public class TokenInterceptorTest extends StrutsInternalTestCase {
|
||||
}
|
||||
|
||||
protected ActionProxy buildProxy(String actionName) throws Exception {
|
||||
return actionProxyFactory.createActionProxy("", actionName, extraContext, true, true);
|
||||
return actionProxyFactory.createActionProxy("", actionName, null, extraContext, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ public class URLTagTest extends AbstractUITagTest {
|
||||
ActionContext.getContext().setActionInvocation(new DefaultActionInvocation(null, true));
|
||||
DefaultActionProxyFactory apFactory = new DefaultActionProxyFactory();
|
||||
apFactory.setContainer(container);
|
||||
ActionProxy ap = apFactory.createActionProxy("/", "hello", null);
|
||||
ActionProxy ap = apFactory.createActionProxy("/", "hello", null, null);
|
||||
ActionContext.getContext().getActionInvocation().init(ap);
|
||||
|
||||
request.setScheme("http");
|
||||
|
||||
Reference in New Issue
Block a user