Author: apetrelli
Date: Fri Dec 17 17:05:14 2010
New Revision: 1050453
URL: http://svn.apache.org/viewvc?rev=1050453&view=rev
Log:
VELTOOLS-133
Added some tests to velocity-tools-view-jsp.
Added:
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponseTest.java
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtilsTest.java
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImplTest.java
Removed:
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/
Modified:
velocity/tools/trunk/velocity-tools-view-jsp/pom.xml
Modified: velocity/tools/trunk/velocity-tools-view-jsp/pom.xml
URL:
http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/pom.xml?rev=1050453&r1=1050452&r2=1050453&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/pom.xml (original)
+++ velocity/tools/trunk/velocity-tools-view-jsp/pom.xml Fri Dec 17 17:05:14
2010
@@ -28,5 +28,17 @@
<version>2.1</version>
<scope>provided</scope>
</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>
</dependencies>
</project>
\ No newline at end of file
Added:
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponseTest.java
URL:
http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponseTest.java?rev=1050453&view=auto
==============================================================================
---
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponseTest.java
(added)
+++
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponseTest.java
Fri Dec 17 17:05:14 2010
@@ -0,0 +1,57 @@
+/*
+ * $Id: ExternalWriterHttpServletResponseTest.java 892369 2009-12-18 20:21:36Z
apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.velocity.tools.view.jsp.jspimpl;
+
+import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Test;
+
+/**
+ * Tests {...@link ExternalWriterHttpServletResponse}.
+ */
+public class ExternalWriterHttpServletResponseTest {
+
+ /**
+ * Test method for {...@link
org.apache.tiles.request.servlet.ExternalWriterHttpServletResponse#getWriter()}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testGetWriter() {
+ HttpServletResponse wrappedResponse =
createMock(HttpServletResponse.class);
+ Writer writer = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(writer);
+ replay(wrappedResponse);
+ ExternalWriterHttpServletResponse response = new
ExternalWriterHttpServletResponse(
+ wrappedResponse, printWriter);
+ assertEquals(printWriter, response.getWriter());
+ verify(wrappedResponse);
+ }
+
+}
Added:
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtilsTest.java
URL:
http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtilsTest.java?rev=1050453&view=auto
==============================================================================
---
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtilsTest.java
(added)
+++
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtilsTest.java
Fri Dec 17 17:05:14 2010
@@ -0,0 +1,140 @@
+package org.apache.velocity.tools.view.jsp.jspimpl;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.StringWriter;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.BodyTag;
+import javax.servlet.jsp.tagext.JspTag;
+import javax.servlet.jsp.tagext.SimpleTag;
+import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.TagAdapter;
+
+import org.apache.velocity.context.Context;
+import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.parser.node.ASTBlock;
+import org.apache.velocity.runtime.parser.node.Node;
+import org.junit.Test;
+
+/**
+ * Tests {...@link JspUtils}.
+ *
+ */
+public class JspUtilsTest
+{
+ /**
+ * The attribute name under which the latest encountered tag is put.
+ */
+ private final static String LATEST_TAG_ATTRIBUTE_NAME =
"org.apache.velocity.tools.view.jsp.taglib.jspimpl.LATEST_TAG";
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#setLatestTag(org.apache.velocity.context.Context,
javax.servlet.jsp.tagext.JspTag)}.
+ */
+ @Test
+ public void testSetLatestTag()
+ {
+ Context context = createMock(Context.class);
+ JspTag tag = createMock(JspTag.class);
+
+ expect(context.put(LATEST_TAG_ATTRIBUTE_NAME, tag)).andReturn(null);
+
+ replay(context, tag);
+ JspUtils.setLatestTag(context, tag);
+ verify(context, tag);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#getLatestJspTag(org.apache.velocity.context.Context)}.
+ */
+ @Test
+ public void testGetLatestJspTag()
+ {
+ Context context = createMock(Context.class);
+ JspTag tag = createMock(JspTag.class);
+
+ expect(context.get(LATEST_TAG_ATTRIBUTE_NAME)).andReturn(tag);
+
+ replay(context, tag);
+ assertSame(tag, JspUtils.getLatestJspTag(context));
+ verify(context, tag);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#wrapTag(javax.servlet.jsp.tagext.JspTag)}.
+ */
+ @Test
+ public void testWrapTag()
+ {
+ Tag tag = createMock(Tag.class);
+ SimpleTag simpleTag = createMock(SimpleTag.class);
+
+ replay(tag, simpleTag);
+ assertSame(tag, JspUtils.wrapTag(tag));
+ assertSame(simpleTag, ((TagAdapter)
JspUtils.wrapTag(simpleTag)).getAdaptee());
+ verify(tag, simpleTag);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#executeSimpleTag(org.apache.velocity.context.InternalContextAdapter,
org.apache.velocity.runtime.parser.node.Node, javax.servlet.jsp.PageContext,
javax.servlet.jsp.tagext.SimpleTag)}.
+ * @throws IOException If something goes wrong.
+ * @throws JspException If something goes wrong.
+ */
+ @Test
+ public void testExecuteSimpleTag() throws JspException, IOException
+ {
+ InternalContextAdapter context =
createMock(InternalContextAdapter.class);
+ Node node = createMock(Node.class);
+ PageContext pageContext = createMock(PageContext.class);
+ SimpleTag tag = createMock(SimpleTag.class);
+ ASTBlock block = createMock(ASTBlock.class);
+
+ tag.setJspBody(isA(VelocityJspFragment.class));
+ expect(node.jjtGetChild(1)).andReturn(block);
+ tag.doTag();
+
+ replay(context, node, pageContext, block, tag);
+ JspUtils.executeSimpleTag(context, node, pageContext, tag);
+ verify(context, node, pageContext, block, tag);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#executeTag(org.apache.velocity.context.InternalContextAdapter,
org.apache.velocity.runtime.parser.node.Node, javax.servlet.jsp.PageContext,
javax.servlet.jsp.tagext.Tag)}.
+ * @throws JspException If something goes wrong.
+ * @throws IOException If something goes wrong.
+ * @throws ParseErrorException If something goes wrong.
+ * @throws ResourceNotFoundException If something goes wrong.
+ * @throws MethodInvocationException If something goes wrong.
+ */
+ @Test
+ public void testExecuteTag() throws JspException,
MethodInvocationException, ResourceNotFoundException, ParseErrorException,
IOException
+ {
+ InternalContextAdapter context =
createMock(InternalContextAdapter.class);
+ Node node = createMock(Node.class);
+ PageContext pageContext = createMock(PageContext.class);
+ BodyTag tag = createMock(BodyTag.class);
+ ASTBlock block = createMock(ASTBlock.class);
+ JspWriter writer = createMock(JspWriter.class);
+
+ expect(tag.doStartTag()).andReturn(BodyTag.EVAL_BODY_BUFFERED);
+ tag.setBodyContent(isA(VelocityBodyContent.class));
+ tag.doInitBody();
+ expect(node.jjtGetChild(1)).andReturn(block);
+ expect(tag.doAfterBody()).andReturn(BodyTag.SKIP_BODY);
+ expect(tag.doEndTag()).andReturn(BodyTag.EVAL_PAGE);
+ expect(pageContext.getOut()).andReturn(writer);
+ expect(block.render(eq(context),
isA(StringWriter.class))).andReturn(true);
+
+ replay(context, node, pageContext, block, tag, writer);
+ JspUtils.executeTag(context, node, pageContext, tag);
+ verify(context, node, pageContext, block, tag, writer);
+ }
+
+}
Added:
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImplTest.java
URL:
http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImplTest.java?rev=1050453&view=auto
==============================================================================
---
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImplTest.java
(added)
+++
velocity/tools/trunk/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImplTest.java
Fri Dec 17 17:05:14 2010
@@ -0,0 +1,478 @@
+package org.apache.velocity.tools.view.jsp.jspimpl;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {...@link JspWriterImpl}.
+ *
+ */
+public class JspWriterImplTest
+{
+
+ private Writer writer;
+
+ private JspWriterImpl jspWriter;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception
+ {
+ writer = createMock(Writer.class);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(int)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testWriteInt() throws IOException
+ {
+ writer.write(10);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.write(10);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(char[])}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testWriteCharArray() throws IOException
+ {
+ writer.write(aryEq("hello".toCharArray()), eq(0), eq(5));
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.write("hello".toCharArray());
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(char[], int,
int)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testWriteCharArrayIntInt() throws IOException
+ {
+ writer.write(aryEq("hello".toCharArray()), eq(2), eq(3));
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.write("hello".toCharArray(), 2, 3);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#flush()}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testFlush() throws IOException
+ {
+ writer.flush();
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.flush();
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#close()}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testClose() throws IOException
+ {
+ writer.close();
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.close();
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#newLine()}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testNewLine() throws IOException
+ {
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.newLine();
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(boolean)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintBoolean() throws IOException
+ {
+ writer.write("true", 0, 4);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.print(true);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(char)}.
+ * @throws IOException
+ */
+ @Test
+ public void testPrintChar() throws IOException
+ {
+ writer.write("x", 0, 1);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.print('x');
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(int)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintInt() throws IOException
+ {
+ writer.write("152", 0, 3);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.print(152);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(long)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintLong() throws IOException
+ {
+ writer.write("152", 0, 3);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.print(152l);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(float)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintFloat() throws IOException
+ {
+ writer.write("0.5", 0, 3);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.print(0.5f);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(double)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintDouble() throws IOException
+ {
+ writer.write("0.5", 0, 3);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.print(0.5d);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(char[])}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintCharArray() throws IOException
+ {
+ writer.write(aryEq("hello".toCharArray()), eq(0), eq(5));
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.print("hello".toCharArray());
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println()}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintln() throws IOException
+ {
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println();
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(boolean)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintlnBoolean() throws IOException
+ {
+ writer.write("true", 0, 4);
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println(true);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(char)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintlnChar() throws IOException
+ {
+ writer.write("x", 0, 1);
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println('x');
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(int)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintlnInt() throws IOException
+ {
+ writer.write("152", 0, 3);
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println(152);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(long)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintlnLong() throws IOException
+ {
+ writer.write("152", 0, 3);
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println(152l);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(float)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintlnFloat() throws IOException
+ {
+ writer.write("0.5", 0, 3);
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println(0.5f);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(double)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintlnDouble() throws IOException
+ {
+ writer.write("0.5", 0, 3);
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println(0.5d);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(char[])}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintlnCharArray() throws IOException
+ {
+ writer.write(aryEq("hello".toCharArray()), eq(0), eq(5));
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println("hello".toCharArray());
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#clear()}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test(expected = IllegalStateException.class)
+ public void testClear() throws IOException
+ {
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.clear();
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#clearBuffer()}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test(expected = IllegalStateException.class)
+ public void testClearBuffer() throws IOException
+ {
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.clearBuffer();
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#getRemaining()}.
+ */
+ @Test
+ public void testGetRemaining()
+ {
+ jspWriter = new JspWriterImpl(writer);
+ assertEquals(0, jspWriter.getRemaining());
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(java.lang.String,
int, int)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testWriteStringIntInt() throws IOException
+ {
+ writer.write("hello", 0, 3);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.write("hello", 0, 3);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(java.lang.String)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testWriteString() throws IOException
+ {
+ writer.write("hello", 0, 5);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.write("hello");
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(java.lang.String)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintString() throws IOException
+ {
+ writer.write("hello", 0, 5);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.print("hello");
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(java.lang.Object)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintObject() throws IOException
+ {
+ writer.write("null", 0, 4);
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.print((Object) null);
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(java.lang.String)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintlnString() throws IOException
+ {
+ writer.write("hello", 0, 5);
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println("hello");
+ verify(writer);
+ }
+
+ /**
+ * Test method for {...@link
org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(java.lang.Object)}.
+ * @throws IOException If something goes wrong.
+ */
+ @Test
+ public void testPrintlnObject() throws IOException
+ {
+ writer.write("null", 0, 4);
+ writer.write(JspWriterImpl.lineSeparator, 0,
JspWriterImpl.lineSeparator.length());
+
+ replay(writer);
+ jspWriter = new JspWriterImpl(writer);
+ jspWriter.println((Object) null);
+ verify(writer);
+ }
+
+}