Title: [waffle-scm] [352] trunk/core/src/main/java/org/codehaus/waffle: Renamed ActionMonitor instances and parameters names to actionMonitor render more explicit the nature of the monitor.

Diff

Modified: trunk/core/src/main/java/org/codehaus/waffle/ComponentRegistry.java (351 => 352)

--- trunk/core/src/main/java/org/codehaus/waffle/ComponentRegistry.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/main/java/org/codehaus/waffle/ComponentRegistry.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -45,12 +45,20 @@
 
     ActionMethodResponseHandler getActionMethodResponseHandler();
 
+    ArgumentResolver getArgumentResolver();
+
+    MethodDefinitionFinder getMethodDefinitionFinder();
+
+    MethodNameResolver getMethodNameResolver();
+
     ActionMonitor getActionMonitor();
 
-    ArgumentResolver getArgumentResolver();
-
     BindErrorMessageResolver getBindErrorMessageResolver();
 
+    DataBinder getDataBinder();
+
+    RequestAttributeBinder getRequestAttributeBinder();
+
     BindMonitor getBindMonitor();
 
     ContextContainerFactory getContextContainerFactory();
@@ -59,16 +67,8 @@
 
     ControllerDefinitionFactory getControllerDefinitionFactory();
 
-    DataBinder getDataBinder();
-
     MessageResources getMessageResources();
 
-    MethodDefinitionFinder getMethodDefinitionFinder();
-
-    MethodNameResolver getMethodNameResolver();
-
-    RequestAttributeBinder getRequestAttributeBinder();
-
     TypeConverter getTypeConverter();
 
     Validator getValidator();

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

--- trunk/core/src/main/java/org/codehaus/waffle/action/AbstractMethodDefinitionFinder.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/main/java/org/codehaus/waffle/action/AbstractMethodDefinitionFinder.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -50,18 +50,18 @@
     private final ArgumentResolver argumentResolver;
     private final TypeConverter typeConverter;
     private final MethodNameResolver methodNameResolver;
-    private final ActionMonitor monitor;
+    private final ActionMonitor actionMonitor;
 
     public AbstractMethodDefinitionFinder(ServletContext servletContext,
                                           ArgumentResolver argumentResolver,
                                           TypeConverter typeConverter,
                                           MethodNameResolver methodNameResolver, 
-                                          ActionMonitor monitor) {
+                                          ActionMonitor actionMonitor) {
         this.servletContext = servletContext;
         this.argumentResolver = argumentResolver;
         this.typeConverter = typeConverter;
         this.methodNameResolver = methodNameResolver;
-        this.monitor = monitor;
+        this.actionMonitor = actionMonitor;
     }
 
     public MethodDefinition find(Object controller,
@@ -91,7 +91,7 @@
 
         if (defaultMethodCache.containsKey(controllerType)) { // cache hit
             MethodDefinition methodDefinition = buildDefaultMethodDefinition(defaultMethodCache.get(controllerType), request);
-            monitor.defaultActionMethodCached(controllerType, methodDefinition);
+            actionMonitor.defaultActionMethodCached(controllerType, methodDefinition);
             return methodDefinition;
         }
 
@@ -105,7 +105,7 @@
         }
         
         if ( methodDefinition != null ){
-            monitor.defaultActionMethodFound(methodDefinition);
+            actionMonitor.defaultActionMethodFound(methodDefinition);
             return methodDefinition;
         }
         throw new NoDefaultActionMethodException(controllerType.getName());
@@ -122,7 +122,7 @@
 
         List<Object> arguments = resolveArguments(request, iterator);
         MethodDefinition methodDefinition = findPragmaticMethodDefinition(request, response, methods, arguments);
-        monitor.pragmaticActionMethodFound(methodDefinition);
+        actionMonitor.pragmaticActionMethodFound(methodDefinition);
         return methodDefinition;
     }
 
@@ -138,7 +138,7 @@
         }
 
         MethodDefinition methodDefinition = methodDefinitions.get(0);
-        monitor.actionMethodFound(methodDefinition);
+        actionMonitor.actionMethodFound(methodDefinition);
         return methodDefinition;
     }
 

Modified: trunk/core/src/main/java/org/codehaus/waffle/action/AnnotatedMethodDefinitionFinder.java (351 => 352)

--- trunk/core/src/main/java/org/codehaus/waffle/action/AnnotatedMethodDefinitionFinder.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/main/java/org/codehaus/waffle/action/AnnotatedMethodDefinitionFinder.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -38,8 +38,8 @@
                                            ArgumentResolver argumentResolver,
                                            TypeConverter typeConverter,
                                            MethodNameResolver methodNameResolver, 
-                                           ActionMonitor monitor) {
-        super(servletContext, argumentResolver, typeConverter, methodNameResolver, monitor);
+                                           ActionMonitor actionMonitor) {
+        super(servletContext, argumentResolver, typeConverter, methodNameResolver, actionMonitor);
     }
 
     protected List<Object> getArguments(Method method, HttpServletRequest request) {

Modified: trunk/core/src/main/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandler.java (351 => 352)

--- trunk/core/src/main/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandler.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/main/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandler.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -32,18 +32,18 @@
  */
 public class DefaultActionMethodResponseHandler implements ActionMethodResponseHandler {
     private final ViewDispatcher viewDispatcher;
-    private final ActionMonitor monitor;
+    private final ActionMonitor actionMonitor;
 
-    public DefaultActionMethodResponseHandler(ViewDispatcher viewDispatcher, ActionMonitor monitor) {
+    public DefaultActionMethodResponseHandler(ViewDispatcher viewDispatcher, ActionMonitor actionMonitor) {
         if (viewDispatcher == null) {
             throw new IllegalArgumentException("ViewDispatcher cannot be null");
         }
-        if (monitor == null) {
+        if (actionMonitor == null) {
             throw new IllegalArgumentException("ActionMonitor cannot be null");
         }
 
         this.viewDispatcher = viewDispatcher;
-        this.monitor = monitor;
+        this.actionMonitor = actionMonitor;
     }
 
     public void handle(HttpServletRequest request,
@@ -60,7 +60,8 @@
             viewDispatcher.dispatch(request, response, view);
         } else if (returnValue instanceof ActionMethodException) {
             ActionMethodException exception = (ActionMethodException) returnValue;
-            monitor.actionMethodExecutionFailed(exception); // todo ... this isn't really necessarily a true failure
+            actionMonitor.actionMethodExecutionFailed(exception); 
+            // todo ... this isn't really necessarily a true failure
             response.setStatus(exception.getStatusCode());
             handleResponse(response, exception.getMessage());
         } else {

Modified: trunk/core/src/main/java/org/codehaus/waffle/action/HierarchicalArgumentResolver.java (351 => 352)

--- trunk/core/src/main/java/org/codehaus/waffle/action/HierarchicalArgumentResolver.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/main/java/org/codehaus/waffle/action/HierarchicalArgumentResolver.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -26,6 +26,8 @@
  * 4. Application attribute
  *
  * else returns null
+ * 
+ * @author Micheal Ward
  */
 public class HierarchicalArgumentResolver implements ArgumentResolver {
     private final Pattern pattern = Pattern.compile("\\{(\\w+)\\}");

Modified: trunk/core/src/main/java/org/codehaus/waffle/action/ParanamerMethodDefinitionFinder.java (351 => 352)

--- trunk/core/src/main/java/org/codehaus/waffle/action/ParanamerMethodDefinitionFinder.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/main/java/org/codehaus/waffle/action/ParanamerMethodDefinitionFinder.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -43,8 +43,8 @@
                                            ArgumentResolver argumentResolver,
                                            TypeConverter typeConverter,
                                            MethodNameResolver methodNameResolver, 
-                                           ActionMonitor monitor) {
-        super(servletContext, argumentResolver, typeConverter, methodNameResolver, monitor);
+                                           ActionMonitor actionMonitor) {
+        super(servletContext, argumentResolver, typeConverter, methodNameResolver, actionMonitor);
     }
 
     protected List<Object> getArguments(Method method, HttpServletRequest request) {

Modified: trunk/core/src/main/java/org/codehaus/waffle/action/RequestParameterMethodNameResolver.java (351 => 352)

--- trunk/core/src/main/java/org/codehaus/waffle/action/RequestParameterMethodNameResolver.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/main/java/org/codehaus/waffle/action/RequestParameterMethodNameResolver.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -25,21 +25,21 @@
  */
 public class RequestParameterMethodNameResolver implements MethodNameResolver {
     private String methodParameterKey = "method";
-    private ActionMonitor monitor;
+    private ActionMonitor actionMonitor;
 
-    public RequestParameterMethodNameResolver(ActionMonitor monitor) {
-        this.monitor = monitor;
+    public RequestParameterMethodNameResolver(ActionMonitor actionMonitor) {
+        this.actionMonitor = actionMonitor;
     }
 
-    public RequestParameterMethodNameResolver(RequestParameterMethodNameResolverConfig configuration, ActionMonitor monitor) {
+    public RequestParameterMethodNameResolver(RequestParameterMethodNameResolverConfig configuration, ActionMonitor actionMonitor) {
         this.methodParameterKey = configuration.getMethodParameterKey();
-        this.monitor = monitor;
+        this.actionMonitor = actionMonitor;
     }
 
     @SuppressWarnings({"unchecked"})
     public String resolve(HttpServletRequest request) {
         String methodName = request.getParameter(methodParameterKey);
-        monitor.methodNameResolved(methodName, methodParameterKey, request.getParameterMap().keySet());
+        actionMonitor.methodNameResolved(methodName, methodParameterKey, request.getParameterMap().keySet());
         return methodName;
     }
 }

Modified: trunk/core/src/test/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandlerTest.java (351 => 352)

--- trunk/core/src/test/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandlerTest.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/test/java/org/codehaus/waffle/action/DefaultActionMethodResponseHandlerTest.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -1,5 +1,14 @@
 package org.codehaus.waffle.action;
 
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.codehaus.waffle.monitor.ActionMonitor;
 import org.codehaus.waffle.testmodel.StubMonitor;
 import org.codehaus.waffle.testmodel.StubViewDispatcher;
@@ -8,23 +17,16 @@
 import org.jmock.Expectations;
 import org.jmock.Mockery;
 import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
 @RunWith(JMock.class)
 public class DefaultActionMethodResponseHandlerTest {
-    private final Mockery context = new JUnit4Mockery();
+    private final Mockery mockery = new Mockery();
 
     @Test
-    public void constructorShouldsNotAcceptNulls() {
+    public void cannotAcceptNullsInConstructor() {
         try {
             new DefaultActionMethodResponseHandler(null, null);
             Assert.fail("IllegalArgumentException expected, null is not a valid argument");
@@ -46,53 +48,53 @@
     }
 
     @Test
-    public void executeShouldNotProcessResponseValueWhenResponseHasBeenCommitted() throws Exception {
-        final HttpServletResponse response = context.mock(HttpServletResponse.class);
-        context.checking(new Expectations() {{
+    public void canAvoidProcessingResponseValueWhenResponseHasBeenCommitted() throws Exception {
+        final HttpServletResponse response = mockery.mock(HttpServletResponse.class);
+        mockery.checking(new Expectations() {{
             one (response).isCommitted();
             will(returnValue(true));
         }});
 
-        ViewDispatcher viewDispatcher = context.mock(ViewDispatcher.class);
-        ActionMonitor actionMonitor = context.mock(ActionMonitor.class);
+        ViewDispatcher viewDispatcher = mockery.mock(ViewDispatcher.class);
+        ActionMonitor actionMonitor = mockery.mock(ActionMonitor.class);
 
         ActionMethodResponseHandler handler = new DefaultActionMethodResponseHandler(viewDispatcher, actionMonitor);
         handler.handle(null, response, null);
     }
 
     @Test
-    public void responseValueOfTypeViewShouldBeDelegatedToViewDispatcher() throws IOException, ServletException {
+    public void canDelegateResponseValueOfTypeViewToDispatcher() throws IOException, ServletException {
         final View view = new View("foobar", null);
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodResponse.setReturnValue(view);
 
-        final HttpServletResponse response = context.mock(HttpServletResponse.class);
-        context.checking(new Expectations() {{
+        final HttpServletResponse response = mockery.mock(HttpServletResponse.class);
+        mockery.checking(new Expectations() {{
             one (response).isCommitted();
             will(returnValue(false));
         }});
 
-        final HttpServletRequest request = context.mock(HttpServletRequest.class);
-        final ViewDispatcher viewDispatcher = context.mock(ViewDispatcher.class);
-        context.checking(new Expectations() {{
+        final HttpServletRequest request = mockery.mock(HttpServletRequest.class);
+        final ViewDispatcher viewDispatcher = mockery.mock(ViewDispatcher.class);
+        mockery.checking(new Expectations() {{
             one (viewDispatcher).dispatch(request, response, view);
         }});
 
-        ActionMonitor actionMonitor = context.mock(ActionMonitor.class);
+        ActionMonitor actionMonitor = mockery.mock(ActionMonitor.class);
 
         ActionMethodResponseHandler handler = new DefaultActionMethodResponseHandler(viewDispatcher, actionMonitor);
         handler.handle(request, response, actionMethodResponse);
     }
 
     @Test
-    public void responseValueShouldBeWrittenToOutputStream() throws Exception {
+    public void canWriteResponseValueToOutputStream() throws Exception {
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodResponse.setReturnValue("Mmmmm Waffles!");
 
         final StubServletOutputStream out = new StubServletOutputStream();
 
-        final HttpServletResponse response = context.mock(HttpServletResponse.class);
-        context.checking(new Expectations() {{
+        final HttpServletResponse response = mockery.mock(HttpServletResponse.class);
+        mockery.checking(new Expectations() {{
             one (response).isCommitted();
             will(returnValue(false));
             one(response).getOutputStream();
@@ -100,28 +102,27 @@
             one(response).flushBuffer();
         }});
 
-        HttpServletRequest request = context.mock(HttpServletRequest.class);
-        ViewDispatcher viewDispatcher = context.mock(ViewDispatcher.class);
-        ActionMonitor actionMonitor = context.mock(ActionMonitor.class);
+        HttpServletRequest request = mockery.mock(HttpServletRequest.class);
+        ViewDispatcher viewDispatcher = mockery.mock(ViewDispatcher.class);
+        ActionMonitor actionMonitor = mockery.mock(ActionMonitor.class);
 
         ActionMethodResponseHandler handler = new DefaultActionMethodResponseHandler(viewDispatcher, actionMonitor);
         handler.handle(request, response, actionMethodResponse);
 
-        Assert.assertEquals("Mmmmm Waffles!", out.buffer.toString());
+        assertEquals("Mmmmm Waffles!", out.buffer.toString());
     }
 
-    @SuppressWarnings({"ThrowableInstanceNeverThrown"})
     @Test
-    public void responseValueOfTypeActionMethodExceptionShouldSetResponseCorrectly() throws IOException, ServletException {
+    public void canHandleValueOfTypeActionMethodException() throws IOException, ServletException {
         final Exception exception = new ActionMethodException(1985, "my message");
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodResponse.setReturnValue(exception);
         final StubServletOutputStream out = new StubServletOutputStream();
 
-        HttpServletRequest request = context.mock(HttpServletRequest.class);
+        HttpServletRequest request = mockery.mock(HttpServletRequest.class);
 
-        final HttpServletResponse response = context.mock(HttpServletResponse.class);
-        context.checking(new Expectations() {{
+        final HttpServletResponse response = mockery.mock(HttpServletResponse.class);
+        mockery.checking(new Expectations() {{
             one (response).isCommitted();
             will(returnValue(false));
             one(response).setStatus(1985);
@@ -130,9 +131,9 @@
             one(response).flushBuffer();
         }});
 
-        ViewDispatcher viewDispatcher = context.mock(ViewDispatcher.class);
-        final ActionMonitor actionMonitor = context.mock(ActionMonitor.class);
-        context.checking(new Expectations() {{
+        ViewDispatcher viewDispatcher = mockery.mock(ViewDispatcher.class);
+        final ActionMonitor actionMonitor = mockery.mock(ActionMonitor.class);
+        mockery.checking(new Expectations() {{
             one (actionMonitor).actionMethodExecutionFailed(exception);
         }});
 
@@ -140,7 +141,7 @@
         ActionMethodResponseHandler handler = new DefaultActionMethodResponseHandler(viewDispatcher, actionMonitor);
         handler.handle(request, response, actionMethodResponse);
 
-        Assert.assertEquals("my message", out.buffer.toString());
+        assertEquals("my message", out.buffer.toString());
     }
 
     private class StubServletOutputStream extends ServletOutputStream {

Modified: trunk/core/src/test/java/org/codehaus/waffle/action/HierarchicalArgumentResolverTest.java (351 => 352)

--- trunk/core/src/test/java/org/codehaus/waffle/action/HierarchicalArgumentResolverTest.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/test/java/org/codehaus/waffle/action/HierarchicalArgumentResolverTest.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -23,7 +23,7 @@
     private Mockery mockery = new Mockery();
 
     @Test
-    public void testResolveReturnsNameWhenArgumentNotInCurlyBrackets() {
+    public void canResolveNameWhenArgumentNotInCurlyBrackets() {
         ArgumentResolver argumentResolver = new HierarchicalArgumentResolver(null);
         assertEquals("foobar", argumentResolver.resolve(null, "foobar"));
     }

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

--- trunk/core/src/test/java/org/codehaus/waffle/action/InterceptingActionMethodExecutorTest.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/test/java/org/codehaus/waffle/action/InterceptingActionMethodExecutorTest.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -10,6 +10,10 @@
  *****************************************************************************/
 package org.codehaus.waffle.action;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import org.codehaus.waffle.context.RequestLevelContainer;
 import org.codehaus.waffle.context.pico.PicoContextContainer;
 import org.codehaus.waffle.controller.ControllerDefinition;
@@ -36,7 +40,7 @@
     }
 
     @Test
-    public void executeShouldInvokeNoArgumentActionMethod() throws Exception {
+    public void canInvokeNoArgumentActionMethod() throws Exception {
         FakeController fakeController = new FakeController();
 
         MethodDefinition methodDefinition = new MethodDefinition(FakeController.class.getMethod("sayHello"));
@@ -49,7 +53,7 @@
     }
 
     @Test
-    public void executeShouldInvokeActionMethodWithArgumentValue() throws Exception {
+    public void canInvokeActionMethodWithArgumentValue() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("sayHello", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -59,12 +63,12 @@
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
 
-        Assert.assertNull(actionMethodResponse.getReturnValue());
-        Assert.assertEquals("foobar", fakeController.getName());
+        assertNull(actionMethodResponse.getReturnValue());
+        assertEquals("foobar", fakeController.getName());
     }
 
     @Test
-    public void executeShouldHandleNullArgumentValues() throws Exception {
+    public void canHandleNullArgumentValues() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("sayHello", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -74,12 +78,12 @@
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
 
-        Assert.assertNull(actionMethodResponse.getReturnValue());
-        Assert.assertNull(fakeController.getName());
+        assertNull(actionMethodResponse.getReturnValue());
+        assertNull(fakeController.getName());
     }
 
     @Test
-    public void executeShouldReturnValueFromActionMethod() throws Exception {
+    public void canReturnValueFromActionMethod() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("passThruMethod", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -88,11 +92,11 @@
         ControllerDefinition controllerDefinition = new ControllerDefinition("FakeController", fakeController, methodDefinition);
         ActionMethodResponse actionMethodResponse = new ActionMethodResponse();
         actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
-        Assert.assertEquals("mmmWaffles", actionMethodResponse.getReturnValue());
+        assertEquals("mmmWaffles", actionMethodResponse.getReturnValue());
     }
 
     @Test
-    public void executeShouldWrapCauseOfInvocationTargetExceptionAsActionMethodInvocationException() throws Exception {
+    public void canWrapCauseOfInvocationTargetExceptionAsActionMethodInvocationException() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("methodThrowsException", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -105,12 +109,12 @@
             actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
         } catch (ActionMethodInvocationException e) {
             Throwable rootCause = e.getCause();
-            Assert.assertEquals("mmmWaffles", rootCause.getMessage());
+            assertEquals("mmmWaffles", rootCause.getMessage());
         }
     }
 
     @Test
-    public void executeShouldReturnOriginalExceptionIfTypeIsActionMethodInvocationException() throws Exception {
+    public void canReturnOriginalExceptionIfTypeIsActionMethodInvocationException() throws Exception {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("actionThrowsActionMethodInvocationException", String.class);
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -122,12 +126,12 @@
         try {
             actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
         } catch (ActionMethodInvocationException e) {
-            Assert.assertEquals("BEARS!", e.getMessage());
+            assertEquals("BEARS!", e.getMessage());
         }
     }
 
     @Test
-    public void shouldSetActionResponseValueToExceptionIfTypeIsActionMethodException() throws NoSuchMethodException {
+    public void canSetActionResponseValueToExceptionIfTypeIsActionMethodException() throws NoSuchMethodException {
         FakeController fakeController = new FakeController();
         Method method = FakeController.class.getMethod("actionThrowsActionMethodException");
         MethodDefinition methodDefinition = new MethodDefinition(method);
@@ -137,7 +141,7 @@
 
         actionMethodExecutor.execute(actionMethodResponse, controllerDefinition);
 
-        Assert.assertTrue(actionMethodResponse.getReturnValue() instanceof ActionMethodException);
+        assertTrue(actionMethodResponse.getReturnValue() instanceof ActionMethodException);
     }
 
 }

Modified: trunk/core/src/test/java/org/codehaus/waffle/action/intercept/InterceptorChainImplTest.java (351 => 352)

--- trunk/core/src/test/java/org/codehaus/waffle/action/intercept/InterceptorChainImplTest.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/test/java/org/codehaus/waffle/action/intercept/InterceptorChainImplTest.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -1,31 +1,32 @@
 package org.codehaus.waffle.action.intercept;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.codehaus.waffle.controller.ControllerDefinition;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
 import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
 @RunWith(JMock.class)
 public class InterceptorChainImplTest {
-    private final Mockery context = new JUnit4Mockery();
+    private final Mockery mockery = new Mockery();
 
     @Test
-    public void interceptorAcceptsMethod() throws Exception {
+    public void canAcceptMethod() throws Exception {
         final ControllerDefinition controllerDefinition = new ControllerDefinition(null, null, null);
         final Method method = this.getClass().getMethods()[0];
         final Object argument = "foobar";
 
         // Mock MethodInterceptor
-        final MethodInterceptor methodInterceptor = context.mock(MethodInterceptor.class);
-        context.checking(new Expectations() {{
+        final MethodInterceptor methodInterceptor = mockery.mock(MethodInterceptor.class);
+        mockery.checking(new Expectations() {{
             one (methodInterceptor).accept(method);
             will(returnValue(true));
             one(methodInterceptor).intercept(with(same(controllerDefinition)),
@@ -39,18 +40,18 @@
         interceptors.add(methodInterceptor);
 
         InterceptorChain interceptorChain = new InterceptorChainImpl(interceptors);
-        Assert.assertEquals("hello", interceptorChain.proceed(controllerDefinition, method, argument));
+        assertEquals("hello", interceptorChain.proceed(controllerDefinition, method, argument));
     }
 
     @Test
-    public void interceptorDoesNotAcceptMethod() throws Exception {
+    public void canRefuseMethod() throws Exception {
         ControllerDefinition controllerDefinition = new ControllerDefinition(null, null, null);
         final Method method = this.getClass().getMethods()[0];
         Object argument = "foobar";
 
         // Mock MethodInterceptor
-        final MethodInterceptor methodInterceptor = context.mock(MethodInterceptor.class);
-        context.checking(new Expectations() {{
+        final MethodInterceptor methodInterceptor = mockery.mock(MethodInterceptor.class);
+        mockery.checking(new Expectations() {{
             one (methodInterceptor).accept(method);
             will(returnValue(false));
         }});
@@ -59,7 +60,7 @@
         interceptors.add(methodInterceptor);
 
         InterceptorChainImpl interceptorChain = new InterceptorChainImpl(interceptors);
-        Assert.assertNull(interceptorChain.proceed(controllerDefinition, method, argument));
+        assertNull(interceptorChain.proceed(controllerDefinition, method, argument));
     }
 
 }

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

--- trunk/core/src/test/java/org/codehaus/waffle/action/intercept/MethodInterceptorComparatorTest.java	2007-11-12 18:42:31 UTC (rev 351)
+++ trunk/core/src/test/java/org/codehaus/waffle/action/intercept/MethodInterceptorComparatorTest.java	2007-11-12 19:38:05 UTC (rev 352)
@@ -1,8 +1,6 @@
 package org.codehaus.waffle.action.intercept;
 
-import org.codehaus.waffle.controller.ControllerDefinition;
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.Assert.assertSame;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -10,10 +8,13 @@
 import java.util.Comparator;
 import java.util.List;
 
+import org.codehaus.waffle.controller.ControllerDefinition;
+import org.junit.Test;
+
 public class MethodInterceptorComparatorTest  {
 
     @Test
-    public void shouldSortCollectionOfSortable() {
+    public void canSortCollectionOfSortable() {
         List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>();
 
         MethodInterceptor  SortableMethodInterceptor(1);
@@ -27,13 +28,13 @@
         Comparator<MethodInterceptor> comparator = new MethodInterceptorComparator();
         Collections.sort(interceptors, comparator);
 
-        Assert.assertSame(one, interceptors.get(0));
-        Assert.assertSame(two, interceptors.get(1));
-        Assert.assertSame(three, interceptors.get(2));
+        assertSame(one, interceptors.get(0));
+        assertSame(two, interceptors.get(1));
+        assertSame(three, interceptors.get(2));
     }
 
     @Test
-    public void shouldSortCollectionWithNonSortable() {
+    public void canSortCollectionWithNonSortable() {
         List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>();
 
         MethodInterceptor  SortableMethodInterceptor(1);
@@ -49,10 +50,10 @@
         Comparator<MethodInterceptor> comparator = new MethodInterceptorComparator();
         Collections.sort(interceptors, comparator);
 
-        Assert.assertSame(one, interceptors.get(0));
-        Assert.assertSame(two, interceptors.get(1));
-        Assert.assertSame(three, interceptors.get(2));
-        Assert.assertSame(notSortable, interceptors.get(3));
+        assertSame(one, interceptors.get(0));
+        assertSame(two, interceptors.get(1));
+        assertSame(three, interceptors.get(2));
+        assertSame(notSortable, interceptors.get(3));
     }
 
     private static class SortableMethodInterceptor implements MethodInterceptor, Sortable {


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to