cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1038498 - in /cxf/branches/2.2.x-fixes: common/common/src/main/java/org/apache/cxf/helpers/ systests/transports/src/test/java/org/apache/cxf/systest/jms/
Date Wed, 24 Nov 2010 06:41:57 GMT
Author: ffang
Date: Wed Nov 24 06:41:56 2010
New Revision: 1038498

URL: http://svn.apache.org/viewvc?rev=1038498&view=rev
Log:
[CXF-3146]make gzip encoding works over jms transport

Added:
    cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/GzipServer.java
    cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerGzipTest.java
    cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/gzipBus.xml
Modified:
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java?rev=1038498&r1=1038497&r2=1038498&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
Wed Nov 24 06:41:56 2010
@@ -64,7 +64,11 @@ public final class HttpHeaderHelper {
     }
     
     public static List<String> getHeader(Map<String, List<String>> headerMap,
String key) {
-        return headerMap.get(getHeaderKey(key));
+        if (headerMap.get(getHeaderKey(key)) != null) {
+            return headerMap.get(getHeaderKey(key));
+        } else {
+            return headerMap.get(key);
+        }
     }
     
     public static String getHeaderKey(String key) {

Added: cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/GzipServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/GzipServer.java?rev=1038498&view=auto
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/GzipServer.java
(added)
+++ cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/GzipServer.java
Wed Nov 24 06:41:56 2010
@@ -0,0 +1,54 @@
+/**
+ * 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.cxf.systest.jms;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
+
+
+public class GzipServer extends AbstractBusTestServerBase {
+    public static final String PORT = allocatePort(GzipServer.class);
+   
+    protected void run()  {
+        Object impleDoc = new GreeterImplDoc();
+        SpringBusFactory bf = new SpringBusFactory();
+        Bus bus = bf.createBus("org/apache/cxf/systest/jms/gzipBus.xml");
+        BusFactory.setDefaultBus(bus);
+        EmbeddedJMSBrokerLauncher.updateWsdlExtensors(bus, "testutils/hello_world_doc_lit.wsdl");
+        Endpoint.publish(null, impleDoc);
+    }
+
+
+    public static void main(String[] args) {
+        try {
+            GzipServer s = new GzipServer();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}

Added: cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerGzipTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerGzipTest.java?rev=1038498&view=auto
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerGzipTest.java
(added)
+++ cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerGzipTest.java
Wed Nov 24 06:41:56 2010
@@ -0,0 +1,142 @@
+/**
+ * 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.cxf.systest.jms;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
+import org.apache.cxf.transport.jms.AddressType;
+import org.apache.cxf.transport.jms.JMSNamingPropertyType;
+import org.apache.hello_world_doc_lit.Greeter;
+import org.apache.hello_world_doc_lit.PingMeFault;
+import org.apache.hello_world_doc_lit.SOAPService2;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JMSClientServerGzipTest extends AbstractBusClientServerTestBase {
+    static final String JMS_PORT = EmbeddedJMSBrokerLauncher.PORT;
+    static final String PORT = GzipServer.PORT;
+    
+    private String wsdlString;
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        Map<String, String> props = new HashMap<String, String>();          
     
+        if (System.getProperty("org.apache.activemq.default.directory.prefix") != null) {
+            props.put("org.apache.activemq.default.directory.prefix",
+                      System.getProperty("org.apache.activemq.default.directory.prefix"));
+        }
+        props.put("java.util.logging.config.file", 
+                  System.getProperty("java.util.logging.config.file"));
+        
+        assertTrue("server did not launch correctly", 
+                   launchServer(EmbeddedJMSBrokerLauncher.class, props, null));
+
+        assertTrue("server did not launch correctly", 
+                   launchServer(GzipServer.class));
+        
+    }
+    
+    public URL getWSDLURL(String s) throws Exception {
+        URL u = getClass().getResource(s);
+        wsdlString = u.toString().intern();
+        EmbeddedJMSBrokerLauncher.updateWsdlExtensors(getBus(), wsdlString);
+        System.gc();
+        System.gc();
+        return u;
+    }
+    public QName getServiceName(QName q) {
+        return q;
+    }
+    public QName getPortName(QName q) {
+        return q;
+    }
+    
+    @Test
+    public void testGzipEncodingWithJms() throws Exception {
+        SpringBusFactory bf = new SpringBusFactory();
+        Bus bus = bf.createBus("org/apache/cxf/systest/jms/gzipBus.xml");
+        BusFactory.setDefaultBus(bus);
+        QName serviceName = getServiceName(new QName("http://apache.org/hello_world_doc_lit",

+                                 "SOAPService2"));
+        QName portName = getPortName(new QName("http://apache.org/hello_world_doc_lit", "SoapPort2"));
+        URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
+        assertNotNull(wsdl);
+
+        SOAPService2 service = new SOAPService2(wsdl, serviceName);
+        assertNotNull(service);
+
+        String response1 = new String("Hello Milestone-");
+        String response2 = new String("Bonjour");
+        try {
+            Greeter greeter = service.getPort(portName, Greeter.class);
+            
+            Client client = ClientProxy.getClient(greeter);
+            EndpointInfo ei = client.getEndpoint().getEndpointInfo();
+            AddressType address = ei.getTraversedExtensor(new AddressType(), AddressType.class);
+            JMSNamingPropertyType name = new JMSNamingPropertyType();
+            JMSNamingPropertyType password = new JMSNamingPropertyType();
+            name.setName("java.naming.security.principal");
+            name.setValue("ivan");
+            password.setName("java.naming.security.credentials");
+            password.setValue("the-terrible");
+            address.getJMSNamingProperty().add(name);
+            address.getJMSNamingProperty().add(password);
+            for (int idx = 0; idx < 5; idx++) {
+
+                greeter.greetMeOneWay("test String");
+                
+                String greeting = greeter.greetMe("Milestone-" + idx);
+                assertNotNull("no response received from service", greeting);
+                String exResponse = response1 + idx;
+                assertEquals(exResponse, greeting);
+
+
+                
+                String reply = greeter.sayHi();
+                assertNotNull("no response received from service", reply);
+                assertEquals(response2, reply);
+                
+                try {
+                    greeter.pingMe();
+                    fail("Should have thrown FaultException");
+                } catch (PingMeFault ex) {
+                    assertNotNull(ex.getFaultInfo());
+                }                
+              
+            }
+        } catch (UndeclaredThrowableException ex) {
+            throw (Exception)ex.getCause();
+        }
+    }
+}

Added: cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/gzipBus.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/gzipBus.xml?rev=1038498&view=auto
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/gzipBus.xml
(added)
+++ cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/gzipBus.xml
Wed Nov 24 06:41:56 2010
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xmlns:cxf="http://cxf.apache.org/core"
+      xmlns:jms="http://cxf.apache.org/transports/jms"
+      xsi:schemaLocation="
+http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+
+
+    <cxf:bus>
+        <cxf:features>
+            <bean class="org.apache.cxf.feature.LoggingFeature"/>
+            <bean class="org.apache.cxf.transport.http.gzip.GZIPFeature">
+                <property name="threshold">
+                    <!-- set threshold as 10 byte to ensure gzip compress happen for short
test message-->
+                    <value>10</value>
+                </property>
+            </bean>
+        </cxf:features>
+    </cxf:bus> 
+    <jms:conduit name="{http://apache.org/hello_world_doc_lit}SoapPort2.jms-conduit">
+        <!--must use binary message format for gzip compress-->
+        <jms:runtimePolicy messageType="binary"/>
+    </jms:conduit>
+</beans>
+



Mime
View raw message