mirror of
https://github.com/apache/struts.git
synced 2026-08-06 07:06:58 +00:00
WW-1349 Add configuration test; reorder action elements.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@438331 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
struts.objectFactory = spring
|
||||
struts.devMode = true
|
||||
struts.custom.i18n.resources = resources
|
||||
struts.enable.DynamicMethodInvocation = false
|
||||
|
||||
@@ -28,14 +28,18 @@
|
||||
|
||||
<action name="subscription/Save" class="mailreader2.subscription.Save">
|
||||
<result name="input">/pages/subscription.jsp</result>
|
||||
<result type="redirect-action">registration/vInput</result>
|
||||
<result type="redirect-action">registration/+Input</result>
|
||||
</action>
|
||||
|
||||
<!-- display actions: Welcome, Logoff, MainMenu -->
|
||||
|
||||
<action name="*" class="mailreader2.{1}">
|
||||
<result>/pages/{1}.jsp</result>
|
||||
</action>
|
||||
|
||||
<!-- prepare actions: Confirm/Delete, Edit, Input -->
|
||||
<!-- A "!" might be a better convention,
|
||||
but that doesn't seem to work with a button -->
|
||||
|
||||
<action name="*/v*" class="mailreader2.{1}.{2}">
|
||||
<action name="*/+*" class="mailreader2.{1}.{2}">
|
||||
<result>/pages/{1}.jsp</result>
|
||||
</action>
|
||||
|
||||
@@ -45,28 +49,6 @@
|
||||
<result name="input">/pages/{1}.jsp</result>
|
||||
</action>
|
||||
|
||||
<!-- Why doen't these match * -->
|
||||
<!-- It seems to be concaternating a period to the token -->
|
||||
<!-- Unable to instantiate Action, mailreader2.Welcome.,
|
||||
defined for 'Welcome' in namespace '/'mailreader2.Welcome. -->
|
||||
<action name="Logoff" class="mailreader2.Logoff">
|
||||
<result>/pages/Logoff.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="MainMenu" class="mailreader2.MainMenu">
|
||||
<result>/pages/MainMenu.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="Welcome" class="mailreader2.Welcome">
|
||||
<result>/pages/Welcome.jsp</result>
|
||||
</action>
|
||||
|
||||
<!-- display actions: Welcome, Logoff, MainMenu -->
|
||||
|
||||
<action name="*" class="mailreader2.{1}">
|
||||
<result>/pages/{1}.jsp</result>
|
||||
</action>
|
||||
|
||||
</package>
|
||||
</package>
|
||||
|
||||
</struts>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
value="user.fullName"/></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<s:url id="Input" action="registration/vInput" />
|
||||
<s:url id="Input" action="registration/+Input" />
|
||||
<s:a href="%{Input}">
|
||||
<s:text name="mainMenu.registration"/>
|
||||
</s:a>
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<s:url id="registration" action="registration/vInput" />
|
||||
<s:url id="registration" action="registration/+Input" />
|
||||
<s:a href="%{registration}"><s:text name="index.registration"/></s:a>
|
||||
</li>
|
||||
<li>
|
||||
<s:url id="logon" action="logon/vInput"/>
|
||||
<s:url id="logon" action="logon/+Input"/>
|
||||
<s:a href="%{logon}"><s:text name="index.logon"/></s:a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -100,14 +100,14 @@
|
||||
<s:property value="autoConnect"/>
|
||||
</td>
|
||||
<td align="center">
|
||||
<s:url id="Delete" action="subscription/vDelete" >
|
||||
<s:url id="Delete" action="subscription/+Delete" >
|
||||
<s:param name="host" value="host"/>
|
||||
</s:url>
|
||||
<s:a href="%{Delete}">
|
||||
<s:text name="registration.deleteSubscription"/>
|
||||
</s:a>
|
||||
|
||||
<s:url id="Edit" action="subscription/vEdit">
|
||||
<s:url id="Edit" action="subscription/+Edit">
|
||||
<s:param name="host" value="host"/>
|
||||
</s:url>
|
||||
<s:a href="%{Edit}">
|
||||
@@ -119,7 +119,7 @@
|
||||
|
||||
</table>
|
||||
|
||||
<s:url id="Input" action="subscription/vInput" />
|
||||
<s:url id="Input" action="subscription/+Input" />
|
||||
<s:a href="%{Input}"><s:text name="registration.addSubscription"/></s:a>
|
||||
|
||||
</s:if>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<s:reset value="%{getText('button.reset')}"/>
|
||||
</s:else>
|
||||
|
||||
<s:submit action="registration/vInput"
|
||||
<s:submit action="registration/+Input"
|
||||
value="%{getText('button.cancel')}"
|
||||
onclick="form.onsubmit=null"/>
|
||||
</s:form>
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package mailreader2;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.config.RuntimeConfiguration;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfigTest extends XWorkTestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
XmlConfigurationProvider c = new XmlConfigurationProvider("struts.xml");
|
||||
configurationManager.addConfigurationProvider(c);
|
||||
configurationManager.reload();
|
||||
}
|
||||
|
||||
private ActionConfig assertClass(String action_name, String class_name) {
|
||||
RuntimeConfiguration configuration = configurationManager.getConfiguration().getRuntimeConfiguration();
|
||||
ActionConfig config = configuration.getActionConfig("", action_name);
|
||||
assertNotNull(config);
|
||||
assertTrue("Wrong class name: [" + config.getClassName() + "]",
|
||||
class_name.equals(config.getClassName()));
|
||||
return config;
|
||||
}
|
||||
|
||||
private void assertResult(ActionConfig config, String result_name, String result_value) {
|
||||
Map results = config.getResults();
|
||||
ResultConfig result = (ResultConfig) results.get(result_name);
|
||||
Map params = result.getParams();
|
||||
String value = (String) params.get("actionName");
|
||||
if (value==null)
|
||||
value = (String) params.get("location");
|
||||
assertTrue("Wrong result value: [" + value + "]",
|
||||
result_value.equals(value));
|
||||
}
|
||||
|
||||
public void testSubscriptionSave() throws Exception {
|
||||
ActionConfig config = assertClass("subscription/Save", "mailreader2.subscription.Save");
|
||||
assertResult(config, ActionSupport.SUCCESS, "registration/+Input");
|
||||
assertResult(config, ActionSupport.INPUT, "/pages/subscription.jsp");
|
||||
}
|
||||
|
||||
// */!*
|
||||
public void testPrepareWildcard() throws Exception {
|
||||
ActionConfig config = assertClass("logon/+Input", "mailreader2.logon.Input");
|
||||
assertResult(config, ActionSupport.SUCCESS, "/pages/logon.jsp");
|
||||
}
|
||||
|
||||
// */*
|
||||
public void testExecuteWildcard() throws Exception {
|
||||
ActionConfig config = assertClass("registration/Update", "mailreader2.registration.Update");
|
||||
assertResult(config, ActionSupport.INPUT, "/pages/registration.jsp");
|
||||
ActionConfig config2 = assertClass("logon/Retrieve", "mailreader2.logon.Retrieve");
|
||||
assertResult(config2, ActionSupport.INPUT, "/pages/logon.jsp");
|
||||
}
|
||||
|
||||
// single wildcard
|
||||
public void testDisplayWildcard() throws Exception {
|
||||
assertClass("Welcome", "mailreader2.Welcome");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user