You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ga...@apache.org on 2010/06/25 21:00:38 UTC
svn commit: r958078 - in
/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws:
client/CustomHTTPHeaderTests.java
sample/addnumbers/AddNumbersPortTypeImpl.java
Author: gawor
Date: Fri Jun 25 19:00:37 2010
New Revision: 958078
URL: http://svn.apache.org/viewvc?rev=958078&view=rev
Log:
just a test for passing custom http headers
Added:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/CustomHTTPHeaderTests.java (with props)
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbers/AddNumbersPortTypeImpl.java
Added: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/CustomHTTPHeaderTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/CustomHTTPHeaderTests.java?rev=958078&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/CustomHTTPHeaderTests.java (added)
+++ axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/CustomHTTPHeaderTests.java Fri Jun 25 19:00:37 2010
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.client;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.handler.MessageContext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.axis2.jaxws.framework.AbstractTestCase;
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersPortType;
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersService;
+
+public class CustomHTTPHeaderTests extends AbstractTestCase {
+
+ String axisEndpoint = "http://localhost:6060/axis2/services/AddNumbersService.AddNumbersPortTypeImplPort";
+
+ public static Test suite() {
+ return getTestSetup(new TestSuite(CustomHTTPHeaderTests.class));
+ }
+
+ public void testPort() throws Exception {
+ Map<String, List<String>> headers = new HashMap<String, List<String>>();
+ headers.put("MY_HEADER_1", Collections.singletonList("hello"));
+ // headers.put("MY_HEADER_2", Arrays.asList("value1", "value2"));
+
+ AddNumbersService service = new AddNumbersService();
+ AddNumbersPortType port = service.getAddNumbersPort();
+
+ BindingProvider p = (BindingProvider) port;
+
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ p.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers);
+
+ assertEquals(777, port.addNumbers(333, 444));
+ }
+}
Propchange: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/CustomHTTPHeaderTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/CustomHTTPHeaderTests.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/CustomHTTPHeaderTests.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbers/AddNumbersPortTypeImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbers/AddNumbersPortTypeImpl.java?rev=958078&r1=958077&r2=958078&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbers/AddNumbersPortTypeImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbers/AddNumbersPortTypeImpl.java Fri Jun 25 19:00:37 2010
@@ -25,6 +25,8 @@ import javax.annotation.Resource;
import javax.jws.WebService;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
+
+import java.util.List;
import java.util.Map;
@@ -40,18 +42,44 @@ public class AddNumbersPortTypeImpl impl
public int addNumbers(int arg0, int arg1) throws AddNumbersFault_Exception {
TestLogger.logger.debug(">> Received addNumbers request for " + arg0 + " and " + arg1);
- checkProperties();
+ checkProperties(arg0, arg1);
return arg0+arg1;
}
- private void checkProperties() {
+ private void checkProperties(int arg0, int arg1) {
MessageContext mc = ctx.getMessageContext();
Map headers = (Map)mc.get(MessageContext.HTTP_REQUEST_HEADERS);
+
// the map should contain some headers
if (headers == null || headers.isEmpty()) {
throw new RuntimeException("HTTP request headers map is null or empty!");
}
+
+ // check for custom http headers
+ if (arg0 == 333 && arg1 == 444) {
+ List<String> values;
+
+ // test MY_HEADER_1
+ values = (List<String>) headers.get("MY_HEADER_1");
+ if (values == null || headers.isEmpty()) {
+ throw new RuntimeException("No values for MY_HEADER_1 HTTP header");
+ }
+ if (!values.contains("hello")) {
+ throw new RuntimeException("MY_HEADER_1 HTTP header does not contain expected value: " + values);
+ }
+
+ /*
+ // test MY_HEADER_2
+ values = (List<String>) headers.get("MY_HEADER_2");
+ if (values == null || headers.isEmpty()) {
+ throw new RuntimeException("No values for MY_HEADER_2 HTTP header");
+ }
+ if (!values.contains("values1") && !values.contains("values2")) {
+ throw new RuntimeException("MY_HEADER_2 HTTP header does not contain expected values: " + values);
+ }
+ */
+ }
}
/* (non-Javadoc)