1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.CategoryBag; 19 import org.apache.juddi.datatype.Description; 20 import org.apache.juddi.datatype.KeyedReference; 21 import org.apache.juddi.datatype.Name; 22 import org.apache.juddi.datatype.OverviewDoc; 23 import org.apache.juddi.datatype.RegistryObject; 24 import org.apache.juddi.datatype.binding.AccessPoint; 25 import org.apache.juddi.datatype.binding.BindingTemplate; 26 import org.apache.juddi.datatype.binding.BindingTemplates; 27 import org.apache.juddi.datatype.binding.HostingRedirector; 28 import org.apache.juddi.datatype.binding.InstanceDetails; 29 import org.apache.juddi.datatype.binding.TModelInstanceDetails; 30 import org.apache.juddi.datatype.binding.TModelInstanceInfo; 31 import org.apache.juddi.datatype.request.AuthInfo; 32 import org.apache.juddi.datatype.request.SaveService; 33 import org.apache.juddi.datatype.service.BusinessService; 34 import org.apache.juddi.util.xml.XMLUtils; 35 import org.w3c.dom.Element ; 36 37 40 public class SaveServiceHandlerTests extends HandlerTestCase 41 { 42 private static final String TEST_ID = "juddi.handler.DeleteSaveService.test"; 43 private SaveServiceHandler handler = null; 44 45 public SaveServiceHandlerTests(String arg0) 46 { 47 super(arg0); 48 } 49 50 public static void main(String [] args) 51 { 52 junit.textui.TestRunner.run( SaveServiceHandlerTests.class); 53 } 54 55 public void setUp() 56 { 57 HandlerMaker maker = HandlerMaker.getInstance(); 58 handler = ( SaveServiceHandler)maker.lookup( SaveServiceHandler.TAG_NAME); 59 } 60 61 private RegistryObject getRegistryObject() 62 { 63 AuthInfo authInfo = new AuthInfo(); 64 authInfo.setValue("6f157513-844e-4a95-a856-d257e6ba9726"); 65 66 OverviewDoc overDoc = new OverviewDoc(); 67 overDoc.setOverviewURL("http://www.juddi.org/service.html"); 68 overDoc.addDescription(new Description("over-doc Descr")); 69 overDoc.addDescription(new Description("over-doc Descr Two","en")); 70 71 InstanceDetails instDetails = new InstanceDetails(); 72 instDetails.addDescription(new Description("Description1")); 73 instDetails.addDescription(new Description("Description2","it")); 74 instDetails.setInstanceParms("inst-det parameters"); 75 instDetails.setOverviewDoc(overDoc); 76 77 TModelInstanceInfo tModInstInfo = new TModelInstanceInfo(); 78 tModInstInfo.setTModelKey("uuid:ae0f9fd4-287f-40c9-be91-df47a7c72fd9"); 79 tModInstInfo.addDescription(new Description("tMod-Inst-Info")); 80 tModInstInfo.addDescription(new Description("tMod-Inst-Info too","es")); 81 tModInstInfo.setInstanceDetails(instDetails); 82 83 TModelInstanceDetails tModInstDet = new TModelInstanceDetails(); 84 tModInstDet.addTModelInstanceInfo(tModInstInfo); 85 86 BindingTemplate binding = new BindingTemplate(); 87 binding.setBindingKey("c9613c3c-fe55-4f34-a3da-b3167afbca4a"); 88 binding.setServiceKey("997a55bc-563d-4c04-8a94-781604870d31"); 89 binding.addDescription(new Description("whatever")); 90 binding.addDescription(new Description("whatever too","fr")); 91 binding.setHostingRedirector(new HostingRedirector("92658289-0bd7-443c-8948-0bb4460b44c0")); 92 binding.setAccessPoint(new AccessPoint(AccessPoint.HTTP,"http://www.juddi.org/service.wsdl")); 93 binding.setTModelInstanceDetails(tModInstDet); 94 95 BindingTemplates bindings = new BindingTemplates(); 96 bindings.addBindingTemplate(binding); 97 98 CategoryBag catBag = new CategoryBag(); 99 catBag.addKeyedReference(new KeyedReference("keyName","keyValue")); 100 catBag.addKeyedReference(new KeyedReference("uuid:dfddb58c-4853-4a71-865c-f84509017cc7","keyName2","keyValue2")); 101 102 BusinessService service = new BusinessService(); 103 service.setServiceKey("fe8af00d-3a2c-4e05-b7ca-95a1259aad4f"); 104 service.setBusinessKey("b8cc7266-9eed-4675-b621-34697f252a77"); 105 service.setBindingTemplates(bindings); 106 service.setCategoryBag(catBag); 107 service.addName(new Name("serviceNm")); 108 service.addName(new Name("serviceNm2","en")); 109 service.addDescription(new Description("service whatever")); 110 service.addDescription(new Description("service whatever too","it")); 111 112 SaveService object = new SaveService(); 113 object.setAuthInfo(authInfo); 114 object.addBusinessService(service); 115 object.addBusinessService(service); 116 117 return object; 118 119 } 120 121 private Element getMarshalledElement(RegistryObject regObject) 122 { 123 Element parent = XMLUtils.newRootElement(); 124 Element child = null; 125 126 if(regObject == null) 127 regObject = this.getRegistryObject(); 128 129 handler.marshal(regObject,parent); 130 child = (Element )parent.getFirstChild(); 131 parent.removeChild(child); 132 133 return child; 134 } 135 136 public void testMarshal() 137 { 138 Element child = getMarshalledElement(null); 139 140 String marshalledString = this.getXMLString(child); 141 142 assertNotNull("Marshalled SaveService ", marshalledString); 143 144 } 145 146 public void testUnMarshal() 147 { 148 149 Element child = getMarshalledElement(null); 150 RegistryObject regObject = handler.unmarshal(child); 151 152 assertNotNull("UnMarshalled SaveService ", regObject); 153 154 } 155 156 public void testMarshUnMarshal() 157 { 158 Element child = getMarshalledElement(null); 159 160 String marshalledString = this.getXMLString(child); 161 162 assertNotNull("Marshalled SaveService ", marshalledString); 163 164 RegistryObject regObject = handler.unmarshal(child); 165 166 child = getMarshalledElement(regObject); 167 168 String unMarshalledString = this.getXMLString(child); 169 170 assertNotNull("Unmarshalled SaveService ", unMarshalledString); 171 172 boolean equals = marshalledString.equals(unMarshalledString); 173 174 assertEquals("Expected SaveService: ", marshalledString, unMarshalledString ); 175 } 176 177 } 178 | Popular Tags |