Title: [waffle-scm] [384] trunk/core/src/main/java/org/codehaus/waffle: Added validation and view monitors.

Diff

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

--- trunk/core/src/main/java/org/codehaus/waffle/ComponentRegistry.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/main/java/org/codehaus/waffle/ComponentRegistry.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -30,6 +30,8 @@
 import org.codehaus.waffle.monitor.ControllerMonitor;
 import org.codehaus.waffle.monitor.RegistrarMonitor;
 import org.codehaus.waffle.monitor.ServletMonitor;
+import org.codehaus.waffle.monitor.ValidationMonitor;
+import org.codehaus.waffle.monitor.ViewMonitor;
 import org.codehaus.waffle.validation.Validator;
 import org.codehaus.waffle.view.ViewDispatcher;
 import org.codehaus.waffle.view.ViewResolver;
@@ -85,8 +87,12 @@
 
     Validator getValidator();
 
+    ValidationMonitor getValidationMonitor();
+
     ViewDispatcher getViewDispatcher();
 
+    ViewMonitor getViewMonitor();
+
     ViewResolver getViewResolver();
 
 }

Modified: trunk/core/src/main/java/org/codehaus/waffle/context/pico/PicoComponentRegistry.java (383 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/context/pico/PicoComponentRegistry.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/main/java/org/codehaus/waffle/context/pico/PicoComponentRegistry.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -49,6 +49,8 @@
 import org.codehaus.waffle.monitor.RegistrarMonitor;
 import org.codehaus.waffle.monitor.ServletMonitor;
 import org.codehaus.waffle.monitor.SilentMonitor;
+import org.codehaus.waffle.monitor.ValidationMonitor;
+import org.codehaus.waffle.monitor.ViewMonitor;
 import org.codehaus.waffle.validation.DefaultValidator;
 import org.codehaus.waffle.validation.Validator;
 import org.codehaus.waffle.view.DefaultViewDispatcher;
@@ -98,7 +100,9 @@
         register(ServletMonitor.class, SilentMonitor.class, servletContext);
         register(TypeConverter.class, OgnlTypeConverter.class, servletContext);
         register(Validator.class, DefaultValidator.class, servletContext);
+        register(ValidationMonitor.class, SilentMonitor.class, servletContext);
         register(ViewDispatcher.class, DefaultViewDispatcher.class, servletContext);
+        register(ViewMonitor.class, SilentMonitor.class, servletContext);
         register(ViewResolver.class, DefaultViewResolver.class, servletContext);
 
         // register other components
@@ -157,7 +161,7 @@
         
         String className = servletContext.getInitParameter(parameterName);
 
-        if (className == null || className.equals("")) {
+        if (className == null || className.length() == 0) {
             return defaultClass;
         } else {
             return loadClass(className);
@@ -179,11 +183,11 @@
     }
 
     /**
-     * Register the correct class to the underlying container
+     * Register the component class in the underlying container
      */
     private void register(Object key, Class<?> defaultClass, ServletContext servletContext) throws WaffleException {
-        Class<?> actualClass = locateComponentClass(key, defaultClass, servletContext);
-        picoContainer.registerComponentImplementation(key, actualClass);
+        Class<?> componentClass = locateComponentClass(key, defaultClass, servletContext);
+        picoContainer.registerComponentImplementation(key, componentClass);
     }
 
     /**
@@ -279,10 +283,18 @@
         return locateByType(Validator.class);
     }
 
+    public ValidationMonitor getValidationMonitor() {
+        return locateByType(ValidationMonitor.class);
+    }
+
     public ViewDispatcher getViewDispatcher() {
         return locateByType(ViewDispatcher.class);
     }
 
+    public ViewMonitor getViewMonitor() {
+        return locateByType(ViewMonitor.class);
+    }
+
     public ViewResolver getViewResolver() {
         return locateByType(ViewResolver.class);
     }

Modified: trunk/core/src/main/java/org/codehaus/waffle/monitor/AbstractWritingMonitor.java (383 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/monitor/AbstractWritingMonitor.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/main/java/org/codehaus/waffle/monitor/AbstractWritingMonitor.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -30,8 +30,11 @@
 import org.codehaus.waffle.action.MethodDefinition;
 import org.codehaus.waffle.action.HierarchicalArgumentResolver.Scope;
 import org.codehaus.waffle.context.ContextContainer;
+import org.codehaus.waffle.controller.ControllerDefinition;
 import org.codehaus.waffle.registrar.Registrar;
 import org.codehaus.waffle.validation.BindErrorMessage;
+import org.codehaus.waffle.view.RedirectView;
+import org.codehaus.waffle.view.ResponderView;
 import org.codehaus.waffle.view.View;
 
 /**
@@ -39,7 +42,8 @@
  * 
  * @author Mauro Talevi
  */
-public abstract class AbstractWritingMonitor implements ActionMonitor, BindMonitor, ContextMonitor, ControllerMonitor, RegistrarMonitor, ServletMonitor {
+public abstract class AbstractWritingMonitor implements ActionMonitor, BindMonitor, ContextMonitor, ControllerMonitor,
+        RegistrarMonitor, ServletMonitor, ValidationMonitor, ViewMonitor {
 
     private Map<String, Level> levels;
     private Map<String, String> templates;
@@ -80,6 +84,12 @@
         levels.put("instanceRegistered", DEBUG);
         levels.put("nonCachingComponentRegistered", DEBUG);
         levels.put("servletServiceFailed", WARN);
+        levels.put("controllerValidatorNotFound", WARN);
+        levels.put("methodDefinitionNotFound", WARN);        
+        levels.put("validationFailed", WARN);  
+        levels.put("viewForwarded", DEBUG);        
+        levels.put("viewRedirected", DEBUG);
+        levels.put("viewResponded", DEBUG);        
         return levels;
     }
 
@@ -114,6 +124,12 @@
         templates.put("instanceRegistered", "Registered instance {1} with key {0}");
         templates.put("nonCachingComponentRegistered", "Registered non-caching component of type {1} with key {0} and parameters {2}");
         templates.put("servletServiceFailed", "Servlet service failed: {0}");
+        templates.put("controllerValidatorNotFound", "Controller validator not found");
+        templates.put("methodDefinitionNotFound", "Method definition not found in controller definition {0}");        
+        templates.put("validationFailed", "Validation failed: {0}");  
+        templates.put("viewForwarded", "View forwarded to path {0}");        
+        templates.put("viewRedirected", "View redirected: {0}");
+        templates.put("viewResponded", "View responded: {0}");
         return templates;
     }
 
@@ -149,6 +165,22 @@
         return exceptions;
     }
 
+    /**
+     * Writes message for a given level. Concrete implementations should provide writing functionality.
+     * 
+     * @param level the Level
+     * @param message the message to write 
+     */
+    protected abstract void write(Level level, String message);
+
+    /**
+     * Traces an exception. Concrete implementations should provide writing functionality.
+     *
+     * @param exception the Throwable to trace
+     */
+    protected abstract void trace(Throwable exception);
+
+
     public void defaultActionMethodFound(MethodDefinition methodDefinition) {
         write("defaultActionMethodFound", methodDefinition);
     }
@@ -265,19 +297,27 @@
         write("servletServiceFailed", cause);        
     }
     
-    /**
-     * Writes message for a given level. Concrete implementations should provide writing functionality.
-     * 
-     * @param level the Level
-     * @param message the message to write 
-     */
-    protected abstract void write(Level level, String message);
+    public void controllerValidatorNotFound() {
+        write("controllerValidatorNotFound");
+    }
 
-    /**
-     * Traces an exception. Concrete implementations should provide writing functionality.
-     *
-     * @param exception the Throwable to trace
-     */
-    protected abstract void trace(Throwable exception);
+    public void methodDefinitionNotFound(ControllerDefinition controllerDefinition) {
+        write("methodDefinitionNotFound", controllerDefinition);        
+    }
 
+    public void validationFailed(Exception cause) {
+        write("validationFailed", cause);        
+    }
+
+    public void viewForwarded(String path) {
+        write("viewForwarded", path);        
+    }
+
+    public void viewRedirected(RedirectView redirectView) {
+        write("viewRedirected", redirectView);        
+    }
+
+    public void viewResponded(ResponderView responderView) {
+        write("viewResponded", responderView);        
+    }
 }

Added: trunk/core/src/main/java/org/codehaus/waffle/monitor/ValidationMonitor.java (0 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/monitor/ValidationMonitor.java	                        (rev 0)
+++ trunk/core/src/main/java/org/codehaus/waffle/monitor/ValidationMonitor.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (C) 2005,2006 Michael Ward                                      *
+ * All rights reserved.                                                      *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD      *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file.                                                     *
+ *                                                                           *
+ * Original code by: Mauro Talevi                                            *
+ *****************************************************************************/
+package org.codehaus.waffle.monitor;
+
+import org.codehaus.waffle.controller.ControllerDefinition;
+
+/**
+ * A monitor for validation-related events
+ * 
+ * @author Mauro Talevi
+ */
+public interface ValidationMonitor extends Monitor {
+
+    void controllerValidatorNotFound();
+
+    void methodDefinitionNotFound(ControllerDefinition controllerDefinition);
+
+    void validationFailed(Exception cause);
+
+}

Added: trunk/core/src/main/java/org/codehaus/waffle/monitor/ViewMonitor.java (0 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/monitor/ViewMonitor.java	                        (rev 0)
+++ trunk/core/src/main/java/org/codehaus/waffle/monitor/ViewMonitor.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (C) 2005,2006 Michael Ward                                      *
+ * All rights reserved.                                                      *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD      *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file.                                                     *
+ *                                                                           *
+ * Original code by: Mauro Talevi                                            *
+ *****************************************************************************/
+package org.codehaus.waffle.monitor;
+
+import org.codehaus.waffle.view.RedirectView;
+import org.codehaus.waffle.view.ResponderView;
+
+/**
+ * A monitor for view-related events
+ * 
+ * @author Mauro Talevi
+ */
+public interface ViewMonitor extends Monitor {
+
+    void viewForwarded(String path);
+
+    void viewResponded(ResponderView responderView);
+
+    void viewRedirected(RedirectView redirectView);
+
+}

Modified: trunk/core/src/main/java/org/codehaus/waffle/validation/DefaultValidator.java (383 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/validation/DefaultValidator.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/main/java/org/codehaus/waffle/validation/DefaultValidator.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -10,31 +10,45 @@
  *****************************************************************************/
 package org.codehaus.waffle.validation;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.codehaus.waffle.WaffleException;
-import org.codehaus.waffle.controller.ControllerDefinition;
 import org.codehaus.waffle.action.MethodDefinition;
 import org.codehaus.waffle.context.ContextContainer;
 import org.codehaus.waffle.context.RequestLevelContainer;
+import org.codehaus.waffle.controller.ControllerDefinition;
+import org.codehaus.waffle.monitor.ValidationMonitor;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
+/**
+ * Default implementation of Validator
+ * 
+ * @author Michael Ward
+ * @author Mauro Talevi
+ */
 public class DefaultValidator implements Validator {
     protected static final String VALIDATOR_SUFFIX = "Validator";
+    private final ValidationMonitor validationMonitor;
 
+    public DefaultValidator(ValidationMonitor validationMonitor){
+        this.validationMonitor = validationMonitor;        
+    }
+
     public void validate(ControllerDefinition controllerDefinition, ErrorsContext errorsContext) {
         ContextContainer container = RequestLevelContainer.get();
         Object controllerValidator = container.getComponentInstance(controllerDefinition.getName() + VALIDATOR_SUFFIX);
 
         if (controllerValidator == null) {
+            validationMonitor.controllerValidatorNotFound();
             return; // doesn't exist ... go no further
         }
 
         MethodDefinition methodDefinition = controllerDefinition.getMethodDefinition();
         
-        if(methodDefinition == null) {
+        if (methodDefinition == null) {
+            validationMonitor.methodDefinitionNotFound(controllerDefinition);
             return; // no method ... go no further
         }
 
@@ -56,12 +70,13 @@
             methodArguments.add(0, errorsContext);
 
             validationMethod.invoke(controllerValidator, methodArguments.toArray());
-
         } catch (NoSuchMethodException ignore) {
             // ignore
         } catch (IllegalAccessException e) {
+            validationMonitor.validationFailed(e);
             throw new WaffleException(e);
         } catch (InvocationTargetException e) {
+            validationMonitor.validationFailed(e);
             throw new WaffleException(e);
         }
     }

Modified: trunk/core/src/main/java/org/codehaus/waffle/view/BeanPropertyConverter.java (383 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/view/BeanPropertyConverter.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/main/java/org/codehaus/waffle/view/BeanPropertyConverter.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -57,6 +57,7 @@
         throw new UnsupportedOperationException("Converter only available for marshaling");
     }
 
+    @SuppressWarnings("unchecked")
     public boolean canConvert(Class clazz) {
         return true;
     }

Modified: trunk/core/src/main/java/org/codehaus/waffle/view/DefaultViewDispatcher.java (383 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/view/DefaultViewDispatcher.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/main/java/org/codehaus/waffle/view/DefaultViewDispatcher.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -14,6 +14,9 @@
 import javax.servlet.RequestDispatcher;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
+import org.codehaus.waffle.monitor.ViewMonitor;
+
 import java.io.IOException;
 
 /**
@@ -21,30 +24,36 @@
  *
  * @author Michael Ward
  * @author Paulo Silveira
+ * @author Mauro Talevi
  */
 public class DefaultViewDispatcher implements ViewDispatcher {
     private final ViewResolver viewResolver;
+    private final ViewMonitor viewMonitor;
 
-    public DefaultViewDispatcher(ViewResolver viewResolver) {
+    public DefaultViewDispatcher(ViewResolver viewResolver, ViewMonitor viewMonitor) {
         this.viewResolver = viewResolver;
+        this.viewMonitor = viewMonitor;
     }
 
     // todo may need to handle ... http://java.sun.com/products/servlet/Filters.html for Character Encoding from request
     public void dispatch(HttpServletRequest request,
                          HttpServletResponse response,
                          View view) throws IOException, ServletException {
-        String url = ""
+        String path = viewResolver.resolve(view);
 
         if (view instanceof RedirectView) {
             RedirectView redirectView = (RedirectView) view;
-
             response.setStatus(redirectView.getStatusCode());
-            response.setHeader("Location", url);
+            response.setHeader("Location", path);
+            viewMonitor.viewRedirected(redirectView);
         } else if (view instanceof ResponderView) {
-            ((ResponderView) view).respond(request, response);
+            ResponderView responderView = (ResponderView) view;
+            responderView.respond(request, response);
+            viewMonitor.viewResponded(responderView);
         } else {
-            RequestDispatcher requestDispatcher = request.getRequestDispatcher(url);
+            RequestDispatcher requestDispatcher = request.getRequestDispatcher(path);
             requestDispatcher.forward(request, response);
+            viewMonitor.viewForwarded(path);
         }
     }
 }

Modified: trunk/core/src/main/java/org/codehaus/waffle/view/DefaultViewResolver.java (383 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/view/DefaultViewResolver.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/main/java/org/codehaus/waffle/view/DefaultViewResolver.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -11,15 +11,12 @@
 package org.codehaus.waffle.view;
 
 /**
- * The default view resolver
+ * The default ViewResolver simply returns the vale of the View being resolved.
  *
  * @author Michael Ward
  */
 public class DefaultViewResolver implements ViewResolver {
 
-    /**
-     * The Default ViewResolver simply return the vale of the View being reolved.
-     */
     public String resolve(View view) {
         return view.getValue();
     }

Modified: trunk/core/src/main/java/org/codehaus/waffle/view/ViewResolver.java (383 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/view/ViewResolver.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/main/java/org/codehaus/waffle/view/ViewResolver.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -10,13 +10,18 @@
  *****************************************************************************/
 package org.codehaus.waffle.view;
 
+/**
+ * The view resolver determines the path the next view
+ *
+ * @author Michael Ward
+ */
 public interface ViewResolver {
 
     /**
-     * Determine what the path is to the next view
+     * Resolves the view by return the path to the next view
      *
-     * @param view
-     * @return the path to the next View.
+     * @param view the View
+     * @return The path to the next View.
      */
     String resolve(View view);
 }

Modified: trunk/core/src/main/java/org/codehaus/waffle/view/XMLView.java (383 => 384)

--- trunk/core/src/main/java/org/codehaus/waffle/view/XMLView.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/main/java/org/codehaus/waffle/view/XMLView.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -48,6 +48,7 @@
         XStream xstream = new XStream(new DomDriver()) {
             protected MapperWrapper wrapMapper(MapperWrapper next) {
                 return new MapperWrapper(next) {
+                    @SuppressWarnings("unchecked")
                     @Override
                     public String serializedClass(Class type) {
                         String value = super.serializedClass(type);
@@ -61,6 +62,7 @@
         };
         xstream.registerConverter(new BeanPropertyConverter(), -19);
         xstream.registerConverter(new CollectionConverter(xstream.getMapper()) {
+            @SuppressWarnings("unchecked")
             @Override
             public boolean canConvert(Class clazz) {
                 return Collection.class.isAssignableFrom(clazz);

Modified: trunk/core/src/test/java/org/codehaus/waffle/context/pico/PicoComponentRegistryTest.java (383 => 384)

--- trunk/core/src/test/java/org/codehaus/waffle/context/pico/PicoComponentRegistryTest.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/test/java/org/codehaus/waffle/context/pico/PicoComponentRegistryTest.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -49,6 +49,8 @@
 import org.codehaus.waffle.monitor.ControllerMonitor;
 import org.codehaus.waffle.monitor.RegistrarMonitor;
 import org.codehaus.waffle.monitor.ServletMonitor;
+import org.codehaus.waffle.monitor.ValidationMonitor;
+import org.codehaus.waffle.monitor.ViewMonitor;
 import org.codehaus.waffle.testmodel.StubActionMethodExecutor;
 import org.codehaus.waffle.testmodel.StubActionMethodResponseHandler;
 import org.codehaus.waffle.testmodel.StubArgumentResolver;
@@ -131,7 +133,7 @@
             {
                 one(servletContext).getInitParameterNames();
                 will(returnValue(EMPTY_ENUMERATION));
-                exactly(22).of(servletContext).getInitParameter(with(any(String.class)));
+                exactly(24).of(servletContext).getInitParameter(with(any(String.class)));
             }
         });
 
@@ -153,9 +155,11 @@
         assertTrue(componentRegistry.getRegistrarMonitor() instanceof AbstractWritingMonitor);
         assertTrue(componentRegistry.getServletMonitor() instanceof AbstractWritingMonitor);
         assertTrue(componentRegistry.getTypeConverter() instanceof OgnlTypeConverter);
+        assertTrue(componentRegistry.getValidator() instanceof DefaultValidator);
+        assertTrue(componentRegistry.getValidationMonitor() instanceof AbstractWritingMonitor);
         assertTrue(componentRegistry.getViewDispatcher() instanceof DefaultViewDispatcher);
+        assertTrue(componentRegistry.getViewMonitor() instanceof AbstractWritingMonitor);
         assertTrue(componentRegistry.getViewResolver() instanceof DefaultViewResolver);
-        assertTrue(componentRegistry.getValidator() instanceof DefaultValidator);
     }
 
     @Test
@@ -206,8 +210,15 @@
                 will(returnValue(StubMonitor.class.getName()));
                 one(servletContext).getInitParameter(TypeConverter.class.getName());
                 will(returnValue(DefaultTypeConverter.class.getName()));
+// TODO fails for some reason                
+//                one(servletContext).getInitParameter(Validator.class.getName());
+//                will(returnValue(StubValidator.class.getName()));
+                one(servletContext).getInitParameter(ValidationMonitor.class.getName());
+                will(returnValue(StubMonitor.class.getName()));
                 one(servletContext).getInitParameter(ViewDispatcher.class.getName());
                 will(returnValue(StubViewDispatcher.class.getName()));
+                one(servletContext).getInitParameter(ViewMonitor.class.getName());
+                will(returnValue(StubMonitor.class.getName()));
                 one(servletContext).getInitParameter(ViewResolver.class.getName());
                 will(returnValue(StubViewResolver.class.getName()));
             }
@@ -232,7 +243,9 @@
         assertTrue(componentRegistry.getServletMonitor() instanceof StubMonitor);
         assertTrue(componentRegistry.getTypeConverter() instanceof DefaultTypeConverter);
         assertTrue(componentRegistry.getValidator() instanceof StubValidator);
+        assertTrue(componentRegistry.getValidationMonitor() instanceof StubMonitor);
         assertTrue(componentRegistry.getViewDispatcher() instanceof StubViewDispatcher);
+        assertTrue(componentRegistry.getViewMonitor() instanceof StubMonitor);
         assertTrue(componentRegistry.getViewResolver() instanceof StubViewResolver);
     }
 

Modified: trunk/core/src/test/java/org/codehaus/waffle/testmodel/StubMonitor.java (383 => 384)

--- trunk/core/src/test/java/org/codehaus/waffle/testmodel/StubMonitor.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/test/java/org/codehaus/waffle/testmodel/StubMonitor.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -9,17 +9,23 @@
 import org.codehaus.waffle.action.MethodDefinition;
 import org.codehaus.waffle.action.HierarchicalArgumentResolver.Scope;
 import org.codehaus.waffle.context.ContextContainer;
+import org.codehaus.waffle.controller.ControllerDefinition;
 import org.codehaus.waffle.monitor.ActionMonitor;
 import org.codehaus.waffle.monitor.BindMonitor;
 import org.codehaus.waffle.monitor.ContextMonitor;
 import org.codehaus.waffle.monitor.ControllerMonitor;
 import org.codehaus.waffle.monitor.RegistrarMonitor;
 import org.codehaus.waffle.monitor.ServletMonitor;
+import org.codehaus.waffle.monitor.ValidationMonitor;
+import org.codehaus.waffle.monitor.ViewMonitor;
 import org.codehaus.waffle.registrar.Registrar;
 import org.codehaus.waffle.validation.BindErrorMessage;
+import org.codehaus.waffle.view.RedirectView;
+import org.codehaus.waffle.view.ResponderView;
 import org.codehaus.waffle.view.View;
 
-public class StubMonitor implements ActionMonitor, BindMonitor, ContextMonitor, ControllerMonitor, RegistrarMonitor, ServletMonitor {
+public class StubMonitor implements ActionMonitor, BindMonitor, ContextMonitor, ControllerMonitor, RegistrarMonitor,
+        ServletMonitor, ValidationMonitor, ViewMonitor {
 
     public void defaultActionMethodFound(MethodDefinition methodDefinition) {
     }
@@ -30,18 +36,18 @@
     public void pragmaticActionMethodFound(MethodDefinition methodDefinition) {
     }
 
-    public void actionMethodFound(MethodDefinition methodDefinition) {        
+    public void actionMethodFound(MethodDefinition methodDefinition) {
     }
 
     public void actionMethodExecuted(ActionMethodResponse actionMethodResponse) {
-    }  
+    }
 
     public void actionMethodExecutionFailed(Exception exception) {
     }
 
     public void methodNameResolved(String methodName, String methodKey, Set<String> keys) {
     }
-    
+
     public void methodIntercepted(Method method, Object[] arguments, Object returnValue) {
     }
 
@@ -50,7 +56,7 @@
 
     public void argumentNameResolved(String name, Object value, Scope scope) {
     }
-    
+
     public void responseIsCommitted(HttpServletResponse response) {
     }
 
@@ -84,7 +90,7 @@
     public void sessionContextContainerCreated(ContextContainer applicationContextContainer) {
     }
 
-    public void controllerNameResolved(String name, String path) {        
+    public void controllerNameResolved(String name, String path) {
     }
 
     public void controllerNotFound(String name) {
@@ -108,5 +114,22 @@
     public void servletServiceFailed(Exception cause) {
     }
 
+    public void controllerValidatorNotFound() {
+    }
 
+    public void methodDefinitionNotFound(ControllerDefinition controllerDefinition) {        
+    }
+
+    public void validationFailed(Exception cause) {
+    }
+
+    public void viewForwarded(String path) {
+    }
+
+    public void viewRedirected(RedirectView redirectView) {
+    }
+
+    public void viewResponded(ResponderView responderView) {
+    }
+
 }

Modified: trunk/core/src/test/java/org/codehaus/waffle/validation/DefaultValidatorTest.java (383 => 384)

--- trunk/core/src/test/java/org/codehaus/waffle/validation/DefaultValidatorTest.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/test/java/org/codehaus/waffle/validation/DefaultValidatorTest.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -9,6 +9,7 @@
 import org.codehaus.waffle.context.ContextContainer;
 import org.codehaus.waffle.context.RequestLevelContainer;
 import org.codehaus.waffle.controller.ControllerDefinition;
+import org.codehaus.waffle.monitor.SilentMonitor;
 import org.codehaus.waffle.testmodel.FakeController;
 import org.codehaus.waffle.testmodel.FakeControllerValidator;
 import org.jmock.Expectations;
@@ -56,7 +57,7 @@
         ControllerDefinition controllerDefinition = new ControllerDefinition("theController", fakeController, methodDefinition);
 
         ErrorsContext errorsContext = new DefaultErrorsContext();
-        Validator validator = new DefaultValidator();
+        Validator validator = new DefaultValidator(new SilentMonitor());
         validator.validate(controllerDefinition, errorsContext);
 
         assertSame(errorsContext, fakeControllerValidator.errorsContext);
@@ -81,7 +82,7 @@
         ControllerDefinition controllerDefinition = new ControllerDefinition("theController", fakeController, null);
 
         ErrorsContext errorsContext = new DefaultErrorsContext();
-        Validator validator = new DefaultValidator();
+        Validator validator = new DefaultValidator(new SilentMonitor());
         validator.validate(controllerDefinition, errorsContext);
     }
 

Modified: trunk/core/src/test/java/org/codehaus/waffle/view/DefaultViewDispatcherTest.java (383 => 384)

--- trunk/core/src/test/java/org/codehaus/waffle/view/DefaultViewDispatcherTest.java	2007-11-15 17:27:08 UTC (rev 383)
+++ trunk/core/src/test/java/org/codehaus/waffle/view/DefaultViewDispatcherTest.java	2007-11-15 22:03:12 UTC (rev 384)
@@ -1,5 +1,14 @@
 package org.codehaus.waffle.view;
 
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.codehaus.waffle.monitor.SilentMonitor;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
 import org.jmock.integration.junit4.JMock;
@@ -7,13 +16,6 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
 /**
  * @author Michael Ward
  * @author Mauro Talevi
@@ -46,7 +48,7 @@
 
         ViewResolver viewResolver = mockViewResolver(view, PATH);
 
-        DefaultViewDispatcher viewDispatcher = new DefaultViewDispatcher(viewResolver);
+        DefaultViewDispatcher viewDispatcher = new DefaultViewDispatcher(viewResolver, new SilentMonitor());
         viewDispatcher.dispatch(mockRequest, mockResponse, view);
         Assert.assertTrue(view.isResponded());
     }
@@ -61,7 +63,7 @@
             one(mockResponse).setHeader("Location", PATH);
         }});
 
-        DefaultViewDispatcher viewDispatcher = new DefaultViewDispatcher(viewResolver);
+        DefaultViewDispatcher viewDispatcher = new DefaultViewDispatcher(viewResolver, new SilentMonitor());
         viewDispatcher.dispatch(mockRequest, mockResponse, redirectView);
     }
 
@@ -78,7 +80,7 @@
             one(requestDispatcher).forward(mockRequest, mockResponse);
         }});
 
-        DefaultViewDispatcher viewDispatcher = new DefaultViewDispatcher(viewResolver);
+        DefaultViewDispatcher viewDispatcher = new DefaultViewDispatcher(viewResolver, new SilentMonitor());
         viewDispatcher.dispatch(mockRequest, mockResponse, view);
     }
 


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to