1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.CategoryBag; 19 import org.apache.juddi.datatype.IdentifierBag; 20 import org.apache.juddi.datatype.KeyedReference; 21 import org.apache.juddi.datatype.Name; 22 import org.apache.juddi.datatype.RegistryObject; 23 import org.apache.juddi.datatype.request.FindQualifier; 24 import org.apache.juddi.datatype.request.FindTModel; 25 import org.apache.juddi.util.xml.XMLUtils; 26 import org.w3c.dom.Element ; 27 28 31 public class FindTModelHandlerTests extends HandlerTestCase 32 { 33 private static final String TEST_ID = "juddi.handler.DeletePublisher.test"; 34 private FindTModelHandler handler = null; 35 36 public FindTModelHandlerTests(String arg0) 37 { 38 super(arg0); 39 } 40 41 public static void main(String [] args) 42 { 43 junit.textui.TestRunner.run( FindTModelHandlerTests.class); 44 } 45 46 public void setUp() 47 { 48 HandlerMaker maker = HandlerMaker.getInstance(); 49 handler = ( FindTModelHandler)maker.lookup( FindTModelHandler.TAG_NAME); 50 } 51 52 private RegistryObject getRegistryObject() 53 { 54 FindTModel object = new FindTModel(); 55 56 IdentifierBag idBag = new IdentifierBag(); 57 idBag.addKeyedReference(new KeyedReference("idBagKeyName","idBagKeyValue")); 58 idBag.addKeyedReference(new KeyedReference("uuid:3860b975-9e0c-4cec-bad6-87dfe00e3864","idBagKeyName2","idBagKeyValue2")); 59 60 CategoryBag catBag = new CategoryBag(); 61 catBag.addKeyedReference(new KeyedReference("catBagKeyName","catBagKeyValue")); 62 catBag.addKeyedReference(new KeyedReference("uuid:8ff45356-acde-4a4c-86bf-f953611d20c6","catBagKeyName2","catBagKeyValue2")); 63 64 object.setName(new Name("serviceNm2","en")); 65 object.addFindQualifier(new FindQualifier(FindQualifier.SORT_BY_DATE_ASC)); 66 object.addFindQualifier(new FindQualifier(FindQualifier.AND_ALL_KEYS)); 67 object.setMaxRows(37); 68 object.setIdentifierBag(idBag); 69 object.setCategoryBag(catBag); 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 FindTModel ", 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 FindTModel ", 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 FindTModel ", marshalledString); 117 118 RegistryObject regObject = handler.unmarshal(child); 119 120 child = getMarshalledElement(regObject); 121 122 String unMarshalledString = this.getXMLString(child); 123 124 assertNotNull("Unmarshalled FindTModel ", unMarshalledString); 125 126 boolean equals = marshalledString.equals(unMarshalledString); 127 128 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 129 } 130 131 } 132 | Popular Tags |