Title: [waffle-scm] [648] trunk/waffle-core/src/test/java/org/codehaus/waffle/view: WAFFLE-76: Renamed View.getValue() to View.getPath().

Diff

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/view/DefaultViewResolver.java (647 => 648)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/view/DefaultViewResolver.java	2008-04-21 16:31:04 UTC (rev 647)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/view/DefaultViewResolver.java	2008-04-21 16:59:00 UTC (rev 648)
@@ -11,13 +11,14 @@
 package org.codehaus.waffle.view;
 
 /**
- * The default ViewResolver simply returns the vale of the View being resolved.
+ * The default ViewResolver simply returns the path of the View being resolved.
  *
  * @author Michael Ward
  */
 public class DefaultViewResolver implements ViewResolver {
 
     public String resolve(View view) {
-        return view.getValue();
+        return view.getPath();
     }
+    
 }

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/view/ExportView.java (647 => 648)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/view/ExportView.java	2008-04-21 16:31:04 UTC (rev 647)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/view/ExportView.java	2008-04-21 16:59:00 UTC (rev 648)
@@ -11,8 +11,8 @@
 package org.codehaus.waffle.view;
 
 /**
- * Indicates that the view should contain export data.
- *
+ * Indicates that the view has content which should be exported to a filename using the given content type.
+ * 
  * @author Mauro Talevi
  */
 public class ExportView extends View {
@@ -20,8 +20,8 @@
     private final byte[] content;
     private final String filename;
 
-    public ExportView(Object fromController, String contentType, byte[] content, String filename) {
-        super(null, fromController);
+    public ExportView(Object controller, String contentType, byte[] content, String filename) {
+        super(null, controller);
         this.contentType = contentType;
         this.content = content;
         this.filename = filename;        

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/view/RedirectView.java (647 => 648)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/view/RedirectView.java	2008-04-21 16:31:04 UTC (rev 647)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/view/RedirectView.java	2008-04-21 16:59:00 UTC (rev 648)
@@ -20,16 +20,17 @@
 public class RedirectView extends View {
     private int statusCode;
 
-    public RedirectView(String value, Object fromController) {
-        this(value, fromController, HttpServletResponse.SC_SEE_OTHER);
+    public RedirectView(String path, Object controller) {
+        this(path, controller, HttpServletResponse.SC_SEE_OTHER);
     }
 
-    public RedirectView(String value, Object fromController, int statusCode) {
-        super(value, fromController);
+    public RedirectView(String path, Object controller, int statusCode) {
+        super(path, controller);
         this.statusCode = statusCode;
     }
 
     public int getStatusCode() {
         return statusCode;
     }
+    
 }

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/view/ResponderView.java (647 => 648)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/view/ResponderView.java	2008-04-21 16:31:04 UTC (rev 647)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/view/ResponderView.java	2008-04-21 16:59:00 UTC (rev 648)
@@ -14,7 +14,7 @@
 public abstract class ResponderView extends View {
 
     public ResponderView() {
-        super(null, "");
+        super(null, null);
     }
 
     /**

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/view/View.java (647 => 648)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/view/View.java	2008-04-21 16:31:04 UTC (rev 647)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/view/View.java	2008-04-21 16:59:00 UTC (rev 648)
@@ -11,39 +11,45 @@
 package org.codehaus.waffle.view;
 
 /**
- * 
- * Represents the value of the view that the resolver will dispatch.
- * View holds:
+ * Represents the view that the resolver will dispatch.  View holds:
  * <ol>
- *   <li>the value from the controller method</li>
+ *   <li>the path of the view</li>
  *   <li>the controller object </li>
  * </ol>
- * this allows for more granular decisions on how to handle a View
+ * which allows for more granular decisions on how to handle a View.
  *
  * @author Michael Ward
+ * @author Mauro Talevi
  */
 public class View {
-    private final String value;
+    private final String path;
     private final Object controller;
 
     /**
      * Creates a View
      * 
-     * @param value represents the name of the View to be resolved
+     * @param path represents the path of the View to be resolved
      * @param controller the controller where the view originated from
      */
-    public View(String value, Object controller) {
-        this.value = value;
+    public View(String path, Object controller) {
+        this.path = path;
         this.controller = controller;
     }
 
     /**
-     * Returns the view value.  The term "value" is used to be purposely open ended.
+     * Returns the view path
      * 
-     * @return The View value
+     * @return The View path
      */
+    public String getPath() {
+        return path;
+    }
+    
+    /**
+     * @deprecated Use #getPath()
+     */
     public String getValue() {
-        return value;
+        return getPath();
     }
 
     /**

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/view/ViewDispatcher.java (647 => 648)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/view/ViewDispatcher.java	2008-04-21 16:31:04 UTC (rev 647)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/view/ViewDispatcher.java	2008-04-21 16:59:00 UTC (rev 648)
@@ -16,10 +16,12 @@
 import java.io.IOException;
 
 /**
+ * Responsible for dispatching a view
+ * 
  * @author Michael Ward
  */
 public interface ViewDispatcher {
 
-    void dispatch(HttpServletRequest request, HttpServletResponse response, View view)
-            throws IOException, ServletException;
+    void dispatch(HttpServletRequest request, HttpServletResponse response, View view) throws IOException,
+            ServletException;
 }

Modified: trunk/waffle-core/src/test/java/org/codehaus/waffle/servlet/WaffleServletTest.java (647 => 648)

--- trunk/waffle-core/src/test/java/org/codehaus/waffle/servlet/WaffleServletTest.java	2008-04-21 16:31:04 UTC (rev 647)
+++ trunk/waffle-core/src/test/java/org/codehaus/waffle/servlet/WaffleServletTest.java	2008-04-21 16:59:00 UTC (rev 648)
@@ -575,7 +575,7 @@
         ControllerDefinition controllerDefinition = new ControllerDefinition("foobar", null, null);
         View view = servlet.buildView(controllerDefinition);
 
-        assertEquals("prefix-foobar-suffix", view.getValue());
+        assertEquals("prefix-foobar-suffix", view.getPath());
     }
 
     @SuppressWarnings("serial")

Modified: trunk/waffle-core/src/test/java/org/codehaus/waffle/view/DefaultViewResolverTest.java (647 => 648)

--- trunk/waffle-core/src/test/java/org/codehaus/waffle/view/DefaultViewResolverTest.java	2008-04-21 16:31:04 UTC (rev 647)
+++ trunk/waffle-core/src/test/java/org/codehaus/waffle/view/DefaultViewResolverTest.java	2008-04-21 16:59:00 UTC (rev 648)
@@ -8,9 +8,9 @@
 
     @Test
     public void canResolve() {
-        View view = new View("/helloWorld.jsp", null);
+        String path = "/helloWorld.jsp";
+        View view = new View(path, null);
         ViewResolver viewResolver = new DefaultViewResolver();
-
-        assertEquals("/helloWorld.jsp", viewResolver.resolve(view));
+        assertEquals(path, viewResolver.resolve(view));
     }
 }

Modified: trunk/waffle-core/src/test/java/org/codehaus/waffle/view/ExportViewTest.java (647 => 648)

--- trunk/waffle-core/src/test/java/org/codehaus/waffle/view/ExportViewTest.java	2008-04-21 16:31:04 UTC (rev 647)
+++ trunk/waffle-core/src/test/java/org/codehaus/waffle/view/ExportViewTest.java	2008-04-21 16:59:00 UTC (rev 648)
@@ -1,6 +1,7 @@
 package org.codehaus.waffle.view;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
 import org.junit.Test;
 
@@ -15,10 +16,13 @@
         String content = "1,2,3";
         String contentType = "text/csv";
         String filename = "export.csv";
-        ExportView view = new ExportView(null, contentType, content.getBytes(), filename);
+        Object controller = new Object();
+        ExportView view = new ExportView(controller, contentType, content.getBytes(), filename);
         assertEquals(content, new String(view.getContent()));
         assertEquals(contentType, view.getContentType());
         assertEquals(filename, view.getFilename());
+        assertEquals(controller, view.getController());
+        assertNull(view.getPath());
     }
 
 }


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to