Author: germuska
Date: Fri Apr 15 12:22:47 2005
New Revision: 161516
URL: http://svn.apache.org/viewcvs?view=rev&rev=161516
Log:
add a test for the default "toKey" value; adjust a few meaningless (although
still successful) pre-assertions to be more meaningful.
Modified:
struts/core/trunk/src/test/org/apache/struts/chain/commands/generic/TestCopyFormToContext.java
Modified:
struts/core/trunk/src/test/org/apache/struts/chain/commands/generic/TestCopyFormToContext.java
URL:
http://svn.apache.org/viewcvs/struts/core/trunk/src/test/org/apache/struts/chain/commands/generic/TestCopyFormToContext.java?view=diff&r1=161515&r2=161516
==============================================================================
---
struts/core/trunk/src/test/org/apache/struts/chain/commands/generic/TestCopyFormToContext.java
(original)
+++
struts/core/trunk/src/test/org/apache/struts/chain/commands/generic/TestCopyFormToContext.java
Fri Apr 15 12:22:47 2005
@@ -82,8 +82,8 @@
command.setToKey(POST_EXECUTION_CONTEXT_KEY);
assertNull(context.get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getRequestScope().get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getSessionScope().get(POST_EXECUTION_CONTEXT_KEY));
+ assertNull(context.getRequestScope().get(formName));
+ assertNull(context.getSessionScope().get(formName));
command.execute(context);
@@ -100,15 +100,15 @@
CopyFormToContext command = new CopyFormToContext();
command.setActionPath("/Test");
command.setToKey(POST_EXECUTION_CONTEXT_KEY);
+ String formName = "foo"; // we know this, even though it's not being
used for the lookup.
assertNull(context.get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getRequestScope().get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getSessionScope().get(POST_EXECUTION_CONTEXT_KEY));
+ assertNull(context.getRequestScope().get(formName));
+ assertNull(context.getSessionScope().get(formName));
command.execute(context);
assertNotNull(context.get(POST_EXECUTION_CONTEXT_KEY));
- String formName = "foo";
assertNotNull(context.getRequestScope().get(formName));
assertNull(context.getSessionScope().get(formName));
@@ -125,8 +125,8 @@
command.setToKey(POST_EXECUTION_CONTEXT_KEY);
assertNull(context.get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getRequestScope().get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getSessionScope().get(POST_EXECUTION_CONTEXT_KEY));
+ assertNull(context.getRequestScope().get(formName));
+ assertNull(context.getSessionScope().get(formName));
command.execute(context);
@@ -151,8 +151,8 @@
command.setToKey(POST_EXECUTION_CONTEXT_KEY);
assertNull(context.get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getRequestScope().get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getSessionScope().get(POST_EXECUTION_CONTEXT_KEY));
+ assertNull(context.getRequestScope().get(formName));
+ assertNull(context.getSessionScope().get(formName));
try {
command.execute(context);
@@ -173,8 +173,8 @@
// command.setToKey(POST_EXECUTION_CONTEXT_KEY);
assertNull(context.get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getRequestScope().get(POST_EXECUTION_CONTEXT_KEY));
- assertNull(context.getSessionScope().get(POST_EXECUTION_CONTEXT_KEY));
+ assertNull(context.getRequestScope().get(formName));
+ assertNull(context.getSessionScope().get(formName));
try {
command.execute(context);
@@ -183,8 +183,30 @@
; // expected.
}
+
}
+ public void testCopyToDefaultContextKey() throws Exception {
+ CopyFormToContext command = new CopyFormToContext();
+ String formName = "foo";
+ command.setFormName(formName);
+ command.setScope("request");
+
+ assertNull(context.getActionForm());
+ assertNull(context.getRequestScope().get(POST_EXECUTION_CONTEXT_KEY));
+ assertNull(context.getSessionScope().get(POST_EXECUTION_CONTEXT_KEY));
+
+ command.execute(context);
+
+ assertNotNull(context.getActionForm());
+ assertNotNull(context.getRequestScope().get(formName));
+ assertNull(context.getSessionScope().get(formName));
+
+ assertSame(context.getActionForm(),
context.getRequestScope().get(formName));
+ ActionForm theForm = (ActionForm) context.getActionForm();
+ assertTrue(theForm instanceof MockFormBean);
+
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]