servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r797309 - in /servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse: CxfSeContextInjectionTest.java GreeterImpl.java
Date Fri, 24 Jul 2009 02:40:02 GMT
Author: ffang
Date: Fri Jul 24 02:40:02 2009
New Revision: 797309

URL: http://svn.apache.org/viewvc?rev=797309&view=rev
Log:
[SMXCOMP-593]cxf se should be able to use the injected WebServiceContext to get/set in/out
properties from/to JBI message

Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java?rev=797309&r1=797308&r2=797309&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java
Fri Jul 24 02:40:02 2009
@@ -102,6 +102,27 @@
         client.sendSync(io);
         assertNull(io.getMessage("out"));
     }
+    
+    public void testWebServiceContextInjection() throws Exception {
+        LOG.info("test WebServiceContext Injection");
+        client = new DefaultServiceMixClient(jbi);
+        io = client.createInOutExchange();
+        io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPService"));
+        io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
+        io.setOperation(new QName("http://apache.org/hello_world_soap_http", "greetMe"));
+        io.getMessage("in").setContent(new StringSource(
+                "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+              + "<part> "
+              + "<greetMe xmlns='http://apache.org/hello_world_soap_http/types'><requestType>"
+              + "WebServiceContext"
+              + "</requestType></greetMe>"
+              + "</part> "
+              + "</message>"));
+        io.getMessage("in").setProperty("test-property", "Hello ");
+        client.sendSync(io);
+        assertEquals("Hello ffang", io.getMessage("out").getProperty("test-property"));
+        client.done(io);
+    }
 
     @Override
     protected AbstractXmlApplicationContext createBeanFactory() {

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java?rev=797309&r1=797308&r2=797309&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java
Fri Jul 24 02:40:02 2009
@@ -17,7 +17,7 @@
 package org.apache.servicemix.cxfse;
 
 import java.util.concurrent.Future;
-
+import javax.annotation.Resource;
 import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
 import javax.jbi.messaging.InOut;
@@ -26,7 +26,10 @@
 import javax.xml.namespace.QName;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Response;
-
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+import org.apache.cxf.jaxws.context.WrappedMessageContext;
+import org.apache.cxf.message.Message;
 import org.apache.hello_world_soap_http.BadRecordLitFault;
 import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.NoSuchCodeLitFault;
@@ -46,8 +49,14 @@
         targetNamespace = "http://apache.org/hello_world_soap_http")
 public class GreeterImpl implements Greeter {
 
+    @Resource
+    private WebServiceContext wsContext;
     private ComponentContext context;
     public String greetMe(String me) {
+        if ("WebServiceContext".equals(me)) {
+            testWebServiceContext();
+        }
+
         try {
             
             // here use client api to test the injected context to invoke another endpoint
@@ -83,7 +92,13 @@
     public void setContext(ComponentContext context) {
         this.context = context;
     }
-
+   
+    private void testWebServiceContext() {
+        MessageContext ctx = wsContext.getMessageContext();
+        Message message = ((WrappedMessageContext) ctx).getWrappedMessage();
+        String testProperty = (String) message.get("test-property");
+        message.put("test-property", testProperty + "ffang");
+    }
     public Response<GreetMeResponse> greetMeAsync(String arg0) {
         return null;
     }



Mime
View raw message