Title: [waffle-scm] [319] trunk: refactored test to JUnit 4 style

Diff

Modified: trunk/core/src/main/java/org/codehaus/waffle/action/AbstractMethodDefinitionFinder.java (318 => 319)

--- trunk/core/src/main/java/org/codehaus/waffle/action/AbstractMethodDefinitionFinder.java	2007-10-08 13:45:35 UTC (rev 318)
+++ trunk/core/src/main/java/org/codehaus/waffle/action/AbstractMethodDefinitionFinder.java	2007-10-09 14:51:34 UTC (rev 319)
@@ -169,7 +169,7 @@
                     methodDefinitions.add(buildMethodDefinition(request, response, method, arguments));
                 } catch ( NoValidActionMethodException e) {
                     // continue
-                }                 
+                }
             }
         }
     

Modified: trunk/core/src/test/java/org/codehaus/waffle/action/InterceptingActionMethodExecutorTest.java (318 => 319)

--- trunk/core/src/test/java/org/codehaus/waffle/action/InterceptingActionMethodExecutorTest.java	2007-10-08 13:45:35 UTC (rev 318)
+++ trunk/core/src/test/java/org/codehaus/waffle/action/InterceptingActionMethodExecutorTest.java	2007-10-09 14:51:34 UTC (rev 319)
@@ -14,23 +14,29 @@
 import org.codehaus.waffle.context.pico.PicoContextContainer;
 import org.codehaus.waffle.controller.ControllerDefinition;
 import org.codehaus.waffle.testmodel.FakeController;
-import org.jmock.MockObjectTestCase;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.picocontainer.defaults.DefaultPicoContainer;
 
 import java.lang.reflect.Method;
 
-public class InterceptingActionMethodExecutorTest extends MockObjectTestCase {
+public class InterceptingActionMethodExecutorTest {
     private ActionMethodExecutor actionMethodExecutor = new InterceptingActionMethodExecutor();
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         RequestLevelContainer.set(new PicoContextContainer(new DefaultPicoContainer()));
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         RequestLevelContainer.set(null);
     }
 
-    public void testMethodWithNoArgsFiredOnController() throws Exception {
+    @Test
+    public void executeShouldInvokeNoArgumentActionMethod() throws Exception {
         FakeController fakeController = new FakeController();
 
         MethodDefinition methodDefinition = new MethodDefinition(FakeController.class.getMethod("sayHello"));
@@ -38,11 +44,12 @@
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
 
-        assertNull(actionMethodResponse.getReturnValue());
-        assertEquals("hello", fakeController.getName());
+        Assert.assertNull(actionMethodResponse.getReturnValue());
+        Assert.assertEquals("hello", fakeController.getName());
     }
 
-    public void testFireWithArguments() throws Exception {
+    @Test
+    public void executeShouldInvokeActionMethodWithArgumentValue() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("sayHello", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -52,11 +59,12 @@
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
 
-        assertNull(actionMethodResponse.getReturnValue());
-        assertEquals("foobar", fakeController.getName());
+        Assert.assertNull(actionMethodResponse.getReturnValue());
+        Assert.assertEquals("foobar", fakeController.getName());
     }
 
-    public void testFireWhenArgumentValuesIsNull() throws Exception {
+    @Test
+    public void executeShouldHandleNullArgumentValues() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("sayHello", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -66,11 +74,12 @@
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
 
-        assertNull(actionMethodResponse.getReturnValue());
-        assertNull(fakeController.getName());
+        Assert.assertNull(actionMethodResponse.getReturnValue());
+        Assert.assertNull(fakeController.getName());
     }
 
-    public void testFireMethodWithReturnType() throws Exception {
+    @Test
+    public void executeShouldReturnValueFromActionMethod() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("passThruMethod", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -79,10 +88,11 @@
         ControllerDefinition controllerDefinition = new ControllerDefinition("FakeController", fakeController, methodDefinition);
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
-        assertEquals("mmmWaffles", actionMethodResponse.getReturnValue());
+        Assert.assertEquals("mmmWaffles", actionMethodResponse.getReturnValue());
     }
 
-    public void testExecuteShouldWrapCauseOfInvocationTargetExceptionAsActionMethodInvocationException() throws Exception {
+    @Test
+    public void executeShouldWrapCauseOfInvocationTargetExceptionAsActionMethodInvocationException() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("methodThrowsException", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -95,11 +105,12 @@
             actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
         } catch (ActionMethodInvocationException e) {
             Throwable rootCause = e.getCause();
-            assertEquals("mmmWaffles", rootCause.getMessage());
+            Assert.assertEquals("mmmWaffles", rootCause.getMessage());
         }
     }
 
-    public void testExecuteShouldReturnOriginalExceptionIfTypeIsActionMethodInvocationException() throws Exception {
+    @Test
+    public void executeShouldReturnOriginalExceptionIfTypeIsActionMethodInvocationException() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("actionThrowsActionMethodInvocationException", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -111,7 +122,7 @@
         try {
             actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
         } catch (ActionMethodInvocationException e) {
-            assertEquals("BEARS!", e.getMessage());
+            Assert.assertEquals("BEARS!", e.getMessage());
         }
     }
 

Modified: trunk/core/src/test/java/org/codehaus/waffle/action/intercept/MethodInterceptorComparatorTest.java (318 => 319)

--- trunk/core/src/test/java/org/codehaus/waffle/action/intercept/MethodInterceptorComparatorTest.java	2007-10-08 13:45:35 UTC (rev 318)
+++ trunk/core/src/test/java/org/codehaus/waffle/action/intercept/MethodInterceptorComparatorTest.java	2007-10-09 14:51:34 UTC (rev 319)
@@ -1,11 +1,8 @@
 package org.codehaus.waffle.action.intercept;
 
 import org.codehaus.waffle.controller.ControllerDefinition;
-import org.codehaus.waffle.action.intercept.MethodInterceptor;
-import org.codehaus.waffle.action.intercept.Sortable;
-import org.codehaus.waffle.action.intercept.InterceptorChain;
-import org.codehaus.waffle.action.intercept.MethodInterceptorComparator;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -13,9 +10,10 @@
 import java.util.Comparator;
 import java.util.List;
 
-public class MethodInterceptorComparatorTest extends TestCase {
+public class MethodInterceptorComparatorTest  {
 
-    public void testSortCollectionOfSortable() {
+    @Test
+    public void shouldSortCollectionOfSortable() {
         List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>();
 
         MethodInterceptor  SortableMethodInterceptor(1);
@@ -29,12 +27,13 @@
         Comparator<MethodInterceptor> comparator = new MethodInterceptorComparator();
         Collections.sort(interceptors, comparator);
 
-        assertSame(one, interceptors.get(0));
-        assertSame(two, interceptors.get(1));
-        assertSame(three, interceptors.get(2));
+        Assert.assertSame(one, interceptors.get(0));
+        Assert.assertSame(two, interceptors.get(1));
+        Assert.assertSame(three, interceptors.get(2));
     }
 
-    public void testSortCollectionWithNonSortable() {
+    @Test
+    public void shouldSortCollectionWithNonSortable() {
         List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>();
 
         MethodInterceptor  SortableMethodInterceptor(1);
@@ -50,10 +49,10 @@
         Comparator<MethodInterceptor> comparator = new MethodInterceptorComparator();
         Collections.sort(interceptors, comparator);
 
-        assertSame(one, interceptors.get(0));
-        assertSame(two, interceptors.get(1));
-        assertSame(three, interceptors.get(2));
-        assertSame(notSortable, interceptors.get(3));
+        Assert.assertSame(one, interceptors.get(0));
+        Assert.assertSame(two, interceptors.get(1));
+        Assert.assertSame(three, interceptors.get(2));
+        Assert.assertSame(notSortable, interceptors.get(3));
     }
 
     private static class SortableMethodInterceptor implements MethodInterceptor, Sortable {

Modified: trunk/waffle-parent.ipr (318 => 319)

--- trunk/waffle-parent.ipr	2007-10-08 13:45:35 UTC (rev 318)
+++ trunk/waffle-parent.ipr	2007-10-09 14:51:34 UTC (rev 319)
@@ -62,14 +62,6 @@
       <entry name="?*.tld" />
     </wildcardResourcePatterns>
   </component>
-  <component name="CompilerWorkspaceConfiguration">
-    <option name="COMPILE_IN_BACKGROUND" value="false" />
-    <option name="AUTO_SHOW_ERRORS_IN_EDITOR" value="true" />
-    <option name="CLOSE_MESSAGE_VIEW_IF_SUCCESS" value="true" />
-    <option name="COMPILE_DEPENDENT_FILES" value="false" />
-    <option name="CLEAR_OUTPUT_DIRECTORY" value="false" />
-    <option name="ASSERT_NOT_NULL" value="true" />
-  </component>
   <component name="CreatePatchCommitExecutor">
     <option name="PATCH_PATH" value="" />
     <option name="REVERSE_PATCH" value="false" />
@@ -206,6 +198,21 @@
               <file url="" />
             </files>
           </module>
+          <module name="waffle-simple-example">
+            <files>
+              <file url="" />
+            </files>
+          </module>
+          <module name="waffle-freemarker-example">
+            <files>
+              <file url="" />
+            </files>
+          </module>
+          <module name="waffle-paranamer-example">
+            <files>
+              <file url="" />
+            </files>
+          </module>
         </modules>
       </facet-type>
     </autodetection-disabled>
@@ -453,7 +460,7 @@
       <SplitterProportionsDataImpl />
     </option>
   </component>
-  <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="JRuby SDK 1.8.5" project-jdk-type="JRUBY_SDK">
+  <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.5" project-jdk-type="JavaSDK">
     <output url="" />
   </component>
   <component name="ProjectView">
@@ -482,9 +489,6 @@
     <RUBY_DOC NAME="DEFAULTS" VALUE="TRUE" />
     <RUBY_DOC NAME="NUMBER" VALUE="0" />
   </component>
-  <component name="ReadonlyStatusHandler">
-    <option name="SHOW_DIALOG" value="true" />
-  </component>
   <component name="ResourceManagerContainer">
     <option name="myResourceBundles">
       <value>
@@ -672,10 +676,6 @@
     </GetOptions>
   </component>
   <component name="WebServicesPlugin" addRequiredLibraries="true" />
-  <component name="antWorkspaceConfiguration">
-    <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
-    <option name="FILTER_TARGETS" value="false" />
-  </component>
   <component name="com.intellij.ide.util.scopeChooser.ScopeChooserConfigurable" proportions="" version="1">
     <option name="myLastEditedConfigurable" />
   </component>
@@ -693,10 +693,5 @@
   <component name="com.intellij.profile.ui.ErrorOptionsConfigurable" proportions="" version="1">
     <option name="myLastEditedConfigurable" />
   </component>
-  <component name="uidesigner-configuration">
-    <option name="INSTRUMENT_CLASSES" value="true" />
-    <option name="COPY_FORMS_RUNTIME_TO_OUTPUT" value="true" />
-    <option name="DEFAULT_LAYOUT_MANAGER" value="GridLayoutManager" />
-  </component>
 </project>
 


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to