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