You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by jb...@apache.org on 2009/10/05 16:50:48 UTC

svn commit: r821813 - in /servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec: ./ itest/smx4/ marshaler/ tests/ tests/marshaler/ tests/smx3/ tests/smx4/

Author: jbonofre
Date: Mon Oct  5 14:50:48 2009
New Revision: 821813

URL: http://svn.apache.org/viewvc?rev=821813&view=rev
Log:
Cleanup tests structure.

Added:
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/marshaler/
      - copied from r821769, servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/marshaler/
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx3/
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx3/ExecEndpointTest.java
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/
      - copied from r821774, servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/itest/smx4/
Removed:
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/ExecEndpointTest.java
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/itest/smx4/
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/marshaler/
Modified:
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/marshaler/DefaultExecMarshalerTest.java
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/AbstractFeatureTest.java
    servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/ExecTest.java

Modified: servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/marshaler/DefaultExecMarshalerTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/marshaler/DefaultExecMarshalerTest.java?rev=821813&r1=821769&r2=821813&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/marshaler/DefaultExecMarshalerTest.java (original)
+++ servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/marshaler/DefaultExecMarshalerTest.java Mon Oct  5 14:50:48 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicemix.exec.marshaler;
+package org.apache.servicemix.exec.tests.marshaler;
 
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -24,6 +24,10 @@
 
 import junit.framework.TestCase;
 
+import org.apache.servicemix.exec.marshaler.DefaultExecMarshaler;
+import org.apache.servicemix.exec.marshaler.ExecMarshalerSupport;
+import org.apache.servicemix.exec.marshaler.ExecRequest;
+import org.apache.servicemix.exec.marshaler.ExecResponse;
 import org.apache.servicemix.id.IdGenerator;
 import org.apache.servicemix.jbi.helper.MessageExchangePattern;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;

Added: servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx3/ExecEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx3/ExecEndpointTest.java?rev=821813&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx3/ExecEndpointTest.java (added)
+++ servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx3/ExecEndpointTest.java Mon Oct  5 14:50:48 2009
@@ -0,0 +1,178 @@
+/*
+ * 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.servicemix.exec.tests.smx3;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.exec.ExecComponent;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+
+/**
+ * Test the Exec XBean descriptor.
+ * 
+ * @author jbonofre
+ */
+public class ExecEndpointTest extends TestCase {
+    
+    protected JBIContainer container;
+    
+    /*
+     * (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        // start SMX JBI container
+        container = new JBIContainer();
+        container.setUseMBeanServer(false);
+        container.setCreateMBeanServer(false);
+        container.setEmbedded(true);
+        container.init();
+        // deploy the exec component
+        ExecComponent component = new ExecComponent();
+        container.activateComponent(component, "ExecComponent");
+        // start the JBI container
+        container.start();
+        // deploy an exec SU
+        URL url = getClass().getClassLoader().getResource("xbean/xbean.xml");
+        File path = new File(new URI(url.toString()));
+        path = path.getParentFile();
+        component.getServiceUnitManager().deploy("xbean", path.getAbsolutePath());
+        component.getServiceUnitManager().init("xbean", path.getAbsolutePath());
+        component.getServiceUnitManager().start("xbean");
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+       if (container != null) {
+           container.shutDown();
+       }
+    }
+    
+    /**
+     * <p>
+     * Test if the exec endpoint described by the xbean.xml is deployed and expose a WSDL.
+     * </p>
+     * 
+     * @throws Exception in case of lookup failure.
+     */
+    public void testDeployment() throws Exception {
+        // test if the endpoint is present
+        assertNotNull("The endpoint http://test/service/exec is not found in the JBI container.", container.getRegistry().getEndpoint(new QName("http://test", "service"), "exec"));
+        
+        // test if the endpoint descriptor contains the WSDL
+        assertNotNull("The endpoint http://test/service/exec descriptor is null", container.getRegistry().getEndpointDescriptor(container.getRegistry().getEndpoint(new QName("http://test", "service"), "exec")));
+    }
+    
+    /**
+     * <p>
+     * InOnly test using a valid in message.
+     * </p>
+     * 
+     * @throws Exception if an error occurs during the test.
+     */
+    public void testInOnlyWithValidPayloadMessage() throws Exception {   
+        // InOnly MEP test
+        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
+        InOnly inOnly = client.createInOnlyExchange();
+        inOnly.setService(new QName("http://test", "service"));
+        inOnly.getInMessage().setContent(new StringSource(
+                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                "<exec:execRequest xmlns:exec=\"http://servicemix.apache.org/exec\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+                "<command>touch</command>" +
+                "<arguments>" +
+                "<argument>/tmp/test</argument>" +
+                "</arguments>" +
+                "</exec:execRequest>"));
+        client.sendSync(inOnly);
+        
+        if (inOnly.getStatus() == ExchangeStatus.ERROR) {
+            fail("Received ERROR status.");
+        } else if (inOnly.getFault() != null) {
+            fail("Received fault: " + new SourceTransformer().toString(inOnly.getFault().getContent()));
+        }
+    }
+    
+    /**
+     * <p>
+     * InOnly test with an empty in message (using the static command).
+     * </p>
+     * 
+     * @throws Exception
+     */
+    public void testInOnlyWithEmptyMessage() throws Exception {
+        // InOnly MEP test
+        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
+        InOnly inOnly = client.createInOnlyExchange();
+        inOnly.setService(new QName("http://test", "service"));
+        inOnly.getInMessage().setContent(new StringSource(
+                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                "<exec:execRequest xmlns:exec=\"http://servicemix.apache.org/exec\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"/>"));
+        client.sendSync(inOnly);
+        
+        if (inOnly.getStatus() == ExchangeStatus.ERROR) {
+            fail("Received ERROR status.");
+        } else if (inOnly.getFault() != null) {
+            fail("Received fault: " + new SourceTransformer().toString(inOnly.getFault().getContent()));
+        }
+    }
+    
+    /**
+     * <p>
+     * InOut test using a valid in message.
+     * </p>
+     * 
+     * @throws Exception if an error occurs during the test.
+     */
+    public void testInOutWithValidMessage() throws Exception {
+        // InOut MEP test
+        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
+        InOut inOut = client.createInOutExchange();
+        inOut.setService(new QName("http://test", "service"));        
+        inOut.getInMessage().setContent(new StringSource(
+                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                "<exec:execRequest xmlns:exec=\"http://servicemix.apache.org/exec\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+                "<command>ls</command>" +
+                "</exec:execRequest>"));
+        client.sendSync(inOut);
+        
+        if (inOut.getStatus() == ExchangeStatus.ERROR) {
+            fail("Received ERROR status.");
+        } else if (inOut.getFault() != null) {
+            fail("Received fault: " + new SourceTransformer().toString(inOut.getFault().getContent()));
+        } else {
+            System.out.println(new SourceTransformer().toString(inOut.getMessage("out").getContent()));
+        }
+        
+        client.done(inOut);
+    }
+
+}

Modified: servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/AbstractFeatureTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/AbstractFeatureTest.java?rev=821813&r1=821774&r2=821813&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/AbstractFeatureTest.java (original)
+++ servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/AbstractFeatureTest.java Mon Oct  5 14:50:48 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicemix.exec.itest.smx4;
+package org.apache.servicemix.exec.tests.smx4;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -57,7 +57,7 @@
         Option[] options = options(
                 profile("log").version("1.4"),
                 org.ops4j.pax.exam.CoreOptions.systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
-                scanFeatures(mavenBundle().groupId("org.apache.servicemix.nmr").artifactId("apache-servicemix-nmr").version("1.1.0-SNAPSHOT").type("xml/features"), "jbi"), felix());
+                scanFeatures(mavenBundle().groupId("org.apache.servicemix.nmr").artifactId("apache-servicemix-nmr").version("1.1.0-SNAPSHOT").type("xml/features"), "jbi/1.1.0-SNAPSHOT"), felix());
         return options;
     }
 

Modified: servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/ExecTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/ExecTest.java?rev=821813&r1=821774&r2=821813&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/ExecTest.java (original)
+++ servicemix/components/engines/servicemix-exec/trunk/src/test/java/org/apache/servicemix/exec/tests/smx4/ExecTest.java Mon Oct  5 14:50:48 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicemix.exec.itest.smx4;
+package org.apache.servicemix.exec.tests.smx4;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;