Author: julien(a)jboss.com
Date: 2007-02-12 12:35:08 -0500 (Mon, 12 Feb 2007)
New Revision: 6220
Modified:
trunk/core/build.xml
trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java
Log:
test that cloning a CCP within a registration context will relate the new state to the
registration
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2007-02-12 17:28:11 UTC (rev 6219)
+++ trunk/core/build.xml 2007-02-12 17:35:08 UTC (rev 6220)
@@ -550,6 +550,7 @@
</x-sysproperty>
<x-test>
+<!--
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
@@ -578,6 +579,7 @@
<parameter name="CloneOnCreate" value="false"/>
<parameter name="CacheNaturalId" value="true"/>
</zest>
+-->
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.state.ProducerTestCase"
outfile="TEST-ProducerTestCase-WithoutRegistration">
<parameter name="UseRegistration"
value="false"/>
@@ -586,15 +588,19 @@
outfile="TEST-ProducerTestCase-WithRegistration">
<parameter name="UseRegistration"
value="true"/>
</zest>
+<!--
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.state.RegistrationPersistenceManagerTestCase"
outfile="TEST-RegistrationPersistenceManagerTestCase">
</zest>
+-->
+<!--
<test todir="${test.reports}"
name="org.jboss.portal.test.core.deployment.JBossApplicationMetaDataFactoryTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectPermissionTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectIdTestCase"/>
+-->
</x-test>
<x-classpath>
<pathelement location="${build.lib}/portal-core-lib.jar"/>
Modified: trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java 2007-02-12
17:28:11 UTC (rev 6219)
+++ trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java 2007-02-12
17:35:08 UTC (rev 6220)
@@ -45,7 +45,6 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -310,43 +309,6 @@
runtimeContext.stop();
}
- private PortletContext clonePortlet(PortletContext context) throws
PortletInvokerException
- {
- beginTX();
- PortletContext cloneCtx = consumer.createClone(context);
- commitTX();
- return cloneCtx;
- }
-
- public void _testCloneNonExistingPortletWithinTx() throws Exception
- {
- try
- {
- beginTX();
-
consumer.createClone(PortletContext.createPortletContext("UnknownPortlet"));
- fail("Was expecting no such portlet exception");
- }
- catch (NoSuchPortletException e)
- {
- rollbackTX();
- }
-
- // todo check state
-
-// try
-// {
-// TransactionAssert.beginTransaction();
-// statefulPortletInvoker.createClone("_1");
-// fail("Was expecting no such portlet exception");
-// }
-// catch (NoSuchPortletException e)
-// {
-// TransactionAssert.rollbackTransaction(true);
-// }
-
- // todo check state
- }
-
public void beginTX()
{
TransactionAssert.beginTransaction();
@@ -417,7 +379,9 @@
public void testCloneExistingCCPWithinTx() throws Exception
{
// Clone a POP
- PortletContext cloneCtx =
clonePortlet(PortletContext.createPortletContext("SimplePortlet"));
+ beginTX();
+ PortletContext cloneCtx =
consumer.createClone(PortletContext.createPortletContext("SimplePortlet"));
+ commitTX();
// Update CCP state directly
beginTX();
@@ -428,12 +392,14 @@
commitTX();
// Clone the modified CCP
- PortletContext cloneCloneCtx = clonePortlet(cloneCtx);
+ beginRegistrationScopedTX();
+ PortletContext cloneCloneCtx = consumer.createClone(cloneCtx);
+ commitTX();
// Check the clone clone state
beginTX();
assertTrue(cloneCloneCtx.getId().startsWith("_"));
- PortletStateContext cloneCloneState =
persistenceManager.loadState(cloneCloneCtx.getId().substring(1));
+ PersistentPortletState cloneCloneState =
(PersistentPortletState)persistenceManager.loadState(cloneCloneCtx.getId().substring(1));
assertNotNull(cloneCloneState);
assertEquals(cloneCloneCtx.getId(), "_" + cloneCloneState.getId());
assertEquals("SimplePortlet",
cloneCloneState.getState().getPortletId());
@@ -442,33 +408,15 @@
assertNotNull(cloneCloneValues.keySet());
assertEquals(1, cloneCloneValues.keySet().size());
assertEquals(new StringValue("fed"),
cloneCloneValues.getProperty("abc"));
+ if (useRegistration)
+ {
+ PersistentRegistration registration = cloneCloneState.getRelatedRegistration();
+ assertNotNull(registration);
+ assertEquals(registrationId, registration.getId());
+ }
commitTX();
}
- public void testABC()
- {
- beginTX();
- Session session = hibernateSupport.getCurrentSession();
- PersistentConsumer consumer = new PersistentConsumer("myconsumer",
"myconsumer");
- session.persist(consumer);
- Long consumerPK = consumer.getKey();
- commitTX();
-
- beginTX();
- session = hibernateSupport.getCurrentSession();
- consumer = (PersistentConsumer)session.get(PersistentConsumer.class, consumerPK);
- HashMap properties = new HashMap();
- properties.put(new QName("a", "b"), "abc");
- properties.put(new QName("b"), "def");
- PersistentRegistration reg = new PersistentRegistration(properties,
RegistrationStatus.PENDING);
- reg.setPersistentHandle("handle");
- reg.setRelatedConsumer(consumer);
- consumer.getRelatedRegistrations().add(reg);
- session.persist(reg);
- session.flush();
- commitTX();
- }
-
public void testCloneNullPortletWithinTx() throws Exception
{
try
@@ -524,12 +472,16 @@
public void testDestroyCCPWithinTx() throws Exception
{
// Clone a POP 2 times
- PortletContext cloneId1 =
clonePortlet(PortletContext.createPortletContext("SimplePortlet"));
- PortletContext cloneId2 =
clonePortlet(PortletContext.createPortletContext("SimplePortlet"));
+ beginTX();
+ PortletContext cloneId1 =
consumer.createClone(PortletContext.createPortletContext("SimplePortlet"));
+ PortletContext cloneId2 =
consumer.createClone(PortletContext.createPortletContext("SimplePortlet"));
+ commitTX();
// Clone the modified CCP 2 times
- PortletContext cloneCloneId1 = clonePortlet(cloneId1);
- PortletContext cloneCloneId2 = clonePortlet(cloneId1);
+ beginTX();
+ PortletContext cloneCloneId1 = consumer.createClone(cloneId1);
+ PortletContext cloneCloneId2 = consumer.createClone(cloneId1);
+ commitTX();
// Destroy the clone 2
beginTX();
@@ -620,7 +572,9 @@
public void testInvokeCloneBeforeWriteCCPWithinTx() throws Exception
{
- PortletContext cloningPortletId =
clonePortlet(PortletContext.createPortletContext("CloningPortlet"));
+ beginTX();
+ PortletContext cloningPortletId =
consumer.createClone(PortletContext.createPortletContext("CloningPortlet"));
+ commitTX();
// Modify the state of the CCP
beginTX();
@@ -657,7 +611,9 @@
public void testInvokeReadWriteCCPWithinTx() throws Exception
{
- PortletContext cloningPortletId =
clonePortlet(PortletContext.createPortletContext("CloningPortlet"));
+ beginTX();
+ PortletContext cloningPortletId =
consumer.createClone(PortletContext.createPortletContext("CloningPortlet"));
+ commitTX();
//
beginTX();
@@ -685,7 +641,9 @@
public void testInvokeReadOnlyCCPWithinTx() throws Exception
{
- PortletContext cloneFailedCloningPortletId =
clonePortlet(PortletContext.createPortletContext("CloneFailedCloningPortlet"));
+ beginTX();
+ PortletContext cloneFailedCloningPortletId =
consumer.createClone(PortletContext.createPortletContext("CloneFailedCloningPortlet"));
+ commitTX();
//
beginTX();
@@ -738,7 +696,9 @@
public void testGetCCP() throws Exception
{
// Clone a POP
- PortletContext cloneContext =
clonePortlet(PortletContext.createPortletContext("SimplePortlet"));
+ beginTX();
+ PortletContext cloneContext =
consumer.createClone(PortletContext.createPortletContext("SimplePortlet"));
+ commitTX();
//
beginTX();
@@ -748,7 +708,9 @@
commitTX();
// Clone the modified CCP
- PortletContext cloneCloneContext = clonePortlet(cloneContext);
+ beginTX();
+ PortletContext cloneCloneContext = consumer.createClone(cloneContext);
+ commitTX();
//
beginTX();
@@ -758,4 +720,32 @@
commitTX();
}
+ public void _testCloneNonExistingPortletWithinTx() throws Exception
+ {
+ try
+ {
+ beginTX();
+
consumer.createClone(PortletContext.createPortletContext("UnknownPortlet"));
+ fail("Was expecting no such portlet exception");
+ }
+ catch (NoSuchPortletException e)
+ {
+ rollbackTX();
+ }
+
+ // todo check state
+
+// try
+// {
+// TransactionAssert.beginTransaction();
+// statefulPortletInvoker.createClone("_1");
+// fail("Was expecting no such portlet exception");
+// }
+// catch (NoSuchPortletException e)
+// {
+// TransactionAssert.rollbackTransaction(true);
+// }
+
+ // todo check state
+ }
}
Show replies by date