[jboss-svn-commits] JBoss Portal SVN: r5483 - in trunk/wsrp/src/main/org/jboss/portal/test/wsrp: framework v1/consumer v1/consumer/behaviors
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 18 18:38:20 EDT 2006
Author: chris.laprun at jboss.com
Date: 2006-10-18 18:38:17 -0400 (Wed, 18 Oct 2006)
New Revision: 5483
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicMarkupBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionMarkupBehavior.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionBehavior.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java
Log:
- Renamed BasicBehavior and SessionBehavior to BasicMarkupBehavior and SessionMarkupBehavior respectively.
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-10-18 22:37:16 UTC (rev 5482)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-10-18 22:38:17 UTC (rev 5483)
@@ -25,10 +25,10 @@
import org.jboss.invocation.Invocation;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.test.wsrp.framework.support.ServiceObjectFactory;
-import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.EmptyMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.NullMarkupBehavior;
-import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
@@ -148,8 +148,8 @@
serviceDescription = WSRPTypeFactory.createServiceDescription(requiresRegistration);
//Prepare description of two portlets
- PortletDescription pd1 = createPortletDescription(BasicBehavior.PORTLET_HANDLE, "");
- PortletDescription pd2 = createPortletDescription(SessionBehavior.PORTLET_HANDLE, "2");
+ PortletDescription pd1 = createPortletDescription(BasicMarkupBehavior.PORTLET_HANDLE, "");
+ PortletDescription pd2 = createPortletDescription(SessionMarkupBehavior.PORTLET_HANDLE, "2");
serviceDescription.setOfferedPortlets(new PortletDescription[]{pd1, pd2});
if (response != null)
@@ -160,8 +160,8 @@
requiresInitCookie = null;
- registerMarkupBehavior(new BasicBehavior());
- registerMarkupBehavior(new SessionBehavior());
+ registerMarkupBehavior(new BasicMarkupBehavior());
+ registerMarkupBehavior(new SessionMarkupBehavior());
registerMarkupBehavior(new NullMarkupBehavior());
registerMarkupBehavior(new EmptyMarkupBehavior());
@@ -284,11 +284,11 @@
return WSRPTypeFactory.createBlockingInteractionResponse("http://jboss.com");
}
- if (BasicBehavior.PORTLET_HANDLE.equals(handle))
+ if (BasicMarkupBehavior.PORTLET_HANDLE.equals(handle))
{
ns = "ns1";
}
- if (SessionBehavior.PORTLET_HANDLE.equals(handle))
+ if (SessionMarkupBehavior.PORTLET_HANDLE.equals(handle))
{
ns = "ns2";
}
@@ -417,11 +417,11 @@
}
PortletDescription[] offeredPortlets = serviceDescription.getOfferedPortlets();
- if (BasicBehavior.PORTLET_HANDLE.equals(handle))
+ if (BasicMarkupBehavior.PORTLET_HANDLE.equals(handle))
{
return offeredPortlets[0];
}
- if (SessionBehavior.PORTLET_HANDLE.equals(handle))
+ if (SessionMarkupBehavior.PORTLET_HANDLE.equals(handle))
{
return offeredPortlets[1];
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2006-10-18 22:37:16 UTC (rev 5482)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2006-10-18 22:38:17 UTC (rev 5483)
@@ -38,10 +38,10 @@
import org.jboss.portal.test.wsrp.framework.support.BasicSecurityContext;
import org.jboss.portal.test.wsrp.framework.support.BasicUserContext;
import org.jboss.portal.test.wsrp.framework.support.TestPortletInvocationContext;
-import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.EmptyMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.NullMarkupBehavior;
-import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
import org.jboss.portal.wsrp.core.CookieProtocol;
@@ -72,30 +72,30 @@
public void testRender() throws Exception
{
- RenderInvocation render = createRenderInvocation(BasicBehavior.PORTLET_HANDLE, Mode.EDIT,
+ RenderInvocation render = createRenderInvocation(BasicMarkupBehavior.PORTLET_HANDLE, Mode.EDIT,
WindowState.NORMAL, "someNS");
FragmentResponse result = checkRenderResult(consumer.invoke(render), "portlet1:edit:normal:someNS");
assertEquals(15, result.getExpirationSecs());
- render = createRenderInvocation(SessionBehavior.PORTLET_HANDLE);
+ render = createRenderInvocation(SessionMarkupBehavior.PORTLET_HANDLE);
result = checkRenderResult(consumer.invoke(render), "portlet2:0:view:maximized");
assertEquals(0, result.getExpirationSecs());
}
public void testAction() throws Exception
{
- ActionInvocation action = createActionInvocation(BasicBehavior.PORTLET_HANDLE);
+ ActionInvocation action = createActionInvocation(BasicMarkupBehavior.PORTLET_HANDLE);
PortletInvocationResponse response = consumer.invoke(action);
assertNotNull(response);
assertTrue("Was expecting a RenderResponse. Got: " + response, response instanceof RenderResponse);
RenderResponse render = (RenderResponse)response;
- assertEquals(BasicBehavior.NS, render.getNavigationalState().getStringValue());
+ assertEquals(BasicMarkupBehavior.NS, render.getNavigationalState().getStringValue());
}
public void testSessionHandling() throws Exception
{
- RenderInvocation render = createRenderInvocation(SessionBehavior.PORTLET_HANDLE);
+ RenderInvocation render = createRenderInvocation(SessionMarkupBehavior.PORTLET_HANDLE);
PortletInvocationResponse response = consumer.invoke(render);
@@ -103,9 +103,9 @@
// checking session information
ProducerSessionInformation sessionInfo = consumer.getProducerSessionInformationFrom(render);
- String sessionId = sessionInfo.getSessionIdForPortlet(SessionBehavior.PORTLET_HANDLE);
+ String sessionId = sessionInfo.getSessionIdForPortlet(SessionMarkupBehavior.PORTLET_HANDLE);
assertNotNull(sessionId);
- assertEquals(SessionBehavior.SESSION_ID, sessionId);
+ assertEquals(SessionMarkupBehavior.SESSION_ID, sessionId);
assertNotNull(sessionInfo.getUserCookie());
assertFalse(sessionInfo.isPerGroupCookies());
assertFalse(sessionInfo.isInitCookieDone());
@@ -117,7 +117,7 @@
public void testInitCookie() throws Exception
{
// first test that we don't initialize cookies if we don't need it
- RenderInvocation render = createRenderInvocation(BasicBehavior.PORTLET_HANDLE);
+ RenderInvocation render = createRenderInvocation(BasicMarkupBehavior.PORTLET_HANDLE);
TestPortletInvocationContext invocationContext = (TestPortletInvocationContext)render.getContext();
HttpSession session = invocationContext.getClientRequest().getSession();
producer.setResponse(invocationContext.getClientResponse());
@@ -130,7 +130,7 @@
// now require cookie initialization and check that everything went well
producer.setRequiresInitCookie(CookieProtocol.perUser);
- render = createRenderInvocation(BasicBehavior.PORTLET_HANDLE);
+ render = createRenderInvocation(BasicMarkupBehavior.PORTLET_HANDLE);
invocationContext = (TestPortletInvocationContext)render.getContext();
session = invocationContext.getClientRequest().getSession();
producer.setResponse(invocationContext.getClientResponse());
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java 2006-10-18 22:37:16 UTC (rev 5482)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java 2006-10-18 22:38:17 UTC (rev 5483)
@@ -24,8 +24,8 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicBehavior;
-import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
import java.util.Set;
@@ -54,17 +54,17 @@
Portlet p1 = portletArray[0];
Portlet p2 = portletArray[1];
- assertTrue((p1.getContext().getId().equals(BasicBehavior.PORTLET_HANDLE) && p2.getContext().getId().equals(SessionBehavior.PORTLET_HANDLE)) ||
- (p2.getContext().getId().equals(BasicBehavior.PORTLET_HANDLE) && p1.getContext().getId().equals(SessionBehavior.PORTLET_HANDLE)));
+ assertTrue((p1.getContext().getId().equals(BasicMarkupBehavior.PORTLET_HANDLE) && p2.getContext().getId().equals(SessionMarkupBehavior.PORTLET_HANDLE)) ||
+ (p2.getContext().getId().equals(BasicMarkupBehavior.PORTLET_HANDLE) && p1.getContext().getId().equals(SessionMarkupBehavior.PORTLET_HANDLE)));
}
public void testGetPortlet() throws Exception
{
//obtain one portlet
- Portlet portlet = consumer.getPortlet(new PortletContext(BasicBehavior.PORTLET_HANDLE));
- checkPortlet(portlet, "", BasicBehavior.PORTLET_HANDLE);
+ Portlet portlet = consumer.getPortlet(new PortletContext(BasicMarkupBehavior.PORTLET_HANDLE));
+ checkPortlet(portlet, "", BasicMarkupBehavior.PORTLET_HANDLE);
- portlet = consumer.getPortlet(new PortletContext(SessionBehavior.PORTLET_HANDLE));
- checkPortlet(portlet, "2", SessionBehavior.PORTLET_HANDLE);
+ portlet = consumer.getPortlet(new PortletContext(SessionMarkupBehavior.PORTLET_HANDLE));
+ checkPortlet(portlet, "2", SessionMarkupBehavior.PORTLET_HANDLE);
}
}
Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicBehavior.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicBehavior.java 2006-10-18 22:37:16 UTC (rev 5482)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicBehavior.java 2006-10-18 22:38:17 UTC (rev 5483)
@@ -1,80 +0,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. *
- ******************************************************************************/
-
-package org.jboss.portal.test.wsrp.v1.consumer.behaviors;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.test.wsrp.framework.MarkupBehavior;
-import org.jboss.portal.wsrp.WSRPConstants;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
-import org.jboss.portal.wsrp.core.GetMarkup;
-import org.jboss.portal.wsrp.core.MarkupResponse;
-import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
-import org.jboss.portal.wsrp.core.UpdateResponse;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.producer.BasicProducer">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class BasicBehavior extends MarkupBehavior
-{
- public static final String PORTLET_HANDLE = "SamplePortletHandle";
- public static final String NS = "ns1";
-
-
- public BasicBehavior()
- {
- portletHandle = PORTLET_HANDLE;
- }
-
- public String getMarkupString(Mode mode, WindowState windowState, String navigationalState, GetMarkup getMarkup)
- {
- StringBuffer markupString = new StringBuffer("portlet1:");
-
- markupString.append(mode).append(":").append(windowState);
- if (navigationalState != null)
- {
- markupString.append(":").append(navigationalState);
- }
-
- return markupString.toString();
- }
-
-
- public BlockingInteractionResponse performBlockingInteraction(PerformBlockingInteraction performBlockingInteraction)
- {
- UpdateResponse ur = WSRPTypeFactory.createUpdateResponse();
- ur.setNavigationalState(NS);
- return WSRPTypeFactory.createBlockingInteractionResponse(ur);
- }
-
- public void modifyResponseIfNeeded(MarkupResponse markupResponse)
- {
- // fake markup caching
- markupResponse.getMarkupContext().setCacheControl(WSRPTypeFactory.createCacheControl(15, WSRPConstants.CACHE_PER_USER));
- }
-}
Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicMarkupBehavior.java (from rev 5482, trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicBehavior.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicBehavior.java 2006-10-18 22:37:16 UTC (rev 5482)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicMarkupBehavior.java 2006-10-18 22:38:17 UTC (rev 5483)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * 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.wsrp.v1.consumer.behaviors;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.test.wsrp.framework.MarkupBehavior;
+import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
+import org.jboss.portal.wsrp.core.GetMarkup;
+import org.jboss.portal.wsrp.core.MarkupResponse;
+import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
+import org.jboss.portal.wsrp.core.UpdateResponse;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.producer.BasicProducer">Chris
+ * Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class BasicMarkupBehavior extends MarkupBehavior
+{
+ public static final String PORTLET_HANDLE = "SamplePortletHandle";
+ public static final String NS = "ns1";
+
+
+ public BasicMarkupBehavior()
+ {
+ portletHandle = PORTLET_HANDLE;
+ }
+
+ public String getMarkupString(Mode mode, WindowState windowState, String navigationalState, GetMarkup getMarkup)
+ {
+ StringBuffer markupString = new StringBuffer("portlet1:");
+
+ markupString.append(mode).append(":").append(windowState);
+ if (navigationalState != null)
+ {
+ markupString.append(":").append(navigationalState);
+ }
+
+ return markupString.toString();
+ }
+
+
+ public BlockingInteractionResponse performBlockingInteraction(PerformBlockingInteraction performBlockingInteraction)
+ {
+ UpdateResponse ur = WSRPTypeFactory.createUpdateResponse();
+ ur.setNavigationalState(NS);
+ return WSRPTypeFactory.createBlockingInteractionResponse(ur);
+ }
+
+ public void modifyResponseIfNeeded(MarkupResponse markupResponse)
+ {
+ // fake markup caching
+ markupResponse.getMarkupContext().setCacheControl(WSRPTypeFactory.createCacheControl(15, WSRPConstants.CACHE_PER_USER));
+ }
+}
Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionBehavior.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionBehavior.java 2006-10-18 22:37:16 UTC (rev 5482)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionBehavior.java 2006-10-18 22:38:17 UTC (rev 5483)
@@ -1,84 +0,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. *
- ******************************************************************************/
-
-package org.jboss.portal.test.wsrp.v1.consumer.behaviors;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.test.wsrp.framework.MarkupBehavior;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.core.GetMarkup;
-import org.jboss.portal.wsrp.core.MarkupResponse;
-import org.jboss.portal.wsrp.core.SessionContext;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.producer.SessionBehavior">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class SessionBehavior extends MarkupBehavior
-{
- public static final String PORTLET_HANDLE = "SecondPortletHandle";
- public static final String SESSION_ID = "sessionID";
-
- private int count = 0;
- private String sessionId;
-
- public SessionBehavior()
- {
- portletHandle = PORTLET_HANDLE;
- }
-
- public String getMarkupString(Mode mode, WindowState windowState, String navigationalState, GetMarkup getMarkup)
- {
- StringBuffer markupString = new StringBuffer("portlet2:");
- sessionId = getMarkup.getRuntimeContext().getSessionID();
-
- // if we have a session, increments count to simulate session usage
- if (SESSION_ID.equals(sessionId))
- {
- count++;
- }
- markupString.append(count).append(":");
-
- markupString.append(mode).append(":").append(windowState);
- if (navigationalState != null)
- {
- markupString.append(":").append(navigationalState);
- }
-
- return markupString.toString();
- }
-
-
- public void modifyResponseIfNeeded(MarkupResponse markupResponse)
- {
- // fakes creation of a portlet session if not already present
- if (count == 0 || SESSION_ID.equals(sessionId))
- {
- SessionContext sessionContext = WSRPTypeFactory.createSessionContext(SESSION_ID, 30);
- markupResponse.setSessionContext(sessionContext);
- }
- }
-}
Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionMarkupBehavior.java (from rev 5482, trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionBehavior.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionBehavior.java 2006-10-18 22:37:16 UTC (rev 5482)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionMarkupBehavior.java 2006-10-18 22:38:17 UTC (rev 5483)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * 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.wsrp.v1.consumer.behaviors;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.test.wsrp.framework.MarkupBehavior;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.core.GetMarkup;
+import org.jboss.portal.wsrp.core.MarkupResponse;
+import org.jboss.portal.wsrp.core.SessionContext;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.producer.SessionBehavior">Chris
+ * Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class SessionMarkupBehavior extends MarkupBehavior
+{
+ public static final String PORTLET_HANDLE = "SecondPortletHandle";
+ public static final String SESSION_ID = "sessionID";
+
+ private int count = 0;
+ private String sessionId;
+
+ public SessionMarkupBehavior()
+ {
+ portletHandle = PORTLET_HANDLE;
+ }
+
+ public String getMarkupString(Mode mode, WindowState windowState, String navigationalState, GetMarkup getMarkup)
+ {
+ StringBuffer markupString = new StringBuffer("portlet2:");
+ sessionId = getMarkup.getRuntimeContext().getSessionID();
+
+ // if we have a session, increments count to simulate session usage
+ if (SESSION_ID.equals(sessionId))
+ {
+ count++;
+ }
+ markupString.append(count).append(":");
+
+ markupString.append(mode).append(":").append(windowState);
+ if (navigationalState != null)
+ {
+ markupString.append(":").append(navigationalState);
+ }
+
+ return markupString.toString();
+ }
+
+
+ public void modifyResponseIfNeeded(MarkupResponse markupResponse)
+ {
+ // fakes creation of a portlet session if not already present
+ if (count == 0 || SESSION_ID.equals(sessionId))
+ {
+ SessionContext sessionContext = WSRPTypeFactory.createSessionContext(SESSION_ID, 30);
+ markupResponse.setSessionContext(sessionContext);
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list