servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r797312 - in /servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse: CxfSeContextInjectionTest.java GreeterImpl.java
Date Fri, 24 Jul 2009 02:51:37 GMT
Author: ffang
Date: Fri Jul 24 02:51:37 2009
New Revision: 797312

URL: http://svn.apache.org/viewvc?rev=797312&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/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java
    servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java

Modified: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java?rev=797312&r1=797311&r2=797312&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java
(original)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeContextInjectionTest.java
Fri Jul 24 02:51:37 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/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java?rev=797312&r1=797311&r2=797312&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java
(original)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImpl.java
Fri Jul 24 02:51:37 2009
@@ -19,6 +19,7 @@
 
 import java.util.concurrent.Future;
 
+import javax.annotation.Resource;
 import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
 import javax.jbi.messaging.InOut;
@@ -27,7 +28,11 @@
 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,10 +51,16 @@
         endpointInterface = "org.apache.hello_world_soap_http.Greeter", 
         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();
+        }
         String txt = null;
         try {
             
@@ -80,6 +91,13 @@
         return txt;
     }
     
+    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 String greetMeLater(long later) {
         return "test";
     }



Mime
View raw message