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