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