Author: chris.laprun(a)jboss.com
Date: 2007-01-12 20:42:19 -0500 (Fri, 12 Jan 2007)
New Revision: 6004
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/BehaviorRegistry.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ListBehaviorSequence.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/SingleBehaviorSequence.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestBehaviorSequence.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPConsumerBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/MarkupBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducer.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
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/BasicPortletManagementBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/EmptyMarkupBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/NullMarkupBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionMarkupBehavior.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
Log:
- Refactored handling of behaviors. Should now be simpler and easier to work with.
- Introduced concept of BehaviorRegistry.
- Removed dependency of TestWSRPProducerImpl on test behaviors.
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPConsumerBaseTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPConsumerBaseTest.java 2007-01-12
23:32:39 UTC (rev 6003)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPConsumerBaseTest.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -55,7 +55,6 @@
public void setUp() throws Exception
{
consumer.getProducerInfo().setId(TEST_PRODUCER_ID);
- producer.reset();
}
public TestWSRPProducer getProducer()
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/BehaviorRegistry.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/BehaviorRegistry.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/BehaviorRegistry.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+
+package org.jboss.portal.test.wsrp.framework;
+
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class BehaviorRegistry
+{
+ private final Map behaviors = new HashMap();
+ private PortletManagementBehavior portletManagementBehavior;
+ private ServiceDescriptionBehavior serviceDescriptionBehavior;
+ private RegistrationBehavior registrationBehavior;
+
+ public ServiceDescriptionBehavior getServiceDescriptionBehavior()
+ {
+ // this is required since the consumer will try to access the producer as soon as
it's started and the test
+ // producer will not be properly setup at that time since it's set up in the
test's setUp method...
+ if (serviceDescriptionBehavior == null)
+ {
+ return ServiceDescriptionBehavior.DEFAULT;
+ }
+
+ return serviceDescriptionBehavior;
+ }
+
+ public void clear()
+ {
+ behaviors.clear();
+ }
+
+ public MarkupBehavior getMarkupBehaviorFor(String handle) throws InvalidHandleFault
+ {
+ if (behaviors.containsKey(handle))
+ {
+ return (MarkupBehavior)behaviors.get(handle);
+ }
+ System.out.println("There is no registered MarkupBehavior for handle
'" + handle + "'");
+ throw new InvalidHandleFault();
+ }
+
+ public void registerMarkupBehavior(MarkupBehavior behavior)
+ {
+ for (Iterator handles = behavior.getSupportedHandles().iterator();
handles.hasNext();)
+ {
+ String handle = (String)handles.next();
+ MarkupBehavior existing = (MarkupBehavior)behaviors.get(handle);
+ if (existing != null)
+ {
+ throw new IllegalArgumentException("Cannot register behavior " +
behavior.getClass().getName()
+ + " because it uses a handle '" + handle + "'
that's already associated with behavior "
+ + existing.getClass().getName());
+ }
+ behaviors.put(handle, behavior);
+ }
+ }
+
+ public PortletManagementBehavior getPortletManagementBehavior()
+ {
+ return portletManagementBehavior;
+ }
+
+ public void setPortletManagementBehavior(PortletManagementBehavior
portletManagementBehavior)
+ {
+ this.portletManagementBehavior = portletManagementBehavior;
+ }
+
+ public void setServiceDescriptionBehavior(ServiceDescriptionBehavior
serviceDescriptionBehavior)
+ {
+ this.serviceDescriptionBehavior = serviceDescriptionBehavior;
+ }
+
+ public RegistrationBehavior getRegistrationBehavior()
+ {
+ return registrationBehavior;
+ }
+
+ public void setRegistrationBehavior(RegistrationBehavior registrationBehavior)
+ {
+ this.registrationBehavior = registrationBehavior;
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/BehaviorRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ListBehaviorSequence.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ListBehaviorSequence.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ListBehaviorSequence.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -1,55 +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.framework;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.jboss.portal.test.wsrp.framework.ListBehaviorSequence">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class ListBehaviorSequence extends TestBehaviorSequence
-{
- private List sequence;
-
- public ListBehaviorSequence(TestBehaviorSet behaviorSet)
- {
- super(behaviorSet);
- sequence = new ArrayList(3);
- sequence.add(behaviorSet);
- }
-
- public void setBehaviorSetAt(TestBehaviorSet behaviorSet, int sequenceOrder)
- {
- sequence.set(sequenceOrder, behaviorSet);
- }
-
- protected TestBehaviorSet getBehaviorSetFor(int sequenceOrder)
- {
- return (TestBehaviorSet)sequence.get(sequenceOrder);
- }
-}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/MarkupBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/MarkupBehavior.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/MarkupBehavior.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -43,6 +43,7 @@
import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
+import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.PortletStateChangeRequiredFault;
import org.jboss.portal.wsrp.core.ReleaseSessions;
import org.jboss.portal.wsrp.core.ReturnAny;
@@ -53,6 +54,8 @@
import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.List;
/**
* Behavior delivering Markup services.
@@ -64,20 +67,8 @@
*/
public abstract class MarkupBehavior extends TestProducerBehavior implements
WSRP_v1_Markup_PortType
{
- protected String portletHandle;
+ protected List handles = new ArrayList(3);
- /**
- * The portlet handle associated with this behavior for the behaviors that react to a
specific portlet handle. Used
- * essentially for markup/interaction requests.
- *
- * @return
- */
- public String getPortletHandle()
- {
- return portletHandle;
- }
-
-
public MarkupResponse getMarkup(GetMarkup getMarkup) throws
UnsupportedWindowStateFault, InvalidCookieFault,
InvalidSessionFault, AccessDeniedFault, InconsistentParametersFault,
InvalidHandleFault, UnsupportedLocaleFault,
UnsupportedModeFault, OperationFailedFault, MissingParametersFault,
InvalidUserCategoryFault,
@@ -153,4 +144,24 @@
{
// default implementation does not nothing
}
+
+ public List getSupportedHandles()
+ {
+ return handles;
+ }
+
+ public PortletDescription getPortletDescriptionFor(String handle)
+ {
+ if (handles.contains(handle))
+ {
+ return createPortletDescription(handle, getSuffixFor(handle));
+ }
+ throw new IllegalArgumentException("MarkupBehavior " +
getClass().getName() + " is not associated with handle '"
+ + handle + "'");
+ }
+
+ protected String getSuffixFor(String handle)
+ {
+ return "";
+ }
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/ServiceDescriptionBehavior.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -39,9 +39,11 @@
* @version $Revision$
* @since 2.6
*/
-public abstract class ServiceDescriptionBehavior extends TestProducerBehavior implements
WSRP_v1_ServiceDescription_PortType
+public class ServiceDescriptionBehavior extends TestProducerBehavior implements
WSRP_v1_ServiceDescription_PortType
{
protected ServiceDescription serviceDescription;
+ private static final ServiceDescription DEFAULT_SERVICE_DESCRIPTION =
WSRPTypeFactory.createServiceDescription(false);
+ public static final ServiceDescriptionBehavior DEFAULT = new
ServiceDescriptionBehavior();
protected ServiceDescriptionBehavior()
{
@@ -52,7 +54,7 @@
public ServiceDescription getServiceDescription(GetServiceDescription
getServiceDescription) throws
OperationFailedFault, InvalidRegistrationFault, RemoteException
{
- return null;
+ return DEFAULT_SERVICE_DESCRIPTION;
}
public void setRequiresRegistration(boolean requiresRegistration)
@@ -64,4 +66,9 @@
{
serviceDescription.setRequiresInitCookie(requiresInitCookie);
}
+
+ public static ServiceDescription getDefaultServiceDescription()
+ {
+ return DEFAULT_SERVICE_DESCRIPTION;
+ }
}
Deleted:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/SingleBehaviorSequence.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/SingleBehaviorSequence.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/SingleBehaviorSequence.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -1,63 +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.framework;
-
-/**
- * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.jboss.portal.test.wsrp.framework.SingleBehaviorSequence">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class SingleBehaviorSequence extends TestBehaviorSequence
-{
- private TestBehaviorSet behaviorSet;
-
- public SingleBehaviorSequence(TestBehaviorSet behaviorSet)
- {
- super(behaviorSet);
- setBehaviorSetAt(behaviorSet, 0);
- }
-
- public void setBehaviorSetAt(TestBehaviorSet behaviorSet, int sequenceOrder)
- {
- if (sequenceOrder != 0)
- {
- throw new IllegalArgumentException("SingleBehaviorSequence only accepts a
single BehaviorSet.");
- }
- this.behaviorSet = behaviorSet;
- }
-
- protected TestBehaviorSet getBehaviorSetFor(int sequenceOrder)
- {
- return behaviorSet;
- }
-
-
- public String toString()
- {
- return "SingleBehaviorSequence{" +
- "behaviorSet=" + behaviorSet +
- '}';
- }
-}
Deleted:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestBehaviorSequence.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestBehaviorSequence.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestBehaviorSequence.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -1,130 +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.framework;
-
-/**
- * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.jboss.portal.test.wsrp.framework.TestBehaviorSequence">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public abstract class TestBehaviorSequence
-{
-
- public TestBehaviorSequence(TestBehaviorSet behaviorSet)
- {
- }
-
- public abstract void setBehaviorSetAt(TestBehaviorSet behaviorSet, int
sequenceOrder);
-
- protected abstract TestBehaviorSet getBehaviorSetFor(int sequenceOrder);
-
- public void setBehaviorAt(TestProducerBehavior behavior, int sequenceOrder)
- {
- getBehaviorSetFor(sequenceOrder).setBehavior(behavior);
- }
-
- public ServiceDescriptionBehavior getServiceDescriptionBehaviorFor(int sequenceOrder)
- {
- return getBehaviorSetFor(sequenceOrder).descriptionBehavior;
- }
-
- public MarkupBehavior getMarkupBehaviorFor(int sequenceOrder)
- {
- return getBehaviorSetFor(sequenceOrder).markupBehavior;
- }
-
- public PortletManagementBehavior getPortletManagementBehaviorFor(int sequenceOrder)
- {
- return getBehaviorSetFor(sequenceOrder).managementBehavior;
- }
-
- public RegistrationBehavior getRegistrationBehaviorFor(int sequenceOrder)
- {
- return getBehaviorSetFor(sequenceOrder).registrationBehavior;
- }
-
- public static class TestBehaviorSet
- {
-
- public TestBehaviorSet(ServiceDescriptionBehavior descriptionBehavior,
MarkupBehavior markupBehavior,
- PortletManagementBehavior managementBehavior,
RegistrationBehavior registrationBehavior)
- {
- this.descriptionBehavior = descriptionBehavior;
- this.markupBehavior = markupBehavior;
- this.managementBehavior = managementBehavior;
- this.registrationBehavior = registrationBehavior;
- }
-
- /**
- * Constructs a set containing only one behavior. Used for simple tests.
- *
- * @param behavior
- */
- public TestBehaviorSet(TestProducerBehavior behavior)
- {
- setBehavior(behavior);
- }
-
-
- public String toString()
- {
- return "TestBehaviorSet{" +
- "descriptionBehavior=" + descriptionBehavior +
- ", markupBehavior=" + markupBehavior +
- ", managementBehavior=" + managementBehavior +
- ", registrationBehavior=" + registrationBehavior +
- '}';
- }
-
- private ServiceDescriptionBehavior descriptionBehavior;
- private MarkupBehavior markupBehavior;
- private PortletManagementBehavior managementBehavior;
- private RegistrationBehavior registrationBehavior;
-
- public void setBehavior(TestProducerBehavior behavior)
- {
- if (behavior instanceof ServiceDescriptionBehavior)
- {
- descriptionBehavior = (ServiceDescriptionBehavior)behavior;
- }
- else if (behavior instanceof MarkupBehavior)
- {
- markupBehavior = (MarkupBehavior)behavior;
- }
- else if (behavior instanceof PortletManagementBehavior)
- {
- managementBehavior = (PortletManagementBehavior)behavior;
- }
- else if (behavior instanceof RegistrationBehavior)
- {
- registrationBehavior = (RegistrationBehavior)behavior;
- }
- else
- {
- throw new IllegalArgumentException("Invalid behavior: " +
behavior);
- }
- }
- }
-}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducer.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducer.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducer.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -40,4 +40,5 @@
void setResponse(HttpServletResponse response);
+ BehaviorRegistry getBehaviorRegistry();
}
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 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -25,14 +25,6 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.registration.RegistrationManager;
-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.BasicServiceDescriptionBehavior;
-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.NullMarkupBehavior;
-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.core.AccessDeniedFault;
import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
@@ -54,7 +46,6 @@
import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
import org.jboss.portal.wsrp.core.MarkupResponse;
import org.jboss.portal.wsrp.core.MissingParametersFault;
-import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.ModifyRegistration;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
@@ -80,54 +71,27 @@
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import java.rmi.RemoteException;
-import java.util.HashMap;
-import java.util.Map;
/**
* This is dummy clone of org.jboss.portal.wsrp.producer.WSRPProducerImpl customizable
from client side. Just for
* consumer implementation testing purposes.
*
* @author <a href="mailto:Boleslaw.Dawidowicz@jboss.com">Boleslaw
Dawidowicz</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
* @since 2.4
*/
public class TestWSRPProducerImpl extends AbstractJBossService implements
TestWSRPProducer
{
- //injected objects to return by WS methods (for tests)
-
- /**
- * The ServiceDescription that is returned to an unregistred Consumer when
registration is required: no information
- * is provided apart from the fact that registration is required and what information
is required to sucessfully
- * register.
- *
- * @see TestWSRPProducerImpl#requiredRegistrationInfo
- */
- private ServiceDescription requiredRegistrationNotProvidedSD;
-
- /**
- * <code>true</code> if registration is required to access this
Producer's information and services,
- * <code>false</code> otherwise. Note: server-side registration is not
supported in 2.4
- */
- private boolean requiresRegistration;
-
private int sessionExpirationTime = DEFAULT_SESSION_EXPIRATION_TIME;
private CookieProtocol requiresInitCookie = CookieProtocol.none;
- /** Required registration information to be provided by consumers to access this
Producer's information and services. */
- private ModelDescription requiredRegistrationInfo;
-
/** Used to set the cookie in initCookie */
private HttpServletResponse response;
- /** The behavior sequence that will be used for the current test. */
- private TestBehaviorSequence sequence;
+ private BehaviorRegistry behaviorRegistry = new BehaviorRegistry();
- /** The current order in the sequence (number of times the methods have been called)
*/
- private int sequenceOrder;
-
- private PortletManagementBehavior portletManagementBehavior;
-
public static final String USER_COOKIE = "cookie";
public TestWSRPProducerImpl()
@@ -135,13 +99,13 @@
reset();
}
- public void reset()
+ public BehaviorRegistry getBehaviorRegistry()
{
- requiresRegistration = false;
- requiredRegistrationInfo = new ModelDescription();
- requiredRegistrationNotProvidedSD = new ServiceDescription(true, null, null, null,
null, null, requiresInitCookie,
- requiredRegistrationInfo, WSRPConstants.DEFAULT_LOCALES, null, null);
+ return behaviorRegistry;
+ }
+ public void reset()
+ {
if (response != null)
{
response.reset();
@@ -149,82 +113,24 @@
response = null;
requiresInitCookie = null;
-
- registerMarkupBehavior(new BasicMarkupBehavior());
- registerMarkupBehavior(new SessionMarkupBehavior());
- registerMarkupBehavior(new NullMarkupBehavior());
- registerMarkupBehavior(new EmptyMarkupBehavior());
- registerMarkupBehavior(new InitCookieMarkupBehavior());
-
- sequence = new SingleBehaviorSequence(new TestBehaviorSequence.TestBehaviorSet(new
BasicServiceDescriptionBehavior()));
- sequenceOrder = 0;
- portletManagementBehavior = new BasicPortletManagementBehavior();
+ behaviorRegistry.clear();
}
- // Behavior management
**********************************************************************************************
- Map registeredBehaviors = new HashMap();
-
- private void useBehavior(TestProducerBehavior behavior)
+ private MarkupBehavior getMarkupBehaviorFor(String portletHandle) throws
InvalidHandleFault
{
- sequence = new SingleBehaviorSequence(new
TestBehaviorSequence.TestBehaviorSet(behavior));
+ return behaviorRegistry.getMarkupBehaviorFor(portletHandle);
}
- private void registerMarkupBehavior(MarkupBehavior behavior)
+ private ServiceDescriptionBehavior getServiceDescriptionBehavior()
{
- registeredBehaviors.put(behavior.getPortletHandle(), behavior);
+ return behaviorRegistry.getServiceDescriptionBehavior();
}
- private MarkupBehavior getMarkupBehaviorFor(String portletHandle)
+ public PortletManagementBehavior getPortletManagementBehavior()
{
- return (MarkupBehavior)registeredBehaviors.get(portletHandle);
+ return behaviorRegistry.getPortletManagementBehavior();
}
- private void updateCurrentMarkupBehaviorIfNeeded(String handle)
- {
- if (sequence == null)
- {
- if (handle != null)
- {
- useBehavior(getMarkupBehaviorFor(handle));
- }
- }
- else
- {
- MarkupBehavior markupBehavior = sequence.getMarkupBehaviorFor(sequenceOrder);
- if (markupBehavior == null || handle != null)
- {
- MarkupBehavior behavior = getMarkupBehaviorFor(handle);
- sequence.setBehaviorAt(behavior, sequenceOrder);
- }
- }
- }
-
- private void incrementBehaviorCallCount()
- {
- sequenceOrder++;
- }
-
- private MarkupBehavior getMarkupBehavior()
- {
- if (sequence != null)
- {
- MarkupBehavior markupBehavior = sequence.getMarkupBehaviorFor(sequenceOrder);
- System.out.println("Using markup behavior for " +
markupBehavior.getPortletHandle() + " portlet handle.");
- return markupBehavior;
- }
- throw new IllegalStateException("Don't have a MarkupBehavior to
return!");
- }
-
- private ServiceDescriptionBehavior getServiceDescriptionBehavior()
- {
- if (sequence != null)
- {
- ServiceDescriptionBehavior behavior =
sequence.getServiceDescriptionBehaviorFor(sequenceOrder);
- return behavior;
- }
- throw new IllegalStateException("Don't have a ServiceDescriptionBehavior
to return!");
- }
-
public void setResponse(HttpServletResponse response)
{
this.response = response;
@@ -236,7 +142,6 @@
throws InvalidRegistrationFault, OperationFailedFault, RemoteException
{
ServiceDescription response =
getServiceDescriptionBehavior().getServiceDescription(gs);
- incrementBehaviorCallCount();
return response;
}
@@ -248,11 +153,9 @@
OperationFailedFault, MissingParametersFault, InvalidUserCategoryFault,
InvalidRegistrationFault,
UnsupportedMimeTypeFault, RemoteException
{
-
updateCurrentMarkupBehaviorIfNeeded(getMarkup.getPortletContext().getPortletHandle());
+ MarkupResponse markupResponse =
getMarkupBehaviorFor(getMarkup.getPortletContext().getPortletHandle())
+ .getMarkup(getMarkup);
- MarkupResponse markupResponse = getMarkupBehavior().getMarkup(getMarkup);
-
- incrementBehaviorCallCount();
return markupResponse;
}
@@ -262,18 +165,15 @@
InvalidRegistrationFault, MissingParametersFault, InvalidUserCategoryFault,
InconsistentParametersFault,
InvalidHandleFault, InvalidCookieFault, RemoteException
{
-
updateCurrentMarkupBehaviorIfNeeded(performBlockingInteraction.getPortletContext().getPortletHandle());
+ BlockingInteractionResponse res =
getMarkupBehaviorFor(performBlockingInteraction.getPortletContext().getPortletHandle())
+ .performBlockingInteraction(performBlockingInteraction);
- BlockingInteractionResponse res =
getMarkupBehavior().performBlockingInteraction(performBlockingInteraction);
-
- incrementBehaviorCallCount();
return res;
}
public ReturnAny releaseSessions(ReleaseSessions releaseSessions)
throws InvalidRegistrationFault, OperationFailedFault, MissingParametersFault,
AccessDeniedFault, RemoteException
{
- incrementBehaviorCallCount();
return null;
}
@@ -288,7 +188,6 @@
response.addCookie(new Cookie("cookieName", USER_COOKIE));
- incrementBehaviorCallCount();
return null;
}
@@ -296,19 +195,16 @@
public RegistrationContext register(RegistrationData register) throws
MissingParametersFault, OperationFailedFault, RemoteException
{
- incrementBehaviorCallCount();
return WSRPTypeFactory.createRegistrationContext("registration");
}
public ReturnAny deregister(RegistrationContext deregister) throws
OperationFailedFault, InvalidRegistrationFault, RemoteException
{
- incrementBehaviorCallCount();
return null;
}
public RegistrationState modifyRegistration(ModifyRegistration modifyRegistration)
throws MissingParametersFault, OperationFailedFault, InvalidRegistrationFault,
RemoteException
{
- incrementBehaviorCallCount();
return null;
}
@@ -318,44 +214,32 @@
throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault,
InconsistentParametersFault,
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault,
RemoteException
{
- PortletDescriptionResponse response =
portletManagementBehavior.getPortletDescription(getPortletDescription);
- incrementBehaviorCallCount();
- return response;
+ return
getPortletManagementBehavior().getPortletDescription(getPortletDescription);
}
public PortletContext clonePortlet(ClonePortlet clonePortlet) throws
InvalidUserCategoryFault, AccessDeniedFault, OperationFailedFault, InvalidHandleFault,
InvalidRegistrationFault, InconsistentParametersFault, MissingParametersFault,
RemoteException
{
- PortletContext portletContext =
portletManagementBehavior.clonePortlet(clonePortlet);
- incrementBehaviorCallCount();
- return portletContext;
+ return getPortletManagementBehavior().clonePortlet(clonePortlet);
}
public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws
InconsistentParametersFault, MissingParametersFault, InvalidRegistrationFault,
OperationFailedFault, RemoteException
{
- DestroyPortletsResponse response =
portletManagementBehavior.destroyPortlets(destroyPortlets);
- incrementBehaviorCallCount();
- return response;
+ return getPortletManagementBehavior().destroyPortlets(destroyPortlets);
}
public PortletContext setPortletProperties(SetPortletProperties setPortletProperties)
throws OperationFailedFault, InvalidHandleFault, MissingParametersFault,
InconsistentParametersFault, InvalidUserCategoryFault, AccessDeniedFault,
InvalidRegistrationFault, RemoteException
{
- PortletContext portletContext =
portletManagementBehavior.setPortletProperties(setPortletProperties);
- incrementBehaviorCallCount();
- return portletContext;
+ return getPortletManagementBehavior().setPortletProperties(setPortletProperties);
}
public PropertyList getPortletProperties(GetPortletProperties getPortletProperties)
throws InvalidHandleFault, MissingParametersFault, InvalidRegistrationFault,
AccessDeniedFault, OperationFailedFault, InconsistentParametersFault,
InvalidUserCategoryFault, RemoteException
{
- PropertyList list =
portletManagementBehavior.getPortletProperties(getPortletProperties);
- incrementBehaviorCallCount();
- return list;
+ return getPortletManagementBehavior().getPortletProperties(getPortletProperties);
}
public PortletPropertyDescriptionResponse
getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription)
throws MissingParametersFault, InconsistentParametersFault, InvalidUserCategoryFault,
InvalidRegistrationFault, AccessDeniedFault, InvalidHandleFault, OperationFailedFault,
RemoteException
{
- PortletPropertyDescriptionResponse descriptionResponse =
portletManagementBehavior.getPortletPropertyDescription(getPortletPropertyDescription);
- incrementBehaviorCallCount();
- return descriptionResponse;
+ return
getPortletManagementBehavior().getPortletPropertyDescription(getPortletPropertyDescription);
}
// Producer implementation
******************************************************************************************
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -26,7 +26,15 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.test.wsrp.WSRPConsumerBaseTest;
+import org.jboss.portal.test.wsrp.framework.BehaviorRegistry;
import org.jboss.portal.test.wsrp.framework.support.ServiceObjectFactory;
+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.BasicServiceDescriptionBehavior;
+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.NullMarkupBehavior;
+import org.jboss.portal.test.wsrp.v1.consumer.behaviors.SessionMarkupBehavior;
/**
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
@@ -54,6 +62,15 @@
{
super.setUp();
producer.reset();
+ // reset the behaviors
+ BehaviorRegistry registry = producer.getBehaviorRegistry();
+ registry.setPortletManagementBehavior(new
BasicPortletManagementBehavior(registry));
+ registry.setServiceDescriptionBehavior(new BasicServiceDescriptionBehavior());
+ registry.registerMarkupBehavior(new BasicMarkupBehavior());
+ registry.registerMarkupBehavior(new EmptyMarkupBehavior());
+ registry.registerMarkupBehavior(new InitCookieMarkupBehavior());
+ registry.registerMarkupBehavior(new NullMarkupBehavior());
+ registry.registerMarkupBehavior(new SessionMarkupBehavior());
// make sure we use clean producer info for each test
consumer.refreshProducerInfo();
}
Modified:
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/BasicMarkupBehavior.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicMarkupBehavior.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -48,7 +48,7 @@
public BasicMarkupBehavior()
{
- portletHandle = PORTLET_HANDLE;
+ handles.add(PORTLET_HANDLE);
}
public String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/BasicPortletManagementBehavior.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -23,6 +23,8 @@
package org.jboss.portal.test.wsrp.v1.consumer.behaviors;
+import org.jboss.portal.test.wsrp.framework.BehaviorRegistry;
+import org.jboss.portal.test.wsrp.framework.MarkupBehavior;
import org.jboss.portal.test.wsrp.framework.PortletManagementBehavior;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
@@ -56,7 +58,14 @@
public static final String PROPERTY_VALUE = "value1";
public static final String PROPERTY_NEW_VALUE = "value2";
public static final String CLONED_HANDLE = BasicMarkupBehavior.PORTLET_HANDLE +
CLONE_SUFFIX;
+ private BehaviorRegistry registry;
+ public BasicPortletManagementBehavior(BehaviorRegistry registry)
+ {
+ super();
+ this.registry = registry;
+ }
+
public PortletContext clonePortlet(ClonePortlet clonePortlet) throws
InvalidUserCategoryFault, AccessDeniedFault,
OperationFailedFault, InvalidHandleFault, InvalidRegistrationFault,
InconsistentParametersFault,
MissingParametersFault, RemoteException
@@ -80,24 +89,8 @@
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(getPortletDescription,
"GetPortletDescription");
String handle = getHandleFrom(getPortletDescription.getPortletContext(),
"GetPortletDescription");
- String suffix;
- if (handle.startsWith(BasicMarkupBehavior.PORTLET_HANDLE)
- || NullMarkupBehavior.PORTLET_HANDLE.equals(handle)
- || EmptyMarkupBehavior.PORTLET_HANDLE.equals(handle)
- || InitCookieMarkupBehavior.PORTLET_HANDLE.equals(handle))
- {
- suffix = "";
- }
- else if (handle.startsWith(SessionMarkupBehavior.PORTLET_HANDLE))
- {
- suffix = "2";
- }
- else
- {
- throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class,
- new IllegalArgumentException("Unknown handle '" + handle +
"'"));
- }
- return
WSRPTypeFactory.createPortletDescriptionResponse(createPortletDescription(handle,
suffix));
+ MarkupBehavior markupBehaviorFor = registry.getMarkupBehaviorFor(handle);
+ return
WSRPTypeFactory.createPortletDescriptionResponse(markupBehaviorFor.getPortletDescriptionFor(handle));
}
public PropertyList getPortletProperties(GetPortletProperties getPortletProperties)
throws InvalidHandleFault, MissingParametersFault, InvalidRegistrationFault,
AccessDeniedFault, OperationFailedFault, InconsistentParametersFault,
InvalidUserCategoryFault, RemoteException
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/EmptyMarkupBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/EmptyMarkupBehavior.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/EmptyMarkupBehavior.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -41,7 +41,7 @@
public EmptyMarkupBehavior()
{
- portletHandle = PORTLET_HANDLE;
+ handles.add(PORTLET_HANDLE);
}
public String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/InitCookieMarkupBehavior.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -42,7 +42,7 @@
public InitCookieMarkupBehavior()
{
- portletHandle = PORTLET_HANDLE;
+ handles.add(PORTLET_HANDLE);
}
protected String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup) throws InvalidCookieFault, OperationFailedFault
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/NullMarkupBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/NullMarkupBehavior.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/NullMarkupBehavior.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -41,7 +41,7 @@
public NullMarkupBehavior()
{
- portletHandle = PORTLET_HANDLE;
+ handles.add(PORTLET_HANDLE);
}
public String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionMarkupBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionMarkupBehavior.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/SessionMarkupBehavior.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -52,7 +52,7 @@
public SessionMarkupBehavior()
{
- portletHandle = PORTLET_HANDLE;
+ handles.add(PORTLET_HANDLE);
}
public String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
@@ -92,4 +92,10 @@
markupResponse.setSessionContext(sessionContext);
}
}
+
+
+ protected String getSuffixFor(String handle)
+ {
+ return "2";
+ }
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2007-01-12
23:32:39 UTC (rev 6003)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2007-01-13
01:42:19 UTC (rev 6004)
@@ -128,6 +128,10 @@
// Check offered portlets
PortletDescription[] offeredPortlets = sd.getOfferedPortlets();
ExtendedAssert.assertNotNull(offeredPortlets);
+ for (int i = 0; i < offeredPortlets.length; i++)
+ {
+ System.out.println("handle " +
offeredPortlets[i].getPortletHandle());
+ }
ExtendedAssert.assertEquals(1, offeredPortlets.length);
// Check portlet description