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