Author: chris.laprun(a)jboss.com
Date: 2008-04-16 16:54:59 -0400 (Wed, 16 Apr 2008)
New Revision: 10610
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/GroupedPortletsServiceDescriptionBehavior.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieNotRequiredMarkupBehavior.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/PerGroupInitCookieMarkupBehavior.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/PerUserInitCookieMarkupBehavior.java
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducer.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicServiceDescriptionBehavior.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
Log:
- Added setCurrentMarkupBehaviorHandle on TestWSRPProducer to be able to access the proper
behavior when calling initCookie.
- Added V1ConsumerBaseTest.setUpWith method to allow switching of
ServiceDescriptionBehavior on a per-method basis in test cases.
- Fixed a problem with ProducerSessionInformation.getGroupCookieFor method: the case where
no cookies were found for the given
group id was not handled properly.
- ProducerInfo.getRequiresInitCookie is now public (used by tests and could potentially be
exposed to the GUI).
- Added more test cases and behaviors to better test initCookie handling.
- Removed empty MarkupTestCase.testImplicitCloning method.
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducer.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducer.java 2008-04-16
20:31:54 UTC (rev 10609)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducer.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -37,4 +37,12 @@
void reset();
BehaviorRegistry getBehaviorRegistry();
+
+ /**
+ * Sets the currently used portlet handle identifying the MarkupBehavior we're
using. This is needed to be able to
+ * dispatch calls to initCookie to the proper behavior.
+ *
+ * @param handle
+ */
+ void setCurrentMarkupBehaviorHandle(String handle);
}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2008-04-16
20:31:54 UTC (rev 10609)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -89,6 +89,8 @@
public static final String USER_COOKIE = "cookie";
+ private String currentMarkupBehaviorHandle;
+
public TestWSRPProducerImpl()
{
reset();
@@ -99,9 +101,15 @@
return behaviorRegistry;
}
+ public void setCurrentMarkupBehaviorHandle(String handle)
+ {
+ currentMarkupBehaviorHandle = handle;
+ }
+
public void reset()
{
requiresInitCookie = null;
+ currentMarkupBehaviorHandle = null;
behaviorRegistry.clear();
}
@@ -162,12 +170,19 @@
throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault,
RemoteException
{
// should only be called if we required cookies to be initialized
- if (requiresInitCookie == null)
+ if (requiresInitCookie == null || CookieProtocol.none.equals(requiresInitCookie))
{
throw new OperationFailedFault();
}
- return null;
+ try
+ {
+ return
getMarkupBehaviorFor(currentMarkupBehaviorHandle).initCookie(initCookie);
+ }
+ catch (InvalidHandleFault invalidHandleFault)
+ {
+ throw new OperationFailedFault();
+ }
}
// Registration implementation
**************************************************************************************
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2008-04-16
20:31:54 UTC (rev 10609)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -43,12 +43,17 @@
import org.jboss.portal.test.wsrp.framework.support.TestPortletInvocationContext;
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.GroupedPortletsServiceDescriptionBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.InitCookieMarkupBehavior;
+import
org.jboss.portal.test.wsrp.v1.consumer.behaviors.InitCookieNotRequiredMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.NullMarkupBehavior;
+import
org.jboss.portal.test.wsrp.v1.consumer.behaviors.PerGroupInitCookieMarkupBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.PerUserInitCookieMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.ResourceMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
import org.jboss.portal.wsrp.core.CookieProtocol;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
import javax.servlet.http.HttpSession;
@@ -73,6 +78,7 @@
}
catch (PortletInvokerException expected)
{
+ // expected
}
}
@@ -134,39 +140,48 @@
checkRenderResult(response, "portlet2:1:view:maximized");
}
- public void testInitCookie() throws Exception
+ public void testInitCookieNotCalledWhenNotNeeded() throws Exception
{
- // first test that we don't initialize cookies if we don't need it
- RenderInvocation render =
createRenderInvocation(InitCookieMarkupBehavior.PORTLET_HANDLE);
- TestPortletInvocationContext invocationContext =
(TestPortletInvocationContext)render.getContext();
- HttpSession session = invocationContext.getClientRequest().getSession();
+ String handle =
InitCookieNotRequiredMarkupBehavior.INIT_COOKIE_NOT_REQUIRED_HANDLE;
+ InitCookieMarkupBehavior behavior =
(InitCookieMarkupBehavior)producer.getBehaviorRegistry().getMarkupBehaviorFor(handle);
- ProducerSessionInformation sessionInfo =
consumer.getProducerSessionInformationFrom(session);
- ExtendedAssert.assertNull(sessionInfo);
+ ProducerSessionInformation sessionInfo = commonInitCookieTest(handle, behavior,
null);
- consumer.invoke(render);
-
- sessionInfo = consumer.getProducerSessionInformationFrom(session);
ExtendedAssert.assertNotNull(sessionInfo);
ExtendedAssert.assertFalse(sessionInfo.isPerGroupCookies());
ExtendedAssert.assertFalse(sessionInfo.isInitCookieDone());
- // now require cookie initialization and check that everything went well
- producer.setRequiresInitCookie(CookieProtocol.perUser);
- render = createRenderInvocation(InitCookieMarkupBehavior.PORTLET_HANDLE,
invocationContext);
+ ExtendedAssert.assertEquals(0, behavior.getInitCookieCallCount());
+ }
- consumer.invoke(render);
+ public void testInitCookiePerUser() throws PortletInvokerException,
InvalidHandleFault
+ {
+ String handle = PerUserInitCookieMarkupBehavior.PER_USER_INIT_COOKIE_HANDLE;
+ InitCookieMarkupBehavior behavior =
(InitCookieMarkupBehavior)producer.getBehaviorRegistry().getMarkupBehaviorFor(handle);
- sessionInfo = consumer.getProducerSessionInformationFrom(session);
+ ProducerSessionInformation sessionInfo = commonInitCookieTest(handle, behavior,
CookieProtocol.perUser);
+
ExtendedAssert.assertFalse(sessionInfo.isPerGroupCookies());
ExtendedAssert.assertTrue(sessionInfo.isInitCookieDone());
ExtendedAssert.assertNotNull(sessionInfo.getUserCookie());
+
+ ExtendedAssert.assertEquals(1, behavior.getInitCookieCallCount());
}
- public void testImplicitCloning() throws Exception
+ public void testInitCookiePerGroup() throws PortletInvokerException,
InvalidHandleFault
{
-// ActionInvocation action = createActionInvocation()
+ // need to setup with a specific service description behavior
+ setUpWith(new GroupedPortletsServiceDescriptionBehavior());
+ String handle = PerGroupInitCookieMarkupBehavior.PER_GROUP_INIT_COOKIE_HANDLE;
+ InitCookieMarkupBehavior behavior =
(InitCookieMarkupBehavior)producer.getBehaviorRegistry().getMarkupBehaviorFor(handle);
+
+ ProducerSessionInformation sessionInfo = commonInitCookieTest(handle, behavior,
CookieProtocol.perGroup);
+ ExtendedAssert.assertTrue(sessionInfo.isPerGroupCookies());
+ ExtendedAssert.assertTrue(sessionInfo.isInitCookieDone());
+ ExtendedAssert.assertNull(sessionInfo.getUserCookie());
+
+ ExtendedAssert.assertEquals(3, behavior.getInitCookieCallCount());
}
public void testResource() throws PortletInvokerException
@@ -177,6 +192,30 @@
checkRenderResult(response, "<img
src='http://localhost:8080/test-resource-portlet/gif/logo.gif'/>");
}
+ private ProducerSessionInformation commonInitCookieTest(String handle,
InitCookieMarkupBehavior behavior, CookieProtocol cookieProtocol)
+ throws PortletInvokerException
+ {
+ RenderInvocation render = createRenderInvocation(handle);
+ TestPortletInvocationContext invocationContext =
(TestPortletInvocationContext)render.getContext();
+ HttpSession session = invocationContext.getClientRequest().getSession();
+
+ // set init cookie requirement
+ producer.setRequiresInitCookie(cookieProtocol);
+
+ // tell the producer which markup behavior we want to use
+ producer.setCurrentMarkupBehaviorHandle(handle);
+
+ render = createRenderInvocation(handle, invocationContext);
+
+ ExtendedAssert.assertEquals(0, behavior.getInitCookieCallCount());
+
+ consumer.invoke(render);
+
+ ExtendedAssert.assertEquals(cookieProtocol,
consumer.getProducerInfo().getRequiresInitCookie());
+
+ return consumer.getProducerSessionInformationFrom(session);
+ }
+
private FragmentResponse checkRenderResult(PortletInvocationResponse response, String
markup)
{
ExtendedAssert.assertNotNull(response);
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2008-04-16
20:31:54 UTC (rev 10609)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -24,6 +24,7 @@
import org.jboss.portal.common.junit.ExtendedAssert;
import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.test.wsrp.WSRPConsumerBaseTest;
import org.jboss.portal.test.wsrp.framework.BehaviorRegistry;
@@ -33,8 +34,10 @@
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicPortletManagementBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.EmptyMarkupBehavior;
-import org.jboss.portal.test.wsrp.v1.consumer.behaviors.InitCookieMarkupBehavior;
+import
org.jboss.portal.test.wsrp.v1.consumer.behaviors.InitCookieNotRequiredMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.NullMarkupBehavior;
+import
org.jboss.portal.test.wsrp.v1.consumer.behaviors.PerGroupInitCookieMarkupBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.PerUserInitCookieMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.ResourceMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
@@ -63,17 +66,23 @@
public void setUp() throws Exception
{
super.setUp();
+ setUpWith(new ServiceDescriptionBehavior());
+ }
+ protected void setUpWith(ServiceDescriptionBehavior serviceDescriptionBehavior) throws
PortletInvokerException
+ {
// reset producer state
producer.reset();
// reset the behaviors
BehaviorRegistry registry = producer.getBehaviorRegistry();
registry.setPortletManagementBehavior(new
BasicPortletManagementBehavior(registry));
- registry.setServiceDescriptionBehavior(new ServiceDescriptionBehavior());
+ registry.setServiceDescriptionBehavior(serviceDescriptionBehavior);
registry.registerMarkupBehavior(new BasicMarkupBehavior(registry));
registry.registerMarkupBehavior(new EmptyMarkupBehavior(registry));
- registry.registerMarkupBehavior(new InitCookieMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new
InitCookieNotRequiredMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new PerGroupInitCookieMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new PerUserInitCookieMarkupBehavior(registry));
registry.registerMarkupBehavior(new NullMarkupBehavior(registry));
registry.registerMarkupBehavior(new SessionMarkupBehavior(registry));
registry.registerMarkupBehavior(new ResourceMarkupBehavior(registry));
@@ -85,6 +94,6 @@
consumer.refreshProducerInfo();
// use cache to avoid un-necessary calls
- consumer.getProducerInfo().setExpirationCacheSeconds(new Integer(120));
+ consumer.getProducerInfo().setExpirationCacheSeconds(120);
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicServiceDescriptionBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicServiceDescriptionBehavior.java 2008-04-16
20:31:54 UTC (rev 10609)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicServiceDescriptionBehavior.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -49,6 +49,7 @@
serviceDescription.setOfferedPortlets(new PortletDescription[]{pd1, pd2});
}
+ @Override
public ServiceDescription getServiceDescription(GetServiceDescription
getServiceDescription)
throws OperationFailedFault, InvalidRegistrationFault, RemoteException
{
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/GroupedPortletsServiceDescriptionBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/GroupedPortletsServiceDescriptionBehavior.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/GroupedPortletsServiceDescriptionBehavior.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -0,0 +1,53 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.test.wsrp.framework.ServiceDescriptionBehavior;
+import org.jboss.portal.wsrp.core.GetServiceDescription;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.PortletDescription;
+import org.jboss.portal.wsrp.core.ServiceDescription;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class GroupedPortletsServiceDescriptionBehavior extends
ServiceDescriptionBehavior
+{
+ @Override
+ public ServiceDescription getServiceDescription(GetServiceDescription
getServiceDescription) throws OperationFailedFault, InvalidRegistrationFault,
RemoteException
+ {
+ ServiceDescription sd = super.getServiceDescription(getServiceDescription);
+ PortletDescription[] portlets = sd.getOfferedPortlets();
+
+ for (int i = 0; i < portlets.length; i++)
+ {
+ portlets[i].setGroupID("group" + i % 3);
+ }
+
+ return sd;
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java 2008-04-16
20:31:54 UTC (rev 10609)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -27,45 +27,74 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.test.wsrp.framework.BehaviorRegistry;
import org.jboss.portal.test.wsrp.framework.MarkupBehavior;
+import org.jboss.portal.wsrp.core.AccessDeniedFault;
import org.jboss.portal.wsrp.core.GetMarkup;
+import org.jboss.portal.wsrp.core.InitCookie;
import org.jboss.portal.wsrp.core.InvalidCookieFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.ReturnAny;
+import java.rmi.RemoteException;
+
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
* @since 2.6
*/
-public class InitCookieMarkupBehavior extends MarkupBehavior
+public abstract class InitCookieMarkupBehavior extends MarkupBehavior
{
- public static final String PORTLET_HANDLE = "initcookiehandle";
+ protected String portletHandle;
+ protected int initCookieCallCount;
-
public InitCookieMarkupBehavior(BehaviorRegistry registry)
{
super(registry);
- registerHandle(PORTLET_HANDLE);
+ initPortletHandle();
+ registerHandle(portletHandle);
}
+ protected abstract void initPortletHandle();
+
protected String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup) throws InvalidCookieFault, OperationFailedFault
{
- System.out.println("InitCookieMarkupBehavior getMarkupString call count:
" + callCount);
- String markup = "markup";
+ String handle = getMarkup.getPortletContext().getPortletHandle();
+
+ if (portletHandle.equals(handle))
+ {
+ return getMarkupString(handle);
+ }
+
+ // shouldn't happen
+ throw new OperationFailedFault();
+ }
+
+ protected String getMarkupString(String handle) throws InvalidCookieFault,
OperationFailedFault
+ {
switch (callCount++)
{
case 0:
- return markup;
-
- case 1:
// simulate change of configuration between calls: upon receiving this, the
consumer should invoke initCookie
throw new InvalidCookieFault();
- case 2:
- return markup;
+ case 1:
+ return handle;
default:
- // shouldn't be called more than 3 times
+ // shouldn't be called more than twice
throw new OperationFailedFault();
}
}
+
+ @Override
+ public ReturnAny initCookie(InitCookie initCookie) throws AccessDeniedFault,
OperationFailedFault, InvalidRegistrationFault, RemoteException
+ {
+ initCookieCallCount++;
+ return null;
+ }
+
+ public int getInitCookieCallCount()
+ {
+ return initCookieCallCount;
+ }
}
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieNotRequiredMarkupBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieNotRequiredMarkupBehavior.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieNotRequiredMarkupBehavior.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -0,0 +1,65 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.test.wsrp.framework.BehaviorRegistry;
+import org.jboss.portal.wsrp.core.AccessDeniedFault;
+import org.jboss.portal.wsrp.core.InitCookie;
+import org.jboss.portal.wsrp.core.InvalidCookieFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.ReturnAny;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class InitCookieNotRequiredMarkupBehavior extends InitCookieMarkupBehavior
+{
+ public static final String INIT_COOKIE_NOT_REQUIRED_HANDLE =
"InitCookieNotRequired";
+
+ public InitCookieNotRequiredMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ }
+
+ protected void initPortletHandle()
+ {
+ portletHandle = INIT_COOKIE_NOT_REQUIRED_HANDLE;
+ }
+
+ @Override
+ protected String getMarkupString(String handle) throws InvalidCookieFault,
OperationFailedFault
+ {
+ return handle;
+ }
+
+ @Override
+ public ReturnAny initCookie(InitCookie initCookie) throws AccessDeniedFault,
OperationFailedFault, InvalidRegistrationFault, RemoteException
+ {
+ super.initCookie(initCookie);
+ throw new OperationFailedFault();
+ }
+}
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/PerGroupInitCookieMarkupBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/PerGroupInitCookieMarkupBehavior.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/PerGroupInitCookieMarkupBehavior.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -0,0 +1,66 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.test.wsrp.framework.BehaviorRegistry;
+import org.jboss.portal.wsrp.core.AccessDeniedFault;
+import org.jboss.portal.wsrp.core.InitCookie;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.ReturnAny;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class PerGroupInitCookieMarkupBehavior extends InitCookieMarkupBehavior
+{
+ public static final String PER_GROUP_INIT_COOKIE_HANDLE =
"PerGroupInitCookie";
+
+ public PerGroupInitCookieMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ }
+
+ protected void initPortletHandle()
+ {
+ portletHandle = PER_GROUP_INIT_COOKIE_HANDLE;
+ }
+
+ @Override
+ public ReturnAny initCookie(InitCookie initCookie) throws AccessDeniedFault,
OperationFailedFault, InvalidRegistrationFault, RemoteException
+ {
+ ReturnAny result = super.initCookie(initCookie);
+
+ if (initCookieCallCount > 3)
+ {
+ OperationFailedFault fault = new OperationFailedFault();
+ fault.initCause(new IllegalStateException("Service description only defines
3 groups so initCookie should only be called 3 times!"));
+ throw fault;
+ }
+
+ return result;
+ }
+}
Added:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/PerUserInitCookieMarkupBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/PerUserInitCookieMarkupBehavior.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/PerUserInitCookieMarkupBehavior.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -0,0 +1,44 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.test.wsrp.framework.BehaviorRegistry;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class PerUserInitCookieMarkupBehavior extends InitCookieMarkupBehavior
+{
+ public static final String PER_USER_INIT_COOKIE_HANDLE =
"PerUserInitCookie";
+
+ public PerUserInitCookieMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ }
+
+ protected void initPortletHandle()
+ {
+ portletHandle = PER_USER_INIT_COOKIE_HANDLE;
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-04-16
20:31:54 UTC (rev 10609)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -231,7 +231,7 @@
return isModifyRegistrationRequired || (persistentRegistrationInfo != null
&& persistentRegistrationInfo.isModified());
}
- CookieProtocol getRequiresInitCookie()
+ public CookieProtocol getRequiresInitCookie()
{
return requiresInitCookie;
}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2008-04-16
20:31:54 UTC (rev 10609)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2008-04-16
20:54:59 UTC (rev 10610)
@@ -175,18 +175,25 @@
// purge expired cookies
Cookie[] cookies = groupCookies.get(groupId);
- cookies = purgeExpiredCookies(cookies);
+ if (cookies != null)
+ {
+ cookies = purgeExpiredCookies(cookies);
- // if there are no non-expired cookies left, we will need to re-init them
- if (cookies.length == 0)
+ // if there are no non-expired cookies left, we will need to re-init them
+ if (cookies.length == 0)
+ {
+ setInitCookieDone(false);
+ }
+
+ // update cookies for the considered group id
+ groupCookies.put(groupId, cookies);
+
+ return outputToExternalForm(cookies);
+ }
+ else
{
- setInitCookieDone(false);
+ return null;
}
-
- // update cookies for the considered group id
- groupCookies.put(groupId, cookies);
-
- return outputToExternalForm(cookies);
}
public void clearGroupCookies()
@@ -363,6 +370,8 @@
*/
private Cookie[] purgeExpiredCookies(Cookie[] cookies)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(cookies,
"cookies");
+
List<Cookie> cleanCookies = Tools.toList(cookies);
for (Cookie cookie : cookies)