Author: richard.opalka(a)jboss.com
Date: 2010-04-07 06:52:08 -0400 (Wed, 07 Apr 2010)
New Revision: 11951
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/Endpoint.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/EndpointImpl.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/JBWS2982TestCase.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/web.xml
Removed:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/Endpoint.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/EndpointImpl.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/JBWS2982TestCase.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/web.xml
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
Log:
[JBPAPP-4063] fixing MessageContext.HTTP_*_HEADERS propagation
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2010-04-07
10:05:46 UTC (rev 11950)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2010-04-07
10:52:08 UTC (rev 11951)
@@ -350,10 +350,14 @@
EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress,
callProps);
if (shouldMaintainSession())
addSessionInfo(reqMessage, callProps);
+
+ propagateRequestHeaders(reqMessage, getRequestContext());
RemoteConnection remoteConnection = new
RemoteConnectionFactory().getRemoteConnection(epInfo);
MessageAbstraction resMessage = remoteConnection.invoke(reqMessage, epInfo,
oneway);
+ propagateResponseHeaders(callProps, getRequestContext());
+
if (shouldMaintainSession())
saveSessionInfo(callProps, getRequestContext());
@@ -435,6 +439,11 @@
closeHandlerChain(portName, handlerType[0]);
}
}
+
+ private void propagateResponseHeaders(Map<String, Object> remotingMetadata,
Map<String, Object> responseContext)
+ {
+ responseContext.put(MessageContext.HTTP_RESPONSE_HEADERS,
remotingMetadata.get("ResponseHeaders"));
+ }
private void saveSessionInfo(Map<String, Object> remotingMetadata,
Map<String, Object> requestContext)
{
@@ -485,6 +494,34 @@
}
}
}
+
+ private void propagateRequestHeaders(MessageAbstraction reqMessage, Map<String,
Object> callProperties)
+ {
+ Map<String, List<String>> requestHeaders = (Map<String,
List<String>>)callProperties.get(MessageContext.HTTP_REQUEST_HEADERS);
+ if (requestHeaders != null)
+ {
+ for (Map.Entry<String, List<String>> header :
requestHeaders.entrySet())
+ {
+ final String key = header.getKey();
+ final List<String> values = header.getValue();
+
+ if (key != null)
+ {
+ final StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < values.size(); i++)
+ {
+ boolean addLWS = (i != (values.size() - 1));
+ sb.append(values.get(i));
+ if (addLWS)
+ {
+ sb.append("\r\n ");
+ }
+ }
+ reqMessage.getMimeHeaders().addHeader(key, sb.toString());
+ }
+ }
+ }
+ }
private CommonMessageContext processPivotInternal(CommonMessageContext msgContext,
DirectionHolder direction)
{
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2010-04-07
10:05:46 UTC (rev 11950)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2010-04-07
10:52:08 UTC (rev 11951)
@@ -662,6 +662,14 @@
</webinf>
</war>
+ <!-- jaxws-jbws2982 -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-jbws2982.war"
webxml="${tests.output.dir}/test-resources/jaxws/jbws2982/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2982/*.class" />
+ <exclude name="org/jboss/test/ws/jaxws/jbws2982/*TestCase*.class"
/>
+ </classes>
+ </war>
+
<!-- jaxws-webserviceref -->
<war warfile="${tests.output.dir}/test-libs/jaxws-webserviceref.war"
webxml="${tests.output.dir}/test-resources/jaxws/webserviceref/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982
(from rev 11949,
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982)
Deleted:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/Endpoint.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/Endpoint.java 2010-04-07
10:01:01 UTC (rev 11949)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/Endpoint.java 2010-04-07
10:52:08 UTC (rev 11951)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.test.ws.jaxws.jbws2982;
-
-import javax.jws.WebMethod;
-import javax.jws.WebService;
-
-/**
- * Endpoint interface.
- *
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-@WebService(name="Endpoint",
targetNamespace="http://jboss.org/jbws2982")
-public interface Endpoint
-{
- @WebMethod
- public int getRequestParameter(String key);
-}
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/Endpoint.java
(from rev 11949,
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/Endpoint.java)
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/Endpoint.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/Endpoint.java 2010-04-07
10:52:08 UTC (rev 11951)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ws.jaxws.jbws2982;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+/**
+ * Endpoint interface.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+@WebService(name="Endpoint",
targetNamespace="http://jboss.org/jbws2982")
+public interface Endpoint
+{
+ @WebMethod
+ public int getRequestParameter(String key);
+}
Deleted:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/EndpointImpl.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/EndpointImpl.java 2010-04-07
10:01:01 UTC (rev 11949)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/EndpointImpl.java 2010-04-07
10:52:08 UTC (rev 11951)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.test.ws.jaxws.jbws2982;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.jws.WebMethod;
-import javax.jws.WebService;
-import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.handler.MessageContext;
-
-/**
- * Endpoint implementation.
- *
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-@WebService
-(
- name = "Endpoint",
- serviceName = "EndpointService",
-
targetNamespace="http://jboss.org/jbws2982",
- endpointInterface="org.jboss.test.ws.jaxws.jbws2982.Endpoint"
-)
-public class EndpointImpl implements Endpoint
-{
- @Resource
- WebServiceContext ctx;
-
- private int getRequestParameterInternal(String key)
- {
- int ctxValue = this.getValue(this.ctx, key);
-
- return ++ctxValue;
- }
-
- private int getValue(WebServiceContext wsCtx, String paramKey)
- {
- Map<String, List<String>> requestHeaders = (Map<String,
List<String>>)wsCtx.getMessageContext().get(MessageContext.HTTP_REQUEST_HEADERS);
-
- return Integer.valueOf(requestHeaders.get("extension-header").get(0));
- }
-
- @WebMethod
- public int getRequestParameter(String key)
- {
- return this.getRequestParameterInternal(key);
- }
-}
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/EndpointImpl.java
(from rev 11949,
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/EndpointImpl.java)
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/EndpointImpl.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/EndpointImpl.java 2010-04-07
10:52:08 UTC (rev 11951)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ws.jaxws.jbws2982;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+/**
+ * Endpoint implementation.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+@WebService
+(
+ name = "Endpoint",
+ serviceName = "EndpointService",
+
targetNamespace="http://jboss.org/jbws2982",
+ endpointInterface="org.jboss.test.ws.jaxws.jbws2982.Endpoint"
+)
+public class EndpointImpl implements Endpoint
+{
+ @Resource
+ WebServiceContext ctx;
+
+ private int getRequestParameterInternal(String key)
+ {
+ int ctxValue = this.getValue(this.ctx, key);
+
+ return ++ctxValue;
+ }
+
+ private int getValue(WebServiceContext wsCtx, String paramKey)
+ {
+ Map<String, List<String>> requestHeaders = (Map<String,
List<String>>)wsCtx.getMessageContext().get(MessageContext.HTTP_REQUEST_HEADERS);
+
+ return Integer.valueOf(requestHeaders.get("extension-header").get(0));
+ }
+
+ @WebMethod
+ public int getRequestParameter(String key)
+ {
+ return this.getRequestParameterInternal(key);
+ }
+}
Deleted:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/JBWS2982TestCase.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/JBWS2982TestCase.java 2010-04-07
10:01:01 UTC (rev 11949)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/JBWS2982TestCase.java 2010-04-07
10:52:08 UTC (rev 11951)
@@ -1,162 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.test.ws.jaxws.jbws2982;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Service;
-import javax.xml.ws.handler.MessageContext;
-
-import junit.framework.Test;
-
-import org.jboss.logging.Logger;
-import org.jboss.wsf.test.JBossWSTest;
-import org.jboss.wsf.test.JBossWSTestSetup;
-
-/**
- * [JBWS-2982] Native ignores user specified MessageContext.HTTP_REQUEST_HEADERS
- *
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-public final class JBWS2982TestCase extends JBossWSTest
-{
- public static Test suite()
- {
- return new JBossWSTestSetup(JBWS2982TestCase.class,
"jaxws-jbws2982.war");
- }
- private static final int THREADS_COUNT = 5;
- private static final int REQUESTS_COUNT = 5;
- private static final String ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-jbws2982";
- private final Endpoint[] proxies = new Endpoint[THREADS_COUNT];
- private final Thread[] threads = new Thread[THREADS_COUNT];
- private final TestJob[] jobs = new TestJob[THREADS_COUNT];
- private final Logger log = Logger.getLogger(this.getClass());
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- QName serviceName = new
QName("http://jboss.org/jbws2982",
"EndpointService");
- URL wsdlURL = new URL(ENDPOINT_ADDRESS + "?wsdl");
-
- Service service = Service.create(wsdlURL, serviceName);
- for (int i = 0; i < THREADS_COUNT; i++)
- proxies[i] = service.getPort(Endpoint.class);
- }
-
- public void testEndpointConcurrently() throws Exception
- {
- for (int i = 0; i < THREADS_COUNT; i++)
- {
- log.debug("Creating thread " + (i + 1));
- jobs[i] = new TestJob(proxies[i], REQUESTS_COUNT, "TestJob" + i);
- threads[i] = new Thread(jobs[i]);
- }
- for (int i = 0; i < THREADS_COUNT; i++)
- {
- log.debug("Starting thread " + (i + 1));
- threads[i].start();
- }
- Exception e = null;
- for (int i = 0; i < THREADS_COUNT; i++)
- {
- log.debug("Joining thread " + (i + 1));
- threads[i].join();
- if (e == null)
- e = jobs[i].getException();
- }
- if (e != null) throw e;
- }
-
- private static final class TestJob implements Runnable
- {
- private final String jobName;
- private final Endpoint proxy;
- private final int countOfRequests;
- private Exception exception;
- private static final Logger log = Logger.getLogger(TestJob.class);
-
- TestJob(Endpoint proxy, int countOfRequests, String jobName)
- {
- this.proxy = proxy;
- this.countOfRequests = countOfRequests;
- this.jobName = jobName;
- }
-
- public void run()
- {
- try
- {
- for (int i = 0; i < this.countOfRequests; i++)
- {
- this.setRequestParameter(proxy, i);
- int retVal = proxy.getRequestParameter(jobName);
- log.debug("Thread=" + this.jobName + ", iteration=" +
i);
- if (retVal != (i + 1))
- throw new RuntimeException("Thread=" + this.jobName + ",
iteration=" + i + ", received=" + retVal);
- assertNotNull(this.getResponseHeaders(proxy));
- }
- }
- catch (Exception e)
- {
- log.error("Exception caught: " + e.getMessage());
- this.exception = e;
- }
- }
-
- @SuppressWarnings("unchecked")
- private Map<String, List<String>> getResponseHeaders(Endpoint proxy)
- {
- BindingProvider bp = (BindingProvider)proxy;
-
- return (Map<String,
List<String>>)bp.getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
- }
-
- @SuppressWarnings("unchecked")
- private void setRequestParameter(Endpoint proxy, int value)
- {
- BindingProvider bp = (BindingProvider)proxy;
-
- Map<String, List<String>> requestHeaders = (Map<String,
List<String>>)bp.getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);
- if (requestHeaders == null)
- {
- requestHeaders = new HashMap<String, List<String>>();
- }
- List<String> encodedValue = new LinkedList<String>();
- encodedValue.add(String.valueOf(value));
- requestHeaders.put("extension-header", encodedValue);
- bp.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
requestHeaders);
- }
-
- Exception getException()
- {
- return this.exception;
- }
- }
-}
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/JBWS2982TestCase.java
(from rev 11949,
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/JBWS2982TestCase.java)
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/JBWS2982TestCase.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2982/JBWS2982TestCase.java 2010-04-07
10:52:08 UTC (rev 11951)
@@ -0,0 +1,161 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ws.jaxws.jbws2982;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import javax.xml.ws.handler.MessageContext;
+
+import junit.framework.Test;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * [JBWS-2982] Native ignores user specified MessageContext.HTTP_REQUEST_HEADERS
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class JBWS2982TestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(JBWS2982TestCase.class,
"jaxws-jbws2982.war");
+ }
+ private static final int THREADS_COUNT = 1;
+ private static final int REQUESTS_COUNT = 1;
+ private final Endpoint[] proxies = new Endpoint[THREADS_COUNT];
+ private final Thread[] threads = new Thread[THREADS_COUNT];
+ private final TestJob[] jobs = new TestJob[THREADS_COUNT];
+ private final Logger log = Logger.getLogger(this.getClass());
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ QName serviceName = new
QName("http://jboss.org/jbws2982",
"EndpointService");
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-jbws2982" + "?wsdl");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ for (int i = 0; i < THREADS_COUNT; i++)
+ proxies[i] = service.getPort(Endpoint.class);
+ }
+
+ public void testEndpointConcurrently() throws Exception
+ {
+ for (int i = 0; i < THREADS_COUNT; i++)
+ {
+ log.debug("Creating thread " + (i + 1));
+ jobs[i] = new TestJob(proxies[i], REQUESTS_COUNT, "TestJob" + i);
+ threads[i] = new Thread(jobs[i]);
+ }
+ for (int i = 0; i < THREADS_COUNT; i++)
+ {
+ log.debug("Starting thread " + (i + 1));
+ threads[i].start();
+ }
+ Exception e = null;
+ for (int i = 0; i < THREADS_COUNT; i++)
+ {
+ log.debug("Joining thread " + (i + 1));
+ threads[i].join();
+ if (e == null)
+ e = jobs[i].getException();
+ }
+ if (e != null) throw e;
+ }
+
+ private static final class TestJob implements Runnable
+ {
+ private final String jobName;
+ private final Endpoint proxy;
+ private final int countOfRequests;
+ private Exception exception;
+ private static final Logger log = Logger.getLogger(TestJob.class);
+
+ TestJob(Endpoint proxy, int countOfRequests, String jobName)
+ {
+ this.proxy = proxy;
+ this.countOfRequests = countOfRequests;
+ this.jobName = jobName;
+ }
+
+ public void run()
+ {
+ try
+ {
+ for (int i = 0; i < this.countOfRequests; i++)
+ {
+ this.setRequestParameter(proxy, i);
+ int retVal = proxy.getRequestParameter(jobName);
+ log.debug("Thread=" + this.jobName + ", iteration=" +
i);
+ if (retVal != (i + 1))
+ throw new RuntimeException("Thread=" + this.jobName + ",
iteration=" + i + ", received=" + retVal);
+ assertNotNull(this.getResponseHeaders(proxy));
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Exception caught: " + e.getMessage());
+ this.exception = e;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private Map<String, List<String>> getResponseHeaders(Endpoint proxy)
+ {
+ BindingProvider bp = (BindingProvider)proxy;
+
+ return (Map<String,
List<String>>)bp.getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void setRequestParameter(Endpoint proxy, int value)
+ {
+ BindingProvider bp = (BindingProvider)proxy;
+
+ Map<String, List<String>> requestHeaders = (Map<String,
List<String>>)bp.getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);
+ if (requestHeaders == null)
+ {
+ requestHeaders = new HashMap<String, List<String>>();
+ }
+ List<String> encodedValue = new LinkedList<String>();
+ encodedValue.add(String.valueOf(value));
+ requestHeaders.put("extension-header", encodedValue);
+ bp.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
requestHeaders);
+ }
+
+ Exception getException()
+ {
+ return this.exception;
+ }
+ }
+}
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982
(from rev 11949,
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982)
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF
(from rev 11949,
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF)
Deleted:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/web.xml
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/web.xml 2010-04-07
10:01:01 UTC (rev 11949)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/web.xml 2010-04-07
10:52:08 UTC (rev 11951)
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
-
- <servlet>
- <servlet-name>TestEndpoint</servlet-name>
-
<servlet-class>org.jboss.test.ws.jaxws.jbws2982.EndpointImpl</servlet-class>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>TestEndpoint</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
-
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/web.xml
(from rev 11949,
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/web.xml)
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/web.xml
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2982/WEB-INF/web.xml 2010-04-07
10:52:08 UTC (rev 11951)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+
+ <servlet>
+ <servlet-name>TestEndpoint</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.jbws2982.EndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestEndpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+