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