Author: julien(a)jboss.com
Date: 2007-11-08 20:49:07 -0500 (Thu, 08 Nov 2007)
New Revision: 8855
Modified:
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
Log:
JBPORTAL-1787: Runtime clone before write of a Producer Offered Portlet using the remote
storage state management strategy produces a local storage instead of a remote storage
Modified:
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
===================================================================
---
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java 2007-11-09
01:38:40 UTC (rev 8854)
+++
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java 2007-11-09
01:49:07 UTC (rev 8855)
@@ -250,11 +250,12 @@
//
if (access == AccessMode.CLONE_BEFORE_WRITE)
{
+ boolean persist = stateManagementPolicy.persistLocally();
+
// Create the state
if (context.isStateful())
{
StatefulContext statefulContext = (StatefulContext)context;
- boolean persist = stateManagementPolicy.persistLocally();
if (persist)
{
try
@@ -291,14 +292,24 @@
// Add the missing mutable portlet state
getPropertiesFromMetaData(portlet.getContext(), newPrefs);
- // Create the new state
- String cloneStateId =
persistenceManager.createState(context.getPortletId(), newPrefs);
+ //
+ if (persist)
+ {
+ // Create the new state
+ String cloneStateId =
persistenceManager.createState(context.getPortletId(), newPrefs);
- // Return the clone context
- String cloneId = PRODUCER_CLONE_ID_PREFIX + cloneStateId;
- PortletContext clonedCtx = PortletContext.createPortletContext(cloneId);
- StateEvent event = new StateEvent(clonedCtx,
StateEvent.PORTLET_CLONED_EVENT);
- instanceCtx.onStateEvent(event);
+ // Return the clone context
+ String cloneId = PRODUCER_CLONE_ID_PREFIX + cloneStateId;
+ PortletContext clonedCtx =
PortletContext.createPortletContext(cloneId);
+ StateEvent event = new StateEvent(clonedCtx,
StateEvent.PORTLET_CLONED_EVENT);
+ instanceCtx.onStateEvent(event);
+ }
+ else
+ {
+ PortletContext clonedCtx = marshall(context.getPortletId(), newPrefs);
+ StateEvent event = new StateEvent(clonedCtx,
StateEvent.PORTLET_CLONED_EVENT);
+ instanceCtx.onStateEvent(event);
+ }
}
}
else if (access == AccessMode.READ_WRITE)
Modified:
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
===================================================================
---
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java 2007-11-09
01:38:40 UTC (rev 8854)
+++
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java 2007-11-09
01:49:07 UTC (rev 8855)
@@ -61,6 +61,14 @@
public abstract class AbstractStatefulPortletInvokerTestCase extends TestCase
{
+ /** . */
+ protected final boolean persistLocally;
+
+ protected AbstractStatefulPortletInvokerTestCase(boolean persistLocally)
+ {
+ this.persistLocally = persistLocally;
+ }
+
/**
*
*/
@@ -159,6 +167,41 @@
/**
*
*/
+ protected final void assertCloneDoesNotExist(PortletContext ref)
+ {
+ if (persistLocally)
+ {
+ try
+ {
+ getProperties(ref);
+ fail("Was expecting a NoSuchPortletException to be thrown");
+ }
+ catch (NoSuchPortletException expected)
+ {
+ }
+ catch (PortletInvokerException e)
+ {
+ fail();
+ }
+ }
+ else
+ {
+ // We cannot assert it because we really store the state on the consumer and
keep no reference
+ // on the producer, so the best we can do is to call it and assert that nothing
wrong happens.
+ try
+ {
+ getProperties(ref);
+ }
+ catch (PortletInvokerException e)
+ {
+ fail();
+ }
+ }
+ }
+
+ /**
+ *
+ */
protected final PortletContext createPOPRef(PortletInfoSupport portletInfo) throws
PortletInvokerException
{
PortletSupport portletSupport = new PortletSupport(portletInfo);
@@ -708,8 +751,18 @@
ValueMapAssert.assertEquals(expectedProps, ccpProps);
}
- public void testInvokeCloneBeforeWriteWithUpdate() throws Exception
+ public void testInvokeCloneBeforeWritePOPWithUpdate() throws Exception
{
+ invokeCloneBeforeWriteWithUpdate(true);
+ }
+
+ public void testInvokeCloneBeforeWriteCCPWithUpdate() throws Exception
+ {
+ invokeCloneBeforeWriteWithUpdate(false);
+ }
+
+ public void invokeCloneBeforeWriteWithUpdate(boolean pop) throws Exception
+ {
PortletInfoSupport info = new PortletInfoSupport();
PortletSupport portletSupport = new PortletSupport(info)
{
@@ -720,11 +773,24 @@
return null;
}
};
- PortletContext popCtx = createPOPRef(portletSupport);
- addPreference(popCtx, "abc", new StringValue("def"));
+ PortletContext ctx;
+ if (pop)
+ {
+ PortletContext popCtx = createPOPRef(portletSupport);
+ addPreference(popCtx, "abc", new StringValue("def"));
+ ctx = popCtx;
+ }
+ else
+ {
+ PortletContext popCtx = createPOPRef(portletSupport);
+ addPreference(popCtx, "abc", new StringValue("def"));
+ PortletContext ccpCtx = createClone(popCtx);
+ ctx = ccpCtx;
+ }
+
//
- ActionInvocation invocation = createAction(popCtx, AccessMode.CLONE_BEFORE_WRITE);
+ ActionInvocation invocation = createAction(ctx, AccessMode.CLONE_BEFORE_WRITE);
invoke(invocation);
//
@@ -736,6 +802,12 @@
PropertyMap expectedProps = new SimplePropertyMap();
expectedProps.setProperty("abc", new StringValue("_def"));
ValueMapAssert.assertEquals(expectedProps, blah);
+
+ // Now we test the clone destruction
+ destroyClone(cloneRef);
+
+ // Assert clone ref does not exist anymore
+ assertCloneDoesNotExist(cloneRef);
}
public void testInvokeReadOnlyWithUpdate() throws Exception
Modified:
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
===================================================================
---
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java 2007-11-09
01:38:40 UTC (rev 8854)
+++
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java 2007-11-09
01:49:07 UTC (rev 8855)
@@ -54,13 +54,10 @@
public ConsumerStatefulPortletInvokerTestCase(boolean persistLocally)
{
- this.persistLocally = persistLocally;
+ super(persistLocally);
}
/** . */
- protected final boolean persistLocally;
-
- /** . */
protected ConsumerPortletInvoker consumer;
/** . */
Modified:
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
===================================================================
---
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java 2007-11-09
01:38:40 UTC (rev 8854)
+++
modules/portlet/branches/JBP_PORTLET_BRANCH_1_0/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java 2007-11-09
01:49:07 UTC (rev 8855)
@@ -52,13 +52,10 @@
protected ProducerStatefulPortletInvokerTestCase(boolean persistLocally)
{
- this.persistLocally = persistLocally;
+ super(persistLocally);
}
/** . */
- protected final boolean persistLocally;
-
- /** . */
protected ProducerPortletInvoker producer;
/** . */
Show replies by date