1 17 package org.apache.servicemix.jbi.nmr; 18 19 import javax.xml.namespace.QName ; 20 21 import junit.framework.TestCase; 22 23 import org.apache.servicemix.jbi.container.ActivationSpec; 24 import org.apache.servicemix.jbi.container.JBIContainer; 25 import org.apache.servicemix.tck.Receiver; 26 import org.apache.servicemix.tck.ReceiverComponent; 27 import org.apache.servicemix.tck.Sender; 28 import org.apache.servicemix.tck.SenderComponent; 29 30 public class ConnectionsTest extends TestCase { 31 32 private JBIContainer container; 33 34 protected void setUp() throws Exception { 35 container = new JBIContainer(); 36 container.setEmbedded(true); 37 container.init(); 38 container.start(); 39 } 40 41 protected void tearDown() throws Exception { 42 container.shutDown(); 43 } 44 45 public void testEndpointConnection() throws Exception { 46 Receiver receiver = new ReceiverComponent(); 47 ActivationSpec asReceiver = new ActivationSpec(); 48 asReceiver.setComponent(receiver); 49 asReceiver.setService(new QName ("service")); 50 asReceiver.setEndpoint("endpoint"); 51 52 Sender sender = new SenderComponent(); 53 ActivationSpec asSender = new ActivationSpec(); 54 asSender.setComponent(sender); 55 asSender.setDestinationService(new QName ("service")); 56 asSender.setDestinationEndpoint("linkedEndpoint"); 57 58 container.activateComponent(asReceiver); 59 container.activateComponent(asSender); 60 container.getRegistry().registerEndpointConnection(new QName ("service"), "linkedEndpoint", new QName ("service"), "endpoint", null); 61 62 sender.sendMessages(1); 63 receiver.getMessageList().assertMessagesReceived(1); 64 } 65 66 public void testInterfaceConnection() throws Exception { 67 Receiver receiver = new ReceiverComponent(); 68 ActivationSpec asReceiver = new ActivationSpec(); 69 asReceiver.setComponent(receiver); 70 asReceiver.setService(new QName ("service")); 71 asReceiver.setEndpoint("endpoint"); 72 73 Sender sender = new SenderComponent(); 74 ActivationSpec asSender = new ActivationSpec(); 75 asSender.setComponent(sender); 76 asSender.setDestinationInterface(new QName ("interface")); 77 78 container.activateComponent(asReceiver); 79 container.activateComponent(asSender); 80 container.getRegistry().registerInterfaceConnection(new QName ("interface"), new QName ("service"), "endpoint"); 81 82 sender.sendMessages(1); 83 receiver.getMessageList().assertMessagesReceived(1); 84 } 85 86 } 87 | Popular Tags |