1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.BindingKey; 19 import org.apache.juddi.datatype.RegistryObject; 20 import org.apache.juddi.datatype.request.AuthInfo; 21 import org.apache.juddi.datatype.request.DeleteBinding; 22 import org.apache.juddi.util.xml.XMLUtils; 23 import org.w3c.dom.Element ; 24 25 28 public class DeleteBindingHandlerTests extends HandlerTestCase 29 { 30 private static final String TEST_ID = "juddi.handler.DeleteBinding.test"; 31 private DeleteBindingHandler handler = null; 32 33 public DeleteBindingHandlerTests(String arg0) 34 { 35 super(arg0); 36 } 37 38 public static void main(String [] args) 39 { 40 junit.textui.TestRunner.run(DeleteBindingHandlerTests.class); 41 } 42 43 public void setUp() 44 { 45 HandlerMaker maker = HandlerMaker.getInstance(); 46 handler = (DeleteBindingHandler)maker.lookup(DeleteBindingHandler.TAG_NAME); 47 } 48 49 private RegistryObject getRegistryObject() 50 { 51 52 AuthInfo authInfo = new AuthInfo(); 53 authInfo.setValue("6f157513-844e-4a95-a856-d257e6ba9726"); 54 55 DeleteBinding object = new DeleteBinding(); 56 57 object.setAuthInfo(authInfo); 58 object.addBindingKey("1bd50f65-9671-41ae-8d13-b3b5a5afcda0"); 59 object.addBindingKey(new BindingKey("1fbe67e6-f8b5-4743-a23f-9c13e4273d9f")); 60 61 return object; 62 63 } 64 65 private Element getMarshalledElement(RegistryObject regObject) 66 { 67 Element parent = XMLUtils.newRootElement(); 68 Element child = null; 69 70 if(regObject == null) 71 regObject = this.getRegistryObject(); 72 73 handler.marshal(regObject,parent); 74 child = (Element )parent.getFirstChild(); 75 parent.removeChild(child); 76 77 return child; 78 } 79 80 public void testMarshal() 81 { 82 Element child = getMarshalledElement(null); 83 84 String marshalledString = this.getXMLString(child); 85 86 assertNotNull("Marshalled DeleteBinding ", marshalledString); 87 88 } 89 90 public void testUnMarshal() 91 { 92 93 Element child = getMarshalledElement(null); 94 RegistryObject regObject = handler.unmarshal(child); 95 96 assertNotNull("UnMarshalled DeleteBinding ", regObject); 97 98 } 99 100 public void testMarshUnMarshal() 101 { 102 Element child = getMarshalledElement(null); 103 104 String marshalledString = this.getXMLString(child); 105 106 assertNotNull("Marshalled DeleteBinding ", marshalledString); 107 108 RegistryObject regObject = handler.unmarshal(child); 109 110 child = getMarshalledElement(regObject); 111 112 String unMarshalledString = this.getXMLString(child); 113 114 assertNotNull("Unmarshalled DeleteBinding ", unMarshalledString); 115 116 boolean equals = marshalledString.equals(unMarshalledString); 117 118 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 119 } 120 121 } 122 | Popular Tags |