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.datatype.assertion.PublisherAssertion; 21 import org.apache.juddi.util.xml.XMLUtils; 22 import org.w3c.dom.Element ; 23 24 27 public class PublisherAssertionHandlerTests extends HandlerTestCase 28 { 29 private static final String TEST_ID = "juddi.handler.DeletePublisher.test"; 30 private PublisherAssertionHandler handler = null; 31 32 public PublisherAssertionHandlerTests(String arg0) 33 { 34 super(arg0); 35 } 36 37 public static void main(String [] args) 38 { 39 junit.textui.TestRunner.run( PublisherAssertionHandlerTests.class); 40 } 41 42 public void setUp() 43 { 44 HandlerMaker maker = HandlerMaker.getInstance(); 45 handler = ( PublisherAssertionHandler)maker.lookup( PublisherAssertionHandler.TAG_NAME); 46 } 47 48 private RegistryObject getRegistryObject() 49 { 50 PublisherAssertion object = new PublisherAssertion(); 51 object.setFromKey("b2f072e7-6013-4385-93b4-9c1c2ece1c8f"); 52 object.setToKey("115be72d-0c04-4b5f-a729-79a522629c19"); 53 object.setKeyedReference(new KeyedReference("uuid:8ff45356-acde-4a4c-86bf-f953611d20c6","catBagKeyName2","catBagKeyValue2")); 54 55 return object; 56 57 } 58 59 private Element getMarshalledElement(RegistryObject regObject) 60 { 61 Element parent = XMLUtils.newRootElement(); 62 Element child = null; 63 64 if(regObject == null) 65 regObject = this.getRegistryObject(); 66 67 handler.marshal(regObject,parent); 68 child = (Element )parent.getFirstChild(); 69 parent.removeChild(child); 70 71 return child; 72 } 73 74 public void testMarshal() 75 { 76 Element child = getMarshalledElement(null); 77 78 String marshalledString = this.getXMLString(child); 79 80 assertNotNull("Marshalled PublisherAssertion ", marshalledString); 81 82 } 83 84 public void testUnMarshal() 85 { 86 87 Element child = getMarshalledElement(null); 88 RegistryObject regObject = handler.unmarshal(child); 89 90 assertNotNull("UnMarshalled PublisherAssertion ", regObject); 91 92 } 93 94 public void testMarshUnMarshal() 95 { 96 Element child = getMarshalledElement(null); 97 98 String marshalledString = this.getXMLString(child); 99 100 assertNotNull("Marshalled PublisherAssertion ", marshalledString); 101 102 RegistryObject regObject = handler.unmarshal(child); 103 104 child = getMarshalledElement(regObject); 105 106 String unMarshalledString = this.getXMLString(child); 107 108 assertNotNull("Unmarshalled PublisherAssertion ", unMarshalledString); 109 110 boolean equals = marshalledString.equals(unMarshalledString); 111 112 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 113 } 114 115 } 116 | Popular Tags |