1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.Description; 19 import org.apache.juddi.datatype.OverviewDoc; 20 import org.apache.juddi.datatype.RegistryObject; 21 import org.apache.juddi.datatype.binding.AccessPoint; 22 import org.apache.juddi.datatype.binding.BindingTemplate; 23 import org.apache.juddi.datatype.binding.HostingRedirector; 24 import org.apache.juddi.datatype.binding.InstanceDetails; 25 import org.apache.juddi.datatype.binding.TModelInstanceDetails; 26 import org.apache.juddi.datatype.binding.TModelInstanceInfo; 27 import org.apache.juddi.util.xml.XMLUtils; 28 import org.w3c.dom.Element ; 29 30 33 public class BindingTemplateHandlerTests extends HandlerTestCase 34 { 35 private static final String TEST_ID = "juddi.handler.BindingTemplate.test"; 36 private BindingTemplateHandler handler = null; 37 38 public BindingTemplateHandlerTests(String arg0) 39 { 40 super(arg0); 41 } 42 43 public static void main(String [] args) 44 { 45 junit.textui.TestRunner.run(BindingTemplateHandlerTests.class); 46 } 47 48 public void setUp() 49 { 50 HandlerMaker maker = HandlerMaker.getInstance(); 51 handler = (BindingTemplateHandler)maker.lookup(BindingTemplateHandler.TAG_NAME); 52 } 53 54 private RegistryObject getRegistryObject() 55 { 56 57 OverviewDoc overDoc = new OverviewDoc(); 58 overDoc.setOverviewURL("http://www.juddi.org/service.html"); 59 overDoc.addDescription(new Description("over-doc Descr")); 60 overDoc.addDescription(new Description("over-doc Descr Two","en")); 61 62 InstanceDetails instDetails = new InstanceDetails(); 63 instDetails.addDescription(new Description("inst-det descr")); 64 instDetails.addDescription(new Description("inst-det descr in italy","it")); 65 instDetails.setInstanceParms("inst-det parameters"); 66 instDetails.setOverviewDoc(overDoc); 67 68 TModelInstanceInfo tModInstInfo = new TModelInstanceInfo(); 69 tModInstInfo.setTModelKey("uuid:ae0f9fd4-287f-40c9-be91-df47a7c72fd9"); 70 tModInstInfo.addDescription(new Description("tMod-Inst-Info")); 71 tModInstInfo.addDescription(new Description("tMod-Inst-Info too","es")); 72 tModInstInfo.setInstanceDetails(instDetails); 73 74 TModelInstanceDetails tModInstDet = new TModelInstanceDetails(); 75 tModInstDet.addTModelInstanceInfo(tModInstInfo); 76 77 BindingTemplate object = new BindingTemplate(); 78 object.setBindingKey("c9613c3c-fe55-4f34-a3da-b3167afbca4a"); 79 object.setServiceKey("997a55bc-563d-4c04-8a94-781604870d31"); 80 object.addDescription(new Description("whatever")); 81 object.addDescription(new Description("whatever too","fr")); 82 object.setHostingRedirector(new HostingRedirector("92658289-0bd7-443c-8948-0bb4460b44c0")); 83 object.setAccessPoint(new AccessPoint(AccessPoint.HTTP,"http://www.juddi.org/service.wsdl")); 84 object.setTModelInstanceDetails(tModInstDet); 85 86 return object; 87 88 } 89 90 private Element getMarshalledElement(RegistryObject regObject) 91 { 92 Element parent = XMLUtils.newRootElement(); 93 Element child = null; 94 95 if(regObject == null) 96 regObject = this.getRegistryObject(); 97 98 handler.marshal(regObject,parent); 99 child = (Element )parent.getFirstChild(); 100 parent.removeChild(child); 101 102 return child; 103 } 104 105 public void testMarshal() 106 { 107 Element child = getMarshalledElement(null); 108 109 String marshalledString = this.getXMLString(child); 110 111 assertNotNull("Marshalled BindingTemplate ", marshalledString); 112 113 } 114 115 public void testUnMarshal() 116 { 117 118 Element child = getMarshalledElement(null); 119 RegistryObject regObject = handler.unmarshal(child); 120 121 assertNotNull("UnMarshalled BindingTemplate ", regObject); 122 123 } 124 125 public void testMarshUnMarshal() 126 { 127 Element child = getMarshalledElement(null); 128 129 String marshalledString = this.getXMLString(child); 130 131 assertNotNull("Marshalled BindingTemplate ", marshalledString); 132 133 RegistryObject regObject = handler.unmarshal(child); 134 135 child = getMarshalledElement(regObject); 136 137 String unMarshalledString = this.getXMLString(child); 138 139 assertNotNull("Unmarshalled BindingTemplate ", unMarshalledString); 140 141 boolean equals = marshalledString.equals(unMarshalledString); 142 143 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 144 } 145 146 } 147 | Popular Tags |