1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.RegistryObject; 19 import org.apache.juddi.datatype.assertion.PublisherAssertion; 20 import org.apache.juddi.datatype.request.AuthInfo; 21 import org.apache.juddi.datatype.request.DeletePublisherAssertions; 22 import org.apache.juddi.util.xml.XMLUtils; 23 import org.w3c.dom.Element ; 24 25 28 public class DeletePublisherAssertionsHandlerTests extends HandlerTestCase 29 { 30 private static final String TEST_ID = "juddi.handler.DeletePublisherAssertion.test"; 31 private DeletePublisherAssertionsHandler handler = null; 32 33 public DeletePublisherAssertionsHandlerTests(String arg0) 34 { 35 super(arg0); 36 } 37 38 public static void main(String [] args) 39 { 40 junit.textui.TestRunner.run(DeletePublisherAssertionsHandlerTests.class); 41 } 42 43 public void setUp() 44 { 45 HandlerMaker maker = HandlerMaker.getInstance(); 46 handler = (DeletePublisherAssertionsHandler)maker.lookup(DeletePublisherAssertionsHandler.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 PublisherAssertion assertion1 = new PublisherAssertion(); 56 assertion1.setFromKey("6f157513-844e-4a95-a856-d257e6ba0000"); 57 assertion1.setToKey("6f157513-844e-4a95-a856-d257e6ba1111"); 58 59 PublisherAssertion assertion2 = new PublisherAssertion(); 60 assertion2.setFromKey("6f157513-844e-4a95-a856-d257e6ba2222"); 61 assertion2.setToKey("6f157513-844e-4a95-a856-d257e6ba3333"); 62 63 DeletePublisherAssertions object = new DeletePublisherAssertions(); 64 object.setAuthInfo(authInfo); 65 object.addPublisherAssertion(assertion1); 66 object.addPublisherAssertion(assertion2); 67 68 return object; 69 70 } 71 72 private Element getMarshalledElement(RegistryObject regObject) 73 { 74 Element parent = XMLUtils.newRootElement(); 75 Element child = null; 76 77 if(regObject == null) 78 regObject = this.getRegistryObject(); 79 80 handler.marshal(regObject,parent); 81 child = (Element )parent.getFirstChild(); 82 parent.removeChild(child); 83 84 return child; 85 } 86 87 public void testMarshal() 88 { 89 Element child = getMarshalledElement(null); 90 91 String marshalledString = this.getXMLString(child); 92 93 assertNotNull("Marshalled DeletePublisherAssertions ", marshalledString); 94 95 } 96 97 public void testUnMarshal() 98 { 99 100 Element child = getMarshalledElement(null); 101 RegistryObject regObject = handler.unmarshal(child); 102 103 assertNotNull("UnMarshalled DeletePublisherAssertions ", regObject); 104 105 } 106 107 public void testMarshUnMarshal() 108 { 109 Element child = getMarshalledElement(null); 110 111 String marshalledString = this.getXMLString(child); 112 113 assertNotNull("Marshalled DeletePublisherAssertions ", marshalledString); 114 115 RegistryObject regObject = handler.unmarshal(child); 116 117 child = getMarshalledElement(regObject); 118 119 String unMarshalledString = this.getXMLString(child); 120 121 assertNotNull("Unmarshalled DeletePublisherAssertions ", unMarshalledString); 122 123 boolean equals = marshalledString.equals(unMarshalledString); 124 125 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 126 } 127 128 } 129 | Popular Tags |