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