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