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