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