You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2009/06/11 03:36:02 UTC

svn commit: r783597 - in /servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test: java/org/apache/servicemix/eip/ java/org/apache/servicemix/eip/packaging/ java/org/apache/servicemix/eip/support/ resources/org/apache...

Author: ffang
Date: Thu Jun 11 01:36:02 2009
New Revision: 783597

URL: http://svn.apache.org/viewvc?rev=783597&view=rev
Log:
[SMXCOMP-531]Improve test coverage - ServiceMix :: EIP

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterSwitchPredicateTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/packaging/
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/packaging/EipServiceUnitAnalyzerTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/ExchangeTargetTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch-off.properties   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch.properties   (with props)
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterTest.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SplitAggregatorTest.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/XPathSplitterTest.java

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterSwitchPredicateTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterSwitchPredicateTest.java?rev=783597&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterSwitchPredicateTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterSwitchPredicateTest.java Thu Jun 11 01:36:02 2009
@@ -0,0 +1,185 @@
+/*
+ * 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.eip;
+
+import java.net.URL;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.eip.patterns.MessageFilter;
+import org.apache.servicemix.eip.support.SwitchPredicate;
+import org.apache.servicemix.tck.ReceiverComponent;
+import org.springframework.core.io.FileSystemResource;
+
+// Test for SwitchPredicate methods.  Switch can be turned on/off with a
+// property file, a property on the message exchange, or a system property.
+public class MessageFilterSwitchPredicateTest extends AbstractEIPTest {
+    
+    private static Log log = LogFactory.getLog(MessageFilterSwitchPredicateTest.class);
+    protected MessageFilter messageFilter;
+    protected SwitchPredicate predicate;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        messageFilter = new MessageFilter();
+        predicate = new SwitchPredicate();
+
+    }
+
+    protected void tearDown() throws Exception {
+        messageFilter = null;
+        predicate = null;
+
+        super.tearDown();
+    }
+
+    // Test for switch predicate on/off when set on the message exchange.
+    public void testPropertyOnExchange() throws Exception {
+        InOnly me = client.createInOnlyExchange();
+        me.setProperty("on", Boolean.FALSE);
+        predicate.setFromExchange(true);
+        predicate.setPropertyName("on");
+
+        messageFilter.setFilter(predicate);
+        messageFilter.setTarget(createServiceExchangeTarget(new QName("target")));
+        configurePattern(messageFilter);
+        activateComponent(messageFilter, "messageFilter");
+        ReceiverComponent rec = activateReceiver("target");
+        me.setService(new QName("messageFilter"));
+
+        // Message exchange turned off - message should NOT reach the target.
+        me.getInMessage().setContent(createSource("<orderIn><widget>5</widget></orderIn>"));
+        me.getInMessage().setProperty("on", Boolean.FALSE);
+        log.info("Before client.sendSync me.getProperty(\"on\") is: " + me.getProperty("on"));
+        client.sendSync(me);
+        log.info("After client.sendSync me.getProperty(\"on\" is: " + me.getProperty("on"));
+        assertEquals("Message exchange status should be DONE", ExchangeStatus.DONE, me.getStatus());
+
+        rec.getMessageList().assertMessagesReceived(0);
+
+/*
+ * Comment this part of the test out until SMXCOMP-553 is fixed.        
+        // Message exchange turned on - message should reach the target.
+        me = client.createInOnlyExchange();
+        me.setProperty("on", Boolean.TRUE);
+        predicate.setFromExchange(true);
+        predicate.setPropertyName("on");
+        
+        messageFilter.setFilter(predicate);
+        configurePattern(messageFilter);
+        me.setService(new QName("messageFilter"));
+        
+        me.getInMessage().setContent(createSource("<orderIn><widget>5</widget></orderIn>"));
+        me.getInMessage().setProperty("on", Boolean.TRUE);
+        log.info("Before client.sendSync me.getProperty(\"on\") is: " + me.getProperty("on"));
+        client.sendSync(me);
+        log.info("After client.sendSync me.getProperty(\"on\" is: " + me.getProperty("on"));
+        assertEquals("Message exchange status should be DONE", ExchangeStatus.DONE, me.getStatus());
+        
+        rec.getMessageList().assertMessagesReceived(1);
+*/
+    }
+
+    // Test switch predicate on and off when property value comes from a file.
+    public void testPropertyFromFile() throws Exception {
+        InOnly me = client.createInOnlyExchange();
+
+        URL fileUrl = getClass().getResource("switch-off.properties");
+        FileSystemResource propFile = new FileSystemResource(fileUrl.getFile());
+        predicate.setPropertyResource(propFile);
+        predicate.setPropertyName("on");
+
+        // Message exchange turned off - message should not reach the target.
+        messageFilter.setFilter(predicate);
+        messageFilter.setTarget(createServiceExchangeTarget(new QName("target")));
+        configurePattern(messageFilter);
+        activateComponent(messageFilter, "messageFilter");
+        ReceiverComponent rec = activateReceiver("target");
+        me.setService(new QName("messageFilter"));
+
+        me.getInMessage().setContent(createSource("<orderIn><gadget>10</gadget></orderIn>"));
+        client.sendSync(me);
+        assertEquals("Message exchange status should be DONE", ExchangeStatus.DONE, me.getStatus());
+
+        rec.getMessageList().assertMessagesReceived(0);
+
+        // Message exchange turned on - message should reach the target.
+        me = client.createInOnlyExchange();
+        fileUrl = getClass().getResource("switch.properties");
+        propFile = new FileSystemResource(fileUrl.getFile());
+        predicate.setPropertyResource(propFile);
+        predicate.setPropertyName("on");
+
+        messageFilter.setFilter(predicate);
+        me.setService(new QName("messageFilter"));
+
+        me.getInMessage().setContent(createSource("<orderIn><widget>5</widget></orderIn>"));
+        client.sendSync(me);
+        assertEquals("Message exchange status should be DONE", ExchangeStatus.DONE, me.getStatus());
+
+        rec.getMessageList().assertMessagesReceived(1);
+
+    }
+
+    // Test switch predicate on and off when property is a system property.
+    public void testSystemProperty() throws Exception {
+        System.setProperty("on", "false");
+
+        InOnly me = client.createInOnlyExchange();
+
+        predicate.setPropertyName("on");
+
+        // Message exchange turned off - message should not reach the target.
+        messageFilter.setFilter(predicate);
+        messageFilter.setTarget(createServiceExchangeTarget(new QName("target")));
+        configurePattern(messageFilter);
+        activateComponent(messageFilter, "messageFilter");
+        ReceiverComponent rec = activateReceiver("target");
+        me.setService(new QName("messageFilter"));
+
+        me.getInMessage().setContent(createSource("<orderIn><gadget>10</gadget></orderIn>"));
+        client.sendSync(me);
+        assertEquals("Message exchange status should be DONE", ExchangeStatus.DONE, me.getStatus());
+
+        rec.getMessageList().assertMessagesReceived(0);
+
+        // Need to clear the previously set System property.
+        System.clearProperty("on");
+        System.setProperty("on", "true");
+
+        me = client.createInOnlyExchange();
+
+        predicate.setPropertyName("on");
+
+        // Message exchange turned on - message should reach the target.
+        messageFilter.setFilter(predicate);
+        messageFilter.setTarget(createServiceExchangeTarget(new QName("target")));
+        configurePattern(messageFilter);
+        me.setService(new QName("messageFilter"));
+
+        me.getInMessage().setContent(createSource("<orderIn><gadget>10</gadget></orderIn>"));
+        client.sendSync(me);
+        assertEquals("Message exchange status should be DONE", ExchangeStatus.DONE, me.getStatus());
+
+        rec.getMessageList().assertMessagesReceived(1);
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterSwitchPredicateTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterSwitchPredicateTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterTest.java?rev=783597&r1=783596&r2=783597&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/MessageFilterTest.java Thu Jun 11 01:36:02 2009
@@ -41,13 +41,13 @@
     
     public void testInOnly() throws Exception {
         ReceiverComponent rec = activateReceiver("target");
-        
+
         InOnly me = client.createInOnlyExchange();
         me.setService(new QName("messageFilter"));
         me.getInMessage().setContent(createSource("<hello><one/><two/><three/></hello>"));
         client.sendSync(me);
         assertEquals(ExchangeStatus.DONE, me.getStatus());
-        
+
         rec.getMessageList().assertMessagesReceived(0); 
 
         me = client.createInOnlyExchange();
@@ -55,7 +55,7 @@
         me.getInMessage().setContent(createSource("<hello id='1'><one/><two/><three/></hello>"));
         client.sendSync(me);
         assertEquals(ExchangeStatus.DONE, me.getStatus());
-        
+
         rec.getMessageList().assertMessagesReceived(1); 
     }
 
@@ -67,4 +67,24 @@
         assertEquals(ExchangeStatus.ERROR, me.getStatus());
     }
 
+    // Test XPath filter when XPath expression is invalid.
+    public void testInvalidXPathExpression() throws Exception {
+        // Create an invalid XPath expression predicate and set it 
+        //as the filter.
+        XPathPredicate predicate = new XPathPredicate();
+        predicate.setXPath("\\invalid");
+        messageFilter.setFilter(predicate);
+        configurePattern(messageFilter);
+        ReceiverComponent rec = activateReceiver("target");
+
+        // Create an inOnly exchange and send a basic XML message.
+        InOnly me = client.createInOnlyExchange();
+        me.setService(new QName("messageFilter"));
+        me.getInMessage().setContent(createSource("<hello><one/><two/><three/></hello>"));
+        client.sendSync(me);
+        assertEquals("", ExchangeStatus.DONE, me.getStatus());
+
+        // No messages should be received due to the invalid XPath expression.
+        rec.getMessageList().assertMessagesReceived(0);
+    }
 }

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SplitAggregatorTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SplitAggregatorTest.java?rev=783597&r1=783596&r2=783597&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SplitAggregatorTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SplitAggregatorTest.java Thu Jun 11 01:36:02 2009
@@ -21,6 +21,7 @@
 import javax.jbi.JBIException;
 import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOut;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessagingException;
 import javax.jbi.messaging.NormalizedMessage;
@@ -52,7 +53,7 @@
         int nbMessages = 3;
         int nbMessagesSent = 0;
         String corrId = Long.toString(System.currentTimeMillis());
-        for (int i = 0; i < 3; i++) {
+        for (int i = 0; i < nbMessages; i++) {
             if (msgs == null || msgs[i]) {
                 InOnly me = client.createInOnlyExchange();
                 me.setService(new QName("aggregator"));
@@ -165,4 +166,43 @@
         Thread.sleep(500);
         rec.getMessageList().assertMessagesReceived(0);
     }
+
+    // Test aggregator when InOut MEP is used.  An exception should be thrown.
+    public void testInvalidInOutMep() throws Exception {
+
+        int nbMessages = 3;
+        String corrId = Long.toString(System.currentTimeMillis());
+        try {
+            for (int i = 0; i < nbMessages; i++) {
+                InOut me = client.createInOutExchange();
+                me.setService(new QName("aggregator"));
+                me.getInMessage().setContent(createSource("<hello id='" + i + "' />"));
+                me.getInMessage().setProperty(AbstractSplitter.SPLITTER_COUNT, new Integer(nbMessages));
+                me.getInMessage().setProperty(AbstractSplitter.SPLITTER_INDEX, new Integer(i));
+                me.getInMessage().setProperty(AbstractSplitter.SPLITTER_CORRID, corrId);
+                me.getInMessage().setProperty("prop", "value");
+                client.send(me);
+            }
+        } catch (UnsupportedOperationException uoe) {
+            // test succeeds
+        }
+    }
+
+    // Test aggregator when no correlation id is set on the message.
+    public void testNullCorrelationId() throws Exception {
+        int nbMessages = 3;
+        try {
+            for (int i = 0; i < nbMessages; i++) {
+                InOut me = client.createInOutExchange();
+                me.setService(new QName("aggregator"));
+                me.getInMessage().setContent(createSource("<hello id='" + i + "' />"));
+                me.getInMessage().setProperty(AbstractSplitter.SPLITTER_COUNT, new Integer(nbMessages));
+                me.getInMessage().setProperty(AbstractSplitter.SPLITTER_INDEX, new Integer(i));
+                me.getInMessage().setProperty("prop", "value");
+                client.send(me);
+            }
+        } catch (IllegalArgumentException iae) {
+            // test succeeds
+        }
+    }
 }

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/XPathSplitterTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/XPathSplitterTest.java?rev=783597&r1=783596&r2=783597&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/XPathSplitterTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/XPathSplitterTest.java Thu Jun 11 01:36:02 2009
@@ -16,12 +16,14 @@
  */
 package org.apache.servicemix.eip;
 
+import javax.jbi.management.DeploymentException;
 import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.InOnly;
 import javax.jbi.messaging.InOut;
 import javax.xml.namespace.QName;
 
 import org.apache.servicemix.eip.patterns.XPathSplitter;
+import org.apache.servicemix.eip.support.ExchangeTarget;
 import org.apache.servicemix.tck.ReceiverComponent;
 
 public class XPathSplitterTest extends AbstractEIPTest {
@@ -58,4 +60,31 @@
         assertEquals(ExchangeStatus.ERROR, me.getStatus());
     }
 
+    // Test validate() with null target
+    public void testValidateNullTarget() throws Exception {
+        ExchangeTarget target = null;
+        splitter.setTarget(target);
+
+        try {
+            splitter.validate();
+            fail("ExchangeTarget is null, validate should throw an exception");
+        } catch (IllegalArgumentException iae) {
+            // test succeeds
+        }
+    }
+
+    // Test validate() with null XPath expression
+    public void testValidateNullXPathExpression() throws Exception {
+        XPathSplitter badSplitter = new XPathSplitter();
+        badSplitter.setTarget(createServiceExchangeTarget(new QName("target")));
+        badSplitter.setXPath(null);
+
+        try {
+            badSplitter.validate();
+            fail("XPath expression is null, validate should throw an exception");
+        } catch (DeploymentException de) {
+            // test succeeds
+        }
+    }
+
 }

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/packaging/EipServiceUnitAnalyzerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/packaging/EipServiceUnitAnalyzerTest.java?rev=783597&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/packaging/EipServiceUnitAnalyzerTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/packaging/EipServiceUnitAnalyzerTest.java Thu Jun 11 01:36:02 2009
@@ -0,0 +1,329 @@
+/*
+ * 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.eip.packaging;
+
+import java.util.List;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.common.packaging.Consumes;
+import org.apache.servicemix.eip.AbstractEIPTest;
+import org.apache.servicemix.eip.patterns.ContentBasedRouter;
+import org.apache.servicemix.eip.patterns.ContentEnricher;
+import org.apache.servicemix.eip.patterns.MessageFilter;
+import org.apache.servicemix.eip.patterns.Pipeline;
+import org.apache.servicemix.eip.patterns.SplitAggregator;
+import org.apache.servicemix.eip.patterns.StaticRecipientList;
+import org.apache.servicemix.eip.patterns.StaticRoutingSlip;
+import org.apache.servicemix.eip.patterns.WireTap;
+import org.apache.servicemix.eip.patterns.XPathSplitter;
+import org.apache.servicemix.eip.support.ExchangeTarget;
+import org.apache.servicemix.eip.support.RoutingRule;
+import org.apache.servicemix.eip.support.XPathPredicate;
+
+public class EipServiceUnitAnalyzerTest extends AbstractEIPTest {
+
+    private EipServiceUnitAnalyzer analyzer;
+    private ServiceUnit su;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        analyzer = new EipServiceUnitAnalyzer();
+        su = new ServiceUnit();
+    }
+
+    protected void tearDown() throws Exception {
+        su = null;
+        analyzer = null;
+        super.tearDown();
+    }
+
+    // Test isValidEndpoint for a valid EIP endpoint.
+    public void testIsValidEndpointTrue() throws Exception {
+        ContentBasedRouter router = new ContentBasedRouter();
+        router.setService(new QName("cbr"));
+        router.setEndpoint("cbr");
+        su.addEndpoint(router);
+
+        assertTrue("isValidEndpoint() should return true for ContentBasedRouter endpoint", 
+                analyzer.isValidEndpoint(router));
+    }
+
+    // test getConsumes() with a ContentBasedRouter endpoint
+    public void testGetConsumesContentBasedRouter() throws Exception {
+        ContentBasedRouter router = new ContentBasedRouter();
+        router.setService(new QName("cbr"));
+        router.setEndpoint("cbr");
+        router.setRules(new RoutingRule[] {
+            new RoutingRule(
+                new XPathPredicate("/hello/@id = '1'"),
+                createServiceExchangeTarget(new QName("target1"))),
+            new RoutingRule(
+                new XPathPredicate("/hello/@id = '2'"),
+                createServiceExchangeTarget(new QName("target2"))),
+            new RoutingRule(
+                null,
+                createServiceExchangeTarget(new QName("target3")))
+        });
+        su.addEndpoint(router);
+
+        List<Consumes> consumesList = analyzer.getConsumes(router);
+
+        assertNotNull("getConsumes() for ContentBasedRouter endpoint should return a non-null list", 
+                consumesList);
+        assertTrue("Consumes list should contain 3 entries", consumesList.size() == 3);
+    }
+
+    // test getConsumes() with the MessageFilter endpoint
+    public void testGetConsumesMessageFilter() throws Exception {
+        MessageFilter messageFilter = new MessageFilter();
+        messageFilter = new MessageFilter();
+        messageFilter.setFilter(new XPathPredicate("/hello/@id = '1'"));
+        messageFilter.setTarget(createServiceExchangeTarget(new QName("target")));
+        messageFilter.setService(new QName("messageFilter"));
+        messageFilter.setEndpoint("messageFilter");
+
+        su.addEndpoint(messageFilter);
+
+        List<Consumes> consumesList = analyzer.getConsumes(messageFilter);
+
+        assertNotNull("getConsumes() for MessageFilter endpoint should return a non-null list", 
+                consumesList);
+        assertTrue("Consumes list should contain 1 entry", consumesList.size() == 1);
+    }
+
+    // test getConsumes() with the Pipeline endpoint
+    public void testGetConsumesPipeline() throws Exception {
+        Pipeline pipeline = new Pipeline();
+        pipeline.setTransformer(createServiceExchangeTarget(new QName("transformer")));
+        pipeline.setTarget(createServiceExchangeTarget(new QName("target")));
+        pipeline.setService(new QName("pipeline"));
+        pipeline.setEndpoint("pipeline");
+
+        su.addEndpoint(pipeline);
+
+        List<Consumes> consumesList = analyzer.getConsumes(pipeline);
+
+        assertNotNull("getConsumes() for Pipeline endpoint should return a non-null list", 
+                consumesList);
+        assertTrue("Consumes list should contain 2 entries", consumesList.size() == 2);
+    }
+
+    // test getConsumes() with SplitAggregator endpoint
+    public void testGetConsumesSplitAggregator() throws Exception {
+        SplitAggregator aggregator = new SplitAggregator();
+        aggregator.setTarget(createServiceExchangeTarget(new QName("target")));
+        aggregator.setCopyProperties(true);
+        aggregator.setService(new QName("splitAggregator"));
+        aggregator.setEndpoint("splitAggregator");
+
+        su.addEndpoint(aggregator);
+
+        List<Consumes> consumesList = analyzer.getConsumes(aggregator);
+
+        assertNotNull("getConsumes() for SplitAggregator endpoint should return a non-null list", 
+                consumesList);
+        assertTrue("Consumes list should contain 1 entry", consumesList.size() == 1);      
+    }
+
+    // test getConsumes() with StaticRecipientList endpoint
+    public void testGetConsumesStaticRecipientList() throws Exception {
+        StaticRecipientList recipientList = new StaticRecipientList();
+        recipientList.setRecipients(
+                new ExchangeTarget[] {
+                        createServiceExchangeTarget(new QName("recipient1")),
+                        createServiceExchangeTarget(new QName("recipient2")),
+                        createServiceExchangeTarget(new QName("recipient3")),
+                        createServiceExchangeTarget(new QName("recipient4"))
+                });
+        recipientList.setService(new QName("recipList"));
+        recipientList.setEndpoint("recipList");
+
+        su.addEndpoint(recipientList);
+
+        List<Consumes> consumesList = analyzer.getConsumes(recipientList);
+
+        assertNotNull("getConsumes() for StaticRecipientList endpoint should return a non-null list", 
+                consumesList);
+        assertTrue("Consumes list should contain 4 entries", consumesList.size() == 4);          
+    }
+
+    // test getConsumes() with StaticRoutingSlip endpoint
+    public void testGetConsumesStaticRoutingSlip() throws Exception {
+        StaticRoutingSlip routingSlip = new StaticRoutingSlip();
+        routingSlip.setTargets(
+                new ExchangeTarget[] {
+                        createServiceExchangeTarget(new QName("target1")),
+                        createServiceExchangeTarget(new QName("target2")),
+                        createServiceExchangeTarget(new QName("target3"))
+                });
+        routingSlip.setService(new QName("routingSlip"));
+        routingSlip.setEndpoint("routingSlip");
+
+        su.addEndpoint(routingSlip);
+
+        List<Consumes> consumesList = analyzer.getConsumes(routingSlip);
+
+        assertNotNull("getConsumes() for StaticRoutingSlip endpoint should return a non-null list", 
+                consumesList);
+        assertTrue("Consumes list should contain 3 entries", consumesList.size() == 3);
+    }
+
+    // test getConsumes() with WireTap endpoint
+    public void testGetConsumesWireTap() throws Exception {
+        WireTap wireTap = new WireTap();
+        wireTap.setInListener(createServiceExchangeTarget(new QName("in")));
+        wireTap.setOutListener(createServiceExchangeTarget(new QName("out")));
+        wireTap.setFaultListener(createServiceExchangeTarget(new QName("fault")));
+        wireTap.setTarget(createServiceExchangeTarget(new QName("target")));
+        wireTap.setService(new QName("wireTap"));
+        wireTap.setEndpoint("wireTap");
+
+        su.addEndpoint(wireTap);
+
+        List<Consumes> consumesList = analyzer.getConsumes(wireTap);
+
+        assertNotNull("getConsumes() for WireTap endpoint should return a non-null list", 
+                consumesList);
+        assertTrue("Consumes list should contain 4 entries", consumesList.size() == 4);
+    }
+
+    // test getConsumes() with XPathSplitter endpoint
+    public void testGetConsumesXPathSplitter() throws Exception {
+        XPathSplitter splitter = new XPathSplitter();
+        splitter.setTarget(createServiceExchangeTarget(new QName("target")));
+        splitter.setXPath("/hello/*");
+        splitter.setService(new QName("splitter"));
+        splitter.setEndpoint("splitter");
+
+        su.addEndpoint(splitter);
+
+        List<Consumes> consumesList = analyzer.getConsumes(splitter);
+
+        assertNotNull("getConsumes() for XPathSplitter endpoint should return a non-null list", 
+                consumesList);
+        assertTrue("Consumes list should contain 1 entry", consumesList.size() == 1);      
+    }
+
+    // test getConsumes() with unresolvable EIP endpoint
+    public void testGetConsumesUnresolvableEndpoint() throws Exception {
+        ContentEnricher enricher = new ContentEnricher();
+        enricher.setEnricherTarget(createServiceExchangeTarget(new QName("enricherTarget")));
+        enricher.setTarget(createServiceExchangeTarget(new QName("target")));
+        enricher.setService(new QName("enricher"));
+        enricher.setEndpoint("enricher");
+
+        su.addEndpoint(enricher);
+
+        List<Consumes> consumesList = analyzer.getConsumes(enricher);
+
+        // EipServiceUnitAnalyzer's getConsumes just creates an empty array for
+        // unresolvable endpoints.  Unresolvable means that there is no resolve*()
+        // method for it in EipServiceUnitAnalyzer.java.
+        assertNotNull("getConsumes() for ContentEnricher endpoint should return a non-null list", 
+                consumesList);
+        assertTrue("Consumes list should contain 0 entries", consumesList.size() == 0);
+    }
+
+    // test getXBeanFile
+    public void testGetXBeanFile() throws Exception {
+        String xbeanFile = analyzer.getXBeanFile();
+
+        assertTrue("getXBeanFile should return xbean.xml", xbeanFile.equalsIgnoreCase("xbean.xml"));
+    }
+
+    // Dummy Endpoint implementation for testing.
+    public static class TestEndpoint extends Endpoint {
+
+        private String key;
+
+        public TestEndpoint() {
+            key = "test";
+        }
+
+        public void activate() throws Exception {
+        }
+
+        public void deactivate() throws Exception {
+        }
+
+        public Document getDescription() {
+            return null;
+        }
+
+        public String getEndpoint() {
+            return null;
+        }
+
+        public QName getInterfaceName() {
+            return null;
+        }
+
+        public String getKey() {
+            return key;
+        }
+
+        public Role getRole() {
+            return null;
+        }
+
+        public QName getService() {
+            return null;
+        }
+
+        public ServiceUnit getServiceUnit() {
+            return null;
+        }
+
+        public ExchangeProcessor getProcessor() {
+            return null;
+        }
+
+        public boolean isExchangeOkay(MessageExchange exchange) {
+            return false;
+        }
+
+        public void process(MessageExchange exchange) throws Exception {
+
+        }
+
+        public void setServiceUnit(ServiceUnit serviceUnit) {
+
+        }
+
+        public void start() throws Exception {
+
+        }
+
+        public void stop() throws Exception {
+
+        }
+
+        public void validate() throws DeploymentException {
+
+        }
+
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/packaging/EipServiceUnitAnalyzerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/packaging/EipServiceUnitAnalyzerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/ExchangeTargetTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/ExchangeTargetTest.java?rev=783597&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/ExchangeTargetTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/ExchangeTargetTest.java Thu Jun 11 01:36:02 2009
@@ -0,0 +1,94 @@
+/*
+ * 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.eip.support;
+
+import javax.jbi.messaging.MessagingException;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.components.util.EchoComponent;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.tck.mock.MockMessageExchange;
+
+// ExchangeTargetTest creates an ExchangeTarget object and tests the methods on it
+// that are not covered by other tests.
+public class ExchangeTargetTest extends TestCase {
+
+    private ExchangeTarget exchangeTarget;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        exchangeTarget = new ExchangeTarget();
+    }
+
+    protected void tearDown() throws Exception {
+        exchangeTarget = null;
+        super.tearDown();
+    }
+
+    // Test afterPropertiesSet() when interface, service, and uri are all null.
+    public void testAfterPropertiesSetException() throws Exception {
+        try {
+            exchangeTarget.afterPropertiesSet();
+            fail("afterPropertiesSet should fail when interface, service, and uri are null.");
+        } catch (MessagingException me) {
+            // test succeeds
+        }
+    }
+
+    // Test configureTarget() when interface, service, and uri are all null.
+    public void testConfigureTargetException() throws Exception {
+        try {
+            exchangeTarget.configureTarget(null, null);
+            fail("configureTarget should fail when interface, service, and uri are null.");
+        } catch (MessagingException me) {
+            // test succeeds
+        }
+    }
+
+    // Test configureTarget() when interface, service, uri, and endpoint are set.
+    public void testConfigureTargetSet() throws Exception {
+        MockMessageExchange exchange = new MockMessageExchange();
+        EchoComponent echo = new EchoComponent();
+        echo.setService(new QName("urn:test", "echo"));
+        echo.setEndpoint("endpoint");
+
+        JBIContainer container = new JBIContainer();
+        container.init();
+
+        container.activateComponent(echo, "echo");
+        container.start();
+
+        exchangeTarget.setInterface(new QName("test-interface"));
+        exchangeTarget.setService(new QName("urn:test", "echo"));
+        exchangeTarget.setUri("urn:test:echo");
+        exchangeTarget.setEndpoint("endpoint");
+
+        // configureTarget should set the interface, service, and endpoint on the
+        // exchange.
+        exchangeTarget.configureTarget(exchange, echo.getContext());
+
+        assertNotNull("Service name should be set on the exchange", exchange.getService());
+        assertNotNull("Interface name should be set on the exchange", exchange.getInterfaceName());
+        assertNotNull("Endpoint should be set on the exchange", exchange.getEndpoint());
+
+        container.stop();
+
+    }
+
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/ExchangeTargetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/ExchangeTargetTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch-off.properties
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch-off.properties?rev=783597&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch-off.properties (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch-off.properties Thu Jun 11 01:36:02 2009
@@ -0,0 +1 @@
+on=false
\ No newline at end of file

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch-off.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch-off.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch-off.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch.properties
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch.properties?rev=783597&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch.properties (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch.properties Thu Jun 11 01:36:02 2009
@@ -0,0 +1 @@
+on=true
\ No newline at end of file

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-eip/src/test/resources/org/apache/servicemix/eip/switch.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain