You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2010/11/25 21:48:18 UTC

svn commit: r1039169 - in /tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime: ./ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/tiles/ src/test/java/org/apache/tiles/autotag/ src/test/java/org/apache/tiles/autotag/jsp/ ...

Author: apetrelli
Date: Thu Nov 25 20:48:18 2010
New Revision: 1039169

URL: http://svn.apache.org/viewvc?rev=1039169&view=rev
Log:
TILESSB-11
Completed tests for tiles-autotag-jsp-runtime.

Added:
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodyTagTest.java   (with props)
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodylessTagTest.java   (with props)
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/JspModelBodyTest.java   (with props)
Modified:
    tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/pom.xml

Modified: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/pom.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/pom.xml?rev=1039169&r1=1039168&r2=1039169&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/pom.xml (original)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/pom.xml Thu Nov 25 20:48:18 2010
@@ -27,5 +27,23 @@
   		<artifactId>tiles-request-jsp</artifactId>
   		<version>1.0-SNAPSHOT</version>
   	</dependency>
+  	<dependency>
+  		<groupId>junit</groupId>
+  		<artifactId>junit</artifactId>
+  		<version>4.8.2</version>
+  		<scope>test</scope>
+  	</dependency>
+  	<dependency>
+  		<groupId>org.easymock</groupId>
+  		<artifactId>easymock</artifactId>
+  		<version>3.0</version>
+  		<scope>test</scope>
+  	</dependency>
+  	<dependency>
+  		<groupId>javax.servlet</groupId>
+  		<artifactId>servlet-api</artifactId>
+  		<version>2.5</version>
+  		<scope>test</scope>
+  	</dependency>
   </dependencies>
 </project>
\ No newline at end of file

Added: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodyTagTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodyTagTest.java?rev=1039169&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodyTagTest.java (added)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodyTagTest.java Thu Nov 25 20:48:18 2010
@@ -0,0 +1,56 @@
+/**
+ *
+ */
+package org.apache.tiles.autotag.jsp.runtime;
+
+import static org.easymock.EasyMock.*;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.JspFragment;
+
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.jsp.JspRequest;
+import org.apache.tiles.request.util.ApplicationAccess;
+import org.junit.Test;
+
+/**
+ * Tests {@link BodyTag}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BodyTagTest {
+
+    /**
+     * Test method for {@link org.apache.tiles.autotag.jsp.runtime.BodyTag#doTag()}.
+     * @throws IOException If something goes wrong.
+     */
+    @Test
+    public void testDoTag() throws IOException {
+        PageContext pageContext = createMock(PageContext.class);
+        JspFragment jspBody = createMock(JspFragment.class);
+        BodyTag tag = createMockBuilder(BodyTag.class).createMock();
+        ApplicationContext applicationContext = createMock(ApplicationContext.class);
+        HttpServletRequest httpServletRequest = createMock(HttpServletRequest.class);
+        HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
+        JspWriter jspWriter = createMock(JspWriter.class);
+
+        expect(pageContext.getAttribute(ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE,
+                PageContext.APPLICATION_SCOPE)).andReturn(applicationContext);
+        expect(pageContext.getRequest()).andReturn(httpServletRequest);
+        expect(pageContext.getResponse()).andReturn(httpServletResponse);
+        expect(pageContext.getOut()).andReturn(jspWriter);
+        tag.execute(isA(JspRequest.class), isA(JspModelBody.class));
+
+        replay(pageContext, jspBody, tag, applicationContext, httpServletRequest, httpServletResponse, jspWriter);
+        tag.setJspContext(pageContext);
+        tag.setJspBody(jspBody);
+        tag.doTag();
+        verify(pageContext, jspBody, tag, applicationContext, httpServletRequest, httpServletResponse, jspWriter);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodyTagTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodyTagTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodylessTagTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodylessTagTest.java?rev=1039169&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodylessTagTest.java (added)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodylessTagTest.java Thu Nov 25 20:48:18 2010
@@ -0,0 +1,50 @@
+/**
+ *
+ */
+package org.apache.tiles.autotag.jsp.runtime;
+
+import static org.easymock.EasyMock.*;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.PageContext;
+
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.jsp.JspRequest;
+import org.apache.tiles.request.util.ApplicationAccess;
+import org.junit.Test;
+
+/**
+ * Tests {@link BodylessTag}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BodylessTagTest {
+
+    /**
+     * Test method for {@link org.apache.tiles.autotag.jsp.runtime.BodylessTag#doTag()}.
+     * @throws IOException If something goes wrong.
+     */
+    @Test
+    public void testDoTag() throws IOException {
+        PageContext pageContext = createMock(PageContext.class);
+        BodylessTag tag = createMockBuilder(BodylessTag.class).createMock();
+        ApplicationContext applicationContext = createMock(ApplicationContext.class);
+        HttpServletRequest httpServletRequest = createMock(HttpServletRequest.class);
+        HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
+
+        expect(pageContext.getAttribute(ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE,
+                PageContext.APPLICATION_SCOPE)).andReturn(applicationContext);
+        expect(pageContext.getRequest()).andReturn(httpServletRequest);
+        expect(pageContext.getResponse()).andReturn(httpServletResponse);
+        tag.execute(isA(JspRequest.class));
+
+        replay(pageContext, tag, applicationContext, httpServletRequest, httpServletResponse);
+        tag.setJspContext(pageContext);
+        tag.doTag();
+        verify(pageContext, tag, applicationContext, httpServletRequest, httpServletResponse);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodylessTagTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/BodylessTagTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/JspModelBodyTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/JspModelBodyTest.java?rev=1039169&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/JspModelBodyTest.java (added)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/JspModelBodyTest.java Thu Nov 25 20:48:18 2010
@@ -0,0 +1,87 @@
+package org.apache.tiles.autotag.jsp.runtime;
+/**
+ *
+ */
+
+
+import static org.easymock.EasyMock.*;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.JspFragment;
+
+import org.junit.Test;
+
+/**
+ * Tests {@link JspModelBody}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JspModelBodyTest {
+
+    /**
+     * Test method for {@link org.apache.tiles.autotag.freemarker.runtime.JspModelBody#evaluate(java.io.Writer)}.
+     * @throws IOException If something goes wrong.
+     * @throws JspException If something goes wrong.
+     */
+    @Test
+    public void testEvaluateWriter() throws JspException, IOException {
+        JspFragment body = createMock(JspFragment.class);
+        PageContext pageContext = createMock(PageContext.class);
+        JspWriter writer = createMock(JspWriter.class);
+
+        expect(pageContext.getOut()).andReturn(null);
+        body.invoke(writer);
+
+        replay(body, pageContext, writer);
+        JspModelBody modelBody = new JspModelBody(body, pageContext);
+        modelBody.evaluate(writer);
+        verify(body, pageContext, writer);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.autotag.freemarker.runtime.JspModelBody#evaluate(java.io.Writer)}.
+     * @throws IOException If something goes wrong.
+     * @throws JspException If something goes wrong.
+     */
+    @Test
+    public void testEvaluateWriterNull() throws JspException, IOException {
+        PageContext pageContext = createMock(PageContext.class);
+        Writer writer = createMock(Writer.class);
+
+        expect(pageContext.getOut()).andReturn(null);
+
+        replay(writer, pageContext);
+        JspModelBody modelBody = new JspModelBody(null, pageContext);
+        modelBody.evaluate(writer);
+        verify(writer, pageContext);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.autotag.freemarker.runtime.JspModelBody#evaluate(java.io.Writer)}.
+     * @throws IOException If something goes wrong.
+     * @throws JspException If something goes wrong.
+     */
+    @Test(expected=IOException.class)
+    public void testEvaluateWriterException() throws JspException, IOException {
+        PageContext pageContext = createMock(PageContext.class);
+        JspFragment body = createMock(JspFragment.class);
+        JspWriter writer = createMock(JspWriter.class);
+
+        expect(pageContext.getOut()).andReturn(null);
+        body.invoke(writer);
+        expectLastCall().andThrow(new JspException());
+
+        replay(body, pageContext, writer);
+        try {
+            JspModelBody modelBody = new JspModelBody(body, pageContext);
+            modelBody.evaluate(writer);
+        } finally {
+            verify(body, pageContext, writer);
+        }
+    }
+}

Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/JspModelBodyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp-runtime/src/test/java/org/apache/tiles/autotag/jsp/runtime/JspModelBodyTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL