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