diff options
author | Henri Sara <henri.sara@itmill.com> | 2011-08-10 14:54:20 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2011-08-10 14:54:20 +0000 |
commit | 19ae86af9b484bcccf4ec3aed3d43a136609c842 (patch) | |
tree | 05c3212cf8f57901a1b3193298f473fb1b06df7e | |
parent | 9e92396665f26de73871ec02ef8c8a1ea62f4822 (diff) | |
download | vaadin-framework-19ae86af9b484bcccf4ec3aed3d43a136609c842.tar.gz vaadin-framework-19ae86af9b484bcccf4ec3aed3d43a136609c842.zip |
#7178 replaced most demo portlets with a test portlet, use it in Liferay 5 integration test
svn changeset:20276/svn branch:6.7
-rw-r--r-- | WebContent/WEB-INF/liferay-display.xml | 8 | ||||
-rw-r--r-- | WebContent/WEB-INF/liferay-portlet.xml | 14 | ||||
-rw-r--r-- | WebContent/WEB-INF/portlet.xml | 174 | ||||
-rw-r--r-- | WebContent/WEB-INF/web.xml | 14 | ||||
-rw-r--r-- | build/build.xml | 1 | ||||
-rw-r--r-- | build/package/WebContent/WEB-INF/web.xml | 14 | ||||
-rw-r--r-- | tests/integration-testscripts/Liferay-5/integration-test-liferay-5.2.3-portlet2.html | 79 | ||||
-rw-r--r-- | tests/src/com/vaadin/tests/integration/JSR286PortletApplication.java | 160 |
8 files changed, 232 insertions, 232 deletions
diff --git a/WebContent/WEB-INF/liferay-display.xml b/WebContent/WEB-INF/liferay-display.xml index 232cec07e1..9fe585e7dc 100644 --- a/WebContent/WEB-INF/liferay-display.xml +++ b/WebContent/WEB-INF/liferay-display.xml @@ -3,14 +3,8 @@ <display> <category name="Vaadin"> - <portlet id="PortletDemoPortlet" /> - <portlet id="Portlet Mode Example" /> - <portlet id="Portlet HTML Mode Example" /> + <portlet id="JSR286TestPortlet" /> <portlet id="AddressBookPortlet" /> <portlet id="Vaadin Liferay Theme Portlet"/> - - <!-- These should be used together --> - <portlet id="InterPortletEventPortlet" /> - <portlet id="VaadinInterPortletEventPortlet" /> </category> </display>
\ No newline at end of file diff --git a/WebContent/WEB-INF/liferay-portlet.xml b/WebContent/WEB-INF/liferay-portlet.xml index 2ed03113b6..f246e0bc4c 100644 --- a/WebContent/WEB-INF/liferay-portlet.xml +++ b/WebContent/WEB-INF/liferay-portlet.xml @@ -3,18 +3,8 @@ <liferay-portlet-app> <portlet> - <portlet-name>PortletDemoPortlet</portlet-name> - <instanceable>true</instanceable> - <ajaxable>false</ajaxable> - </portlet> - <portlet> - <portlet-name>Portlet Mode Example</portlet-name> - <instanceable>true</instanceable> - <ajaxable>false</ajaxable> - </portlet> - <portlet> - <portlet-name>Portlet HTML Mode Example</portlet-name> - <instanceable>true</instanceable> + <portlet-name>JSR286TestPortlet</portlet-name> + <instanceable>false</instanceable> <ajaxable>false</ajaxable> </portlet> <portlet> diff --git a/WebContent/WEB-INF/portlet.xml b/WebContent/WEB-INF/portlet.xml index 49ed5921b1..5d333da67e 100644 --- a/WebContent/WEB-INF/portlet.xml +++ b/WebContent/WEB-INF/portlet.xml @@ -4,12 +4,12 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"> <portlet> - <portlet-name>PortletDemoPortlet</portlet-name> - <display-name>Vaadin PortletDemo</display-name> - <portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet</portlet-class> + <portlet-name>JSR286TestPortlet</portlet-name> + <display-name>Vaadin Portlet 2.0 Test</display-name> + <portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet2</portlet-class> <init-param> <name>application</name> - <value>PortletDemo</value> + <value>com.vaadin.tests.integration.JSR286PortletApplication</value> </init-param> <init-param> <name>widgetset</name> @@ -22,8 +22,8 @@ <portlet-mode>help</portlet-mode> </supports> <portlet-info> - <title>PortletDemo</title> - <short-title>PortletDemo</short-title> + <title>Vaadin Portlet 2.0 Test</title> + <short-title>Vaadin Portlet 2.0 Test</short-title> </portlet-info> <security-role-ref> @@ -41,79 +41,6 @@ </portlet> <portlet> - <portlet-name>Portlet Mode Example</portlet-name> - <display-name>Portlet Mode Example</display-name> - <portlet-class>com.vaadin.demo.portlet.PortletModePortlet</portlet-class> - <init-param> - <name>application</name> - <value>com.vaadin.demo.portlet.PortletModeExample</value> - </init-param> - <init-param> - <name>widgetset</name> - <value>com.vaadin.portal.gwt.PortalDefaultWidgetSet</value> - </init-param> - - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>view</portlet-mode> - <portlet-mode>edit</portlet-mode> - <portlet-mode>help</portlet-mode> - <portlet-mode>config</portlet-mode> - </supports> - <portlet-info> - <title>PortletModeExample</title> - <short-title>PortletModeExample</short-title> - </portlet-info> - - <security-role-ref> - <role-name>administrator</role-name> - </security-role-ref> - <security-role-ref> - <role-name>guest</role-name> - </security-role-ref> - <security-role-ref> - <role-name>power-user</role-name> - </security-role-ref> - <security-role-ref> - <role-name>user</role-name> - </security-role-ref> - </portlet> - - <portlet> - <portlet-name>Portlet HTML Mode Example</portlet-name> - <display-name>Portlet HTML Mode Example</display-name> - <portlet-class>com.vaadin.demo.portlet.HtmlModePortlet</portlet-class> - <init-param> - <name>widgetset</name> - <value>com.vaadin.portal.gwt.PortalDefaultWidgetSet</value> - </init-param> - - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>view</portlet-mode> - <portlet-mode>help</portlet-mode> - </supports> - - <portlet-info> - <title>Portlet HTML Mode Example</title> - <short-title>Portlet HTML Mode Example</short-title> - </portlet-info> - - <security-role-ref> - <role-name>administrator</role-name> - </security-role-ref> - <security-role-ref> - <role-name>guest</role-name> - </security-role-ref> - <security-role-ref> - <role-name>power-user</role-name> - </security-role-ref> - <security-role-ref> - <role-name>user</role-name> - </security-role-ref> - </portlet> - - <portlet> <portlet-name>AddressBookPortlet</portlet-name> <display-name>Address Book</display-name> <portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet2</portlet-class> @@ -186,95 +113,6 @@ </security-role-ref> </portlet> - <!-- A Vaadin portlet and a non-Vaadin portlet that can communicate with each other --> - <portlet> - <portlet-name>VaadinInterPortletEventPortlet</portlet-name> - <display-name>Hello World Event</display-name> - <portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet2</portlet-class> - <init-param> - <name>application</name> - <value>com.vaadin.demo.portlet.VaadinInterPortletEventPortlet</value> - </init-param> - <init-param> - <name>widgetset</name> - <value>com.vaadin.portal.gwt.PortalDefaultWidgetSet</value> - </init-param> - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>view</portlet-mode> - </supports> - <portlet-info> - <title>Inter-portlet events</title> - <short-title>Inter-portlet - events</short-title> - </portlet-info> - <supported-processing-event> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:Hello</qname> - </supported-processing-event> - <supported-processing-event> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:ReplyToVaadin</qname> - </supported-processing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:Reply</qname> - </supported-publishing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:FromVaadin</qname> - </supported-publishing-event> - <supported-public-render-parameter>HelloState</supported-public-render-parameter> - </portlet> - <portlet> - <portlet-name>InterPortletEventPortlet</portlet-name> - <display-name>Hello World Event (non-Vaadin)</display-name> - <portlet-class>com.vaadin.demo.portlet.InterPortletEventPortlet</portlet-class> - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>view</portlet-mode> - </supports> - <portlet-info> - <title>Inter-portlet events (non-Vaadin)</title> - <short-title>Inter-portlet events (non-Vaadin)</short-title> - </portlet-info> - <supported-processing-event> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:Reply</qname> - </supported-processing-event> - <supported-processing-event> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:FromVaadin</qname> - </supported-processing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:Hello</qname> - </supported-publishing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:ReplyToVaadin</qname> - </supported-publishing-event> - <supported-public-render-parameter>HelloState</supported-public-render-parameter> - </portlet> - - <!-- Used by the Portlet mode demo --> - <custom-portlet-mode> - <description>Custom mode</description> - <portlet-mode>config</portlet-mode> - <portal-managed>false</portal-managed> - </custom-portlet-mode> - - <!-- - These can be used to customize the event object types. The types must - be serializable and have JAXB binding. - --> - <event-definition> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:Hello</qname> - <value-type>java.lang.String</value-type> - </event-definition> - - <event-definition> - <qname xmlns:vaadin="http://vaadin.com/hello">vaadin:Reply</qname> - <value-type>java.lang.String</value-type> - </event-definition> - - <public-render-parameter> - <identifier>HelloState</identifier> - <qname xmlns:vaadin="http://vaadin.com/params">vaadin:HelloState</qname> - </public-render-parameter> - <!-- This can be used to work around an issue in liferay 5.0-5.1.1 diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index cd2b6eedab..bdf7fe92a4 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -89,15 +89,6 @@ </servlet>
<servlet>
- <servlet-name>PortletDemo</servlet-name>
- <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
- <init-param>
- <param-name>application</param-name>
- <param-value>com.vaadin.demo.portlet.PortletDemo</param-value>
- </init-param>
- </servlet>
-
- <servlet>
<servlet-name>Parameters</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
@@ -184,11 +175,6 @@ </servlet-mapping>
<servlet-mapping>
- <servlet-name>PortletDemo</servlet-name>
- <url-pattern>/PortletDemo/*</url-pattern>
- </servlet-mapping>
-
- <servlet-mapping>
<servlet-name>GAESyncTest</servlet-name>
<url-pattern>/gaesynctest/*</url-pattern>
</servlet-mapping>
diff --git a/build/build.xml b/build/build.xml index fcf3b7bebc..fffa906ec1 100644 --- a/build/build.xml +++ b/build/build.xml @@ -831,6 +831,7 @@ <copy todir="${output-dir}/WebContent/WEB-INF/classes"> <fileset dir="${result-path}/classes"> <include name="${toolkit-package}/demo/**/*" /> + <include name="${toolkit-package}/tests/integration/**/*" /> <!-- user might want to tweak launcher classes --> <include name="${toolkit-package}/launcher/**" /> </fileset> diff --git a/build/package/WebContent/WEB-INF/web.xml b/build/package/WebContent/WEB-INF/web.xml index ecc4f0fcff..cc57e0d68f 100644 --- a/build/package/WebContent/WEB-INF/web.xml +++ b/build/package/WebContent/WEB-INF/web.xml @@ -40,22 +40,8 @@ </init-param> </servlet> - <!-- Portlet demo application --> - <servlet> - <servlet-name>PortletDemo</servlet-name> - <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class> - <init-param> - <param-name>application</param-name> - <param-value>com.vaadin.demo.portlet.PortletDemo</param-value> - </init-param> - </servlet> - <!-- Servlet Mappings below - see servlets for comments --> <servlet-mapping> - <servlet-name>PortletDemo</servlet-name> - <url-pattern>/PortletDemo/*</url-pattern> - </servlet-mapping> - <servlet-mapping> <servlet-name>VaadinApplicationRunner</servlet-name> <url-pattern>/run/*</url-pattern> </servlet-mapping> diff --git a/tests/integration-testscripts/Liferay-5/integration-test-liferay-5.2.3-portlet2.html b/tests/integration-testscripts/Liferay-5/integration-test-liferay-5.2.3-portlet2.html index 29d63639b5..7b648d0157 100644 --- a/tests/integration-testscripts/Liferay-5/integration-test-liferay-5.2.3-portlet2.html +++ b/tests/integration-testscripts/Liferay-5/integration-test-liferay-5.2.3-portlet2.html @@ -78,7 +78,7 @@ </tr> <tr> <td>mouseClickAndWait</td> - <td>//div[@id='Vaadin-AddressBook']/p/a</td> + <td>//div[@id='Vaadin-VaadinPortlet20Test']/p/a</td> <td>16,11</td> </tr> <tr> @@ -92,34 +92,79 @@ <td></td> </tr> <tr> - <td>mouseClick</td> - <td>vaadin=v-AddressBookPortlet_WAR_demo_LAYOUT_10707::/VVerticalLayout[0]/ChildComponentContainer[1]/VSplitPanelHorizontal[0]/VSplitPanelVertical[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td> - <td>24,10</td> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td></td> </tr> <tr> - <td>click</td> - <td>vaadin=v-AddressBookPortlet_WAR_demo_LAYOUT_10707::/VVerticalLayout[0]/ChildComponentContainer[1]/VSplitPanelHorizontal[0]/VSplitPanelVertical[0]/VForm[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td>verifyTextNotPresent</td> + <td>Action received</td> <td></td> </tr> <tr> - <td>mouseClick</td> - <td>vaadin=v-AddressBookPortlet_WAR_demo_LAYOUT_10707::/VVerticalLayout[0]/ChildComponentContainer[1]/VSplitPanelHorizontal[0]/VSplitPanelVertical[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[1]</td> - <td>9,11</td> + <td>mouseClickAndWait</td> + <td>vaadin=v-JSR286TestPortlet_WAR_demo_LAYOUT_10706::/VVerticalLayout[0]/ChildComponentContainer[2]/VLink[0]/domChild[0]/domChild[0]</td> + <td>8,7</td> </tr> <tr> - <td>mouseClick</td> - <td>vaadin=v-AddressBookPortlet_WAR_demo_LAYOUT_10707::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item8</td> - <td>158,17</td> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>Done</td> + <td></td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>Action received</td> + <td></td> +</tr> +<tr> + <td>mouseClickAndWait</td> + <td>vaadin=v-JSR286TestPortlet_WAR_demo_LAYOUT_10706::/VVerticalLayout[0]/ChildComponentContainer[4]/VLink[0]/domChild[0]/domChild[0]</td> + <td>28,7</td> +</tr> +<tr> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> +</tr> +<tr> + <td>mouseClickAndWait</td> + <td>vaadin=v-JSR286TestPortlet_WAR_demo_LAYOUT_10706::/VVerticalLayout[0]/ChildComponentContainer[3]/VLink[0]/domChild[0]/domChild[0]</td> + <td>37,-41</td> </tr> <tr> - <td>click</td> - <td>vaadin=v-AddressBookPortlet_WAR_demo_LAYOUT_10707::/VVerticalLayout[0]/ChildComponentContainer[1]/VSplitPanelHorizontal[0]/VSplitPanelVertical[0]/VForm[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>Back to normal</td> <td></td> </tr> <tr> - <td>assertText</td> - <td>vaadin=v-AddressBookPortlet_WAR_demo_LAYOUT_10707::/VVerticalLayout[0]/ChildComponentContainer[1]/VSplitPanelHorizontal[0]/VSplitPanelVertical[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[6]/domChild[0]</td> - <td>New York</td> + <td>mouseClickAndWait</td> + <td>vaadin=v-JSR286TestPortlet_WAR_demo_LAYOUT_10706::/VVerticalLayout[0]/ChildComponentContainer[3]/VLink[0]/domChild[0]/domChild[0]</td> + <td>46,-57</td> +</tr> +<tr> + <td>closeNotification</td> + <td>//body/div[2]</td> + <td>0,0</td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>Edit</td> + <td></td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>Maximize</td> + <td></td> </tr> </tbody></table> diff --git a/tests/src/com/vaadin/tests/integration/JSR286PortletApplication.java b/tests/src/com/vaadin/tests/integration/JSR286PortletApplication.java new file mode 100644 index 0000000000..57ee762913 --- /dev/null +++ b/tests/src/com/vaadin/tests/integration/JSR286PortletApplication.java @@ -0,0 +1,160 @@ +package com.vaadin.tests.integration; + +import java.util.Iterator; +import java.util.Map; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.EventRequest; +import javax.portlet.EventResponse; +import javax.portlet.PortletMode; +import javax.portlet.PortletRequest; +import javax.portlet.PortletURL; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.ResourceRequest; +import javax.portlet.ResourceResponse; +import javax.portlet.WindowState; + +import com.vaadin.Application; +import com.vaadin.terminal.ExternalResource; +import com.vaadin.terminal.gwt.server.PortletApplicationContext2; +import com.vaadin.terminal.gwt.server.PortletApplicationContext2.PortletListener; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.TextField; +import com.vaadin.ui.Window; +import com.vaadin.ui.Window.Notification; + +/** + * Adapted from old PortletDemo to support integration testing. + */ +public class JSR286PortletApplication extends Application { + + Window main = new Window(); + TextField tf = new TextField("Some value"); + Label userInfo = new Label(); + Link portletEdit = new Link(); + Link portletMax = new Link(); + Link someAction = null; + + @Override + public void init() { + main = new Window(); + setMainWindow(main); + + userInfo.setCaption("User info"); + userInfo.setContentMode(Label.CONTENT_PREFORMATTED); + main.addComponent(userInfo); + + tf.setEnabled(false); + tf.setImmediate(true); + main.addComponent(tf); + + portletEdit.setEnabled(false); + main.addComponent(portletEdit); + portletMax.setEnabled(false); + main.addComponent(portletMax); + + if (getContext() instanceof PortletApplicationContext2) { + PortletApplicationContext2 ctx = (PortletApplicationContext2) getContext(); + ctx.addPortletListener(this, new DemoPortletListener()); + } else { + getMainWindow().showNotification("Not inited via Portal!", + Notification.TYPE_ERROR_MESSAGE); + } + + } + + private class DemoPortletListener implements PortletListener { + + public void handleActionRequest(ActionRequest request, + ActionResponse response, Window window) { + main.addComponent(new Label("Action received")); + } + + public void handleRenderRequest(RenderRequest request, + RenderResponse response, Window window) { + // Portlet up-and-running, enable stuff + portletEdit.setEnabled(true); + portletMax.setEnabled(true); + + // Editable if we're in editmode + tf.setEnabled((request.getPortletMode() == PortletMode.EDIT)); + + // Show notification about current mode and state + getMainWindow().showNotification( + "Portlet status", + "Mode: " + request.getPortletMode() + " State: " + + request.getWindowState(), + Notification.TYPE_WARNING_MESSAGE); + + // Display current user info + Map<?, ?> uinfo = (Map<?, ?>) request + .getAttribute(PortletRequest.USER_INFO); + if (uinfo != null) { + String s = ""; + for (Iterator<?> it = uinfo.keySet().iterator(); it.hasNext();) { + Object key = it.next(); + Object val = uinfo.get(key); + s += key + ": " + val + "\n"; + } + if (request.isUserInRole("administrator")) { + s += "(administrator)"; + } + userInfo.setValue(s); + } else { + userInfo.setValue("-"); + } + + // Create Edit/Done link (actionUrl) + PortletURL url = response.createActionURL(); + try { + url.setPortletMode((request.getPortletMode() == PortletMode.VIEW ? PortletMode.EDIT + : PortletMode.VIEW)); + portletEdit.setResource(new ExternalResource(url.toString())); + portletEdit + .setCaption((request.getPortletMode() == PortletMode.VIEW ? "Edit" + : "Done")); + } catch (Exception e) { + portletEdit.setEnabled(false); + } + // Create Maximize/Normal link (actionUrl) + url = response.createActionURL(); + try { + url.setWindowState((request.getWindowState() == WindowState.NORMAL ? WindowState.MAXIMIZED + : WindowState.NORMAL)); + portletMax.setResource(new ExternalResource(url.toString())); + portletMax + .setCaption((request.getWindowState() == WindowState.NORMAL ? "Maximize" + : "Back to normal")); + } catch (Exception e) { + portletMax.setEnabled(false); + } + + if (someAction == null) { + url = response.createActionURL(); + try { + someAction = new Link("An action", new ExternalResource( + url.toString())); + main.addComponent(someAction); + } catch (Exception e) { + // Oops + System.err.println("Could not create someAction: " + e); + } + + } + } + + public void handleEventRequest(EventRequest request, + EventResponse response, Window window) { + // events not used by this test + } + + public void handleResourceRequest(ResourceRequest request, + ResourceResponse response, Window window) { + // nothing special to do here + } + } + +} |