
|
If you were logged in you would be able to see more operations.
|
|
|
|
Currently default-class-ref defined in parent packages sticks to actions despite having default-class-ref defined in sub packages. This is inconsistent behavior to how an default interceptor stacks and be redefined for child packages.
The current behavior also takes away a lot of flexibility that could be achieved via templating out abstract pattern packages.
Given a configuration & test that looks like:
<xwork>
....
<package name="Abstract-crud" extends="default">
<!-- edit is often used as the create/view -->
<default-class-ref class="com.opensymphony.xwork2.SimpleAction"/>
<action name="edit" >
<result name="input" type="mock">edit.vm</result>
<result name="success" type="mock">edit.vm</result>
<result name="error" type="mock">edit.vm</result>
</action>
<action name="save" >
<result name="input" type="mock">edit.vm</result>
<result name="success" type="chain">list</result>
<result name="error" type="mock">edit.vm</result>
<result name="cancel" type="mock">list.action</result>
</action>
<action name="list">
<result name="success" type="mock">list</result>
</action>
<action name="delete">
<result name="success" type="mock">list</result>
</action>
</package>
<package name="Example" extends="Abstract-crud" namespace="/example">
<default-class-ref class="com.opensymphony.xwork2.ModelDrivenAction" />
</package>
<package name="Example2" extends="Abstract-crud" namespace="/example2">
<default-class-ref class="com.opensymphony.xwork2.ModelDrivenAction" />
<action name="override">
<result name="success" type="mock">somethingelse.vm</result>
</action>
</package>
<package name="SubItem" extends="Abstract-crud" namespace="/example2/subItem">
<default-class-ref class="com.opensymphony.xwork2.ModelDrivenAction" />
</package>
<package name="Example3" extends="Abstract-crud" namespace="/example3">
<!-- default-class-ref is expected to be inherited -->
</package>
----
</xwork>
public void testDefaultClassDefEvaluation() throws Exception {
ActionProxy proxy = actionProxyFactory.createActionProxy("Abstract-crud", "edit", null);
System.out.println(proxy.getConfig().getClassName());
assertEquals("com.opensymphony.xwork2.SimpleAction", proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example", "edit", null);
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example2", "override", null);
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example2/subItem", "save", null);
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example2", "list", null);
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example3", "list", null);
assertEquals("com.opensymphony.xwork2.SimpleAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
}
The following test should print -->
com.opensymphony.xwork2.SimpleAction
com.opensymphony.xwork2.ModelDrivenAction
com.opensymphony.xwork2.ModelDrivenAction
com.opensymphony.xwork2.ModelDrivenAction
com.opensymphony.xwork2.ModelDrivenAction
com.opensymphony.xwork2.SimpleAction
However, currently xwork prints:
com.opensymphony.xwork2.SimpleAction (correct)
com.opensymphony.xwork2.SimpleAction (incorrect)
com.opensymphony.xwork2.ModelDrivenAction (correct)
com.opensymphony.xwork2.SimpleAction (incorrect)
com.opensymphony.xwork2.SimpleAction (incorrect)
com.opensymphony.xwork2.SimpleAction (correct)
|
|
Description
|
Currently default-class-ref defined in parent packages sticks to actions despite having default-class-ref defined in sub packages. This is inconsistent behavior to how an default interceptor stacks and be redefined for child packages.
The current behavior also takes away a lot of flexibility that could be achieved via templating out abstract pattern packages.
Given a configuration & test that looks like:
<xwork>
....
<package name="Abstract-crud" extends="default">
<!-- edit is often used as the create/view -->
<default-class-ref class="com.opensymphony.xwork2.SimpleAction"/>
<action name="edit" >
<result name="input" type="mock">edit.vm</result>
<result name="success" type="mock">edit.vm</result>
<result name="error" type="mock">edit.vm</result>
</action>
<action name="save" >
<result name="input" type="mock">edit.vm</result>
<result name="success" type="chain">list</result>
<result name="error" type="mock">edit.vm</result>
<result name="cancel" type="mock">list.action</result>
</action>
<action name="list">
<result name="success" type="mock">list</result>
</action>
<action name="delete">
<result name="success" type="mock">list</result>
</action>
</package>
<package name="Example" extends="Abstract-crud" namespace="/example">
<default-class-ref class="com.opensymphony.xwork2.ModelDrivenAction" />
</package>
<package name="Example2" extends="Abstract-crud" namespace="/example2">
<default-class-ref class="com.opensymphony.xwork2.ModelDrivenAction" />
<action name="override">
<result name="success" type="mock">somethingelse.vm</result>
</action>
</package>
<package name="SubItem" extends="Abstract-crud" namespace="/example2/subItem">
<default-class-ref class="com.opensymphony.xwork2.ModelDrivenAction" />
</package>
<package name="Example3" extends="Abstract-crud" namespace="/example3">
<!-- default-class-ref is expected to be inherited -->
</package>
----
</xwork>
public void testDefaultClassDefEvaluation() throws Exception {
ActionProxy proxy = actionProxyFactory.createActionProxy("Abstract-crud", "edit", null);
System.out.println(proxy.getConfig().getClassName());
assertEquals("com.opensymphony.xwork2.SimpleAction", proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example", "edit", null);
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example2", "override", null);
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example2/subItem", "save", null);
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example2", "list", null);
assertEquals("com.opensymphony.xwork2.ModelDrivenAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
proxy = actionProxyFactory.createActionProxy("/example3", "list", null);
assertEquals("com.opensymphony.xwork2.SimpleAction", proxy.getConfig().getClassName());
System.out.println(proxy.getConfig().getClassName());
}
The following test should print -->
com.opensymphony.xwork2.SimpleAction
com.opensymphony.xwork2.ModelDrivenAction
com.opensymphony.xwork2.ModelDrivenAction
com.opensymphony.xwork2.ModelDrivenAction
com.opensymphony.xwork2.ModelDrivenAction
com.opensymphony.xwork2.SimpleAction
However, currently xwork prints:
com.opensymphony.xwork2.SimpleAction (correct)
com.opensymphony.xwork2.SimpleAction (incorrect)
com.opensymphony.xwork2.ModelDrivenAction (correct)
com.opensymphony.xwork2.SimpleAction (incorrect)
com.opensymphony.xwork2.SimpleAction (incorrect)
com.opensymphony.xwork2.SimpleAction (correct)
|
Show » |
|
Adds test defs to xwork-sample.xml and creates DefaultClassTest.java