1 17 package org.apache.servicemix.jbi.servicedesc; 18 19 import org.apache.servicemix.jbi.framework.ComponentNameSpace; 20 import org.apache.servicemix.jbi.servicedesc.InternalEndpoint; 21 22 import javax.xml.namespace.QName ; 23 24 import java.io.ByteArrayInputStream ; 25 import java.io.ByteArrayOutputStream ; 26 import java.io.ObjectInputStream ; 27 import java.io.ObjectOutputStream ; 28 29 import junit.framework.TestCase; 30 31 public class InternalEndpointTest extends TestCase { 32 33 public void testSerializeDeserialize() throws Exception { 34 ComponentNameSpace cns = new ComponentNameSpace("myContainer", "myName"); 35 InternalEndpoint e = new InternalEndpoint(cns, "myEndpoint", new QName ("myService")); 36 37 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 38 ObjectOutputStream oos = new ObjectOutputStream (baos); 39 oos.writeObject(e); 40 oos.close(); 41 42 ByteArrayInputStream bais = new ByteArrayInputStream (baos.toByteArray()); 43 ObjectInputStream ois = new ObjectInputStream (bais); 44 Object out = ois.readObject(); 45 46 assertNotNull(out); 47 assertTrue(out instanceof InternalEndpoint); 48 InternalEndpoint outE = (InternalEndpoint) out; 49 assertNotNull(outE.getComponentNameSpace()); 50 assertNotNull(outE.getServiceName()); 51 assertNotNull(outE.getEndpointName()); 52 } 53 54 public void testEquals() throws Exception { 55 ComponentNameSpace cns = new ComponentNameSpace("myContainer", "myName"); 56 InternalEndpoint e1 = new InternalEndpoint(cns, "myEndpoint1", new QName ("myService")); 57 InternalEndpoint e2 = new InternalEndpoint(cns, "myEndpoint2", new QName ("myService")); 58 assertFalse(e1.equals(e2)); 59 e2 = new InternalEndpoint(cns, "myEndpoint", new QName ("myService2")); 60 assertFalse(e1.equals(e2)); 61 ComponentNameSpace cns2 = new ComponentNameSpace("myContainer2", "myId2"); 62 e2 = new InternalEndpoint(cns2, "myEndpoint1", new QName ("myService")); 63 assertTrue(e1.equals(e2)); 64 cns2 = new ComponentNameSpace("myContainer", "myName"); 65 e2 = new InternalEndpoint(cns2, "myEndpoint1", new QName ("myService")); 66 assertTrue(e1.equals(e2)); 67 } 68 69 } 70 | Popular Tags |