1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.RegistryObject; 19 import org.apache.juddi.datatype.response.PublisherInfo; 20 import org.apache.juddi.datatype.response.PublisherList; 21 import org.apache.juddi.util.xml.XMLUtils; 22 import org.w3c.dom.Element ; 23 24 27 public class PublisherListHandlerTests extends HandlerTestCase 28 { 29 private static final String TEST_ID = "juddi.handler.DeletePublisherList.test"; 30 private PublisherListHandler handler = null; 31 32 public PublisherListHandlerTests(String arg0) 33 { 34 super(arg0); 35 } 36 37 public static void main(String [] args) 38 { 39 junit.textui.TestRunner.run( PublisherListHandlerTests.class); 40 } 41 42 public void setUp() 43 { 44 HandlerMaker maker = HandlerMaker.getInstance(); 45 handler = ( PublisherListHandler)maker.lookup( PublisherListHandler.TAG_NAME); 46 } 47 48 private RegistryObject getRegistryObject() 49 { 50 PublisherList object = new PublisherList(); 51 object.setGeneric("1.0"); 52 object.setOperator("jUDDI.org"); 53 object.setTruncated(false); 54 object.addPublisherInfo(new PublisherInfo("guest1","Guest1")); 55 object.addPublisherInfo(new PublisherInfo("guest2","Guest2")); 56 57 return object; 58 59 } 60 61 private Element getMarshalledElement(RegistryObject regObject) 62 { 63 Element parent = XMLUtils.newRootElement(); 64 Element child = null; 65 66 if(regObject == null) 67 regObject = this.getRegistryObject(); 68 69 handler.marshal(regObject,parent); 70 child = (Element )parent.getFirstChild(); 71 parent.removeChild(child); 72 73 return child; 74 } 75 76 public void testMarshal() 77 { 78 Element child = getMarshalledElement(null); 79 80 String marshalledString = this.getXMLString(child); 81 82 assertNotNull("Marshalled PublisherList ", marshalledString); 83 84 } 85 86 public void testUnMarshal() 87 { 88 89 Element child = getMarshalledElement(null); 90 RegistryObject regObject = handler.unmarshal(child); 91 92 assertNotNull("UnMarshalled PublisherList ", regObject); 93 94 } 95 96 public void testMarshUnMarshal() 97 { 98 Element child = getMarshalledElement(null); 99 100 String marshalledString = this.getXMLString(child); 101 102 assertNotNull("Marshalled PublisherList ", marshalledString); 103 104 RegistryObject regObject = handler.unmarshal(child); 105 106 child = getMarshalledElement(regObject); 107 108 String unMarshalledString = this.getXMLString(child); 109 110 assertNotNull("Unmarshalled PublisherList ", unMarshalledString); 111 112 boolean equals = marshalledString.equals(unMarshalledString); 113 114 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 115 } 116 117 } 118 | Popular Tags |