Commits

Anonymous committed f6ce48e

Fixed unit tests failing due some OGNL changes. Also upgraded to surefire v2.3 otherwise not all unittests would be executed.

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/2.0@1403e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (2)

                 </configuration>
             </plugin>
             <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.3</version>
                 <configuration>
                     <includes>
                         <include>**/*Test.java</include>
                     </includes>
                     <excludes>
                         <exclude>**/XWorkTestCase.java</exclude>
+                        <exclude>**/TestBean.java</exclude>
+                        <exclude>**/TestBean2.java</exclude>
+                        <exclude>**/TestInterceptor.java</exclude>
+                        <exclude>**/AnnotatedTestBean.java</exclude>
                     </excludes>
                 </configuration>
             </plugin>

src/test/com/opensymphony/xwork2/util/OgnlValueStackTest.java

         try {
             vs.setValue("count", "1", true);
             fail("Expected an exception for mismatched getter and setter");
-        } catch (RuntimeException e) {
+        } catch (XWorkException e) {
             //expected
         }
 
         try {
             vs.setValue("count2", "a", true);
             fail("Expected an exception for mismatched getter and setter");
-        } catch (RuntimeException e) {
+        } catch (XWorkException e) {
             //expected
         }
     }
 
         try {
             vs.setValue("count", "1");
-        } catch (RuntimeException e) {
-            fail("Unexpected exception for mismatched getter and setter");
+            fail("Unexpected an exception for mismatched getter and setter");
+        } catch (XWorkException e) {
+            //expected
         }
 
         try {
             vs.setValue("count2", "a");
-        } catch (RuntimeException e) {
-            fail("Unexpected exception for mismatched getter and setter");
+            fail("Unexpected an exception for mismatched getter and setter");
+        } catch (XWorkException e) {
+            //expected
         }
     }
 
         OgnlValueStack stack = new OgnlValueStack();
         stack.getContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
         stack.push(action);
-        stack.setValue("bean", "foobar");
+        try {
+            stack.setValue("bean", "foobar");
+            fail("Should have thrown a type conversion exception");
+        } catch (XWorkException e) {
+            // expected
+        }
 
         Map conversionErrors = (Map) stack.getContext().get(ActionContext.CONVERSION_ERRORS);
         assertTrue(conversionErrors.containsKey("bean"));
         OgnlValueStack stack = new OgnlValueStack();
         stack.push(bean);
         stack.getContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
-        stack.setValue("count", "a");
+        try {
+            stack.setValue("count", "a");
+            fail("Should have thrown a type conversion exception");
+        } catch (XWorkException e) {
+            // expected
+        }
 
         Map conversionErrors = (Map) stack.getContext().get(ActionContext.CONVERSION_ERRORS);
         assertTrue(conversionErrors.containsKey("count"));