Author: julien(a)jboss.com
Date: 2008-01-28 09:58:17 -0500 (Mon, 28 Jan 2008)
New Revision: 9621
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentBufferTestCase.java
Modified:
modules/portlet/trunk/build/pom.xml
modules/portlet/trunk/portlet/pom.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- upgraded portlet poms to use servlet 2.5/jsp 2.1
Modified: modules/portlet/trunk/build/pom.xml
===================================================================
--- modules/portlet/trunk/build/pom.xml 2008-01-28 12:26:38 UTC (rev 9620)
+++ modules/portlet/trunk/build/pom.xml 2008-01-28 14:58:17 UTC (rev 9621)
@@ -28,7 +28,8 @@
<version.apache.portals.bridges>1.0.3</version.apache.portals.bridges>
<version.activation>1.0.2</version.activation>
<version.concurrent>1.3.4</version.concurrent>
- <version.sun.servlet>2.4</version.sun.servlet>
+ <version.javax.servlet>2.5</version.javax.servlet>
+ <version.javax.servlet.jsp>2.1</version.javax.servlet.jsp>
<version.apache.tomcat>5.5.12</version.apache.tomcat>
<version.jboss-common-core>2.2.1.GA</version.jboss-common-core>
<version.jboss-logging>2.0.3.GA</version.jboss-logging>
@@ -167,14 +168,14 @@
<version>${version.javassist}</version>
</dependency>
<dependency>
- <groupId>sun-servlet</groupId>
+ <groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- <version>${version.sun.servlet}</version>
+ <version>${version.javax.servlet}</version>
</dependency>
<dependency>
- <groupId>sun-servlet</groupId>
+ <groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
- <version>${version.sun.servlet}</version>
+ <version>${version.javax.servlet.jsp}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>apache-tomcat</groupId>-->
Modified: modules/portlet/trunk/portlet/pom.xml
===================================================================
--- modules/portlet/trunk/portlet/pom.xml 2008-01-28 12:26:38 UTC (rev 9620)
+++ modules/portlet/trunk/portlet/pom.xml 2008-01-28 14:58:17 UTC (rev 9621)
@@ -32,7 +32,7 @@
<artifactId>web-web</artifactId>
</dependency>
<dependency>
- <groupId>sun-servlet</groupId>
+ <groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</dependency>
<dependency>
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentBufferTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentBufferTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentBufferTestCase.java 2008-01-28
14:58:17 UTC (rev 9621)
@@ -0,0 +1,196 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.portal.portlet.impl.jsr168.ContentBuffer;
+import static org.jboss.unit.api.Assert.*;
+
+import java.io.PrintWriter;
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@Test
+public class ContentBufferTestCase
+{
+
+ @Test
+ public void testResetChars()
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ PrintWriter writer = buffer.getWriter();
+ writer.print("foo");
+ buffer.reset();
+ assertChars("", buffer.getChars().getBuffer());
+ }
+
+ @Test
+ public void testResetBytes() throws IOException
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ OutputStream out = buffer.getOutputStream();
+ out.write("foo".getBytes("UTF8"));
+ buffer.reset();
+ assertEquals(new byte[0], buffer.getBytes().toByteArray());
+ }
+
+ @Test
+ public void testResetAfterCommit()
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ buffer.commit();
+ try
+ {
+ buffer.reset();
+ fail();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+ }
+
+ @Test
+ public void testCommit()
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ assertFalse(buffer.isCommited());
+ buffer.commit();
+ assertTrue(buffer.isCommited());
+ }
+
+ @Test
+ public void testWriteCharsAfterCommit()
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ buffer.commit();
+ PrintWriter writer = buffer.getWriter();
+ assertNotNull(writer);
+ writer.print("foo");
+ writer.close();
+ assertChars("foo", buffer.getChars().getBuffer());
+ }
+
+ @Test
+ public void testWriteCharsAndCommit()
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ PrintWriter writer = buffer.getWriter();
+ assertNotNull(writer);
+ writer.print("foo");
+ buffer.commit();
+ writer.print("bar");
+ writer.close();
+ assertChars("foobar", buffer.getChars().getBuffer());
+ }
+
+ @Test
+ public void testWriteBytesAfterCommit() throws IOException
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ buffer.commit();
+ OutputStream out = buffer.getOutputStream();
+ assertNotNull(out);
+ out.write("foo".getBytes("UTF8"));
+ out.close();
+ assertEquals("foo".getBytes("UTF8"),
buffer.getBytes().toByteArray());
+ }
+
+ @Test
+ public void testWriteBytesAndCommit() throws IOException
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ buffer.commit();
+ OutputStream out = buffer.getOutputStream();
+ out.write("foo".getBytes("UTF8"));
+ assertNotNull(out);
+ out.write("bar".getBytes("UTF8"));
+ out.close();
+ assertEquals("foobar".getBytes("UTF8"),
buffer.getBytes().toByteArray());
+ }
+
+ @Test
+ public void testFlushWriterDoesCommit()
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ PrintWriter writer = buffer.getWriter();
+ writer.print("foo");
+ writer.flush();
+ assertTrue(buffer.isCommited());
+ }
+
+ @Test
+ public void testCloseWriterDoesCommit()
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ PrintWriter writer = buffer.getWriter();
+ writer.print("foo");
+ writer.close();
+ assertTrue(buffer.isCommited());
+ }
+
+ @Test
+ public void testFlushStreamDoesCommit() throws IOException
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ OutputStream out = buffer.getOutputStream();
+ out.write("foo".getBytes("UTF8"));
+ out.flush();
+ assertTrue(buffer.isCommited());
+ }
+
+ @Test
+ public void testClosestreamDoesCommit() throws IOException
+ {
+ ContentBuffer buffer = new ContentBuffer();
+ buffer.setContentType("text/html");
+ OutputStream out = buffer.getOutputStream();
+ out.write("foo".getBytes("UTF8"));
+ out.close();
+ assertTrue(buffer.isCommited());
+ }
+
+ private void assertChars(String s, StringBuffer sb)
+ {
+ int length = s.length();
+ assertEquals(length, sb.length());
+ char[] chars = new char[length];
+ sb.getChars(0, length, chars, 0);
+ assertEquals(s, new String(chars));
+ }
+
+}
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-28
12:26:38 UTC (rev 9620)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-28
14:58:17 UTC (rev 9621)
@@ -9,6 +9,7 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-tck-dispatcher.war"/>
</generic>
+<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-tck-portletconfig.war"/>
@@ -49,8 +50,10 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-tck-windowstates.war"/>
</generic>
+-->
<!--API Tests-->
+<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-api-actionrequest.war"/>
@@ -103,8 +106,10 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-api-windowstate.war"/>
</generic>
+-->
<!--Ext Tests-->
+<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-ext-portletconfig.war"/>
@@ -145,8 +150,10 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-ext-taglib.war"/>
</generic>
+-->
<!--Spec TCK Assertions tests-->
+<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr286-tck-portletconfig.war"/>
@@ -175,14 +182,18 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr286-tck-resourceserving.war"/>
</generic>
+-->
<!--Spec API Assertions tests-->
+<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr286-api-event.war"/>
</generic>
+-->
<!--Ext Assertions tests-->
+<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr286-ext-portletrequests.war"/>
@@ -191,6 +202,7 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr286-ext-portletresponses.war"/>
</generic>
+-->
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr286-ext-dispatcher.war"/>