JBoss Portal SVN: r9620 - modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-28 07:26:38 -0500 (Mon, 28 Jan 2008)
New Revision: 9620
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java
Log:
- implemented content commit/flush
- extends testcase for forward/include dispatch
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java 2008-01-28 12:26:38 UTC (rev 9620)
@@ -0,0 +1,387 @@
+/******************************************************************************
+ * 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.portlet.impl.jsr168;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+
+/**
+ * Data produced.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5602 $
+ */
+public class ContentBuffer
+{
+
+ /** . */
+ public static final int TYPE_EMPTY = 0;
+
+ /** . */
+ public static final int TYPE_CHARS = 1;
+
+ /** . */
+ public static final int TYPE_BYTES = 2;
+
+ /** The output as a bytes if any. */
+ private ClosableOutputStream bytes;
+
+ /** The output as chars if any. */
+ private ClosableWriter chars;
+
+ /** The writer that will produce the chars output if any. */
+ private PrintWriter writer;
+
+ /** The result content type if any. */
+ private String contentType;
+
+ /** . */
+ private boolean commited;
+
+ public ContentBuffer()
+ {
+ this.bytes = null;
+ this.chars = null;
+ this.writer = null;
+ this.contentType = null;
+ this.commited = false;
+ }
+
+ public int getType()
+ {
+ if (bytes == null)
+ {
+ if (chars == null)
+ {
+ return TYPE_EMPTY;
+ }
+ else
+ {
+ return TYPE_CHARS;
+ }
+ }
+ else
+ {
+ return TYPE_BYTES;
+ }
+ }
+
+ /**
+ * Return the content as a string.
+ *
+ * @return the content
+ */
+ public String getContent()
+ {
+ switch (getType())
+ {
+ case TYPE_CHARS:
+ return getChars().toString();
+ case TYPE_BYTES:
+ return getBytes().toString();
+ }
+ return "";
+ }
+
+ /**
+ * Return the bytes of the content held by the fragment.
+ *
+ * @return the bytes
+ * @throws IllegalArgumentException if the type is not bytes
+ */
+ public ByteArrayOutputStream getBytes() throws IllegalArgumentException
+ {
+ if (bytes == null)
+ {
+ throw new IllegalStateException("Bytes not used");
+ }
+ return (ByteArrayOutputStream)bytes.out;
+ }
+
+ /**
+ * Return the chars of the content held by the fragment.
+ *
+ * @return the chars
+ * @throws IllegalArgumentException if the type is not chars
+ */
+ public StringWriter getChars() throws IllegalArgumentException
+ {
+ if (chars == null)
+ {
+ throw new IllegalStateException("Chars not used");
+ }
+ return (StringWriter)chars.writer;
+ }
+
+ /**
+ * Return the content type of the generated fragment.
+ *
+ * @return the content type
+ */
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ /**
+ * Set the fragment of the content type.
+ *
+ * @param contentType the content type
+ */
+ public void setContentType(String contentType)
+ {
+ this.contentType = contentType;
+ }
+
+ /**
+ * Returns the writer.
+ *
+ * @return the writer
+ * @throws IllegalStateException if the output stream is already used or if no content type is defined
+ */
+ public PrintWriter getWriter() throws IllegalStateException
+ {
+ if (bytes != null)
+ {
+ throw new IllegalStateException("The window output stream is already used");
+ }
+ if (contentType == null)
+ {
+ throw new IllegalStateException("No content type defined");
+ }
+ if (chars == null)
+ {
+ chars = new ClosableWriter(new StringWriter());
+ writer = new PrintWriter(chars);
+ }
+ return writer;
+ }
+
+ /**
+ * @return the output stream
+ * @throws IllegalStateException if the window writer is already used or if no content type is defined
+ */
+ public OutputStream getOutputStream() throws IllegalStateException
+ {
+ if (chars != null)
+ {
+ throw new IllegalStateException("The window writer is already used");
+ }
+ if (contentType == null)
+ {
+ throw new IllegalStateException("No content type defined");
+ }
+ if (bytes == null)
+ {
+ bytes = new ClosableOutputStream(new ByteArrayOutputStream());
+ }
+ return bytes;
+ }
+
+ public void reset()
+ {
+ if (commited)
+ {
+ throw new IllegalStateException("Cannot reset a commited stream");
+ }
+ if (bytes != null)
+ {
+ ((ByteArrayOutputStream)bytes.out).reset();
+ }
+ else if (chars != null)
+ {
+ StringWriter sw = (StringWriter)chars.writer;
+ sw.flush();
+ sw.getBuffer().setLength(0);
+ }
+ }
+
+ /**
+ * Simulate a response commit.
+ *
+ * @throws IllegalStateException if no content type is defined
+ */
+ public void commit() throws IllegalStateException
+ {
+ if (contentType == null)
+ {
+ throw new IllegalStateException("No content type defined");
+ }
+ commited = true;
+ }
+
+ public boolean isCommited()
+ {
+ return commited;
+ }
+
+ private class ClosableOutputStream extends OutputStream
+ {
+
+ /** . */
+ boolean closed = false;
+
+ /** . */
+ final OutputStream out;
+
+ public ClosableOutputStream(OutputStream out)
+ {
+ this.out = out;
+ }
+
+
+ public void write(byte b[]) throws IOException
+ {
+ if (closed)
+ {
+ throw new IOException("Cannot write to a closed stream");
+ }
+
+ //
+ out.write(b);
+ }
+
+ public void write(byte b[], int off, int len) throws IOException
+ {
+ if (closed)
+ {
+ throw new IOException("Cannot write to a closed stream");
+ }
+
+ //
+ out.write(b, off, len);
+ }
+
+ public void write(int b) throws IOException
+ {
+ if (closed)
+ {
+ throw new IOException("Cannot write to a closed stream");
+ }
+
+ //
+ out.write(b);
+ }
+
+ public void flush() throws IOException
+ {
+ if (closed)
+ {
+ throw new IOException("Cannot flush a closed stream");
+ }
+
+ //
+ commited = true;
+ }
+
+ public void close() throws IOException
+ {
+ super.close();
+
+ //
+ commited = true;
+
+ //
+ closed = true;
+ }
+ }
+
+ /**
+ * Adds behavior to a writer that complies with JSR-168 notion of writer.
+ */
+ private class ClosableWriter extends Writer
+ {
+
+ /** . */
+ boolean closed = false;
+
+ /** . */
+ final Writer writer;
+
+ public ClosableWriter(Writer writer)
+ {
+ this.writer = writer;
+ }
+
+ public void write(int c) throws IOException
+ {
+ if (closed)
+ {
+ throw new IOException("Cannot write to a closed writer");
+ }
+
+ //
+ writer.write(c);
+ }
+
+
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ if (closed)
+ {
+ throw new IOException("Cannot write to a closed writer");
+ }
+
+ //
+ writer.write(cbuf, off, len);
+ }
+
+
+ public void write(String str) throws IOException
+ {
+ if (closed)
+ {
+ throw new IOException("Cannot write to a closed writer");
+ }
+
+ //
+ writer.write(str);
+ }
+
+ public void flush() throws IOException
+ {
+ if (closed)
+ {
+ throw new IOException("Cannot flush closed writer");
+ }
+
+ //
+ commited = true;
+ }
+
+ public void close() throws IOException
+ {
+ writer.close();
+
+ //
+ commited = true;
+
+ //
+ closed = true;
+ }
+ }
+}
\ No newline at end of file
18 years, 3 months
JBoss Portal SVN: r9619 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/invocation/response and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-28 07:25:21 -0500 (Mon, 28 Jan 2008)
New Revision: 9619
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentServlet.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentTestCase.java
modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/web.xml
Log:
- implemented content commit/flush
- extends testcase for forward/include dispatch
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-28 10:22:35 UTC (rev 9618)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-28 12:25:21 UTC (rev 9619)
@@ -183,6 +183,7 @@
public void flushBuffer() throws IOException
{
+ fragment.getBuffer().commit();
}
public void resetBuffer()
@@ -202,8 +203,7 @@
public boolean isCommitted()
{
- // Never afterCommit
- return false;
+ return fragment.getBuffer().isCommited();
}
public ResourceURL createResourceURL()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-01-28 10:22:35 UTC (rev 9618)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-01-28 12:25:21 UTC (rev 9619)
@@ -23,13 +23,12 @@
package org.jboss.portal.portlet.invocation.response;
import org.jboss.portal.portlet.cache.CacheControl;
+import org.jboss.portal.portlet.impl.jsr168.ContentBuffer;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.io.Writer;
/**
* Data produced.
@@ -41,29 +40,20 @@
{
/** . */
- public static final int TYPE_EMPTY = 0;
+ public static final int TYPE_EMPTY = ContentBuffer.TYPE_EMPTY;
/** . */
- public static final int TYPE_CHARS = 1;
+ public static final int TYPE_CHARS = ContentBuffer.TYPE_CHARS;
/** . */
- public static final int TYPE_BYTES = 2;
+ public static final int TYPE_BYTES = ContentBuffer.TYPE_BYTES;
/** . */
private ResponseProperties properties;
- /** The output as a bytes if any. */
- private ClosableOutputStream bytes;
+ /** . */
+ private ContentBuffer buffer;
- /** The output as chars if any. */
- private ClosableWriter chars;
-
- /** The writer that will produce the chars output if any. */
- private PrintWriter writer;
-
- /** The result content type if any. */
- private String contentType;
-
/** The title if any. */
private String title;
@@ -72,10 +62,7 @@
public FragmentResponse()
{
- this.bytes = null;
- this.chars = null;
- this.writer = null;
- this.contentType = null;
+ this.buffer = new ContentBuffer();
this.title = null;
this.cacheControl = null;
this.properties = null;
@@ -103,21 +90,7 @@
public int getType()
{
- if (bytes == null)
- {
- if (chars == null)
- {
- return TYPE_EMPTY;
- }
- else
- {
- return TYPE_CHARS;
- }
- }
- else
- {
- return TYPE_BYTES;
- }
+ return buffer.getType();
}
/**
@@ -128,11 +101,7 @@
*/
public ByteArrayOutputStream getBytes() throws IllegalArgumentException
{
- if (bytes == null)
- {
- throw new IllegalStateException("Bytes not used");
- }
- return (ByteArrayOutputStream)bytes.out;
+ return buffer.getBytes();
}
/**
@@ -143,11 +112,7 @@
*/
public StringWriter getChars() throws IllegalArgumentException
{
- if (chars == null)
- {
- throw new IllegalStateException("Chars not used");
- }
- return (StringWriter)chars.writer;
+ return buffer.getChars();
}
/**
@@ -177,7 +142,7 @@
*/
public String getContentType()
{
- return contentType;
+ return buffer.getContentType();
}
/**
@@ -187,7 +152,7 @@
*/
public void setContentType(String contentType)
{
- this.contentType = contentType;
+ buffer.setContentType(contentType);
}
/**
@@ -198,20 +163,7 @@
*/
public PrintWriter getWriter() throws IllegalStateException
{
- if (bytes != null)
- {
- throw new IllegalStateException("The window output stream is already used");
- }
- if (contentType == null)
- {
- throw new IllegalStateException("No content type defined");
- }
- if (chars == null)
- {
- chars = new ClosableWriter(new StringWriter());
- writer = new PrintWriter(chars);
- }
- return writer;
+ return buffer.getWriter();
}
/**
@@ -220,197 +172,16 @@
*/
public OutputStream getOutputStream() throws IllegalStateException
{
- if (chars != null)
- {
- throw new IllegalStateException("The window writer is already used");
- }
- if (contentType == null)
- {
- throw new IllegalStateException("No content type defined");
- }
- if (bytes == null)
- {
- bytes = new ClosableOutputStream(new ByteArrayOutputStream());
- }
- return bytes;
+ return buffer.getOutputStream();
}
public void resetBuffer()
{
- if (bytes != null)
- {
- if (bytes.closed)
- {
- throw new IllegalStateException("Cannot reset a closed stream");
- }
- ((ByteArrayOutputStream)bytes.out).reset();
- }
- else if (chars != null)
- {
- if (chars.closed)
- {
- throw new IllegalStateException("Cannot reset a closed writer");
- }
- StringWriter sw = (StringWriter)chars.writer;
- sw.flush();
- sw.getBuffer().setLength(0);
- }
+ buffer.reset();
}
- private class ClosableOutputStream extends OutputStream
+ public ContentBuffer getBuffer()
{
-
- /** . */
- boolean closed = false;
-
- /** . */
- final OutputStream out;
-
- public ClosableOutputStream(OutputStream out)
- {
- this.out = out;
- }
-
-
- public void write(byte b[]) throws IOException
- {
- if (closed)
- {
- throw new IOException("Cannot write to a closed stream");
- }
-
- //
- out.write(b);
- }
-
- public void write(byte b[], int off, int len) throws IOException
- {
- if (closed)
- {
- throw new IOException("Cannot write to a closed stream");
- }
-
- //
- out.write(b, off, len);
- }
-
- public void write(int b) throws IOException
- {
- if (closed)
- {
- throw new IOException("Cannot write to a closed stream");
- }
-
- //
- out.write(b);
- }
-
- public void flush() throws IOException
- {
- if (closed)
- {
- throw new IOException("Cannot flush a closed stream");
- }
-
- //
- out.flush();
- }
-
- public void close() throws IOException
- {
- super.close();
-
- //
- closed = true;
- }
+ return buffer;
}
-
- /**
- * Adds behavior to a writer that complies with JSR-168 notion of writer.
- */
- private class ClosableWriter extends Writer
- {
-
- /** . */
- boolean closed = false;
-
- /** . */
- final Writer writer;
-
- public ClosableWriter(Writer writer)
- {
- this.writer = writer;
- }
-
- public void write(int c) throws IOException
- {
- if (closed)
- {
- throw new IOException("Cannot write to a closed writer");
- }
-
- //
- writer.write(c);
- }
-
-
- public void write(char cbuf[], int off, int len) throws IOException
- {
- if (closed)
- {
- throw new IOException("Cannot write to a closed writer");
- }
-
- //
- writer.write(cbuf, off, len);
- }
-
-
- public void write(String str) throws IOException
- {
- if (closed)
- {
- throw new IOException("Cannot write to a closed writer");
- }
-
- //
- writer.write(str);
- }
-
- public void flush() throws IOException
- {
- if (closed)
- {
- throw new IOException("Cannot flush closed writer");
- }
-
- //
- writer.flush();
- }
-
- public void close() throws IOException
- {
- writer.close();
-
- //
- closed = true;
- }
- }
-
- /**
- * Return the content as a string.
- *
- * @return the content
- */
- public String getContent()
- {
- switch (getType())
- {
- case FragmentResponse.TYPE_CHARS:
- return getChars().toString();
- case FragmentResponse.TYPE_BYTES:
- return getBytes().toString();
- }
- return "";
- }
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentServlet.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentServlet.java 2008-01-28 10:22:35 UTC (rev 9618)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentServlet.java 2008-01-28 12:25:21 UTC (rev 9619)
@@ -37,15 +37,19 @@
{
/** . */
- public static final ThreadLocal<String> value = new ThreadLocal<String>();
+ private String content;
+ public void init() throws ServletException
+ {
+ content = getServletConfig().getInitParameter("content");
+ }
+
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
PrintWriter writer = resp.getWriter();
- String s = value.get();
- if (s != null)
+ if (content != null)
{
- writer.print(value.get());
+ writer.print(content);
}
}
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentTestCase.java 2008-01-28 10:22:35 UTC (rev 9618)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentTestCase.java 2008-01-28 12:25:21 UTC (rev 9619)
@@ -60,7 +60,6 @@
//
PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getRequestDispatcher("/ForwardedRequestContentServlet");
assertNotNull(prd);
- ContentServlet.value.set("@ForwardedRequestContent@");
prd.forward(request, response);
//
@@ -85,25 +84,81 @@
writer.print("@ShouldNotBePresent@");
//
- PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getRequestDispatcher("/NamedRequestContentServlet");
+ PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getNamedDispatcher("ForwardedNamedContentServlet");
assertNotNull(prd);
- ContentServlet.value.set("@NamedRequestContent@");
prd.forward(request, response);
//
- return new EndTestResponse();
+ assertTrue(response.isCommitted());
+
+ //
+ return new InvokeGetResponse(response.createRenderURL().toString());
}
});
- seq.bindAction(1, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ seq.bindAction(2, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
byte[] bytes = context.getResponseBody();
String s = new String(bytes);
assertFalse("Page " + s + " should not contain the string @ShouldNotBePresent@", s.contains("@ShouldNotBePresent@"));
- assertTrue("Page " + s + " should contain the string @NamedRequestContent@", s.contains("@NamedRequestContent@"));
+ assertTrue("Page " + s + " should contain the string @NamedRequestContent@", s.contains("@ForwardedNamedContent@"));
//
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.print("@BeforeIncludeRequestContent@");
+
+ //
+ PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getRequestDispatcher("/IncludedRequestContentServlet");
+ assertNotNull(prd);
+ prd.include(request, response);
+
+ //
+ assertFalse(response.isCommitted());
+ writer.print("@AfterIncludeRequestContent@");
+
+ //
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(3, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ byte[] bytes = context.getResponseBody();
+ String s = new String(bytes);
+ String t = "@BeforeIncludeRequestContent@@IncludedRequestContent@@AfterIncludeRequestContent@";
+ assertTrue("Page " + s + " should contain the string " + t, s.contains(t));
+
+ //
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.print("@BeforeIncludeNamedContent@");
+
+ //
+ PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getNamedDispatcher("IncludedNamedContentServlet");
+ assertNotNull(prd);
+ prd.include(request, response);
+
+ //
+ assertFalse(response.isCommitted());
+ writer.print("@AfterIncludeNamedContent@");
+
+ //
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(4, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ byte[] bytes = context.getResponseBody();
+ String s = new String(bytes);
+ String t = "@BeforeIncludeNamedContent@@IncludedNamedContent@@AfterIncludeNamedContent@";
+ assertTrue("Page " + s + " should contain the string " + t, s.contains(t));
+
+ //
return new EndTestResponse();
}
});
Modified: modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-01-28 10:22:35 UTC (rev 9618)
+++ modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-01-28 12:25:21 UTC (rev 9619)
@@ -31,5 +31,8 @@
<test>
<class name="org.jboss.portal.test.portlet.PropertiesTestCase"/>
</test>
+ <test>
+ <class name="org.jboss.portal.test.portlet.ContentBufferTestCase"/>
+ </test>
</pojo>
</jboss-unit>
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-28 10:22:35 UTC (rev 9618)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-28 12:25:21 UTC (rev 9619)
@@ -742,7 +742,7 @@
if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
{
writer.print("<div id=\"portlet\">");
- writer.print(fragment.getContent());
+ writer.print(fragment.getBuffer().getContent());
writer.print("</div>");
}
else
Modified: modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/web.xml 2008-01-28 10:22:35 UTC (rev 9618)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/web.xml 2008-01-28 12:25:21 UTC (rev 9619)
@@ -175,13 +175,39 @@
<servlet>
<servlet-name>ForwardedRequestContentServlet</servlet-name>
<servlet-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ContentServlet</servlet-class>
+ <init-param>
+ <param-name>content</param-name>
+ <param-value>@ForwardedRequestContent@</param-value>
+ </init-param>
</servlet>
<servlet>
<servlet-name>ForwardedNamedContentServlet</servlet-name>
<servlet-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ContentServlet</servlet-class>
+ <init-param>
+ <param-name>content</param-name>
+ <param-value>@ForwardedNamedContent@</param-value>
+ </init-param>
</servlet>
+ <servlet>
+ <servlet-name>IncludedRequestContentServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ContentServlet</servlet-class>
+ <init-param>
+ <param-name>content</param-name>
+ <param-value>@IncludedRequestContent@</param-value>
+ </init-param>
+ </servlet>
+
+ <servlet>
+ <servlet-name>IncludedNamedContentServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ContentServlet</servlet-class>
+ <init-param>
+ <param-name>content</param-name>
+ <param-value>@IncludedNamedContent@</param-value>
+ </init-param>
+ </servlet>
+
<servlet-mapping>
<servlet-name>UniversalServletA</servlet-name>
<url-pattern>/universalServletA</url-pattern>
@@ -203,8 +229,8 @@
</servlet-mapping>
<servlet-mapping>
- <servlet-name>ForwardedNamedContentServlet</servlet-name>
- <url-pattern>/ForwardedNamedContentServlet</url-pattern>
+ <servlet-name>IncludedRequestContentServlet</servlet-name>
+ <url-pattern>/IncludedRequestContentServlet</url-pattern>
</servlet-mapping>
</web-app>
18 years, 3 months
JBoss Portal SVN: r9618 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168 and 11 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-28 05:22:35 -0500 (Mon, 28 Jan 2008)
New Revision: 9618
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/LifeCyclePhase.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchType.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentServlet.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/DispatchingFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/DispatchingFilterTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/FiltersTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/GetRequestURITestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/RequestHeaderAccessTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ServletFilter.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/
modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/web.xml
modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/dispatchedFromFilter.jsp
Removed:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/
modules/portlet/trunk/test/src/test/resources/jsr168/ext/dispatcher-war/
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletResponse.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- moved ext dispatcher test to 286 (since it is ext)
- started to add forward implemenation and test cases
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/LifeCyclePhase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/LifeCyclePhase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/LifeCyclePhase.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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.portlet;
+
+/**
+ * Enumerate the life cycle phase of a Portlet.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum LifeCyclePhase
+{
+ ACTION, EVENT, RENDER, RESOURCE
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchType.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchType.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchType.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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.portlet.impl.jsr168;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum DispatchType
+{
+
+ INCLUDE, FORWARD
+
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2008-01-27 13:39:31 UTC (rev 9617)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -48,18 +48,35 @@
public class DispatchedHttpServletRequest extends HttpServletRequestWrapper
{
+ /** . */
private static final String REQUEST_URI = "javax.servlet.include.request_uri";
+
+ /** . */
private static final String CONTEXT_PATH = "javax.servlet.include.context_path";
+
+ /** . */
private static final String SERVLET_PATH = "javax.servlet.include.servlet_path";
+
+ /** . */
private static final String PATH_INFO = "javax.servlet.include.path_info";
+
+ /** . */
private static final String QUERY_STRING = "javax.servlet.include.query_string";
+ /** . */
+ final DispatchType dispatchType;
+
+ /** . */
private RenderRequestImpl rreq;
+
+ /** . */
private HttpServletRequest dreq;
- private final Map parameters;
+ /** . */
+ private final Map<String, String[]> parameters;
public DispatchedHttpServletRequest(
+ DispatchType dispatchType,
RenderRequestImpl rreq,
HttpServletRequest dreq,
String path)
@@ -67,6 +84,7 @@
super(dreq);
//
+ this.dispatchType = dispatchType;
this.rreq = rreq;
this.dreq = dreq;
@@ -75,6 +93,7 @@
{
String queryString;
+ //
int endOfServletPath = path.indexOf('/', 1);
if (endOfServletPath == -1)
{
@@ -314,7 +333,7 @@
}
//
- String[] values = (String[])parameters.get(name);
+ String[] values = parameters.get(name);
if (values != null)
{
return values[0];
@@ -337,10 +356,10 @@
}
//
- String[] values = (String[])parameters.get(name);
+ String[] values = parameters.get(name);
if (values != null)
{
- return (String[])values.clone();
+ return values.clone();
}
//
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletResponse.java 2008-01-27 13:39:31 UTC (rev 9617)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletResponse.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -39,12 +39,38 @@
public class DispatchedHttpServletResponse extends HttpServletResponseWrapper
{
+ /** . */
+ DispatchedHttpServletRequest req;
+
+ /** . */
private RenderResponse rresp;
+
+ /** . */
private ServletOutputStream sos;
- public DispatchedHttpServletResponse(RenderResponse rresp, HttpServletResponse dresp)
+ public DispatchedHttpServletResponse(
+ DispatchedHttpServletRequest req,
+ RenderResponse rresp,
+ HttpServletResponse dresp)
{
super(dresp);
+
+ //
+// switch (req.dispatchType)
+// {
+// case INCLUDE:
+// break;
+// case FORWARD:
+//
+// // Discard existing content
+// rresp.reset();
+//
+// //
+// break;
+// }
+
+ //
+ this.req = req;
this.rresp = rresp;
this.sos = null;
}
@@ -104,7 +130,8 @@
{
sos = new ServletOutputStream()
{
- private OutputStream out = rresp.getPortletOutputStream();
+ /** . */
+ private final OutputStream out = rresp.getPortletOutputStream();
public void write(byte b[], int off, int len) throws IOException
{
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java 2008-01-27 13:39:31 UTC (rev 9617)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -27,6 +27,8 @@
import org.jboss.portal.portlet.impl.jsr168.APIConstants;
import org.jboss.portal.portlet.impl.jsr168.DispatchedHttpServletRequest;
import org.jboss.portal.portlet.impl.jsr168.DispatchedHttpServletResponse;
+import org.jboss.portal.portlet.impl.jsr168.DispatchType;
+import org.jboss.portal.portlet.LifeCyclePhase;
import org.jboss.portal.common.NotYetImplemented;
import javax.portlet.PortletException;
@@ -35,6 +37,9 @@
import javax.portlet.RenderResponse;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.EventRequest;
+import javax.portlet.ResourceRequest;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -68,6 +73,42 @@
public void include(RenderRequest req, RenderResponse resp) throws PortletException, IOException
{
+ dispatch(DispatchType.INCLUDE, req, resp);
+ }
+
+ public void include(PortletRequest req, PortletResponse resp) throws PortletException, IOException
+ {
+ dispatch(DispatchType.INCLUDE, req, resp);
+ }
+
+ public void forward(PortletRequest req, PortletResponse resp) throws PortletException, IOException, IllegalStateException
+ {
+ dispatch(DispatchType.FORWARD, req, resp);
+ }
+
+ private void dispatch(
+ DispatchType type,
+ PortletRequest req,
+ PortletResponse resp) throws PortletException, IOException
+ {
+ LifeCyclePhase phase;
+ if (req instanceof ActionRequest)
+ {
+ phase = LifeCyclePhase.ACTION;
+ }
+ else if (req instanceof EventRequest)
+ {
+ phase = LifeCyclePhase.EVENT;
+ }
+ else if (req instanceof RenderRequest)
+ {
+ phase = LifeCyclePhase.RENDER;
+ }
+ else if (req instanceof ResourceRequest)
+ {
+ phase = LifeCyclePhase.RESOURCE;
+ }
+
try
{
// Get the invocation that is still in the request
@@ -77,16 +118,20 @@
HttpServletRequest dreq = invocation.getDispatchedRequest();
HttpServletResponse dresp = invocation.getDispatchedResponse();
- // It was set by the PortletContainerInvoker before diving into the portlet, so let's just reuse them
- RenderRequest rreq = (RenderRequest)req.getAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
- RenderResponse rresp = (RenderResponse)req.getAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
-
//
- DispatchedHttpServletRequest direq = new DispatchedHttpServletRequest((RenderRequestImpl)rreq, dreq, path);
- DispatchedHttpServletResponse diresp = new DispatchedHttpServletResponse(rresp, dresp);
+ DispatchedHttpServletRequest direq = new DispatchedHttpServletRequest(type, (RenderRequestImpl)req, dreq, path);
+ DispatchedHttpServletResponse diresp = new DispatchedHttpServletResponse(direq, (RenderResponse)resp, dresp);
//
- dispatcher.include(direq, diresp);
+ switch (type)
+ {
+ case INCLUDE:
+ dispatcher.include(direq, diresp);
+ break;
+ case FORWARD:
+ dispatcher.forward(direq, diresp);
+ break;
+ }
}
catch (ServletException e)
{
@@ -94,14 +139,4 @@
throw new PortletException(e);
}
}
-
- public void include(PortletRequest portletRequest, PortletResponse portletResponse) throws PortletException, IOException
- {
- throw new NotYetImplemented();
- }
-
- public void forward(PortletRequest portletRequest, PortletResponse portletResponse) throws PortletException, IOException, IllegalStateException
- {
- throw new NotYetImplemented();
- }
}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentServlet.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentServlet.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentServlet.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * 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.jsr286.ext.dispatcher;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ContentServlet extends HttpServlet
+{
+
+ /** . */
+ public static final ThreadLocal<String> value = new ThreadLocal<String>();
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ PrintWriter writer = resp.getWriter();
+ String s = value.get();
+ if (s != null)
+ {
+ writer.print(value.get());
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ContentTestCase.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * 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.jsr286.ext.dispatcher;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP4;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class ContentTestCase
+{
+ public ContentTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.print("@ShouldNotBePresent@");
+
+ //
+ PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getRequestDispatcher("/ForwardedRequestContentServlet");
+ assertNotNull(prd);
+ ContentServlet.value.set("@ForwardedRequestContent@");
+ prd.forward(request, response);
+
+ //
+ assertTrue(response.isCommitted());
+
+ //
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(1, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ byte[] bytes = context.getResponseBody();
+ String s = new String(bytes);
+ assertFalse("Page " + s + " should not contain the string @ShouldNotBePresent@", s.contains("@ShouldNotBePresent@"));
+ assertTrue("Page " + s + " should contain the string @ForwardedRequestContent@", s.contains("@ForwardedRequestContent@"));
+
+ //
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.print("@ShouldNotBePresent@");
+
+ //
+ PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getRequestDispatcher("/NamedRequestContentServlet");
+ assertNotNull(prd);
+ ContentServlet.value.set("@NamedRequestContent@");
+ prd.forward(request, response);
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ seq.bindAction(1, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ byte[] bytes = context.getResponseBody();
+ String s = new String(bytes);
+ assertFalse("Page " + s + " should not contain the string @ShouldNotBePresent@", s.contains("@ShouldNotBePresent@"));
+ assertTrue("Page " + s + " should contain the string @NamedRequestContent@", s.contains("@NamedRequestContent@"));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/DispatchingFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/DispatchingFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/DispatchingFilter.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * 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.jsr286.ext.dispatcher;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.RequestDispatcher;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DispatchingFilter implements Filter
+{
+
+ private FilterConfig cfg;
+
+ public void init(FilterConfig cfg) throws ServletException
+ {
+ this.cfg = cfg;
+ }
+
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException
+ {
+
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+
+ RequestDispatcher rd = cfg.getServletContext().getRequestDispatcher("/dispatchedFromFilter.jsp");
+ rd.include(req, resp);
+
+ }
+
+ public void destroy()
+ {
+ this.cfg = null;
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/DispatchingFilterTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/DispatchingFilterTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/DispatchingFilterTestCase.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * 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.jsr286.ext.dispatcher;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP3;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@TestCase
+public class DispatchingFilterTestCase
+{
+ public DispatchingFilterTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+
+ // Need to set content type as we will include a JSP that will produce output
+ response.setContentType("text/html");
+
+ //
+ PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getNamedDispatcher("TargetForIncludeNamedDispatchingFilter");
+ assertNotNull(prd);
+ prd.include(request, response);
+
+ //
+ prd = request.getPortletSession().getPortletContext().getRequestDispatcher("/TargetForIncludeURLPatternDispatchingFilter");
+ assertNotNull(prd);
+ prd.include(request, response);
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/FiltersTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/FiltersTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/FiltersTestCase.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * 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.jsr286.ext.dispatcher;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP2;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.assertEquals;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import java.io.IOException;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@TestCase
+public class FiltersTestCase
+{
+ public FiltersTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getRequestDispatcher("/noop");
+ assertNotNull(prd);
+ ServletFilter.ids.clear();
+ prd.include(request, response);
+ assertEquals(Tools.toSet("INCLUDE_URL_PATTERN_FILTER", "INCLUDE_NAMED_FILTER"), ServletFilter.ids);
+
+ //
+ prd = request.getPortletSession().getPortletContext().getNamedDispatcher("NoopServlet");
+ assertNotNull(prd);
+ ServletFilter.ids.clear();
+ prd.include(request, response);
+ assertEquals(Collections.singleton("INCLUDE_NAMED_FILTER"), ServletFilter.ids);
+
+ //
+ prd = request.getPortletSession().getPortletContext().getRequestDispatcher("/noop");
+ assertNotNull(prd);
+ ServletFilter.ids.clear();
+ prd.forward(request, response);
+ assertEquals(Tools.toSet("FORWARD_URL_PATTERN_FILTER", "FORWARD_NAMED_FILTER"), ServletFilter.ids);
+
+ //
+ prd = request.getPortletSession().getPortletContext().getNamedDispatcher("NoopServlet");
+ assertNotNull(prd);
+ ServletFilter.ids.clear();
+ prd.forward(request, response);
+ assertEquals(Collections.singleton("FORWARD_NAMED_FILTER"), ServletFilter.ids);
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/GetRequestURITestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/GetRequestURITestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/GetRequestURITestCase.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * 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.jsr286.ext.dispatcher;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.base.AbstractUniversalTestPortlet;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertEquals;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@TestCase
+public class GetRequestURITestCase
+{
+
+ public static final String SERVLET_A_URI = "/test-jsr286-ext-dispatcher/universalServletA";
+
+ public GetRequestURITestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA");
+ response.setContentType("text/html");
+ dispatcher.include(request, response);
+ return null;
+ }
+ });
+
+
+ seq.bindAction(0, UTS1.SERVICE_JOIN_POINT, new ServletServiceTestAction()
+ {
+ protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+ {
+ assertEquals(SERVLET_A_URI, request.getRequestURI());
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/RequestHeaderAccessTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/RequestHeaderAccessTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/RequestHeaderAccessTestCase.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,107 @@
+/******************************************************************************
+ * 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.jsr286.ext.dispatcher;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.base.AbstractUniversalTestPortlet;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertFalse;
+import static org.jboss.unit.api.Assert.assertNull;
+import static org.jboss.unit.api.Assert.assertTrue;
+import static org.jboss.unit.api.Assert.assertEquals;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Set;
+import java.util.Enumeration;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@TestCase
+public class RequestHeaderAccessTestCase
+{
+ public RequestHeaderAccessTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ // Test the value is not there yet
+ Set propertyNames = Tools.toSet(request.getPropertyNames());
+ assertFalse(propertyNames.contains("myheader"));
+ assertNull(request.getProperty("myheader"));
+ assertFalse(request.getProperties("myheader").hasMoreElements());
+
+ // Invoke render with header
+ InvokeGetResponse render = new InvokeGetResponse(response.createRenderURL().toString());
+ render.addHeader("myheader").addElement("render-value");
+ return render;
+ }
+ });
+
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA");
+ response.setContentType("text/html");
+ dispatcher.include(request, response);
+ return null;
+ }
+ });
+
+ seq.bindAction(1, UTS1.SERVICE_JOIN_POINT, new ServletServiceTestAction()
+ {
+ protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context)
+ {
+ // Test the header is here
+ Set headerNames = Tools.toSet(request.getHeaderNames());
+ assertTrue(headerNames.contains("myheader"));
+ assertEquals("render-value", request.getHeader("myheader"));
+ Enumeration values = request.getHeaders("myheader");
+ assertTrue(values.hasMoreElements());
+ assertEquals("render-value", values.nextElement());
+ assertFalse(values.hasMoreElements());
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ServletFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ServletFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/dispatcher/ServletFilter.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * 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.jsr286.ext.dispatcher;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import java.io.IOException;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServletFilter implements Filter
+{
+
+ public static final Set ids = new HashSet();
+
+ private String id;
+
+ public void init(FilterConfig cfg) throws ServletException
+ {
+ id = cfg.getInitParameter("id");
+ }
+
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException
+ {
+ if (id == null)
+ {
+ throw new ServletException("No id found in the servlet filter config");
+ }
+
+ //
+ ids.add(id);
+
+ //
+ chain.doFilter(req, resp);
+ }
+
+ public void destroy()
+ {
+ id = null;
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-27 13:39:31 UTC (rev 9617)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-28 10:22:35 UTC (rev 9618)
@@ -739,9 +739,16 @@
writer.print("<body>");
for (FragmentResponse fragment : fragments)
{
- writer.print("<div>");
- // Do something with fragment
- writer.print("</div>");
+ if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
+ {
+ writer.print("<div id=\"portlet\">");
+ writer.print(fragment.getContent());
+ writer.print("</div>");
+ }
+ else
+ {
+ writer.print("<div/>");
+ }
}
writer.print("</body></html>");
}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-27 13:39:31 UTC (rev 9617)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-28 10:22:35 UTC (rev 9618)
@@ -233,7 +233,6 @@
<package-ext-test test="portletrequests"/>
<package-ext-test test="portletmode"/>
<package-ext-test test="portletconfig"/>
- <package-ext-test test="dispatcher"/>
<package-ext-test test="taglib"/>
<package-misc-test test="log4j"/>
@@ -250,6 +249,7 @@
<package-jsr286-ext-test test="portletrequests"/>
<package-jsr286-ext-test test="portletresponses"/>
+ <package-jsr286-ext-test test="dispatcher"/>
<jar jarfile="${test.temp.lib}/portlet-test-lib.jar">
<fileset dir="${target}/test-classes"/>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/portlet.xml 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ version="1.0">
+
+
+ <portlet>
+ <portlet-name>TestUniversalPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletB</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP2</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletC</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP3</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletD</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP4</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/WEB-INF/web.xml 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,210 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<web-app
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <filter>
+ <filter-name>IncludeURLPatternFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>INCLUDE_URL_PATTERN_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>IncludeNamedFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>INCLUDE_NAMED_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>RequestURLPatternFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>REQUEST_URL_PATTERN_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>RequestNamedFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>REQUEST_NAMED_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>ForwardURLPatternFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>FORWARD_URL_PATTERN_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>ForwardNamedFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ServletFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>FORWARD_NAMED_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>IncludeNamedJSPDispatchingFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.DispatchingFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>INCLUDE_NAMED_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>IncludeURLPatternJSPDispatchingFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.DispatchingFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>INCLUDE_URL_PATTERN_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>IncludeURLPatternFilter</filter-name>
+ <url-pattern>/noop</url-pattern>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>IncludeNamedFilter</filter-name>
+ <servlet-name>NoopServlet</servlet-name>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>ForwardURLPatternFilter</filter-name>
+ <url-pattern>/noop</url-pattern>
+ <dispatcher>FORWARD</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>ForwardNamedFilter</filter-name>
+ <servlet-name>NoopServlet</servlet-name>
+ <dispatcher>FORWARD</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>RequestURLPatternFilter</filter-name>
+ <url-pattern>/noop</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>RequestNamedFilter</filter-name>
+ <servlet-name>NoopServlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>IncludeNamedJSPDispatchingFilter</filter-name>
+ <servlet-name>TargetForIncludeNamedDispatchingFilter</servlet-name>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>IncludeURLPatternJSPDispatchingFilter</filter-name>
+ <url-pattern>/TargetForIncludeURLPatternDispatchingFilter</url-pattern>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <listener>
+ <listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>UniversalServletA</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.framework.UTS1</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>NoopServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.framework.NoopServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>TargetForIncludeNamedDispatchingFilter</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.framework.NoopServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>TargetForIncludeURLPatternDispatchingFilter</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.framework.NoopServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>ForwardedRequestContentServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ContentServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>ForwardedNamedContentServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.jsr286.ext.dispatcher.ContentServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>UniversalServletA</servlet-name>
+ <url-pattern>/universalServletA</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>NoopServlet</servlet-name>
+ <url-pattern>/noop</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>TargetForIncludeURLPatternDispatchingFilter</servlet-name>
+ <url-pattern>/TargetForIncludeURLPatternDispatchingFilter</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>ForwardedRequestContentServlet</servlet-name>
+ <url-pattern>/ForwardedRequestContentServlet</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>ForwardedNamedContentServlet</servlet-name>
+ <url-pattern>/ForwardedNamedContentServlet</url-pattern>
+ </servlet-mapping>
+
+</web-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/dispatchedFromFilter.jsp
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/dispatchedFromFilter.jsp (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/dispatcher-war/dispatchedFromFilter.jsp 2008-01-28 10:22:35 UTC (rev 9618)
@@ -0,0 +1,8 @@
+<%@ page language="java" %>
+
+<%
+ System.out.println("HELLO FROM JSP");
+ System.out.println("HELLO FROM JSP");
+ System.out.println("HELLO FROM JSP");
+ System.out.println("HELLO FROM JSP");
+%>
\ No newline at end of file
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-27 13:39:31 UTC (rev 9617)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-28 10:22:35 UTC (rev 9618)
@@ -107,10 +107,6 @@
<!--Ext Tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
- <property name="archiveId" value="test-jsr168-ext-dispatcher.war"/>
- </generic>
- <generic>
- <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-portletconfig.war"/>
</generic>
<generic>
@@ -195,6 +191,10 @@
<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"/>
+ </generic>
<!--Misc Tests-->
<!--
18 years, 3 months
JBoss Portal SVN: r9617 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/taglib and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-27 08:39:31 -0500 (Sun, 27 Jan 2008)
New Revision: 9617
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/taglib/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/taglib/TaglibTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/
modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/WEB-INF/web.xml
modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/usetaglib.jsp
Modified:
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
added basic test case for JSR 168 taglib
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/taglib/TaglibTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/taglib/TaglibTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/taglib/TaglibTestCase.java 2008-01-27 13:39:31 UTC (rev 9617)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * 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.jsr168.ext.taglib;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.base.AbstractUniversalTestPortlet;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import static org.jboss.unit.api.Assert.assertEquals;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletSession;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletException;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+
+/**
+ * The goal is to test that cross context session attributes are set in container and are accessible from the direct
+ * servlet.
+ * <p/>
+ * 1/ portlet put key=value in the http session 2/ portlet ask the client to perform get on /servlet 3/ servlet check
+ * that key=value
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@TestCase
+public class TaglibTestCase
+{
+ public TaglibTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ response.setContentType("text/html");
+ PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/usetaglib.jsp");
+ dispatcher.include(request, response);
+ return new EndTestResponse();
+ }
+ });
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-25 22:38:16 UTC (rev 9616)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-27 13:39:31 UTC (rev 9617)
@@ -176,6 +176,12 @@
<!--Portlet test framework lib jar-->
<jar jarfile="${test.temp.lib}/portal-portlet-test-framework-lib.jar">
<fileset dir="${test.temp.portlet}" includes="org/jboss/portal/unit/**"/>
+
+ <!-- JSR 168 TLD -->
+ <zipfileset
+ src="${dependency.portal-portlet.jar}"
+ includes="org/jboss/portal/portlet/portlet.tld"
+ fullpath="META-INF/portlet.tld"/>
</jar>
<!--<jar jarfile="${test.temp.lib}/test-info.jar">-->
@@ -228,6 +234,7 @@
<package-ext-test test="portletmode"/>
<package-ext-test test="portletconfig"/>
<package-ext-test test="dispatcher"/>
+ <package-ext-test test="taglib"/>
<package-misc-test test="log4j"/>
@@ -313,7 +320,6 @@
<pathelement path="${dependency.jboss-kernel.jar}"/>
</path>
<path id="mc.portal-common">
- <!--<pathelement path="${dependency.portal-common.jar}"/>-->
<pathelement path="${dependency.portal-common-mc.jar}"/>
</path>
<path id="mc.jboss-unit">
@@ -332,9 +338,6 @@
<path id="mc.log4j">
<pathelement path="${dependency.log4j.jar}"/>
</path>
- <path id="mc.portal-portlet">
- <pathelement path="${dependency.portal-portlet.jar}"/>
- </path>
<path id="mc.jaxb-api">
<pathelement path="${dependency.jaxb-api.jar}"/>
</path>
@@ -346,7 +349,7 @@
<fileset dir="${test.temp.lib}" includes="portlet-test-lib.jar"/>
<path refid="mc.portal-common"/>
- <path refid="mc.portal-portlet"/>
+ <!--<path location="${dependency.portal-portlet.jar}"/>-->
<!-- Remote plugin -->
<path refid="mc.jboss-remoting"/>
@@ -377,9 +380,8 @@
<!-- -->
<fileset dir="${test.temp.lib}" includes="portlet-test-lib.jar"/>
-
+
<path refid="mc.portal-common"/>
- <path refid="mc.portal-portlet"/>
<!-- Remote plugin -->
<path refid="mc.jboss-remoting"/>
@@ -437,13 +439,17 @@
wait="${cargo.wait}">
<!--<sysproperty key="java.io.tmpdir" value="${target}/cargo-tmp"/>-->
<sharedClasspath>
+
<path location="${dependency.portal-common.jar}"/>
<path location="${dependency.portal-common-portal.jar}"/>
+ <path location="${dependency.portal-portlet.jar}"/>
+ <path location="${dependency.portal-web.jar}"/>
+ <path location="${dependency.jsr168api.jar}"/>
+
<path location="${dependency.jboss-unit.jar}"/>
<path location="${dependency.jboss-unit-remote.jar}"/>
<path location="${dependency.portal-test.jar}"/>
- <path location="${dependency.portal-web.jar}"/>
- <path location="${dependency.jsr168api.jar}"/>
+
</sharedClasspath>
<configuration home="${test.jboss-4.2.tempdir}">
<property name="cargo.servlet.port" value="8080"/>
@@ -532,19 +538,22 @@
action="start"
wait="${cargo.wait}">
<sharedClasspath>
+
+ <path location="${dependency.log4j.jar}"/>
+ <path location="${dependency.concurrent.jar}"/>
+ <path location="${dependency.activation.jar}"/>
+ <path location="${dependency.jaxb-api.jar}"/>
+
<path location="${dependency.portal-common.jar}"/>
<path location="${dependency.portal-common-portal.jar}"/>
+ <path location="${dependency.portal-portlet.jar}"/>
+ <path location="${dependency.portal-web.jar}"/>
+ <path location="${dependency.jsr168api.jar}"/>
+
<path location="${dependency.jboss-unit.jar}"/>
<path location="${dependency.jboss-unit-remote.jar}"/>
<path location="${dependency.portal-test.jar}"/>
- <path location="${dependency.portal-web.jar}"/>
- <path location="${dependency.jsr168api.jar}"/>
- <path location="${dependency.log4j.jar}"/>
- <path location="${dependency.concurrent.jar}"/>
- <path location="${dependency.activation.jar}"/>
- <path location="${dependency.jaxb-api.jar}"/>
-
</sharedClasspath>
<configuration>
<property name="cargo.servlet.port" value="8080"/>
Added: modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/WEB-INF/portlet.xml 2008-01-27 13:39:31 UTC (rev 9617)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ version="1.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/WEB-INF/web.xml 2008-01-27 13:39:31 UTC (rev 9617)
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+ <listener>
+ <listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>UniversalServletA</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.framework.UTS1</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>UniversalServletA</servlet-name>
+ <url-pattern>/universalServletA</url-pattern>
+ </servlet-mapping>
+
+</web-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/usetaglib.jsp
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/usetaglib.jsp (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr168/ext/taglib-war/usetaglib.jsp 2008-01-27 13:39:31 UTC (rev 9617)
@@ -0,0 +1,5 @@
+<%@ page language="java" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
+<portlet:defineObjects/>
+<%
+%>
\ No newline at end of file
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-25 22:38:16 UTC (rev 9616)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-27 13:39:31 UTC (rev 9617)
@@ -145,6 +145,10 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-nocache.war"/>
</generic>
+ <generic>
+ <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId" value="test-jsr168-ext-taglib.war"/>
+ </generic>
<!--Spec TCK Assertions tests-->
<generic>
18 years, 3 months
JBoss Portal SVN: r9616 - modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-01-25 17:38:16 -0500 (Fri, 25 Jan 2008)
New Revision: 9616
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java
Log:
- Added space to debug message.
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java 2008-01-25 21:33:36 UTC (rev 9615)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java 2008-01-25 22:38:16 UTC (rev 9616)
@@ -165,7 +165,7 @@
}
else
{
- log.debug("No bundle obtained for locale " + locale + " will use default bundle " + defaultBundle + "instead");
+ log.debug("No bundle obtained for locale " + locale + " will use default bundle " + defaultBundle + " instead");
}
// Cache the bundle
18 years, 3 months
JBoss Portal SVN: r9615 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 16:33:36 -0500 (Fri, 25 Jan 2008)
New Revision: 9615
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java
Log:
fixed a pending wrong test case that was failing on a correct implementation
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java 2008-01-25 21:22:31 UTC (rev 9614)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java 2008-01-25 21:33:36 UTC (rev 9615)
@@ -217,19 +217,19 @@
map.removePublicParameterValue("abc");
Map<String, String[]> privateMap = map.getPrivateMapSnapshot();
- assertEquals(2, privateMap.size());
+ assertEquals(1, privateMap.size());
assertEquals(new String[]{"daa"}, privateMap.get("juu"));
- assertEquals(new String[]{}, privateMap.get("abc"));
+ assertEquals(null, privateMap.get("abc"));
Map<String, String[]> publicMap = map.getPublicMapSnapshot();
- assertEquals(1, publicMap.size());
+ assertEquals(2, publicMap.size());
assertEquals(new String[]{"bar"}, publicMap.get("foo"));
+ assertEquals(new String[]{}, publicMap.get("abc"));
Map<String, String[]> combinedMap = map.getMap();
assertEquals(2, combinedMap.size());
assertEquals(new String[]{"bar"}, combinedMap.get("foo"));
assertEquals(new String[]{"daa"}, combinedMap.get("juu"));
-
}
// @Test
18 years, 3 months
JBoss Portal SVN: r9614 - modules/portlet/trunk/test/src/test/resources/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 16:22:31 -0500 (Fri, 25 Jan 2008)
New Revision: 9614
Modified:
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
test and implemented caching revalidation
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-25 21:18:25 UTC (rev 9613)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-25 21:22:31 UTC (rev 9614)
@@ -4,10 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
-<!--
- -->
-<!--Spec TCK Assertions tests-->
-<!--
+ <!--Spec TCK Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-tck-dispatcher.war"/>
@@ -53,9 +50,7 @@
<property name="archiveId" value="test-jsr168-tck-windowstates.war"/>
</generic>
- -->
-<!--API Tests-->
-<!--
+ <!--API Tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-api-actionrequest.war"/>
@@ -109,9 +104,7 @@
<property name="archiveId" value="test-jsr168-api-windowstate.war"/>
</generic>
- -->
-<!--Ext Tests-->
-<!--
+ <!--Ext Tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-dispatcher.war"/>
@@ -140,7 +133,6 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-session.war"/>
</generic>
--->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-expiringcache.war"/>
@@ -154,8 +146,7 @@
<property name="archiveId" value="test-jsr168-ext-nocache.war"/>
</generic>
-<!--Spec TCK Assertions tests-->
-<!--
+ <!--Spec TCK Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletconfig.war"/>
@@ -185,17 +176,13 @@
<property name="archiveId" value="test-jsr286-tck-resourceserving.war"/>
</generic>
- -->
-<!--Spec API Assertions tests-->
-<!--
+ <!--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-->
-<!--
+ <!--Ext Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletrequests.war"/>
@@ -204,7 +191,6 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletresponses.war"/>
</generic>
--->
<!--Misc Tests-->
<!--
18 years, 3 months
JBoss Portal SVN: r9613 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 16:18:25 -0500 (Fri, 25 Jan 2008)
New Revision: 9613
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
Log:
test and implemented caching revalidation
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 21:13:19 UTC (rev 9612)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 21:18:25 UTC (rev 9613)
@@ -260,7 +260,7 @@
seq.bindAction(10, p1renderjp, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
- //
+ {
return null;
}
});
18 years, 3 months
JBoss Portal SVN: r9612 - in modules/portlet/trunk: test/src/test/resources/test and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 16:13:19 -0500 (Fri, 25 Jan 2008)
New Revision: 9612
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
test and implemented caching revalidation
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 21:12:42 UTC (rev 9611)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 21:13:19 UTC (rev 9612)
@@ -260,7 +260,6 @@
seq.bindAction(10, p1renderjp, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
- {
//
return null;
}
@@ -269,7 +268,6 @@
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
{
- //
Set expected = Tools.toSet("0", "1", "2", "5", "8", "9_render", "9_action");
assertEquals(expected, calls);
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-25 21:12:42 UTC (rev 9611)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-25 21:13:19 UTC (rev 9612)
@@ -4,7 +4,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
- <!--Spec TCK Assertions tests-->
+<!--
+ -->
+<!--Spec TCK Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-tck-dispatcher.war"/>
@@ -50,7 +53,9 @@
<property name="archiveId" value="test-jsr168-tck-windowstates.war"/>
</generic>
- <!--API Tests-->
+ -->
+<!--API Tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-api-actionrequest.war"/>
@@ -104,7 +109,9 @@
<property name="archiveId" value="test-jsr168-api-windowstate.war"/>
</generic>
- <!--Ext Tests-->
+ -->
+<!--Ext Tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-dispatcher.war"/>
@@ -133,6 +140,7 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-session.war"/>
</generic>
+-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-expiringcache.war"/>
@@ -146,7 +154,8 @@
<property name="archiveId" value="test-jsr168-ext-nocache.war"/>
</generic>
- <!--Spec TCK Assertions tests-->
+<!--Spec TCK Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletconfig.war"/>
@@ -176,13 +185,17 @@
<property name="archiveId" value="test-jsr286-tck-resourceserving.war"/>
</generic>
- <!--Spec API Assertions tests-->
+ -->
+<!--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-->
+ -->
+<!--Ext Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletrequests.war"/>
@@ -191,6 +204,7 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletresponses.war"/>
</generic>
+-->
<!--Misc Tests-->
<!--
18 years, 3 months
JBoss Portal SVN: r9611 - in modules/portlet/trunk/portlet/src: main/java/org/jboss/portal/portlet/impl/jsr168/api and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 16:12:42 -0500 (Fri, 25 Jan 2008)
New Revision: 9611
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
Log:
test and implemented caching revalidation
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-01-25 19:59:07 UTC (rev 9610)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-01-25 21:12:42 UTC (rev 9611)
@@ -29,6 +29,7 @@
import org.jboss.portal.portlet.invocation.response.cache.StrongContentRef;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RevalidateMarkupResponse;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.cache.CacheControl;
@@ -124,43 +125,66 @@
{
RenderInvocation render = (RenderInvocation)invocation;
- // Set validation token for revalidation if any
- render.setValidationToken(cachedEntry != null ? cachedEntry.validationToken : null);
+ // Set validation token for revalidation only we have have a fragment
+ if (fragment != null)
+ {
+ render.setValidationToken(cachedEntry.validationToken);
+ }
// Invoke
PortletInvocationResponse response = (PortletInvocationResponse)invocation.invokeNext();
// Try to cache any fragment result
+ CacheControl control = null;
if (response instanceof FragmentResponse)
{
- FragmentResponse renderResult = (FragmentResponse)response;
+ fragment = (FragmentResponse)response;
+ control = fragment.getCacheControl();
+ }
+ else if (response instanceof RevalidateMarkupResponse)
+ {
+ RevalidateMarkupResponse revalidate = (RevalidateMarkupResponse)response;
+ control = revalidate.getCacheControl();
+ }
- //
- CacheControl control = renderResult.getCacheControl();
-
- //
- if (control != null)
+ // Compute expiration time, i.e when it will expire
+ long expirationTimeMillis = 0;
+ String validationToken = null;
+ if (control != null)
+ {
+ if (control.getExpirationSecs() == -1)
{
- // Compute expiration time, i.e when it will expire
- long expirationTimeMillis = 0;
- if (control.getExpirationSecs() == -1)
- {
- expirationTimeMillis = Long.MAX_VALUE;
- }
- else if (control.getExpirationSecs() > 0)
- {
- expirationTimeMillis = System.currentTimeMillis() + control.getExpirationSecs() * 1000;
- }
-
- // Cache if we can
- if (expirationTimeMillis > 0)
- {
- CacheEntry cacheEntry = new CacheEntry(navState, windowState, mode, renderResult, expirationTimeMillis, control.getValidationToken());
- resolver.setAttribute(scopeKey, cacheEntry);
- }
+ expirationTimeMillis = Long.MAX_VALUE;
}
+ else if (control.getExpirationSecs() > 0)
+ {
+ expirationTimeMillis = System.currentTimeMillis() + control.getExpirationSecs() * 1000;
+ }
+ if (control.getValidationToken() != null)
+ {
+ validationToken = control.getValidationToken();
+ }
+ else if (cachedEntry != null)
+ {
+ validationToken = cachedEntry.validationToken;
+ }
}
+ // Compute the validation token
+
+ // Cache if we can
+ if (expirationTimeMillis > 0)
+ {
+ CacheEntry cacheEntry = new CacheEntry(
+ navState,
+ windowState,
+ mode,
+ fragment,
+ expirationTimeMillis,
+ validationToken);
+ resolver.setAttribute(scopeKey, cacheEntry);
+ }
+
//
return response;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-25 19:59:07 UTC (rev 9610)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-25 21:12:42 UTC (rev 9611)
@@ -237,6 +237,13 @@
fragment.getCacheControl().setValidationToken(value);
}
}
+ else if (MimeResponse.USE_CACHED_CONTENT.equals(key))
+ {
+ if (value != null)
+ {
+ getCacheControl().setUseCachedContent(true);
+ }
+ }
else
{
super.addProperty(key, value);
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 19:59:07 UTC (rev 9610)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 21:12:42 UTC (rev 9611)
@@ -33,7 +33,7 @@
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
import org.jboss.unit.Failure;
-import static org.jboss.unit.api.Assert.assertEquals;
+import static org.jboss.unit.api.Assert.*;
import javax.portlet.Portlet;
import javax.portlet.RenderRequest;
@@ -157,36 +157,107 @@
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
{
assertEquals("xyz", request.getETag());
+ assertTrue(Tools.toSet(request.getPropertyNames()).contains(RenderRequest.ETAG));
+ assertEquals("xyz", request.getProperty(RenderRequest.ETAG));
- // Should be called
+ // Record we were called
calls.add("5");
+
+ // Revalidate existing content
response.setProperty(RenderResponse.EXPIRATION_CACHE, "5");
+ response.setProperty(RenderResponse.USE_CACHED_CONTENT, "foo");
+
+ //
+ url = response.createRenderURL().toString();
+ return new InvokeGetResponse(url);
+ }
+ });
+
+ //
+ seq.bindAction(6, p1renderjp, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Should not be called
+ calls.add("6");
+ return null;
+ }
+ });
+ seq.bindAction(6, p2renderjp, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Refresh
+ return new InvokeGetResponse(url);
+ }
+ });
+
+ //
+ seq.bindAction(7, p1renderjp, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Could be called or not depending on the page rendering ordre
+ return null;
+ }
+ });
+ seq.bindAction(7, p2renderjp, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ try
+ {
+ // Wait 5 seconds for the cache entry to be invalid
+ Thread.sleep(5 * 1000);
+
+ // Refresh
+ return new InvokeGetResponse(url);
+ }
+ catch (InterruptedException e)
+ {
+ return new FailureResponse(Failure.createFailure(e));
+ }
+ }
+ });
+
+ //
+ seq.bindAction(8, p1renderjp, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ assertEquals("xyz", request.getETag());
+ assertTrue(Tools.toSet(request.getPropertyNames()).contains(RenderRequest.ETAG));
+ assertEquals("xyz", request.getProperty(RenderRequest.ETAG));
+
+ // Record we were called
+ calls.add("8");
+
url = response.createActionURL().toString();
return new InvokeGetResponse(url);
}
});
//
- seq.bindAction(6, p1actionjp, new PortletActionTestAction()
+ seq.bindAction(9, p1actionjp, new PortletActionTestAction()
{
protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
{
// Should be called
- calls.add("6_action");
+ calls.add("9_action");
}
});
- seq.bindAction(6, p1renderjp, new PortletRenderTestAction()
+ seq.bindAction(9, p1renderjp, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
{
// Should be called
- calls.add("6_render");
+ calls.add("9_render");
return new InvokeGetResponse(response.createRenderURL().toString());
}
});
//
- seq.bindAction(7, p1renderjp, new PortletRenderTestAction()
+ seq.bindAction(10, p1renderjp, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
{
@@ -194,12 +265,12 @@
return null;
}
});
- seq.bindAction(7, p2renderjp, new PortletRenderTestAction()
+ seq.bindAction(10, p2renderjp, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
{
//
- Set expected = Tools.toSet("0", "1", "2", "5", "6_render", "6_action");
+ Set expected = Tools.toSet("0", "1", "2", "5", "8", "9_render", "9_action");
assertEquals(expected, calls);
// Refresh
18 years, 3 months