Skip to content

Commit

Permalink
WW-4518 Drops deprecated API from ActionProxyFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Jun 23, 2015
1 parent 3bbe681 commit a4abb34
Show file tree
Hide file tree
Showing 25 changed files with 87 additions and 114 deletions.
34 changes: 3 additions & 31 deletions core/src/main/java/com/opensymphony/xwork2/ActionProxyFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@
*/
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.
Expand All @@ -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
Expand All @@ -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);


/**
Expand All @@ -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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public String getMyProperty() {

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());
}
Expand All @@ -76,7 +76,7 @@ public void testNestedNoValueStack() throws Exception {
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);
Expand All @@ -90,7 +90,7 @@ public void testNestedValueStack() throws Exception {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ public void testNamespaceAndActionExpressionEvaluation() throws Exception {
}

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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ protected void setUp() throws Exception {
}

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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -46,7 +46,7 @@ public void testGetText() {

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ protected void setUp() throws Exception {

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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -68,7 +68,7 @@ public void testDefaultNamespace() {
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) {
Expand Down Expand Up @@ -118,7 +118,7 @@ public void testWildcardNamespace() {

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();
Expand All @@ -128,7 +128,7 @@ public void testGlobalResults() {

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();
Expand All @@ -143,7 +143,7 @@ public void testInterceptorParamInehritanceOverride() {

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();
Expand All @@ -158,7 +158,7 @@ public void testInterceptorParamInheritance() {

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();
Expand All @@ -173,7 +173,7 @@ public void testInterceptorParamOverride() {

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();
Expand Down Expand Up @@ -277,11 +277,11 @@ public void loadPackages() {
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());
Expand All @@ -293,7 +293,7 @@ public void testMultipleInheritance() {

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testUsingDefaultInterceptorThatAliasPropertiesAreCopied() throws Exc
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand All @@ -51,7 +51,7 @@ public void testPreResultListenersAreCalled() throws Exception {
}

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();
Expand Down Expand Up @@ -84,8 +84,6 @@ public void loadPackages() {

/**
* Tells whether the ConfigurationProvider should reload its configuration
*
* @return
*/
public boolean needsReload() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public void setUp() throws Exception{
}

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);
Expand Down
Loading

0 comments on commit a4abb34

Please sign in to comment.