Author: mvanco(a)redhat.com
Date: 2010-11-01 12:55:20 -0400 (Mon, 01 Nov 2010)
New Revision: 4892
Added:
components/wsrp/trunk/wsrp-producer-war/src/test/assembly/test-resourceserving-portlet.xml
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/ResourceServingPortlet.java
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/WEB-INF/
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/WEB-INF/portlet.xml
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/WEB-INF/web.xml
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/image/
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/image/jboss_logo.png
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/view.jsp
Removed:
components/wsrp/trunk/wsrp-producer-war/src/test/assembly/test-testobject-jar.xml
Modified:
components/wsrp/trunk/wsrp-producer-war/pom.xml
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java
Log:
WSRP2 Sample portlets
- added new sample portlet for resource serving
- removed assembly script for testobject jar (not used anymore)
- updated test for portletmodes
Modified: components/wsrp/trunk/wsrp-producer-war/pom.xml
===================================================================
--- components/wsrp/trunk/wsrp-producer-war/pom.xml 2010-11-01 16:15:31 UTC (rev 4891)
+++ components/wsrp/trunk/wsrp-producer-war/pom.xml 2010-11-01 16:55:20 UTC (rev 4892)
@@ -179,8 +179,8 @@
<descriptor>src/test/assembly/test-events-portlet.xml</descriptor>
<descriptor>src/test/assembly/test-portletmodes-portlet.xml</descriptor>
<descriptor>src/test/assembly/test-prp-portlet.xml</descriptor>
-
<descriptor>src/test/assembly/test-testobject-jar.xml</descriptor>
<descriptor>src/test/assembly/test-state-portlet.xml</descriptor>
+
<descriptor>src/test/assembly/test-resourceserving-portlet.xml</descriptor>
</descriptors>
</configuration>
<executions>
Added:
components/wsrp/trunk/wsrp-producer-war/src/test/assembly/test-resourceserving-portlet.xml
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/assembly/test-resourceserving-portlet.xml
(rev 0)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/assembly/test-resourceserving-portlet.xml 2010-11-01
16:55:20 UTC (rev 4892)
@@ -0,0 +1,27 @@
+<assembly>
+ <id>resourceserving-portlet</id>
+ <formats>
+ <format>war</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <!-- Test Classes -->
+ <fileSet>
+ <directory>target/test-classes</directory>
+ <outputDirectory>WEB-INF/classes</outputDirectory>
+ <includes>
+ <include>org/gatein/wsrp/portlet/ResourceServingPortlet.class
+ </include>
+ </includes>
+ </fileSet>
+ <!-- Fileset for the sar strucuture -->
+ <fileSet>
+ <directory>src/test/test-portlets/test-resourceserving-portlet-war
+ </directory>
+ <outputDirectory></outputDirectory>
+ </fileSet>
+ </fileSets>
+
+</assembly>
+
Deleted:
components/wsrp/trunk/wsrp-producer-war/src/test/assembly/test-testobject-jar.xml
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/assembly/test-testobject-jar.xml 2010-11-01
16:15:31 UTC (rev 4891)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/assembly/test-testobject-jar.xml 2010-11-01
16:55:20 UTC (rev 4892)
@@ -1,20 +0,0 @@
-<assembly>
- <id>events-testobject</id>
- <formats>
- <format>jar</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <fileSets>
- <!-- Test Object Class -->
- <fileSet>
- <directory>target/test-classes</directory>
- <outputDirectory></outputDirectory>
- <includes>
- <include>org/gatein/wsrp/portlet/utils/TestObject.class</include>
- </includes>
- </fileSet>
- </fileSets>
-
-</assembly>
-
Added:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/ResourceServingPortlet.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/ResourceServingPortlet.java
(rev 0)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/ResourceServingPortlet.java 2010-11-01
16:55:20 UTC (rev 4892)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2010, 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.gatein.wsrp.portlet;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+
+/**
+ * @author <a href="mailto:mvanco@redhat.com">Michal Vanco</a>
+ * @version $Revision$
+ */
+public class ResourceServingPortlet extends GenericPortlet
+{
+
+ @Override
+ public void doView(RenderRequest request, RenderResponse response) throws
PortletException, IOException
+ {
+ response.setContentType("text/html");
+ String imageHash = "142b674dd615a0513061cf44c7ae6adb";
+ request.setAttribute("hash", imageHash);
+ String imageWidth = "451";
+ String imageHeight = "257";
+ request.setAttribute("width", imageWidth);
+ request.setAttribute("height", imageHeight);
+ PortletRequestDispatcher dispatcher =
getPortletContext().getRequestDispatcher("/view.jsp");
+ dispatcher.include(request, response);
+ }
+
+ @Override
+ public void serveResource(ResourceRequest request, ResourceResponse response) throws
PortletException, IOException
+ {
+ response.setContentType(" image/png");
+ OutputStream out = response.getPortletOutputStream();
+ File image = new
File(getPortletContext().getRealPath("/image/jboss_logo.png"));
+ BufferedInputStream bis = new BufferedInputStream(new FileInputStream(image));
+ long length = image.length();
+ byte[] bytes = new byte[(int) length];
+ bis.read(bytes, 0, (int) length);
+ out.write(bytes);
+ }
+
+}
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java 2010-11-01
16:15:31 UTC (rev 4891)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java 2010-11-01
16:55:20 UTC (rev 4892)
@@ -923,14 +923,17 @@
GetMarkup getMarkup = createMarkupRequest();
getMarkup.getMarkupParams().setMode(WSRPConstants.EDIT_MODE);
+ assertEquals(WSRPConstants.EDIT_MODE, getMarkup.getMarkupParams().getMode());
MarkupResponse responseEdit = producer.getMarkup(getMarkup);
checkMarkupResponse(responseEdit, "This is EDIT MODE.", false, true);
getMarkup.getMarkupParams().setMode(WSRPConstants.VIEW_MODE);
+ assertEquals(WSRPConstants.VIEW_MODE, getMarkup.getMarkupParams().getMode());
MarkupResponse responseView = producer.getMarkup(getMarkup);
checkMarkupResponse(responseView, "This is VIEW MODE.", false, true);
getMarkup.getMarkupParams().setMode(WSRPConstants.HELP_MODE);
+ assertEquals(WSRPConstants.HELP_MODE, getMarkup.getMarkupParams().getMode());
MarkupResponse responseHelp = producer.getMarkup(getMarkup);
checkMarkupResponse(responseHelp, "This is HELP MODE.", false, true);
}
@@ -951,6 +954,7 @@
{
GetMarkup getMarkup = createMarkupRequest();
getMarkup.getMarkupParams().setMode("test_mode");
+ assertEquals("test_mode", getMarkup.getMarkupParams().getMode());
MarkupResponse response = producer.getMarkup(getMarkup);
checkMarkupResponse(response, "This is TEST MODE.", false, true);
}
Added:
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/WEB-INF/portlet.xml
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/WEB-INF/portlet.xml
(rev 0)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/WEB-INF/portlet.xml 2010-11-01
16:55:20 UTC (rev 4892)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ JBoss, a division of Red Hat
+ ~ Copyright 2010, 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_2_0.xsd'
+
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+
xsi:schemaLocation='http://java.sun.com/xml/ns/portlet/portlet-app_2_...
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd'
+ version='2.0'>
+ <portlet>
+ <description>Resource Portlet</description>
+ <portlet-name>Resource Portlet</portlet-name>
+ <display-name>Resource Portlet</display-name>
+ <portlet-class>org.gatein.wsrp.portlet.ResourceServingPortlet</portlet-class>
+ <expiration-cache>0</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Resource Portlet sample</title>
+ <short-title>Resource Portlet sample</short-title>
+ </portlet-info>
+ </portlet>
+
+ <!-- Make these portlets remotable -->
+ <container-runtime-option>
+ <name>org.gatein.pc.remotable</name>
+ <value>true</value>
+ </container-runtime-option>
+
+</portlet-app>
Added:
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/WEB-INF/web.xml
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/WEB-INF/web.xml
(rev 0)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/WEB-INF/web.xml 2010-11-01
16:55:20 UTC (rev 4892)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2007, 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 version="2.4"
+
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">
+</web-app>
\ No newline at end of file
Added:
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/image/jboss_logo.png
===================================================================
(Binary files differ)
Property changes on:
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/image/jboss_logo.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/view.jsp
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/view.jsp
(rev 0)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/test-portlets/test-resourceserving-portlet-war/view.jsp 2010-11-01
16:55:20 UTC (rev 4892)
@@ -0,0 +1,15 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+<%@ taglib
uri="http://java.sun.com/portlet_2_0"
prefix="portlet"%>
+<portlet:defineObjects />
+<h1>Resource serving...</h1>
+This is sample portlet to verify portlet resource serving.<br />
+In this sample the image is rendered with resourceURL, not static source.<br />
+<br />
+<img src="<portlet:resourceURL />" />
+<br /><br />
+If you can see above image, resource serving works properly. There are parameters to
verify image:<br />
+<ul>
+ <li>hash: <span id="hash">${hash}</span></li>
+ <li>image size: <span id="width">${width}</span>x<span
id="height">${height}</span></li>
+</ul>
\ No newline at end of file