01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.servicemix.jbi.servicedesc;
18:
19: import java.io.ByteArrayInputStream;
20: import java.io.ByteArrayOutputStream;
21: import java.io.ObjectInputStream;
22: import java.io.ObjectOutputStream;
23:
24: import javax.xml.namespace.QName;
25:
26: import junit.framework.TestCase;
27:
28: import org.apache.servicemix.jbi.framework.ComponentNameSpace;
29:
30: public class InternalEndpointTest extends TestCase {
31:
32: public void testSerializeDeserialize() throws Exception {
33: ComponentNameSpace cns = new ComponentNameSpace("myContainer",
34: "myName");
35: InternalEndpoint e = new InternalEndpoint(cns, "myEndpoint",
36: new QName("myService"));
37:
38: ByteArrayOutputStream baos = new ByteArrayOutputStream();
39: ObjectOutputStream oos = new ObjectOutputStream(baos);
40: oos.writeObject(e);
41: oos.close();
42:
43: ByteArrayInputStream bais = new ByteArrayInputStream(baos
44: .toByteArray());
45: ObjectInputStream ois = new ObjectInputStream(bais);
46: Object out = ois.readObject();
47:
48: assertNotNull(out);
49: assertTrue(out instanceof InternalEndpoint);
50: InternalEndpoint outE = (InternalEndpoint) out;
51: assertNotNull(outE.getComponentNameSpace());
52: assertNotNull(outE.getServiceName());
53: assertNotNull(outE.getEndpointName());
54: }
55:
56: public void testEquals() throws Exception {
57: ComponentNameSpace cns = new ComponentNameSpace("myContainer",
58: "myName");
59: InternalEndpoint e1 = new InternalEndpoint(cns, "myEndpoint1",
60: new QName("myService"));
61: InternalEndpoint e2 = new InternalEndpoint(cns, "myEndpoint2",
62: new QName("myService"));
63: assertFalse(e1.equals(e2));
64: e2 = new InternalEndpoint(cns, "myEndpoint", new QName(
65: "myService2"));
66: assertFalse(e1.equals(e2));
67: ComponentNameSpace cns2 = new ComponentNameSpace(
68: "myContainer2", "myId2");
69: e2 = new InternalEndpoint(cns2, "myEndpoint1", new QName(
70: "myService"));
71: assertTrue(e1.equals(e2));
72: cns2 = new ComponentNameSpace("myContainer", "myName");
73: e2 = new InternalEndpoint(cns2, "myEndpoint1", new QName(
74: "myService"));
75: assertTrue(e1.equals(e2));
76: }
77:
78: }
|