servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r410091 - in /incubator/servicemix/trunk/servicemix-components: ./ src/main/java/org/apache/servicemix/components/http/ src/main/java/org/apache/servicemix/components/saaj/ src/test/java/org/apache/servicemix/components/saaj/
Date Mon, 29 May 2006 12:53:51 GMT
Author: gnodet
Date: Mon May 29 05:53:51 2006
New Revision: 410091

URL: http://svn.apache.org/viewvc?rev=410091&view=rev
Log:
SMX-440: SAAJ Lightweight Component SOAPAction Incorrect

Added:
    incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajSoapActionTest.java
Modified:
    incubator/servicemix/trunk/servicemix-components/pom.xml
    incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpConnector.java
    incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajBinding.java
    incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajMarshaler.java
    incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajMarshalerTest.java

Modified: incubator/servicemix/trunk/servicemix-components/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-components/pom.xml?rev=410091&r1=410090&r2=410091&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/pom.xml (original)
+++ incubator/servicemix/trunk/servicemix-components/pom.xml Mon May 29 05:53:51 2006
@@ -188,11 +188,13 @@
       <artifactId>axis</artifactId>
       <scope>test</scope>
     </dependency>
+    <!--  
     <dependency>
       <groupId>net.java.dev.saaj</groupId>
       <artifactId>saaj-impl</artifactId>
       <scope>test</scope>
     </dependency>
+    -->
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
@@ -217,6 +219,7 @@
           <excludes>
             <!--  exclude abstract tests -->
             <exclude>**/Abstract*.*</exclude>
+            <exclude>**/*$*</exclude>
 
             <!--  Need external resources -->
             <exclude>**/Jabber*.*</exclude>

Modified: incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpConnector.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpConnector.java?rev=410091&r1=410090&r2=410091&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpConnector.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpConnector.java
Mon May 29 05:53:51 2006
@@ -135,6 +135,7 @@
      * shutdown
      */
     public void shutDown() throws JBIException {
+        super.shutDown();
         server = null;
     }
 

Modified: incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajBinding.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajBinding.java?rev=410091&r1=410090&r2=410091&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajBinding.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajBinding.java
Mon May 29 05:53:51 2006
@@ -15,6 +15,8 @@
  */
 package org.apache.servicemix.components.saaj;
 
+import java.io.ByteArrayOutputStream;
+
 import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessagingException;
@@ -86,19 +88,27 @@
 
             SOAPMessage inMessage = marshaler.createSOAPMessage(exchange.getMessage("in"));
             if (soapAction != null) {
-				MimeHeaders mh = inMessage.getMimeHeaders();
-				if (mh.getHeader("SOAPAction") == null) {
-					mh.addHeader("SOAPAction", "\"" + soapAction + "\"");
-					inMessage.saveChanges();
-				}
-			}
+                MimeHeaders mh = inMessage.getMimeHeaders();
+                if (mh.getHeader("SOAPAction") == null) {
+                    mh.addHeader("SOAPAction", soapAction);
+                    inMessage.saveChanges();
+                }
+            }
+
+            if (log.isDebugEnabled()) {
+                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+                inMessage.writeTo(buffer);
+                log.debug(new String(buffer.toByteArray()));
+            }
             
             SOAPMessage response = connection.call(inMessage, soapEndpoint);
-
-            NormalizedMessage outMessage = exchange.createMessage();
-            marshaler.toNMS(outMessage, response);
-
-            answer(exchange, outMessage);
+            if (response != null) {
+                NormalizedMessage outMessage = exchange.createMessage();
+                marshaler.toNMS(outMessage, response);
+                answer(exchange, outMessage);
+            } else {
+                done(exchange);
+            }
         }
         catch (Exception e) {
             fail(exchange, e);

Modified: incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajMarshaler.java?rev=410091&r1=410090&r2=410091&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajMarshaler.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/saaj/SaajMarshaler.java
Mon May 29 05:53:51 2006
@@ -146,11 +146,6 @@
 
         addSoapAttachments(soapMessage, normalizedMessage);
 
-        if (log.isDebugEnabled()) {
-            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-            soapMessage.writeTo(buffer);
-            log.debug(new String(buffer.toByteArray()));
-        }
         return soapMessage;
     }
 

Modified: incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajMarshalerTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajMarshalerTest.java?rev=410091&r1=410090&r2=410091&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajMarshalerTest.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajMarshalerTest.java
Mon May 29 05:53:51 2006
@@ -59,10 +59,12 @@
 	}
 	*/
 	
+    /*
 	public void testSunToNMS() throws Exception {
 		MessageFactory messageFactory = new com.sun.xml.messaging.saaj.soap.MessageFactoryImpl();
 		testToNMS(messageFactory);
 	}
+    */
 	
 	/*
 	public void testSunCreateSOAPMessage() throws Exception {

Added: incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajSoapActionTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajSoapActionTest.java?rev=410091&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajSoapActionTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/saaj/SaajSoapActionTest.java
Mon May 29 05:53:51 2006
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.components.saaj;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.messaging.URLEndpoint;
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.MessageExchangeListener;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.components.http.HttpConnector;
+import org.apache.servicemix.components.util.ComponentSupport;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+
+public class SaajSoapActionTest extends TestCase {
+
+    private JBIContainer jbi;
+    private SaajBinding saaj;
+    private HttpConnector http;
+    
+    protected void setUp() throws Exception {
+        jbi = new JBIContainer();
+        jbi.setEmbedded(true);
+        jbi.setUseMBeanServer(false);
+        jbi.setCreateMBeanServer(false);
+        jbi.init();
+    }
+    
+    protected void tearDown() throws Exception {
+        jbi.shutDown();
+    }
+    
+    protected String testSoapAction(String soapAction, MessageFactory messageFactory) throws
Exception {
+        saaj = new SaajBinding();
+        saaj.setService(new QName("saaj"));
+        saaj.setEndpoint("endpoint");
+        saaj.setSoapEndpoint(new URLEndpoint("http://localhost:8192/"));
+        saaj.setSoapAction(soapAction);
+        SaajMarshaler marshaler = new SaajMarshaler();
+        marshaler.setMessageFactory(messageFactory);
+        saaj.setMarshaller(marshaler);
+        jbi.activateComponent(saaj, "saaj");
+        
+        http = new HttpConnector(new org.mortbay.jetty.nio.SelectChannelConnector());
+        http.setHost("localhost");
+        http.setPort(8192);
+        //http.setDefaultInOut(false);
+        ActivationSpec httpAs = new ActivationSpec();
+        httpAs.setComponent(http);
+        httpAs.setComponentName("http");
+        httpAs.setDestinationService(new QName("receiver"));
+        jbi.activateComponent(httpAs);
+        
+        SoapActionReceiver receiver = new SoapActionReceiver();
+        jbi.activateComponent(receiver, "receiver");
+
+        jbi.start();
+        
+        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+        InOut me = client.createInOutExchange();
+        me.setService(new QName("saaj"));
+        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+        client.sendSync(me);
+        if (me.getStatus() == ExchangeStatus.ERROR) {
+            if (me.getError() != null) {
+                throw me.getError();
+            }
+        }
+        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
+        client.done(me);
+        
+        Thread.sleep(50);
+        
+        return receiver.sentSoapAction;
+    }
+    
+    public void testNullSoapActionAxis() throws Exception {
+        String received = testSoapAction(null, new org.apache.axis.soap.MessageFactoryImpl());
+        assertEquals("\"\"", received);
+    }
+    
+    /*
+    public void testNullSoapActionSun() throws Exception {
+        String received = testSoapAction(null, new com.sun.xml.messaging.saaj.soap.MessageFactoryImpl());
+        assertEquals("\"\"", received);
+    }
+    */
+    
+    public void testEmptySoapActionAxis() throws Exception {
+        String received = testSoapAction("", new org.apache.axis.soap.MessageFactoryImpl());
+        assertEquals("\"\"", received);
+    }
+    
+    /*
+    public void testEmptySoapActionSun() throws Exception {
+        String received = testSoapAction("", new com.sun.xml.messaging.saaj.soap.MessageFactoryImpl());
+        assertEquals("", received);
+    }
+    */
+    
+    public void testQuotesSoapActionAxis() throws Exception {
+        String received = testSoapAction("\"\"", new org.apache.axis.soap.MessageFactoryImpl());
+        assertEquals("\"\"\"\"", received);
+    }
+    
+    /*
+    public void testQuotesSoapActionSun() throws Exception {
+        String received = testSoapAction("\"\"", new com.sun.xml.messaging.saaj.soap.MessageFactoryImpl());
+        assertEquals("\"\"", received);
+    }
+    */
+    
+    public void testWithSoapActionAxis() throws Exception {
+        String received = testSoapAction("action", new org.apache.axis.soap.MessageFactoryImpl());
+        assertEquals("\"action\"", received);
+    }
+    
+    /*
+    public void testWithSoapActionSun() throws Exception {
+        String received = testSoapAction("action", new com.sun.xml.messaging.saaj.soap.MessageFactoryImpl());
+        assertEquals("action", received);
+    }
+    */
+    
+    protected static class SoapActionReceiver extends ComponentSupport implements MessageExchangeListener
{
+        public String sentSoapAction;
+        public SoapActionReceiver() {
+            setService(new QName("receiver"));
+            setEndpoint("endpoint");
+        }
+        public void onMessageExchange(MessageExchange exchange) throws MessagingException
{
+            if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+                NormalizedMessage msg = exchange.getMessage("in");
+                sentSoapAction = (String) msg.getProperty("SOAPAction");
+                NormalizedMessage out = exchange.createMessage();
+                out.setContent(msg.getContent());
+                answer(exchange, out);
+            }
+        }
+        
+    }
+    
+}



Mime
View raw message