Author: chris.laprun(a)jboss.com
Date: 2007-06-12 22:40:16 -0400 (Tue, 12 Jun 2007)
New Revision: 7410
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/InitCookieFakerHandler.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
trunk/wsrp/src/resources/tests/test-wsrp-consumer-client/META-INF/application-client.xml
Log:
- Fixed MarkupTestCase.testInitCookie:
+ Introduced InitCookieFakerHandler to simulate cookie setting which wasn't working
due to RMI invocation instead of HTTP of the web service.
+ Fixed MarkupTestCase so that the session is properly kept between invocation
(createRenderInvocation used to create a new MockHttpSession on each call).
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/InitCookieFakerHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/InitCookieFakerHandler.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/InitCookieFakerHandler.java 2007-06-13
02:40:16 UTC (rev 7410)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.jboss.portal.test.wsrp.framework;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.handler.GenericHandler;
+import javax.xml.rpc.handler.MessageContext;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class InitCookieFakerHandler extends GenericHandler
+{
+ public QName[] getHeaders()
+ {
+ return null;
+ }
+
+ public boolean handleResponse(MessageContext msgContext)
+ {
+ SOAPMessageContext smc = (SOAPMessageContext)msgContext;
+ SOAPMessage message = smc.getMessage();
+ try
+ {
+ SOAPBody body = message.getSOAPBody();
+ String messageType = body.getFirstChild().getLocalName();
+
+ if (!"initCookieResponse".equals(messageType))
+ {
+ // only process if we're returning from initCookie
+ return super.handleResponse(msgContext);
+ }
+ }
+ catch (SOAPException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings |
File Templates.
+ }
+
+ MimeHeaders mimeHeaders = message.getMimeHeaders();
+ mimeHeaders.setHeader("Set-Cookie", "value");
+
+ return super.handleResponse(msgContext);
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/InitCookieFakerHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2007-06-13
00:42:44 UTC (rev 7409)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2007-06-13
02:40:16 UTC (rev 7410)
@@ -68,12 +68,6 @@
import org.jboss.portal.wsrp.producer.config.ProducerConfiguration;
import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.rpc.ServiceException;
-import javax.xml.rpc.handler.MessageContext;
-import javax.xml.rpc.server.ServiceLifecycle;
-import javax.xml.rpc.server.ServletEndpointContext;
import java.rmi.RemoteException;
/**
@@ -85,7 +79,7 @@
* @version $Revision$
* @since 2.4
*/
-public class TestWSRPProducerImpl extends AbstractJBossService implements
TestWSRPProducer, ServiceLifecycle
+public class TestWSRPProducerImpl extends AbstractJBossService implements
TestWSRPProducer
{
private int sessionExpirationTime = DEFAULT_SESSION_EXPIRATION_TIME;
@@ -95,18 +89,11 @@
public static final String USER_COOKIE = "cookie";
- private ServletEndpointContext context;
-
public TestWSRPProducerImpl()
{
reset();
}
- public void init(Object context) throws ServiceException
- {
- this.context = (ServletEndpointContext)context;
- }
-
public BehaviorRegistry getBehaviorRegistry()
{
return behaviorRegistry;
@@ -180,10 +167,6 @@
throw new OperationFailedFault();
}
- MessageContext msgContext = context.getMessageContext();
- HttpServletResponse res =
(HttpServletResponse)msgContext.getProperty("javax.xml.ws.servlet.response");
- res.addCookie(new Cookie("name", "value"));
-
return null;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2007-06-13
00:42:44 UTC (rev 7409)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2007-06-13
02:40:16 UTC (rev 7410)
@@ -146,7 +146,7 @@
// now require cookie initialization and check that everything went well
producer.setRequiresInitCookie(CookieProtocol.perUser);
- render = createRenderInvocation(InitCookieMarkupBehavior.PORTLET_HANDLE);
+ render = createRenderInvocation(InitCookieMarkupBehavior.PORTLET_HANDLE,
invocationContext);
consumer.invoke(render);
@@ -186,14 +186,27 @@
private RenderInvocation createRenderInvocation(String portletHandle)
{
- return createRenderInvocation(portletHandle, Mode.VIEW, WindowState.MAXIMIZED,
null);
+ return createRenderInvocation(portletHandle, null);
}
+ private RenderInvocation createRenderInvocation(String portletHandle,
TestPortletInvocationContext invocationContext)
+ {
+ return createRenderInvocation(portletHandle, Mode.VIEW, WindowState.MAXIMIZED,
null, invocationContext);
+ }
+
private RenderInvocation createRenderInvocation(String portletHandle, Mode mode,
WindowState state, String navigationalState)
{
- TestPortletInvocationContext rc = new TestPortletInvocationContext(mode, state,
navigationalState);
+ return createRenderInvocation(portletHandle, mode, state, navigationalState,
null);
+ }
- RenderInvocation render = new RenderInvocation(rc);
+ private RenderInvocation createRenderInvocation(String portletHandle, Mode mode,
WindowState state, String navigationalState, TestPortletInvocationContext
invocationContext)
+ {
+ if (invocationContext == null)
+ {
+ invocationContext = new TestPortletInvocationContext(mode, state,
navigationalState);
+ }
+
+ RenderInvocation render = new RenderInvocation(invocationContext);
render.setTarget(PortletContext.createPortletContext(portletHandle));
render.setInstanceContext(new BasicInstanceContext(portletHandle));
Modified:
trunk/wsrp/src/resources/tests/test-wsrp-consumer-client/META-INF/application-client.xml
===================================================================
---
trunk/wsrp/src/resources/tests/test-wsrp-consumer-client/META-INF/application-client.xml 2007-06-13
00:42:44 UTC (rev 7409)
+++
trunk/wsrp/src/resources/tests/test-wsrp-consumer-client/META-INF/application-client.xml 2007-06-13
02:40:16 UTC (rev 7410)
@@ -37,10 +37,6 @@
<port-component-ref>
<service-endpoint-interface>org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType</service-endpoint-interface>
</port-component-ref>
- <handler>
- <handler-name>RequestHeaderHandler</handler-name>
-
<handler-class>org.jboss.portal.wsrp.handler.RequestHeaderClientHandler</handler-class>
- </handler>
</service-ref>
<service-ref>
@@ -55,6 +51,11 @@
<handler-name>RequestHeaderHandler</handler-name>
<handler-class>org.jboss.portal.wsrp.handler.RequestHeaderClientHandler</handler-class>
</handler>
+ <!-- Added to fake Cookie setting by producer... -->
+ <handler>
+ <handler-name>InitCookieFakerHandler</handler-name>
+
<handler-class>org.jboss.portal.test.wsrp.framework.InitCookieFakerHandler</handler-class>
+ </handler>
</service-ref>
<service-ref>
@@ -65,10 +66,6 @@
<port-component-ref>
<service-endpoint-interface>org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType</service-endpoint-interface>
</port-component-ref>
- <handler>
- <handler-name>RequestHeaderHandler</handler-name>
-
<handler-class>org.jboss.portal.wsrp.handler.RequestHeaderClientHandler</handler-class>
- </handler>
</service-ref>
<service-ref>
@@ -79,9 +76,5 @@
<port-component-ref>
<service-endpoint-interface>org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType</service-endpoint-interface>
</port-component-ref>
- <handler>
- <handler-name>RequestHeaderHandler</handler-name>
-
<handler-class>org.jboss.portal.wsrp.handler.RequestHeaderClientHandler</handler-class>
- </handler>
</service-ref>
</application-client>