Author: chris.laprun(a)jboss.com
Date: 2009-10-12 08:59:41 -0400 (Mon, 12 Oct 2009)
New Revision: 329
Modified:
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java
Log:
- Fixed tests: wrong setup and wrong expectations.
Modified:
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java
===================================================================
---
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java 2009-10-12
11:42:03 UTC (rev 328)
+++
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java 2009-10-12
12:59:41 UTC (rev 329)
@@ -51,10 +51,12 @@
/** . */
private FederatingPortletInvoker federatingInvoker;
- /** . */
- private PortletInvokerSupport federatedInvoker;
- private PortletInvokerSupport localInvoker;
+ private FederatedPortletInvoker federatedInvoker;
+ private PortletInvokerSupport federatedInvokerDelegate;
+ private FederatedPortletInvoker localInvoker;
+ private PortletInvokerSupport localInvokerDelegate;
+
/** . */
private Portlet portlet;
@@ -66,23 +68,24 @@
{
federatingInvoker = new FederatingPortletInvokerService();
- // Invokers
- federatedInvoker = new PortletInvokerSupport();
- localInvoker = new PortletInvokerSupport();
-
- // Add portlets to invokers
+ // create 'foo' invoker and register it with federating service
+ federatedInvokerDelegate = new PortletInvokerSupport();
PortletInfoSupport fooInfo = new PortletInfoSupport();
fooInfo.getMeta().setDisplayName("FooPortlet");
- portlet = federatedInvoker.addPortlet("MyPortlet", fooInfo);
+ portlet = federatedInvokerDelegate.addPortlet("MyPortlet", fooInfo);
portletContext = portlet.getContext();
+ federatedInvoker = federatingInvoker.registerInvoker("foo",
federatedInvokerDelegate);
+ assertNotNull(federatedInvoker);
+ assertEquals("foo", federatedInvoker.getId());
+ // create 'local' invoker and register it with federating service
+ localInvokerDelegate = new PortletInvokerSupport();
PortletInfoSupport localInfo = new PortletInfoSupport();
- fooInfo.getMeta().setDisplayName("LocalPortlet");
- localInvoker.addPortlet("MyLocalPortlet", localInfo);
-
- // Register invokers with federating service
- federatingInvoker.registerInvoker("foo", federatedInvoker);
- federatingInvoker.registerInvoker(PortletInvoker.LOCAL_PORTLET_INVOKER_ID,
localInvoker);
+ localInfo.getMeta().setDisplayName("LocalPortlet");
+ localInvokerDelegate.addPortlet("MyLocalPortlet", localInfo);
+ localInvoker =
federatingInvoker.registerInvoker(PortletInvoker.LOCAL_PORTLET_INVOKER_ID,
localInvokerDelegate);
+ assertNotNull(localInvoker);
+ assertEquals(PortletInvoker.LOCAL_PORTLET_INVOKER_ID, localInvoker.getId());
}
@Destroy
@@ -106,7 +109,7 @@
{
PortletContext context = portlet.getContext();
String id = context.getId();
- assertTrue("MyPortlet".equals(id) ||
"MyLocalPortlet".equals(id));
+ assertTrue("foo.MyPortlet".equals(id) ||
(PortletInvoker.LOCAL_PORTLET_INVOKER_ID + ".MyLocalPortlet").equals(id));
}
}
@@ -120,12 +123,14 @@
FederatedPortletInvoker federated =
federatingInvoker.getFederatedInvoker("foo");
assertNotNull(federated);
assertEquals("foo", federated.getId());
- assertEquals(federatedInvoker, federated.getPortletInvoker());
+ assertEquals(federatedInvoker, federated);
+ assertEquals(federatedInvokerDelegate, federated.getPortletInvoker());
federated =
federatingInvoker.getFederatedInvoker(PortletInvoker.LOCAL_PORTLET_INVOKER_ID);
assertNotNull(federated);
assertEquals(PortletInvoker.LOCAL_PORTLET_INVOKER_ID, federated.getId());
- assertEquals(localInvoker, federated.getPortletInvoker());
+ assertEquals(localInvoker, federated);
+ assertEquals(localInvokerDelegate, federated.getPortletInvoker());
}
@Test
@@ -142,11 +147,26 @@
}
@Test
- public void testGetPortlet() throws PortletInvokerException
+ public void testGetPortletNonFederatedContext() throws PortletInvokerException
{
- Portlet samePortlet = federatingInvoker.getPortlet(portletContext);
+ try
+ {
+ federatingInvoker.getPortlet(portletContext);
+ fail("Non federated context shouldn't be resolved by federating
service");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+
+ @Test
+ public void testGetPortletOnFederatedInvoker() throws PortletInvokerException
+ {
+ PortletContext federatedContext =
PortletContext.createPortletContext(federatedInvoker.getId() + "." +
portletContext.getId());
+ Portlet samePortlet = federatedInvoker.getPortlet(federatedContext);
assertNotNull(samePortlet);
- assertEquals(samePortlet.getContext(), portletContext);
+ assertEquals(samePortlet.getContext(), federatedContext);
}
@Test
@@ -156,7 +176,7 @@
assertEquals(1, localPortlets.size());
Portlet localPortlet = localPortlets.iterator().next();
assertNotNull(localPortlet);
- assertEquals("MyLocalPortlet", localPortlet.getContext().getId());
+ assertEquals("local.MyLocalPortlet", localPortlet.getContext().getId());
}
@Test
@@ -166,10 +186,6 @@
assertEquals(1, portlets.size());
Portlet portlet = portlets.iterator().next();
assertNotNull(portlet);
- assertEquals("MyPortlet", portlet.getContext().getId());
+ assertEquals("foo.MyPortlet", portlet.getContext().getId());
}
-
- public void testInvoke() throws PortletInvokerException
- {
- }
}
Show replies by date