Author: chris.laprun(a)jboss.com
Date: 2011-04-08 06:38:06 -0400 (Fri, 08 Apr 2011)
New Revision: 6183
Modified:
components/pc/trunk/api/src/test/java/org/gatein/pc/api/PortletContextTestCase.java
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/EventControllerContextFailureTestCase.java
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/PortletControllerRequestTestCase.java
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/PortletControllerTestCase.java
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java
components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java
Log:
- GTNPC-58: Improved test cases so that they use properly formatted PortletContexts and
extracted constants to avoid inadvertent collisions of values without the same semantics
(i.e. same String "foo" being used for different purposes).
- GTNPC-61: Used new improved PortletContext to properly resolve invoker from compound
PortletContext.
Modified:
components/pc/trunk/api/src/test/java/org/gatein/pc/api/PortletContextTestCase.java
===================================================================
---
components/pc/trunk/api/src/test/java/org/gatein/pc/api/PortletContextTestCase.java 2011-04-08
10:03:03 UTC (rev 6182)
+++
components/pc/trunk/api/src/test/java/org/gatein/pc/api/PortletContextTestCase.java 2011-04-08
10:38:06 UTC (rev 6183)
@@ -147,7 +147,7 @@
assertNull(components.getStateId());
}
- public void testCreateFromComponents()
+ public void testCreateFromAppAndPortletName()
{
PortletContext fromId =
PortletContext.createPortletContext("/applicationName.portletName");
Modified:
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/EventControllerContextFailureTestCase.java
===================================================================
---
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/EventControllerContextFailureTestCase.java 2011-04-08
10:03:03 UTC (rev 6182)
+++
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/EventControllerContextFailureTestCase.java 2011-04-08
10:38:06 UTC (rev 6183)
@@ -1,25 +1,25 @@
-/******************************************************************************
- * 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 2011, 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.pc.controller;
import org.gatein.pc.portlet.support.PortletInvokerSupport;
@@ -36,9 +36,9 @@
import org.gatein.pc.controller.handlers.NoOpEventHandler;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
-import org.gatein.pc.controller.PortletController;
import org.jboss.unit.api.pojo.annotations.Test;
import org.jboss.unit.api.pojo.annotations.Create;
+
import static org.jboss.unit.api.Assert.assertInstanceOf;
import static org.jboss.unit.api.Assert.assertEquals;
import static org.jboss.unit.api.Assert.assertTrue;
@@ -55,6 +55,8 @@
public class EventControllerContextFailureTestCase
{
+ public static final String DST_WINDOW_ID = "/webappdst.dst";
+
/** . */
private PortletController controller = new PortletController();
@@ -85,11 +87,11 @@
@Create
public void create()
{
- request = context.createActionRequest("foo");
- srcName = new QName("juu", "foo");
- dstName = new QName("juu", "bar");
- fooPortlet = invoker.addPortlet("foo");
- barPortlet = invoker.addPortlet("bar");
+ request = context.createActionRequest(PortletInvokerSupport.FOO_PORTLET_ID);
+ srcName = new QName("ns1", "src");
+ dstName = new QName("ns2", "dst");
+ fooPortlet = invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
+ barPortlet = invoker.addPortlet(PortletInvokerSupport.BAR_PORTLET_ID);
called = false;
}
@@ -104,7 +106,7 @@
throw new RuntimeException();
}
};
- ecc.createWire(srcName, "foo", dstName, "bar");
+ ecc.createWire(srcName, PortletInvokerSupport.FOO_PORTLET_ID, dstName,
PortletInvokerSupport.BAR_PORTLET_ID);
// We test that a runtime exception thrown does not interrrupt the flow of the
controller
context.setEventControllerContext(ecc);
@@ -126,7 +128,7 @@
throw error;
}
};
- ecc.createWire(srcName, "foo", dstName, "bar");
+ ecc.createWire(srcName, PortletInvokerSupport.FOO_PORTLET_ID, dstName,
PortletInvokerSupport.BAR_PORTLET_ID);
//
context.setEventControllerContext(ecc);
@@ -202,7 +204,7 @@
throw new RuntimeException();
}
};
- ecc.createWire(srcName, "foo", dstName, "bar");
+ ecc.createWire(srcName, PortletInvokerSupport.FOO_PORTLET_ID, dstName,
PortletInvokerSupport.BAR_PORTLET_ID);
// We test that a runtime exception thrown does not interrrupt the flow of the
controller
context.setEventControllerContext(ecc);
@@ -224,7 +226,7 @@
throw error;
}
};
- ecc.createWire(srcName, "foo", dstName, "bar");
+ ecc.createWire(srcName, PortletInvokerSupport.FOO_PORTLET_ID, dstName,
PortletInvokerSupport.BAR_PORTLET_ID);
//
context.setEventControllerContext(ecc);
@@ -254,7 +256,7 @@
throw new RuntimeException();
}
};
- ecc.createWire(srcName, "foo", dstName, "bar_");
+ ecc.createWire(srcName, PortletInvokerSupport.FOO_PORTLET_ID, dstName,
DST_WINDOW_ID);
// We test that a runtime exception thrown does not interrrupt the flow of the
controller
context.setEventControllerContext(ecc);
@@ -276,7 +278,7 @@
throw error;
}
};
- ecc.createWire(srcName, "foo", dstName, "bar_");
+ ecc.createWire(srcName, PortletInvokerSupport.FOO_PORTLET_ID, dstName,
DST_WINDOW_ID);
//
context.setEventControllerContext(ecc);
Modified:
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/PortletControllerRequestTestCase.java
===================================================================
---
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/PortletControllerRequestTestCase.java 2011-04-08
10:03:03 UTC (rev 6182)
+++
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/PortletControllerRequestTestCase.java 2011-04-08
10:38:06 UTC (rev 6183)
@@ -1,28 +1,29 @@
-/******************************************************************************
- * 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 2011, 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.pc.controller;
import static org.jboss.unit.api.Assert.*;
+
import org.jboss.unit.api.pojo.annotations.Test;
import org.gatein.pc.portlet.support.PortletInvokerSupport;
import org.gatein.pc.portlet.support.PortletSupport;
@@ -34,7 +35,6 @@
import org.gatein.pc.api.OpaqueStateString;
import org.gatein.pc.api.StateString;
import org.gatein.pc.api.cache.CacheLevel;
-import org.gatein.pc.controller.PortletController;
import org.gatein.pc.controller.request.PortletActionRequest;
import org.gatein.pc.controller.request.PortletResourceRequest;
import org.gatein.pc.controller.request.PortletRenderRequest;
@@ -88,7 +88,7 @@
@Test
public void testPortletControllerActionRequest() throws PortletInvokerException
{
- PortletSupport fooPortlet = invoker.addPortlet("foo");
+ PortletSupport fooPortlet =
invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
fooPortlet.addHandler(new PortletSupport.ActionHandler()
{
protected PortletInvocationResponse invoke(ActionInvocation action) throws
PortletInvokerException
@@ -106,7 +106,7 @@
});
//
- PortletActionRequest action = new PortletActionRequest("foo", is, body,
windowNS, pageNS);
+ PortletActionRequest action = new
PortletActionRequest(PortletInvokerSupport.FOO_PORTLET_ID, is, body, windowNS, pageNS);
//
controller.process(context, action);
@@ -115,15 +115,15 @@
@Test
public void testPortletControllerRenderRequest() throws PortletInvokerException
{
- invoker.addPortlet("foo");
- PortletRenderRequest render = new PortletRenderRequest("foo", windowNS,
new HashMap<String, String[]>(), pageNS);
+ invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
+ PortletRenderRequest render = new
PortletRenderRequest(PortletInvokerSupport.FOO_PORTLET_ID, windowNS, new
HashMap<String, String[]>(), pageNS);
controller.process(context, render);
}
@Test
public void testPortletControllerResourceRequestFullScope() throws
PortletInvokerException
{
- PortletSupport fooPortlet = invoker.addPortlet("foo");
+ PortletSupport fooPortlet =
invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
ResourceHandlerImpl resourceHandler = new ResourceHandlerImpl();
resourceHandler.expectedResourceId = "resourceid";
resourceHandler.expectedRS = rs;
@@ -134,26 +134,26 @@
resourceHandler.expectedWindowState = org.gatein.pc.api.WindowState.NORMAL;
resourceHandler.expectedPublicState = null;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest fullServing = new PortletResourceRequest("foo",
"resourceid", rs, body, new PortletResourceRequest.FullScope());
+ PortletResourceRequest fullServing = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, "resourceid", rs,
body, new PortletResourceRequest.FullScope());
controller.process(context, fullServing);
//
resourceHandler.expectedBody = null;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest fullServing2 = new PortletResourceRequest("foo",
"resourceid", rs, null, new PortletResourceRequest.FullScope());
+ PortletResourceRequest fullServing2 = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, "resourceid", rs,
null, new PortletResourceRequest.FullScope());
controller.process(context, fullServing2);
//
resourceHandler.expectedResourceId = null;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest fullServing3 = new PortletResourceRequest("foo",
null, rs, null, new PortletResourceRequest.FullScope());
+ PortletResourceRequest fullServing3 = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, null, rs, null, new
PortletResourceRequest.FullScope());
controller.process(context, fullServing3);
}
@Test
public void testPortletControllerResourceRequestPortletScope() throws
PortletInvokerException
{
- PortletSupport fooPortlet = invoker.addPortlet("foo");
+ PortletSupport fooPortlet =
invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
ResourceHandlerImpl resourceHandler = new ResourceHandlerImpl();
resourceHandler.expectedResourceId = "resourceid";
resourceHandler.expectedRS = rs;
@@ -164,7 +164,7 @@
resourceHandler.expectedWindowState = org.gatein.pc.api.WindowState.MAXIMIZED;
resourceHandler.expectedPublicState = null;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest portletServing = new PortletResourceRequest("foo",
"resourceid", rs, body, new PortletResourceRequest.PortletScope(windowNS));
+ PortletResourceRequest portletServing = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, "resourceid", rs,
body, new PortletResourceRequest.PortletScope(windowNS));
controller.process(context, portletServing);
//
@@ -172,20 +172,20 @@
resourceHandler.expectedMode = Mode.VIEW;
resourceHandler.expectedWindowState = org.gatein.pc.api.WindowState.NORMAL;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest portletServing2 = new
PortletResourceRequest("foo", "resourceid", rs, body, new
PortletResourceRequest.PortletScope(null));
+ PortletResourceRequest portletServing2 = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, "resourceid", rs,
body, new PortletResourceRequest.PortletScope(null));
controller.process(context, portletServing2);
//
resourceHandler.expectedResourceId = null;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest portletServing3 = new
PortletResourceRequest("foo", null, rs, body, new
PortletResourceRequest.PortletScope(null));
+ PortletResourceRequest portletServing3 = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, null, rs, body, new
PortletResourceRequest.PortletScope(null));
controller.process(context, portletServing3);
}
@Test
public void testPortletControllerResourceRequestPageScope() throws
PortletInvokerException
{
- PortletSupport fooPortlet = invoker.addPortlet("foo");
+ PortletSupport fooPortlet =
invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
ResourceHandlerImpl resourceHandler = new ResourceHandlerImpl();
resourceHandler.expectedResourceId = "resourceid";
resourceHandler.expectedRS = rs;
@@ -196,7 +196,7 @@
resourceHandler.expectedCacheability = CacheLevel.PAGE;
resourceHandler.expectedPublicState = new ParameterMap();
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest pageServing = new PortletResourceRequest("foo",
"resourceid", rs, body, new PortletResourceRequest.PageScope(windowNS,
pageNS));
+ PortletResourceRequest pageServing = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, "resourceid", rs,
body, new PortletResourceRequest.PageScope(windowNS, pageNS));
controller.process(context, pageServing);
//
@@ -204,25 +204,25 @@
resourceHandler.expectedMode = Mode.VIEW;
resourceHandler.expectedWindowState = org.gatein.pc.api.WindowState.NORMAL;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest pageServing2 = new PortletResourceRequest("foo",
"resourceid", rs, body, new PortletResourceRequest.PageScope(null, pageNS));
+ PortletResourceRequest pageServing2 = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, "resourceid", rs,
body, new PortletResourceRequest.PageScope(null, pageNS));
controller.process(context, pageServing2);
//
resourceHandler.expectedBody = null;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest pageServing3 = new PortletResourceRequest("foo",
"resourceid", rs, null, new PortletResourceRequest.PageScope(null, pageNS));
+ PortletResourceRequest pageServing3 = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, "resourceid", rs,
null, new PortletResourceRequest.PageScope(null, pageNS));
controller.process(context, pageServing3);
//
resourceHandler.expectedPublicState = null;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest pageServing4 = new PortletResourceRequest("foo",
"resourceid", rs, null, new PortletResourceRequest.PageScope(null, null));
+ PortletResourceRequest pageServing4 = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, "resourceid", rs,
null, new PortletResourceRequest.PageScope(null, null));
controller.process(context, pageServing4);
//
resourceHandler.expectedResourceId = null;
fooPortlet.addHandler(resourceHandler);
- PortletResourceRequest pageServing5 = new PortletResourceRequest("foo",
null, rs, null, new PortletResourceRequest.PageScope(null, null));
+ PortletResourceRequest pageServing5 = new
PortletResourceRequest(PortletInvokerSupport.FOO_PORTLET_ID, null, rs, null, new
PortletResourceRequest.PageScope(null, null));
controller.process(context, pageServing5);
}
Modified:
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/PortletControllerTestCase.java
===================================================================
---
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/PortletControllerTestCase.java 2011-04-08
10:03:03 UTC (rev 6182)
+++
components/pc/trunk/controller/src/test/java/org/gatein/pc/controller/PortletControllerTestCase.java 2011-04-08
10:38:06 UTC (rev 6183)
@@ -1,25 +1,25 @@
-/******************************************************************************
- * 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 2011, 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.pc.controller;
import org.gatein.pc.controller.request.ControllerRequest;
@@ -45,11 +45,11 @@
import org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse;
import org.gatein.pc.api.invocation.ActionInvocation;
import org.gatein.pc.api.invocation.EventInvocation;
-import org.gatein.pc.controller.PortletController;
import org.gatein.common.util.Tools;
import org.gatein.pc.api.WindowState;
import org.jboss.unit.api.pojo.annotations.Test;
import org.jboss.unit.api.pojo.annotations.Create;
+
import static org.jboss.unit.api.Assert.*;
import javax.xml.namespace.QName;
@@ -75,6 +75,9 @@
/** . */
PortletInvokerSupport invoker = context.getInvoker();
+ public static final QName SRC_NAME = new QName("ns1", "src");
+ public static final QName DST_NAME = new QName("ns2", "dest");
+
@Create
public void create()
{
@@ -84,16 +87,16 @@
@Test
public void testPortletControllerRenderRequest() throws PortletInvokerException
{
- invoker.addPortlet("foo");
+ invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
StateString portletNS = new OpaqueStateString("abc");
PortletPageNavigationalState pageNS =
context.getStateControllerContext().createPortletPageNavigationalState(true);
PortletWindowNavigationalState windowNS = new
PortletWindowNavigationalState(portletNS, org.gatein.pc.api.Mode.EDIT,
WindowState.MAXIMIZED);
- PortletRenderRequest render = new PortletRenderRequest("foo", windowNS,
new HashMap<String, String[]>(), pageNS);
+ PortletRenderRequest render = new
PortletRenderRequest(PortletInvokerSupport.FOO_PORTLET_ID, windowNS, new
HashMap<String, String[]>(), pageNS);
ControllerResponse response = controller.process(context, render);
PageUpdateResponse pageUpdate = assertInstanceOf(response,
PageUpdateResponse.class);
PortletPageNavigationalState pageNS2 =
assertNotNull(pageUpdate.getPageNavigationalState());
- assertEquals(Tools.toSet("foo"), pageNS2.getPortletWindowIds());
- PortletWindowNavigationalState windowNS2 =
pageNS2.getPortletWindowNavigationalState("foo");
+ assertEquals(Tools.toSet(PortletInvokerSupport.FOO_PORTLET_ID),
pageNS2.getPortletWindowIds());
+ PortletWindowNavigationalState windowNS2 =
pageNS2.getPortletWindowNavigationalState(PortletInvokerSupport.FOO_PORTLET_ID);
assertNotNull(windowNS2);
assertEquals(portletNS, windowNS2.getPortletNavigationalState());
assertEquals(org.gatein.pc.api.Mode.EDIT, windowNS2.getMode());
@@ -114,11 +117,8 @@
private void testAction(final boolean publishEvent) throws PortletInvokerException
{
- final QName srcName = new QName("juu", "foo");
- final QName dstName = new QName("juu", "bar");
-
//
- PortletSupport fooPortlet = invoker.addPortlet("foo");
+ PortletSupport fooPortlet =
invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
fooPortlet.addHandler(new PortletSupport.ActionHandler()
{
protected PortletInvocationResponse invoke(ActionInvocation action) throws
PortletInvokerException
@@ -131,21 +131,21 @@
//
if (publishEvent)
{
- updateNS.queueEvent(new UpdateNavigationalStateResponse.Event(srcName,
null));
+ updateNS.queueEvent(new UpdateNavigationalStateResponse.Event(SRC_NAME,
null));
}
-
+
//
return updateNS;
}
});
//
- PortletSupport barPortlet = invoker.addPortlet("bar");
+ PortletSupport barPortlet =
invoker.addPortlet(PortletInvokerSupport.BAR_PORTLET_ID);
barPortlet.addHandler(new PortletSupport.EventHandler()
{
protected PortletInvocationResponse invoke(EventInvocation action) throws
PortletInvokerException
{
- assertEquals(dstName, action.getName());
+ assertEquals(DST_NAME, action.getName());
assertEquals(null, action.getPayload());
//
@@ -160,16 +160,16 @@
});
//
- eventControllerContext.createWire(srcName, "foo", dstName,
"bar");
+ eventControllerContext.createWire(SRC_NAME, PortletInvokerSupport.FOO_PORTLET_ID,
DST_NAME, PortletInvokerSupport.BAR_PORTLET_ID);
//
- ControllerRequest request = context.createActionRequest("foo");
+ ControllerRequest request =
context.createActionRequest(PortletInvokerSupport.FOO_PORTLET_ID);
ControllerResponse response = controller.process(context, request);
PageUpdateResponse pageUpdate = assertInstanceOf(response,
PageUpdateResponse.class);
PortletPageNavigationalState pageNS =
assertNotNull(pageUpdate.getPageNavigationalState());
//
- PortletWindowNavigationalState fooNS =
assertNotNull(pageNS.getPortletWindowNavigationalState("foo"));
+ PortletWindowNavigationalState fooNS =
assertNotNull(pageNS.getPortletWindowNavigationalState(PortletInvokerSupport.FOO_PORTLET_ID));
assertEquals(WindowState.MAXIMIZED, fooNS.getWindowState());
assertEquals(org.gatein.pc.api.Mode.EDIT, fooNS.getMode());
assertEquals(new OpaqueStateString("abc"),
fooNS.getPortletNavigationalState());
@@ -177,17 +177,17 @@
//
if (publishEvent)
{
- assertEquals(Tools.toSet("foo", "bar"),
pageNS.getPortletWindowIds());
+ assertEquals(Tools.toSet(PortletInvokerSupport.FOO_PORTLET_ID,
PortletInvokerSupport.BAR_PORTLET_ID), pageNS.getPortletWindowIds());
//
- PortletWindowNavigationalState barNS =
assertNotNull(pageNS.getPortletWindowNavigationalState("bar"));
+ PortletWindowNavigationalState barNS =
assertNotNull(pageNS.getPortletWindowNavigationalState(PortletInvokerSupport.BAR_PORTLET_ID));
assertEquals(WindowState.MINIMIZED, barNS.getWindowState());
assertEquals(org.gatein.pc.api.Mode.HELP, barNS.getMode());
assertEquals(new OpaqueStateString("def"),
barNS.getPortletNavigationalState());
}
else
{
- assertEquals(Tools.toSet("foo"), pageNS.getPortletWindowIds());
+ assertEquals(Tools.toSet(PortletInvokerSupport.FOO_PORTLET_ID),
pageNS.getPortletWindowIds());
}
}
@@ -195,7 +195,7 @@
public void testActionThrowsPortletInvokerException() throws PortletInvokerException
{
final PortletInvokerException e = new PortletInvokerException();
- PortletSupport fooPortlet = invoker.addPortlet("foo");
+ PortletSupport fooPortlet =
invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
fooPortlet.addHandler(new PortletSupport.ActionHandler()
{
protected PortletInvocationResponse invoke(ActionInvocation action) throws
PortletInvokerException
@@ -205,7 +205,7 @@
});
//
- ControllerRequest request = context.createActionRequest("foo");
+ ControllerRequest request =
context.createActionRequest(PortletInvokerSupport.FOO_PORTLET_ID);
try
{
@@ -221,14 +221,12 @@
@Test
public void testProcessActionProducedEventIsDistributed() throws
PortletInvokerException
{
- QName srcName = new QName("juu", "foo");
- QName dstName = new QName("juu", "bar");
- PortletSupport fooPortlet = invoker.addPortlet("foo");
- PortletSupport barPortlet = invoker.addPortlet("bar");
- EventProducerActionHandler eventProducerHandler = new
EventProducerActionHandler(srcName);
+ PortletSupport fooPortlet =
invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
+ PortletSupport barPortlet =
invoker.addPortlet(PortletInvokerSupport.BAR_PORTLET_ID);
+ EventProducerActionHandler eventProducerHandler = new
EventProducerActionHandler(SRC_NAME);
NoOpEventHandler eventConsumer = new NoOpEventHandler();
- eventControllerContext.createWire(srcName, "foo", dstName,
"bar");
- ControllerRequest request = context.createActionRequest("foo");
+ eventControllerContext.createWire(SRC_NAME, PortletInvokerSupport.FOO_PORTLET_ID,
DST_NAME, PortletInvokerSupport.BAR_PORTLET_ID);
+ ControllerRequest request =
context.createActionRequest(PortletInvokerSupport.FOO_PORTLET_ID);
//
controller.setDistributeNonProduceableEvents(true);
@@ -248,7 +246,7 @@
barPortlet.assertInvocationCountIs(1);
//
- barPortlet.getInfo().getEventing().addConsumedEvent(new
EventInfoSupport(dstName));
+ barPortlet.getInfo().getEventing().addConsumedEvent(new
EventInfoSupport(DST_NAME));
//
controller.setDistributeNonProduceableEvents(true);
@@ -285,7 +283,7 @@
barPortlet.assertInvocationCountIs(3);
//
- fooPortlet.getInfo().getEventing().addProducedEvent(new
EventInfoSupport(srcName));
+ fooPortlet.getInfo().getEventing().addProducedEvent(new
EventInfoSupport(SRC_NAME));
//
controller.setDistributeNonProduceableEvents(false);
@@ -309,14 +307,13 @@
@Test
public void testEventFloodDetection() throws PortletInvokerException
{
- QName srcName = new QName("juu", "foo");
- PortletSupport fooPortlet = invoker.addPortlet("foo");
- eventControllerContext.createWire(srcName, "foo", srcName,
"foo");
- ControllerRequest request = context.createActionRequest("foo");
+ PortletSupport fooPortlet =
invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
+ eventControllerContext.createWire(SRC_NAME, PortletInvokerSupport.FOO_PORTLET_ID,
SRC_NAME, PortletInvokerSupport.FOO_PORTLET_ID);
+ ControllerRequest request =
context.createActionRequest(PortletInvokerSupport.FOO_PORTLET_ID);
//
- EventProducerActionHandler eventProducerActionHandler = new
EventProducerActionHandler(srcName);
- EventProducerEventHandler eventProducerEventHandler = new
EventProducerEventHandler(srcName);
+ EventProducerActionHandler eventProducerActionHandler = new
EventProducerActionHandler(SRC_NAME);
+ EventProducerEventHandler eventProducerEventHandler = new
EventProducerEventHandler(SRC_NAME);
//
controller.setConsumedEventThreshold(10);
@@ -340,13 +337,12 @@
@Test
public void testEventFloodInterruption() throws PortletInvokerException
{
- QName srcName = new QName("juu", "foo");
- PortletSupport fooPortlet = invoker.addPortlet("foo");
- eventControllerContext.createWire(srcName, "foo", srcName,
"foo");
- ControllerRequest request = context.createActionRequest("foo");
+ PortletSupport fooPortlet =
invoker.addPortlet(PortletInvokerSupport.FOO_PORTLET_ID);
+ eventControllerContext.createWire(SRC_NAME, PortletInvokerSupport.FOO_PORTLET_ID,
SRC_NAME, PortletInvokerSupport.FOO_PORTLET_ID);
+ ControllerRequest request =
context.createActionRequest(PortletInvokerSupport.FOO_PORTLET_ID);
//
- EventProducerActionHandler eventProducerActionHandler = new
EventProducerActionHandler(srcName);
+ EventProducerActionHandler eventProducerActionHandler = new
EventProducerActionHandler(SRC_NAME);
//
controller.setConsumedEventThreshold(10);
Modified:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
===================================================================
---
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2011-04-08
10:03:03 UTC (rev 6182)
+++
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2011-04-08
10:38:06 UTC (rev 6183)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -63,7 +63,7 @@
private static final Logger log =
LoggerFactory.getLogger(FederatingPortletInvokerService.class);
/** The separator used in the id to route to the correct invoker. */
- static final String SEPARATOR = ".";
+ public static final String SEPARATOR = ".";
/** The registred FederatedPortletInvokers. */
private volatile Map<String, FederatedPortletInvoker> registry = new
HashMap<String, FederatedPortletInvoker>();
@@ -72,7 +72,7 @@
public static PortletContext dereference(PortletContext compoundPortletContext, String
invokerId)
{
- String portletId = compoundPortletContext.getId().substring(invokerId.length() +
1);
+ String portletId = compoundPortletContext.getId().substring(invokerId.length() +
SEPARATOR.length());
if (compoundPortletContext instanceof StatefulPortletContext)
{
StatefulPortletContext<?> compoundStatefulPortletContext =
(StatefulPortletContext<?>)compoundPortletContext;
@@ -315,18 +315,21 @@
throw new IllegalArgumentException("No null portlet id accepted");
}
- //
- String compoundPortletId = compoundPortletContext.getId();
+ PortletContext.PortletContextComponents components =
compoundPortletContext.getComponents();
+ final String compoundPortletId = compoundPortletContext.getId();
+ if (components == null)
+ {
+ // force intepretation
+ compoundPortletContext = PortletContext.createPortletContext(compoundPortletId,
true);
+ components = compoundPortletContext.getComponents();
+ }
- //
- int pos = compoundPortletId.indexOf(SEPARATOR);
- if (pos == -1)
+ final String invokerId = components.getInvokerName();
+ if (invokerId == null)
{
throw new IllegalArgumentException("Bad portlet id format " +
compoundPortletId);
}
- //
- String invokerId = compoundPortletId.substring(0, pos);
FederatedPortletInvoker federated = registry.get(invokerId);
if (federated == null)
{
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 2011-04-08
10:03:03 UTC (rev 6182)
+++
components/pc/trunk/federation/src/test/java/org/gatein/pc/federation/FederatingPortletInvokerTestCase.java 2011-04-08
10:38:06 UTC (rev 6183)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -51,6 +51,12 @@
public class FederatingPortletInvokerTestCase
{
+ private static final PortletContext PORTLET =
PortletContext.createPortletContext("/webapp.portlet", false);
+ private static final String INVOKER_ID = "foo";
+ private static final PortletContext LOCAL_PORTLET =
PortletContext.createPortletContext("/web.local", false);
+ private static final PortletContext REFERENCED_PORTLET =
FederatingPortletInvokerService.reference(PORTLET, INVOKER_ID);
+ private static final PortletContext REFERENCED_LOCAL_PORTLET =
FederatingPortletInvokerService.reference(LOCAL_PORTLET,
PortletInvoker.LOCAL_PORTLET_INVOKER_ID);
+
/** . */
private FederatingPortletInvoker federatingInvoker;
@@ -75,17 +81,17 @@
federatedInvokerDelegate = new PortletInvokerSupport();
PortletInfoSupport fooInfo = new PortletInfoSupport();
fooInfo.getMeta().setDisplayName("FooPortlet");
- portlet = federatedInvokerDelegate.addPortlet("MyPortlet", fooInfo);
+ portlet = federatedInvokerDelegate.addPortlet(PORTLET.getId(), fooInfo);
portletContext = portlet.getContext();
- federatedInvoker = federatingInvoker.registerInvoker("foo",
federatedInvokerDelegate);
+ federatedInvoker = federatingInvoker.registerInvoker(INVOKER_ID,
federatedInvokerDelegate);
assertNotNull(federatedInvoker);
- assertEquals("foo", federatedInvoker.getId());
+ assertEquals(INVOKER_ID, federatedInvoker.getId());
// create 'local' invoker and register it with federating service
localInvokerDelegate = new PortletInvokerSupport();
PortletInfoSupport localInfo = new PortletInfoSupport();
localInfo.getMeta().setDisplayName("LocalPortlet");
- localInvokerDelegate.addPortlet("MyLocalPortlet", localInfo);
+ localInvokerDelegate.addPortlet(LOCAL_PORTLET.getId(), localInfo);
localInvoker =
federatingInvoker.registerInvoker(PortletInvoker.LOCAL_PORTLET_INVOKER_ID,
localInvokerDelegate);
assertNotNull(localInvoker);
assertEquals(PortletInvoker.LOCAL_PORTLET_INVOKER_ID, localInvoker.getId());
@@ -108,22 +114,22 @@
assertNotNull(portlets);
assertEquals(2, portlets.size());
+
for (Portlet portlet : portlets)
{
PortletContext context = portlet.getContext();
- String id = context.getId();
- assertTrue("foo.MyPortlet".equals(id) ||
(PortletInvoker.LOCAL_PORTLET_INVOKER_ID + ".MyLocalPortlet").equals(id));
+ assertTrue(REFERENCED_PORTLET.getId().equals(context.getId()) ||
REFERENCED_LOCAL_PORTLET.getId().equals(context.getId()));
}
}
@Test
public void testGetStatus() throws PortletInvokerException
{
- assertEquals(PortletStatus.OFFERED,
federatingInvoker.getStatus(PortletContext.createPortletContext("foo.MyPortlet")));
- assertEquals(PortletStatus.OFFERED,
federatingInvoker.getStatus(PortletContext.createPortletContext(PortletInvoker.LOCAL_PORTLET_INVOKER_ID
+ ".MyLocalPortlet")));
+ assertEquals(PortletStatus.OFFERED,
federatingInvoker.getStatus(REFERENCED_PORTLET));
+ assertEquals(PortletStatus.OFFERED,
federatingInvoker.getStatus(REFERENCED_LOCAL_PORTLET));
- assertEquals(PortletStatus.OFFERED,
federatedInvoker.getStatus(PortletContext.createPortletContext("foo.MyPortlet")));
- assertEquals(PortletStatus.OFFERED,
localInvoker.getStatus(PortletContext.createPortletContext(PortletInvoker.LOCAL_PORTLET_INVOKER_ID
+ ".MyLocalPortlet")));
+ assertEquals(PortletStatus.OFFERED,
federatedInvoker.getStatus(REFERENCED_PORTLET));
+ assertEquals(PortletStatus.OFFERED,
localInvoker.getStatus(REFERENCED_LOCAL_PORTLET));
}
@Test
@@ -133,9 +139,9 @@
assertNotNull(federateds);
assertEquals(2, federateds.size());
- FederatedPortletInvoker federated =
federatingInvoker.getFederatedInvoker("foo");
+ FederatedPortletInvoker federated =
federatingInvoker.getFederatedInvoker(INVOKER_ID);
assertNotNull(federated);
- assertEquals("foo", federated.getId());
+ assertEquals(INVOKER_ID, federated.getId());
assertEquals(federatedInvoker, federated);
assertEquals(federatedInvokerDelegate, federated.getPortletInvoker());
@@ -189,7 +195,7 @@
assertEquals(1, localPortlets.size());
Portlet localPortlet = localPortlets.iterator().next();
assertNotNull(localPortlet);
- assertEquals("local.MyLocalPortlet", localPortlet.getContext().getId());
+ assertEquals(REFERENCED_LOCAL_PORTLET, localPortlet.getContext());
}
@Test
@@ -199,7 +205,7 @@
assertEquals(1, portlets.size());
Portlet portlet = portlets.iterator().next();
assertNotNull(portlet);
- assertEquals("foo.MyPortlet", portlet.getContext().getId());
+ assertEquals(REFERENCED_PORTLET, portlet.getContext());
}
@Test
@@ -209,10 +215,12 @@
final TestFederatedPortletInvoker remote = new TestFederatedPortletInvoker();
PortletInfoSupport remoteInfo = new PortletInfoSupport();
remoteInfo.getMeta().setDisplayName("RemotePortlet");
- Portlet portlet = remote.addPortlet("RemotePortlet", remoteInfo);
+ final PortletContext context =
PortletContext.createPortletContext("/app.RemotePortlet");
+ Portlet portlet = remote.addPortlet(context.getId(), remoteInfo);
// this invoker is not registered
- assertNull(federatingInvoker.getFederatedInvoker("inexistent"));
+ final String federatedId = "inexistent";
+ assertNull(federatingInvoker.getFederatedInvoker(federatedId));
federatingInvoker.setNullInvokerHandler(new NullInvokerHandler()
{
@@ -223,7 +231,8 @@
}
});
- assertEquals(portlet,
federatingInvoker.getPortlet(PortletContext.createPortletContext("inexistent.RemotePortlet")));
+ assertEquals(portlet,
federatingInvoker.getPortlet(PortletContext.createPortletContext(federatedId +
FederatingPortletInvokerService.SEPARATOR + context.getId())));
+ assertEquals(portlet,
federatingInvoker.getPortlet(FederatingPortletInvokerService.reference(context,
federatedId)));
}
private class TestFederatedPortletInvoker extends PortletInvokerSupport implements
FederatedPortletInvoker
@@ -239,9 +248,9 @@
{
// fake dereferencing of compound portlet id
String portletId = portletContext.getId();
- if (portletId.startsWith(getId() + "."))
+ if (portletId.startsWith(getId() + FederatingPortletInvokerService.SEPARATOR))
{
- return
super.getPortlet(PortletContext.createPortletContext(portletId.substring(portletId.indexOf('.')
+ 1)));
+ return
super.getPortlet(PortletContext.createPortletContext(portletId.substring(portletId.indexOf(FederatingPortletInvokerService.SEPARATOR)
+ 1)));
}
else
{
Modified:
components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java
===================================================================
---
components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java 2011-04-08
10:03:03 UTC (rev 6182)
+++
components/pc/trunk/portlet/src/test/java/org/gatein/pc/portlet/support/PortletInvokerSupport.java 2011-04-08
10:38:06 UTC (rev 6183)
@@ -1,25 +1,25 @@
-/******************************************************************************
- * 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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.pc.portlet.support;
import org.gatein.pc.api.InvalidPortletIdException;
@@ -52,6 +52,8 @@
public class PortletInvokerSupport implements PortletInvoker
{
+ public static final String FOO_PORTLET_ID = "/webapp1.foo";
+ public static final String BAR_PORTLET_ID = "/webapp2.bar";
/** . */
private Map<String, PortletSupport> portlets;