1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.RegistryObject; 19 import org.apache.juddi.datatype.binding.InstanceParms; 20 import org.apache.juddi.util.xml.XMLUtils; 21 import org.w3c.dom.Element ; 22 23 26 public class InstanceParmsHandlerTests extends HandlerTestCase 27 { 28 private static final String TEST_ID = "juddi.handler.DeletePublisher.test"; 29 private InstanceParmsHandler handler = null; 30 31 public InstanceParmsHandlerTests(String arg0) 32 { 33 super(arg0); 34 } 35 36 public static void main(String [] args) 37 { 38 junit.textui.TestRunner.run( InstanceParmsHandlerTests.class); 39 } 40 41 public void setUp() 42 { 43 HandlerMaker maker = HandlerMaker.getInstance(); 44 handler = ( InstanceParmsHandler)maker.lookup( InstanceParmsHandler.TAG_NAME); 45 } 46 47 private RegistryObject getRegistryObject() 48 { 49 InstanceParms object = new InstanceParms(); 50 object.setText("iParms-whatever"); 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 InstanceParms ", 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 InstanceParms ", 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 InstanceParms ", marshalledString); 98 99 RegistryObject regObject = handler.unmarshal(child); 100 101 child = getMarshalledElement(regObject); 102 103 String unMarshalledString = this.getXMLString(child); 104 105 assertNotNull("Unmarshalled InstanceParms ", unMarshalledString); 106 107 boolean equals = marshalledString.equals(unMarshalledString); 108 109 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 110 } 111 112 } 113 | Popular Tags |