01: package org.objectweb.celtix.bus.handlers;
02:
03: import javax.xml.namespace.QName;
04:
05: import junit.framework.TestCase;
06:
07: public class PortInfoImplTest extends TestCase {
08:
09: private final PortInfoImpl p1 = new PortInfoImpl(new QName(
10: "http://foo.bar.com/test", "Port"), new QName(
11: "http://foo.bar.com/test", "Service"), "bindingid");
12:
13: private final PortInfoImpl p2 = new PortInfoImpl(new QName(
14: "http://foo.bar.com/test", "Port"), new QName(
15: "http://foo.bar.com/test", "Service"), "bindingid");
16: private final PortInfoImpl p3 = new PortInfoImpl(new QName(
17: "http://foo.bar.com/test", "Port"), new QName(
18: "http://foo.bar.com/test", "Service"), "bindingid");
19: private final PortInfoImpl p4 = new PortInfoImpl(new QName(
20: "http://foo.bar.com/test", "Port1"), new QName(
21: "http://foo.bar.com/test", "Service"), "bindingid");
22:
23: public void testConstructor() {
24:
25: try {
26: new PortInfoImpl(null, new QName("", ""), "");
27: fail("did not get expected exception");
28: } catch (IllegalArgumentException ex) {
29: assertTrue(true);
30: }
31: try {
32: new PortInfoImpl(new QName("", ""), null, "");
33: fail("did not get expected exception");
34: } catch (IllegalArgumentException ex) {
35: assertTrue(true);
36: }
37: // this should not throw exception
38: //
39: new PortInfoImpl(new QName("", ""), new QName("", ""), null);
40:
41: }
42:
43: public void testAttributes() {
44:
45: QName portName = new QName("http://foo.bar.com/test", "Port");
46: final QName serviceName = new QName("http://foo.bar.com/test",
47: "Service");
48: final String bindingId = "bindingid";
49:
50: PortInfoImpl pii = new PortInfoImpl(serviceName, portName,
51: bindingId);
52:
53: assertEquals(bindingId, pii.getBindingID());
54: assertEquals(portName, pii.getPortName());
55: assertEquals(serviceName, pii.getServiceName());
56: }
57:
58: public void testEquals() {
59:
60: assertEquals(p1, p1);
61: assertEquals(p1, p2);
62: assertEquals(p2, p3);
63: assertEquals(p1, p3);
64: assertTrue(!p1.equals(p4));
65: assertTrue(!p1.equals(null));
66: assertTrue(!p1.equals("foobar"));
67: }
68:
69: public void testHashCode() {
70:
71: assertEquals(p1.hashCode(), p2.hashCode());
72: assertTrue(p1.hashCode() != p4.hashCode());
73: }
74: }
|