1 package org.objectweb.celtix.bus.handlers; 2 3 import javax.xml.namespace.QName ; 4 5 import junit.framework.TestCase; 6 7 public class PortInfoImplTest extends TestCase { 8 9 private final PortInfoImpl p1 = new PortInfoImpl(new QName ("http://foo.bar.com/test", "Port"), 10 new QName ("http://foo.bar.com/test", "Service"), 11 "bindingid"); 12 13 private final PortInfoImpl p2 = new PortInfoImpl(new QName ("http://foo.bar.com/test", "Port"), 14 new QName ("http://foo.bar.com/test", "Service"), 15 "bindingid"); 16 private final PortInfoImpl p3 = new PortInfoImpl(new QName ("http://foo.bar.com/test", "Port"), 17 new QName ("http://foo.bar.com/test", "Service"), 18 "bindingid"); 19 private final PortInfoImpl p4 = new PortInfoImpl(new QName ("http://foo.bar.com/test", "Port1"), 20 new QName ("http://foo.bar.com/test", "Service"), 21 "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 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", "Service"); 47 final String bindingId = "bindingid"; 48 49 PortInfoImpl pii = new PortInfoImpl(serviceName, portName, bindingId); 50 51 assertEquals(bindingId, pii.getBindingID()); 52 assertEquals(portName, pii.getPortName()); 53 assertEquals(serviceName, pii.getServiceName()); 54 } 55 56 public void testEquals() { 57 58 59 assertEquals(p1, p1); 60 assertEquals(p1, p2); 61 assertEquals(p2, p3); 62 assertEquals(p1, p3); 63 assertTrue(!p1.equals(p4)); 64 assertTrue(!p1.equals(null)); 65 assertTrue(!p1.equals("foobar")); 66 } 67 68 public void testHashCode() { 69 70 assertEquals(p1.hashCode(), p2.hashCode()); 71 assertTrue(p1.hashCode() != p4.hashCode()); 72 } 73 } 74 | Popular Tags |