Author: chris.laprun(a)jboss.com
Date: 2010-12-02 13:26:50 -0500 (Thu, 02 Dec 2010)
New Revision: 5468
Added:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPPortletInvokerTestCase.java
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java
Log:
- GTNWSRP-179: Deactivate WSRPPortletInvoker (and related code for GTNWSRP-72) as it
currently doesn't properly manage state. Added associated test case that shows the
problem associated with WSRPPortletInvoker when it is active.
- Improved error reporting in WSRPProducerImpl when the invoker cannot find the requested
portlet.
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java 2010-12-02
18:14:15 UTC (rev 5467)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java 2010-12-02
18:26:50 UTC (rev 5468)
@@ -36,7 +36,7 @@
* @version $Revision: 8966 $
* @since 2.6
*/
-public interface RegistrationManager extends RegistrationPropertyChangeListener,
RegistrationPolicyChangeListener, RegistrationPortletContextChangeListener
+public interface RegistrationManager extends RegistrationPropertyChangeListener,
RegistrationPolicyChangeListener /*, RegistrationPortletContextChangeListener GTNWSRP-72
*/
{
RegistrationPolicy getPolicy();
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java 2010-12-02
18:14:15 UTC (rev 5467)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java 2010-12-02
18:26:50 UTC (rev 5468)
@@ -26,8 +26,6 @@
import org.gatein.wsrp.registration.PropertyDescription;
import javax.xml.namespace.QName;
-
-import java.util.List;
import java.util.Map;
/**
@@ -122,48 +120,53 @@
* @throws RegistrationException if an exception occurred in the Registration
service
*/
void validateConsumerGroupName(String groupName, RegistrationManager manager) throws
IllegalArgumentException, RegistrationException;
-
+
/**
* Checks if a portlet handle belongs to a specific registration.
- *
+ * GTNWSRP-72
+ *
* @param registration The registration to check
* @param portletHandle The portlet handle to use
* @return True if the registration contains this portlet handle
*/
- boolean checkPortletHandle(Registration registration, String portletHandle);
-
+// boolean checkPortletHandle(Registration registration, String portletHandle);
+
/**
* Adds a Portlet Handle to a Registration
- *
+ * GTNWSRP-72
+ *
* @param registration The registration to use
* @param portletHandle The portletHandle to add
*/
- void addPortletHandle(Registration registration, String portletHandle);
-
+// void addPortletHandle(Registration registration, String portletHandle);
+
/**
* Removes a portlet handle from a specific registration
- *
+ * GTNWSRP-72
+ *
* @param registration The registration to use
* @param portletHandle The portlet handle to remove
*/
- void removePortletHandle(Registration registration, String portletHandle);
-
+// void removePortletHandle(Registration registration, String portletHandle);
+
/**
* Updates the list of currently available portlet handles.
- *
+ * GTNWSRP-72
+ *
* Note: this is not registration specific. This method deals with the situation
where
* the producer has a change in the available portlets. The RegistrationPolicy needs
to either handle
* the globally available portlets separately or update each registration when this
type of change occurs.
- *
+ *
* @param portlets
*/
- void updatePortletHandles(List<String> portlets);
-
+// void updatePortletHandles(List<String> portlets);
+
/**
* Adds a PortletContextChangeListener to the RegistrationPolicy. The
PortletContextChangeListener
* will be called whenever the portlet contexts within a registration changes.
- *
+ * GTNWSRP-72
+ *
* @param listener The listener to add
*/
- void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener);
+// void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener);
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java 2010-12-02
18:14:15 UTC (rev 5467)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java 2010-12-02
18:26:50 UTC (rev 5468)
@@ -1,30 +1,30 @@
-/******************************************************************************
- * 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.gatein.registration;
/**
- * Listeners for when the portlet contexts of a registration change.
- *
+ * Listeners for when the portlet contexts of a registration change. GTNWSRP-72
+ *
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
* @version $Revision$
*/
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2010-12-02
18:14:15 UTC (rev 5467)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2010-12-02
18:26:50 UTC (rev 5468)
@@ -377,10 +377,11 @@
*/
public void policyUpdatedTo(RegistrationPolicy policy)
{
- policy.addPortletContextChangeListener(this);
+// policy.addPortletContextChangeListener(this); // GTNWSRP-72
setPolicy(policy);
}
+ // GTNWSRP-72
public void portletContextsHaveChanged(Registration registration)
{
persistenceManager.saveChangesTo(registration);
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java 2010-12-02
18:14:15 UTC (rev 5467)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java 2010-12-02
18:26:50 UTC (rev 5468)
@@ -25,16 +25,12 @@
import org.gatein.common.util.ParameterValidation;
import org.gatein.registration.InvalidConsumerDataException;
-import org.gatein.registration.Registration;
import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPolicy;
-import org.gatein.registration.RegistrationPortletContextChangeListener;
import org.gatein.wsrp.registration.PropertyDescription;
import javax.xml.namespace.QName;
-
-import java.util.List;
import java.util.Map;
/**
@@ -103,6 +99,7 @@
return consumerName;
}
+ /* GTNWSRP-72
public void addPortletHandle(Registration registration, String portletHandle)
{
delegate.addPortletHandle(registration, portletHandle);
@@ -126,5 +123,5 @@
public void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener)
{
delegate.addPortletContextChangeListener(listener);
- }
+ }*/
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java 2010-12-02
18:14:15 UTC (rev 5467)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java 2010-12-02
18:26:50 UTC (rev 5468)
@@ -20,31 +20,15 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
+
package org.gatein.wsrp.producer;
-import org.gatein.pc.api.NoSuchPortletException;
-import org.gatein.pc.api.Portlet;
-import org.gatein.pc.api.PortletContext;
-import org.gatein.pc.api.PortletInvokerException;
-import org.gatein.pc.api.PortletStateType;
-import org.gatein.pc.api.invocation.PortletInvocation;
-import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
-import org.gatein.pc.api.state.DestroyCloneFailure;
-import org.gatein.pc.api.state.PropertyChange;
-import org.gatein.pc.api.state.PropertyMap;
import org.gatein.pc.portlet.PortletInvokerInterceptor;
-import org.gatein.registration.Registration;
-import org.gatein.registration.RegistrationLocal;
import org.gatein.registration.RegistrationManager;
-import org.gatein.wsrp.WSRPUtils;
-import org.gatein.wsrp.producer.handlers.processors.WSRPInstanceContext;
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
/**
+ * GTNWSRP-72
+ *
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
* @version $Revision$
*/
@@ -63,7 +47,7 @@
this.registrationManager = registrationManager;
}
- public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ /*public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
{
checkPortletContext(portletContext);
Portlet portlet = super.getPortlet(portletContext);
@@ -78,11 +62,11 @@
public Set<Portlet> getPortlets() throws PortletInvokerException
{
- /**
- * Note: due to the way the ProducerPortletInvoker work, when calling
super.getPortlets() it will
- * return the portlets not for the ProducerPortletInvoker from its parent, which
should only return
- * non-cloned Portlets.
- */
+ *//**
+ * Note: due to the way the ProducerPortletInvoker work, when calling super.getPortlets()
it will
+ * return the portlets not for the ProducerPortletInvoker from its parent, which should
only return
+ * non-cloned Portlets.
+ *//*
Registration registration = RegistrationLocal.getRegistration();
Set<Portlet> portlets = super.getPortlets();
@@ -235,6 +219,6 @@
Registration registration = RegistrationLocal.getRegistration();
String portletHandle =
WSRPUtils.convertToWSRPPortletContext(portletContext).getPortletHandle();
this.getRegistrationManager().getPolicy().removePortletHandle(registration,
portletHandle);
- }
+ }*/
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2010-12-02
18:14:15 UTC (rev 5467)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2010-12-02
18:26:50 UTC (rev 5468)
@@ -402,7 +402,8 @@
registrationManager.setPolicy(registrationRequirements.getPolicy());
-
registrationManager.getPolicy().addPortletContextChangeListener(registrationManager);
+ // GTNWSRP-72
+//
registrationManager.getPolicy().addPortletContextChangeListener(registrationManager);
started = true;
}
@@ -452,7 +453,7 @@
}
catch (NoSuchPortletException e)
{
- throw WSRP2ExceptionFactory.throwWSException(InvalidHandle.class,
"Couldn't find portlet with handle '" + portletContext.getId() +
"'", null);
+ throw WSRP2ExceptionFactory.throwWSException(InvalidHandle.class,
"Couldn't find portlet with handle '" + portletContext.getId() +
"'", e);
}
finally
{
Added:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPPortletInvokerTestCase.java
===================================================================
---
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPPortletInvokerTestCase.java
(rev 0)
+++
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPPortletInvokerTestCase.java 2010-12-02
18:26:50 UTC (rev 5468)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.gatein.wsrp.producer;
+
+import junit.framework.TestCase;
+import org.gatein.pc.api.Portlet;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvoker;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.registration.impl.RegistrationManagerImpl;
+import org.gatein.registration.policies.DefaultRegistrationPolicy;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class WSRPPortletInvokerTestCase extends TestCase
+{
+ public void testGetPortletShouldWorkDirectly() throws PortletInvokerException
+ {
+ WSRPPortletInvoker invoker = new WSRPPortletInvoker();
+ RegistrationManagerImpl registrationManager = new RegistrationManagerImpl();
+ registrationManager.setPolicy(new DefaultRegistrationPolicy());
+ invoker.setRegistrationManager(registrationManager);
+
+ PortletInvoker next = mock(PortletInvoker.class);
+ PortletContext portletContext =
PortletContext.createPortletContext("foo");
+ Portlet portlet = mock(Portlet.class);
+ when(next.getPortlet(portletContext)).thenReturn(portlet);
+
+ invoker.setNext(next);
+ assertEquals(portlet, invoker.getPortlet(portletContext));
+ }
+}
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java 2010-12-02
18:14:15 UTC (rev 5467)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java 2010-12-02
18:26:50 UTC (rev 5468)
@@ -20,6 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
+
package org.gatein.wsrp.protocol.v2;
import org.gatein.exports.ExportManager;
@@ -37,7 +38,6 @@
import org.gatein.wsrp.producer.WSRPProducerBaseTest;
import org.gatein.wsrp.servlet.ServletAccess;
import org.gatein.wsrp.support.TestMockExportPersistenceManager;
-import org.gatein.wsrp.test.ExtendedAssert;
import org.gatein.wsrp.test.support.MockHttpServletRequest;
import org.gatein.wsrp.test.support.MockHttpServletResponse;
import org.jboss.arquillian.api.Deployment;
@@ -62,7 +62,6 @@
import org.oasis.wsrp.v2.ImportPortlets;
import org.oasis.wsrp.v2.ImportPortletsResponse;
import org.oasis.wsrp.v2.ImportedPortlet;
-import org.oasis.wsrp.v2.InvalidHandle;
import org.oasis.wsrp.v2.InvalidRegistration;
import org.oasis.wsrp.v2.Lifetime;
import org.oasis.wsrp.v2.MarkupContext;
@@ -243,7 +242,7 @@
//arquillian can't handle non serializable exceptions, print error message
to the server logs
System.out.println("An exception occured calling " + this.getClass() +
" testExportRegistrationRequired");
e.printStackTrace();
- throw new Exception (e);
+ throw new Exception(e);
}
}
@@ -450,7 +449,7 @@
//arquillian can't handle non serializable exceptions, print error message
to the server logs
System.out.println("An exception occured calling " + this.getClass() +
" testImportRegistrationRequired");
e.printStackTrace();
- throw new Exception (e);
+ throw new Exception(e);
}
}
@@ -668,50 +667,50 @@
{
try
{
- undeploy(TEST_BASIC_PORTLET_WAR);
- String sessionPortletArchive = "test-portletstate-portlet.war";
- deploy(sessionPortletArchive);
+ undeploy(TEST_BASIC_PORTLET_WAR);
+ String sessionPortletArchive = "test-portletstate-portlet.war";
+ deploy(sessionPortletArchive);
- try
- {
- String originalHandle = getHandleForCurrentlyDeployedArchive();
+ try
+ {
+ String originalHandle = getHandleForCurrentlyDeployedArchive();
- //check the session portlet to make sure its at the inital state
- checkStatePortlet(originalHandle, "initial");
+ //check the session portlet to make sure its at the inital state
+ checkStatePortlet(originalHandle, "initial");
- PortletContext portletContext =
performBlockingInteractionOnSessionPortlet(originalHandle, "new value",
StateChange.CLONE_BEFORE_WRITE);
- //check that we have a new portlet context
- assertFalse(originalHandle.equals(portletContext.getPortletHandle()));
+ PortletContext portletContext =
performBlockingInteractionOnSessionPortlet(originalHandle, "new value",
StateChange.CLONE_BEFORE_WRITE);
+ //check that we have a new portlet context
+ assertFalse(originalHandle.equals(portletContext.getPortletHandle()));
- checkStatePortlet(portletContext.getPortletHandle(), "new value");
+ checkStatePortlet(portletContext.getPortletHandle(), "new value");
- List<PortletContext> portletContexts =
createPortletContextList(portletContext.getPortletHandle());
- ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
- ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
+ List<PortletContext> portletContexts =
createPortletContextList(portletContext.getPortletHandle());
+ ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
+ ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
- assertFalse(response.getExportedPortlet().isEmpty());
+ assertFalse(response.getExportedPortlet().isEmpty());
- List<PortletContext> portletContextsFromExport =
getPortletContext(response);
+ List<PortletContext> portletContextsFromExport =
getPortletContext(response);
- assertNotNull(portletContextsFromExport.isEmpty());
- assertEquals(1, portletContexts.size());
+ assertNotNull(portletContextsFromExport.isEmpty());
+ assertEquals(1, portletContexts.size());
- PortletContext portletContextFromExport = portletContextsFromExport.get(0);
- //we should be getting the handle of the stateless portlet
- assertEquals(originalHandle, portletContextFromExport.getPortletHandle());
- //assert that we have a portlet state returned
- assertNotNull(portletContextFromExport.getPortletState());
+ PortletContext portletContextFromExport = portletContextsFromExport.get(0);
+ //we should be getting the handle of the stateless portlet
+ assertEquals(originalHandle, portletContextFromExport.getPortletHandle());
+ //assert that we have a portlet state returned
+ assertNotNull(portletContextFromExport.getPortletState());
- //quick check that the imported portlet has the right state
- ImportPortletsResponse importResponse =
createImportPortletsResponse("foo", portletContextFromExport);
- assertEquals(1, importResponse.getImportedPortlets().size());
-
checkStatePortlet(importResponse.getImportedPortlets().get(0).getNewPortletContext().getPortletHandle(),
"new value");
+ //quick check that the imported portlet has the right state
+ ImportPortletsResponse importResponse =
createImportPortletsResponse("foo", portletContextFromExport);
+ assertEquals(1, importResponse.getImportedPortlets().size());
+
checkStatePortlet(importResponse.getImportedPortlets().get(0).getNewPortletContext().getPortletHandle(),
"new value");
+ }
+ finally
+ {
+ undeploy(sessionPortletArchive);
+ }
}
- finally
- {
- undeploy(sessionPortletArchive);
- }
- }
catch (Exception e)
{
System.out.println("ERROR: an error occured " + this.getClass() +
" testExportWithState");
@@ -784,7 +783,7 @@
PropertyMap property = new SimplePropertyMap(properties);
PortletState sstate = new PortletState(portletHandle, property);
-
+
StateConverter stateConverter = new StateConverterV0();
return stateConverter.marshall(PortletStateType.OPAQUE, sstate);
}
@@ -1058,10 +1057,8 @@
return WSRPTypeFactory.createImportPortlets(registrationContext, importContext,
importPortletsList, userContext, lifetime);
}
-
- /**
- * Simpliest check to make sure copy portlets is working
- */
+
+ /** Simpliest check to make sure copy portlets is working */
@Test
public void testSimpleCopyPortletNullRegistrations() throws Exception
{
@@ -1072,21 +1069,21 @@
CopyPortletsResponse response = producer.copyPortlets(copyPortlets);
checkSimpleCopyPortletsResponse(response, createStringList(handle),
createStringList());
-
+
//Check that the proper registration context can access it
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
null);
}
/**
- * Check copyPortlet from a null registration context to a non null registration
context
- * Note: if the toRegistrationContext is null, then it should use the
fromRegistrationContext, which is this case
- * is also null. See also testSimpleCopyPortletToRegistrationNull()
+ * Check copyPortlet from a null registration context to a non null registration
context Note: if the
+ * toRegistrationContext is null, then it should use the fromRegistrationContext,
which is this case is also null.
+ * See also testSimpleCopyPortletToRegistrationNull()
*/
@Test
public void testSimpleCopyPortletFromRegistrationNull() throws Exception
{
try
- {
+ {
RegistrationData toRegistrationData =
WSRPTypeFactory.createRegistrationData("CONSUMERB",
"CONSUMERAGENTB.0.0", true);
RegistrationContext toRegistrationContext =
producer.register(toRegistrationData);
@@ -1099,19 +1096,22 @@
CopyPortletsResponse response = producer.copyPortlets(copyPortlets);
checkSimpleCopyPortletsResponse(response, createStringList(handle),
createStringList());
-
+
//Check that the proper registration context can access it
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
toRegistrationContext);
+
+ /*
+ GTNWSRP-72
//Check that the null registration cannot access it
try
{
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
null);
- ExtendedAssert.fail("The null registration context should not be able to
access this portlet");
+ fail("The null registration context should not be able to access this
portlet");
}
catch (InvalidHandle e)
{
//expected
- }
+ }*/
}
catch (Exception e)
{
@@ -1120,33 +1120,36 @@
throw new Exception(e);
}
}
-
+
/**
- * Check copyPortlets from a non-null registration context to a null registration
context.
- * Note: this does _NOT_ mean the copy should be available from a non registered
consumer, the spec states if
- * the toRegistration is null, it should be registered using the
fromRegistrationContext
+ * Check copyPortlets from a non-null registration context to a null registration
context. Note: this does _NOT_ mean
+ * the copy should be available from a non registered consumer, the spec states if the
toRegistration is null, it
+ * should be registered using the fromRegistrationContext
*/
@Test
public void testSimpleCopyPortletToRegistrationNull() throws Exception
{
//producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
-
+
RegistrationData fromRegistrationData =
WSRPTypeFactory.createRegistrationData("CONSUMERA",
"CONSUMERAGENAT.0.0", true);
RegistrationContext fromRegistrationContext =
producer.register(fromRegistrationData);
-
+
String handle = getDefaultHandle();
List<PortletContext> portletContexts = createPortletContextList(handle);
CopyPortlets copyPortlets = createSimpleCopyPortlets(portletContexts);
//note: createSimpleCopyPortlets sets the toRegistrationContext to null
- copyPortlets.setFromRegistrationContext(fromRegistrationContext);
-
+ copyPortlets.setFromRegistrationContext(fromRegistrationContext);
+
CopyPortletsResponse response = producer.copyPortlets(copyPortlets);
checkSimpleCopyPortletsResponse(response, createStringList(handle),
createStringList());
-
+
//Check that the proper registration context can access it
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
fromRegistrationContext);
+
+ /*
+ GTNWSRP-72
//Check that the null registration cannot access it
try
{
@@ -1156,17 +1159,15 @@
catch (InvalidHandle e)
{
//expected
- }
+ }*/
}
-
- /**
- * Check that we can copy one portlet from one registration context to another
- */
+
+ /** Check that we can copy one portlet from one registration context to another */
@Test
public void testSimpleCopyPortletWithRegistrations() throws Exception
{
//producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
-
+
RegistrationData fromRegistrationData =
WSRPTypeFactory.createRegistrationData("CONSUMERA",
"CONSUMERAGENTA.0.0", true);
RegistrationContext fromRegistrationContext =
producer.register(fromRegistrationData);
RegistrationData toRegistrationData =
WSRPTypeFactory.createRegistrationData("CONSUMERB",
"CONSUMERAGENTB.0.0", true);
@@ -1178,18 +1179,21 @@
CopyPortlets copyPortlets = createSimpleCopyPortlets(portletContexts);
copyPortlets.setFromRegistrationContext(fromRegistrationContext);
copyPortlets.setToRegistrationContext(toRegistrationContext);
-
+
CopyPortletsResponse response = producer.copyPortlets(copyPortlets);
checkSimpleCopyPortletsResponse(response, createStringList(handle),
createStringList());
-
+
//Check that the proper registration context can access it
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
toRegistrationContext);
+
+ /*
+ GTNWSRP-72
//Check that the original registration cannot access it
try
{
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
fromRegistrationContext);
- ExtendedAssert.fail("The null registration context should not be able to
access this portlet");
+ ExtendedAssert.fail("The original registration context should not be able
to access this portlet");
}
catch (InvalidHandle e)
{
@@ -1204,18 +1208,18 @@
catch (InvalidHandle e)
{
//expected
- }
+ }*/
}
-
+
@Test
public void testCopyPortletNullRegistrationWithRR() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
-
+
List<PortletContext> portletContexts =
createPortletContextList(getDefaultHandle());
//creates a copyportlet with a null registration context
CopyPortlets copyPortlets = createSimpleCopyPortlets(portletContexts);
-
+
try
{
producer.copyPortlets(copyPortlets);
@@ -1226,16 +1230,16 @@
//expected
}
}
-
+
@Test
public void testCopyPortletNonRegisteredToRegistration() throws Exception
{
RegistrationContext invalidRegistrationContext =
WSRPTypeFactory.createRegistrationContext("non_registered_handle");
-
+
List<PortletContext> portletContexts =
createPortletContextList(getDefaultHandle());
CopyPortlets copyPortlets = createSimpleCopyPortlets(portletContexts);
copyPortlets.setToRegistrationContext(invalidRegistrationContext);
-
+
try
{
producer.copyPortlets(copyPortlets);
@@ -1246,16 +1250,16 @@
//expected
}
}
-
+
@Test
public void testCopyPortletNonRegisteredFromRegistration() throws Exception
{
RegistrationContext invalidRegistrationContext =
WSRPTypeFactory.createRegistrationContext("non_registered_handle");
-
+
List<PortletContext> portletContexts =
createPortletContextList(getDefaultHandle());
CopyPortlets copyPortlets = createSimpleCopyPortlets(portletContexts);
copyPortlets.setFromRegistrationContext(invalidRegistrationContext);
-
+
try
{
producer.copyPortlets(copyPortlets);
@@ -1266,13 +1270,13 @@
//expected
}
}
-
+
@Test
public void testCopyPortletNullPortletContexts() throws Exception
{
List<PortletContext> portletContexts = null;
CopyPortlets copyPortlets = new CopyPortlets();
-
+
try
{
producer.copyPortlets(copyPortlets);
@@ -1283,14 +1287,14 @@
//expected
}
}
-
+
@Test
public void testCopyPortletsEmptyPortletContexts() throws Exception
{
List<PortletContext> portletContexts = new
ArrayList<PortletContext>();
CopyPortlets copyPortlets = new CopyPortlets();
copyPortlets.getFromPortletContexts().addAll(portletContexts);
-
+
try
{
producer.copyPortlets(copyPortlets);
@@ -1301,7 +1305,7 @@
//expected
}
}
-
+
@Test
public void testCopyPortletsInvalidPortletContexts() throws Exception
{
@@ -1309,36 +1313,36 @@
String fakePortletContext2 = "fakePortletContext2";
List<PortletContext> portletContexts =
createPortletContextList(fakePortletContext1, fakePortletContext2);
CopyPortlets copyPortlets = createSimpleCopyPortlets(portletContexts);
-
+
CopyPortletsResponse response = producer.copyPortlets(copyPortlets);
-
+
assertEquals(0, response.getCopiedPortlets().size());
assertEquals(1, response.getFailedPortlets().size());
assertTrue(response.getFailedPortlets().get(0).getPortletHandles().contains(fakePortletContext1));
assertTrue(response.getFailedPortlets().get(0).getPortletHandles().contains(fakePortletContext2));
assertTrue(response.getFailedPortlets().get(0).getErrorCode().getLocalPart().contains("InvalidHandle"));
}
-
- @Test
+
+ @Test
public void testCopyPortletsMixedPortletContexts() throws Exception
{
String fakePortletContext1 = "fakePortletContext1";
String fakePortletContext2 = "fakePortletContext2";
List<PortletContext> portletContexts =
createPortletContextList(fakePortletContext1, getDefaultHandle(), fakePortletContext2);
CopyPortlets copyPortlets = createSimpleCopyPortlets(portletContexts);
-
+
CopyPortletsResponse response = producer.copyPortlets(copyPortlets);
-
+
assertEquals(1, response.getFailedPortlets().size());
assertTrue(response.getFailedPortlets().get(0).getPortletHandles().contains(fakePortletContext1));
assertTrue(response.getFailedPortlets().get(0).getPortletHandles().contains(fakePortletContext2));
assertTrue(response.getFailedPortlets().get(0).getErrorCode().getLocalPart().contains("InvalidHandle"));
-
+
assertEquals(1, response.getCopiedPortlets().size());
assertEquals(getDefaultHandle(),
response.getCopiedPortlets().get(0).getFromPortletHandle());
assertFalse(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle().equals(getDefaultHandle()));
}
-
+
protected CopyPortlets createSimpleCopyPortlets(List<PortletContext>
portletContexts)
{
RegistrationContext toRegistrationContext = null;
@@ -1347,8 +1351,8 @@
UserContext fromUserContext = null;
return WSRPTypeFactory.createCopyPortlets(toRegistrationContext, toUserContext,
fromRegistrationContext, fromUserContext, portletContexts);
}
-
- protected void checkSimpleCopyPortletsResponse(CopyPortletsResponse response,
List<String> success,List<String> failure)
+
+ protected void checkSimpleCopyPortletsResponse(CopyPortletsResponse response,
List<String> success, List<String> failure)
{
//check that we are getting the expected number of copied portlets
assertEquals(success.size(), response.getCopiedPortlets().size());
@@ -1356,14 +1360,14 @@
{
assertTrue(success.contains(copiedPortlet.getFromPortletHandle()));
}
-
+
//check that we are getting the expected number of failed portlets
assertEquals(failure.size(), response.getFailedPortlets().size());
for (FailedPortlets failedPortlet : response.getFailedPortlets())
{
assertTrue(failure.containsAll(failedPortlet.getPortletHandles()));
}
-
+
//Check that if we do get copiedPortlets back, that the new and old PortletHandle
are not the same
for (CopiedPortlet copiedPortlet : response.getCopiedPortlets())
{
@@ -1371,21 +1375,21 @@
}
}
-
+
protected void checkDefaultMarkup(String portletHandle, RegistrationContext
registrationContext) throws Exception
{
GetMarkup getMarkup = createDefaultGetMarkup(portletHandle);
getMarkup.setRegistrationContext(registrationContext);
MarkupResponse response = producer.getMarkup(getMarkup);
-
+
String defaultMarkup = "<p>symbol unset stock value: value
unset</p>";
-
+
MarkupContext markupContext = response.getMarkupContext();
assertNotNull(markupContext);
assertEquals("text/html", markupContext.getMimeType());
assertTrue(markupContext.getItemString().contains(defaultMarkup));
}
-
+
protected List<String> createStringList(String... names)
{
List<String> list = new ArrayList<String>(names.length);
@@ -1395,79 +1399,81 @@
}
return list;
}
-
- @Test
+
+ @Test
public void testClonePortletAvailabilityRR() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
checkClonePortletAvailability();
}
-
- @Test
+
+ @Test
public void testClonePortletAvailabilityNRR() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(false);
checkClonePortletAvailability();
}
-
+
public void checkClonePortletAvailability() throws Exception
{
RegistrationData registrationDataA =
WSRPTypeFactory.createRegistrationData("CONSUMERA",
"CONSUMERAGENTA.0.0", true);
RegistrationContext registrationContextA = producer.register(registrationDataA);
RegistrationData registrationDataB =
WSRPTypeFactory.createRegistrationData("CONSUMERB",
"CONSUMERAGENTB.0.0", true);
RegistrationContext registrationContextB = producer.register(registrationDataB);
-
+
checkClonePortletAvailability(registrationContextA, registrationContextB);
}
-
+
public void checkClonePortletAvailability(RegistrationContext registrationContextA,
RegistrationContext registrationContextB) throws Exception
{
String handle = getDefaultHandle();
PortletContext portletContext =
WSRPTypeFactory.createPortletContext(getDefaultHandle());
ClonePortlet clonePortlet =
WSRPTypeFactory.createClonePortlet(registrationContextA, portletContext, null);
PortletContext clonedPortletContext = producer.clonePortlet(clonePortlet);
-
-
ExtendedAssert.assertFalse(portletContext.getPortletHandle().equals(clonedPortletContext.getPortletHandle()));
-
+
+
assertFalse(portletContext.getPortletHandle().equals(clonedPortletContext.getPortletHandle()));
+
GetMarkup getMarkupA =
createDefaultGetMarkup(clonedPortletContext.getPortletHandle());
getMarkupA.setRegistrationContext(registrationContextA);
producer.getMarkup(getMarkupA);
-
+
+ /*
+ GTNWSRP-72
try
{
GetMarkup getMarkupB =
createDefaultGetMarkup(clonedPortletContext.getPortletHandle());
getMarkupB.setRegistrationContext(registrationContextB);
producer.getMarkup(getMarkupB);
- ExtendedAssert.fail("Should not be able to render a cloned portlet from a
registration context which didn't create the clone.");
+ fail("Should not be able to render a cloned portlet from a registration
context which didn't create the clone.");
}
catch (InvalidHandle e)
{
//expected
- }
+ }*/
}
-
+
@Test
public void testClonePortletAvailabilityNonRegisteredA() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(false);
-
+
RegistrationData registrationDataA =
WSRPTypeFactory.createRegistrationData("CONSUMERA",
"CONSUMERAGENTA.0.0", true);
RegistrationContext registrationContextA = producer.register(registrationDataA);
-
+
checkClonePortletAvailability(registrationContextA, null);
}
-
+
@Test
public void testClonePortletAvailabilityNonRegisteredB() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(false);
-
+
RegistrationData registrationDataB =
WSRPTypeFactory.createRegistrationData("CONSUMERB",
"CONSUMERAGENTB.0.0", true);
RegistrationContext registrationContextB = producer.register(registrationDataB);
-
+
checkClonePortletAvailability(null, registrationContextB);
}
-
+
@Test
public void testClonePortletAvailabilityNullRegistered() throws Exception
{
@@ -1477,19 +1483,19 @@
PortletContext portletContext =
WSRPTypeFactory.createPortletContext(getDefaultHandle());
ClonePortlet clonePortlet =
WSRPTypeFactory.createClonePortlet(registrationContextA, portletContext, null);
PortletContext clonedPortletContext = producer.clonePortlet(clonePortlet);
-
-
ExtendedAssert.assertFalse(portletContext.getPortletHandle().equals(clonedPortletContext.getPortletHandle()));
-
+
+
assertFalse(portletContext.getPortletHandle().equals(clonedPortletContext.getPortletHandle()));
+
GetMarkup getMarkupA =
createDefaultGetMarkup(clonedPortletContext.getPortletHandle());
getMarkupA.setRegistrationContext(registrationContextA);
producer.getMarkup(getMarkupA);
-
+
//Since both A and B are null, this should work
GetMarkup getMarkupB =
createDefaultGetMarkup(clonedPortletContext.getPortletHandle());
getMarkupB.setRegistrationContext(registrationContextB);
producer.getMarkup(getMarkupB);
}
-
+
protected String getMostUsedPortletWARFileName()
{
return TEST_BASIC_PORTLET_WAR;