1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.CategoryBag; 19 import org.apache.juddi.datatype.KeyedReference; 20 import org.apache.juddi.datatype.Name; 21 import org.apache.juddi.datatype.RegistryObject; 22 import org.apache.juddi.datatype.TModelBag; 23 import org.apache.juddi.datatype.TModelKey; 24 import org.apache.juddi.datatype.request.FindQualifier; 25 import org.apache.juddi.datatype.request.FindService; 26 import org.apache.juddi.util.xml.XMLUtils; 27 import org.w3c.dom.Element ; 28 29 32 public class FindServiceHandlerTests extends HandlerTestCase 33 { 34 private static final String TEST_ID = "juddi.handler.DeletePublisher.test"; 35 private FindServiceHandler handler = null; 36 37 public FindServiceHandlerTests(String arg0) 38 { 39 super(arg0); 40 } 41 42 public static void main(String [] args) 43 { 44 junit.textui.TestRunner.run( FindServiceHandlerTests.class); 45 } 46 47 public void setUp() 48 { 49 HandlerMaker maker = HandlerMaker.getInstance(); 50 handler = ( FindServiceHandler)maker.lookup( FindServiceHandler.TAG_NAME); 51 } 52 53 private RegistryObject getRegistryObject() 54 { 55 FindService object = new FindService(); 56 57 CategoryBag catBag = new CategoryBag(); 58 catBag.addKeyedReference(new KeyedReference("catBagKeyName","catBagKeyValue")); 59 catBag.addKeyedReference(new KeyedReference("uuid:8ff45356-acde-4a4c-86bf-f953611d20c6","catBagKeyName2","catBagKeyValue2")); 60 61 TModelBag tModBag = new TModelBag(); 62 tModBag.addTModelKey("uuid:35d9793b-9911-4b85-9f0e-5d4c65b4f253"); 63 tModBag.addTModelKey(new TModelKey("uuid:c5ab113f-0d6b-4247-b3c4-8c012726acd8")); 64 65 object.addName(new Name("serviceNm")); 66 object.addName(new Name("serviceNm2","en")); 67 object.addFindQualifier(new FindQualifier(FindQualifier.SORT_BY_DATE_ASC)); 68 object.addFindQualifier(new FindQualifier(FindQualifier.AND_ALL_KEYS)); 69 object.setMaxRows(50); 70 object.setBusinessKey("fd36dbce-bc3e-468b-8346-5374975a0843"); 71 object.setTModelBag(tModBag); 72 object.setCategoryBag(catBag); 73 74 return object; 75 76 } 77 78 private Element getMarshalledElement(RegistryObject regObject) 79 { 80 Element parent = XMLUtils.newRootElement(); 81 Element child = null; 82 83 if(regObject == null) 84 regObject = this.getRegistryObject(); 85 86 handler.marshal(regObject,parent); 87 child = (Element )parent.getFirstChild(); 88 parent.removeChild(child); 89 90 return child; 91 } 92 93 public void testMarshal() 94 { 95 Element child = getMarshalledElement(null); 96 97 String marshalledString = this.getXMLString(child); 98 99 assertNotNull("Marshalled FindService ", marshalledString); 100 101 } 102 103 public void testUnMarshal() 104 { 105 106 Element child = getMarshalledElement(null); 107 RegistryObject regObject = handler.unmarshal(child); 108 109 assertNotNull("UnMarshalled FindService ", regObject); 110 111 } 112 113 public void testMarshUnMarshal() 114 { 115 Element child = getMarshalledElement(null); 116 117 String marshalledString = this.getXMLString(child); 118 119 assertNotNull("Marshalled FindService ", marshalledString); 120 121 RegistryObject regObject = handler.unmarshal(child); 122 123 child = getMarshalledElement(regObject); 124 125 String unMarshalledString = this.getXMLString(child); 126 127 assertNotNull("Unmarshalled FindService ", unMarshalledString); 128 129 boolean equals = marshalledString.equals(unMarshalledString); 130 131 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 132 } 133 134 } 135 | Popular Tags |