1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.RegistryObject; 19 import org.apache.juddi.datatype.binding.HostingRedirector; 20 import org.apache.juddi.util.xml.XMLUtils; 21 import org.w3c.dom.Element ; 22 23 26 public class HostingRedirectorHandlerTests extends HandlerTestCase 27 { 28 private static final String TEST_ID = "juddi.handler.DeletePublisher.test"; 29 private HostingRedirectorHandler handler = null; 30 31 public HostingRedirectorHandlerTests(String arg0) 32 { 33 super(arg0); 34 } 35 36 public static void main(String [] args) 37 { 38 junit.textui.TestRunner.run( HostingRedirectorHandlerTests.class); 39 } 40 41 public void setUp() 42 { 43 HandlerMaker maker = HandlerMaker.getInstance(); 44 handler = ( HostingRedirectorHandler)maker.lookup( HostingRedirectorHandler.TAG_NAME); 45 } 46 47 private RegistryObject getRegistryObject() 48 { 49 HostingRedirector object = new HostingRedirector(); 50 object.setBindingKey("92658289-0bd7-443c-8948-0bb4460b44c0"); 51 52 return object; 53 54 } 55 56 private Element getMarshalledElement(RegistryObject regObject) 57 { 58 Element parent = XMLUtils.newRootElement(); 59 Element child = null; 60 61 if(regObject == null) 62 regObject = this.getRegistryObject(); 63 64 handler.marshal(regObject,parent); 65 child = (Element )parent.getFirstChild(); 66 parent.removeChild(child); 67 68 return child; 69 } 70 71 public void testMarshal() 72 { 73 Element child = getMarshalledElement(null); 74 75 String marshalledString = this.getXMLString(child); 76 77 assertNotNull("Marshalled HostingRedirector ", marshalledString); 78 79 } 80 81 public void testUnMarshal() 82 { 83 84 Element child = getMarshalledElement(null); 85 RegistryObject regObject = handler.unmarshal(child); 86 87 assertNotNull("UnMarshalled HostingRedirector ", regObject); 88 89 } 90 91 public void testMarshUnMarshal() 92 { 93 Element child = getMarshalledElement(null); 94 95 String marshalledString = this.getXMLString(child); 96 97 assertNotNull("Marshalled HostingRedirector ", marshalledString); 98 99 RegistryObject regObject = handler.unmarshal(child); 100 101 child = getMarshalledElement(regObject); 102 103 String unMarshalledString = this.getXMLString(child); 104 105 assertNotNull("Unmarshalled HostingRedirector ", unMarshalledString); 106 107 boolean equals = marshalledString.equals(unMarshalledString); 108 109 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 110 } 111 112 } 113 | Popular Tags |