1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.Address; 19 import org.apache.juddi.datatype.AddressLine; 20 import org.apache.juddi.datatype.CategoryBag; 21 import org.apache.juddi.datatype.Description; 22 import org.apache.juddi.datatype.DiscoveryURL; 23 import org.apache.juddi.datatype.DiscoveryURLs; 24 import org.apache.juddi.datatype.Email; 25 import org.apache.juddi.datatype.IdentifierBag; 26 import org.apache.juddi.datatype.KeyedReference; 27 import org.apache.juddi.datatype.Name; 28 import org.apache.juddi.datatype.OverviewDoc; 29 import org.apache.juddi.datatype.Phone; 30 import org.apache.juddi.datatype.RegistryObject; 31 import org.apache.juddi.datatype.UploadRegister; 32 import org.apache.juddi.datatype.binding.AccessPoint; 33 import org.apache.juddi.datatype.binding.BindingTemplate; 34 import org.apache.juddi.datatype.binding.BindingTemplates; 35 import org.apache.juddi.datatype.binding.HostingRedirector; 36 import org.apache.juddi.datatype.binding.InstanceDetails; 37 import org.apache.juddi.datatype.binding.TModelInstanceDetails; 38 import org.apache.juddi.datatype.binding.TModelInstanceInfo; 39 import org.apache.juddi.datatype.business.BusinessEntity; 40 import org.apache.juddi.datatype.business.Contact; 41 import org.apache.juddi.datatype.business.Contacts; 42 import org.apache.juddi.datatype.request.AuthInfo; 43 import org.apache.juddi.datatype.request.SaveBusiness; 44 import org.apache.juddi.datatype.service.BusinessService; 45 import org.apache.juddi.datatype.service.BusinessServices; 46 import org.apache.juddi.util.xml.XMLUtils; 47 import org.w3c.dom.Element ; 48 49 52 public class SaveBusinessHandlerTests extends HandlerTestCase 53 { 54 private static final String TEST_ID = "juddi.handler.DeleteSaveBusiness.test"; 55 private SaveBusinessHandler handler = null; 56 57 public SaveBusinessHandlerTests(String arg0) 58 { 59 super(arg0); 60 } 61 62 public static void main(String [] args) 63 { 64 junit.textui.TestRunner.run( SaveBusinessHandlerTests.class); 65 } 66 67 public void setUp() 68 { 69 HandlerMaker maker = HandlerMaker.getInstance(); 70 handler = ( SaveBusinessHandler)maker.lookup( SaveBusinessHandler.TAG_NAME); 71 } 72 73 private RegistryObject getRegistryObject() 74 { 75 AuthInfo authInfo = new AuthInfo(); 76 authInfo.setValue("6f157513-844e-4a95-a856-d257e6ba9726"); 77 78 OverviewDoc overDoc = new OverviewDoc(); 79 overDoc.setOverviewURL("http://www.sviens.com/service.html"); 80 overDoc.addDescription(new Description("over-doc Descr")); 81 overDoc.addDescription(new Description("over-doc Descr Two","en")); 82 83 InstanceDetails instDetails = new InstanceDetails(); 84 instDetails.addDescription(new Description("body-isa-wunder")); 85 instDetails.addDescription(new Description("sweetchild-o-mine","it")); 86 instDetails.setInstanceParms("inst-det parameters"); 87 instDetails.setOverviewDoc(overDoc); 88 89 TModelInstanceInfo tModInstInfo = new TModelInstanceInfo(); 90 tModInstInfo.setTModelKey("uuid:ae0f9fd4-287f-40c9-be91-df47a7c72fd9"); 91 tModInstInfo.addDescription(new Description("tMod-Inst-Info")); 92 tModInstInfo.addDescription(new Description("tMod-Inst-Info too","es")); 93 tModInstInfo.setInstanceDetails(instDetails); 94 95 TModelInstanceDetails tModInstDet = new TModelInstanceDetails(); 96 tModInstDet.addTModelInstanceInfo(tModInstInfo); 97 98 BindingTemplate binding = new BindingTemplate(); 99 binding.setBindingKey("c9613c3c-fe55-4f34-a3da-b3167afbca4a"); 100 binding.setServiceKey("997a55bc-563d-4c04-8a94-781604870d31"); 101 binding.addDescription(new Description("whatever")); 102 binding.addDescription(new Description("whatever too","fr")); 103 binding.setHostingRedirector(new HostingRedirector("92658289-0bd7-443c-8948-0bb4460b44c0")); 104 binding.setAccessPoint(new AccessPoint(AccessPoint.HTTP,"http://www.sviens.com/service.wsdl")); 105 binding.setTModelInstanceDetails(tModInstDet); 106 107 BindingTemplates bindings = new BindingTemplates(); 108 bindings.addBindingTemplate(binding); 109 110 CategoryBag catBag = new CategoryBag(); 111 catBag.addKeyedReference(new KeyedReference("catBagKeyName","catBagKeyValue")); 112 catBag.addKeyedReference(new KeyedReference("uuid:dfddb58c-4853-4a71-865c-f84509017cc7","catBagKeyName2","catBagKeyValue2")); 113 114 IdentifierBag idBag = new IdentifierBag(); 115 idBag.addKeyedReference(new KeyedReference("idBagKeyName","idBagkeyValue")); 116 idBag.addKeyedReference(new KeyedReference("uuid:f78a135a-4769-4e79-8604-54d440314bc0","idBagKeyName2","idBagkeyValue2")); 117 118 DiscoveryURLs discURLs = new DiscoveryURLs(); 119 discURLs.addDiscoveryURL(new DiscoveryURL("http","http://www.sviens.com/service.wsdl")); 120 discURLs.addDiscoveryURL(new DiscoveryURL("https","https://www.sviens.com/service.wsdl")); 121 discURLs.addDiscoveryURL(new DiscoveryURL("smtp","servicemngr@sviens.com")); 122 123 Address address = new Address(); 124 address.setUseType("myAddressUseType"); 125 address.setSortCode("sortThis"); 126 address.setTModelKey(null); 127 address.addAddressLine(new AddressLine("AddressLine1","keyNameAttr","keyValueAttr")); 128 address.addAddressLine(new AddressLine("AddressLine2")); 129 130 Contact contact = new Contact(); 131 contact.setUseType("myAddressUseType"); 132 contact.setPersonNameValue("Bob Whatever"); 133 contact.addDescription(new Description("Bob is a big fat jerk")); 134 contact.addDescription(new Description("obBay sIay a igBay atFay erkJay","es")); 135 contact.addEmail(new Email("bob@whatever.com")); 136 contact.addPhone(new Phone("(603)559-1901")); 137 contact.addAddress(address); 138 139 Contacts contacts = new Contacts(); 140 contacts.addContact(contact); 141 142 BusinessService service = new BusinessService(); 143 service.setServiceKey("fe8af00d-3a2c-4e05-b7ca-95a1259aad4f"); 144 service.setBusinessKey("b8cc7266-9eed-4675-b621-34697f252a77"); 145 service.setBindingTemplates(bindings); 146 service.setCategoryBag(catBag); 147 service.addName(new Name("serviceNm")); 148 service.addName(new Name("serviceNm2","en")); 149 service.addDescription(new Description("service whatever")); 150 service.addDescription(new Description("service whatever too","it")); 151 152 BusinessServices services = new BusinessServices(); 153 services.addBusinessService(service); 154 services.addBusinessService(service); 155 156 BusinessEntity business = new BusinessEntity(); 157 business.setBusinessKey("6c0ac186-d36b-4b81-bd27-066a5fe0fc1f"); 158 business.setAuthorizedName("Steve Viens"); 159 business.setOperator("jUDDI"); 160 business.addName(new Name("businessNm")); 161 business.addName(new Name("businessNm2","en")); 162 business.addDescription(new Description("business whatever")); 163 business.addDescription(new Description("business whatever too","fr")); 164 business.setDiscoveryURLs(discURLs); 165 business.setCategoryBag(catBag); 166 business.setIdentifierBag(idBag); 167 business.setContacts(contacts); 168 business.setBusinessServices(services); 169 170 SaveBusiness object = new SaveBusiness(); 171 object.setAuthInfo(authInfo); 172 object.addBusinessEntity(business); 173 object.addBusinessEntity(business); 174 object.addUploadRegister(new UploadRegister("http://www.juddi.org/businessEntity.xml")); 175 object.addUploadRegister(new UploadRegister("http://www.sourceforge.net/businessService.xml")); 176 object.addUploadRegister(new UploadRegister("http://www.uddi.org/bindingTemplate.xml")); 177 178 return object; 179 180 } 181 182 private Element getMarshalledElement(RegistryObject regObject) 183 { 184 Element parent = XMLUtils.newRootElement(); 185 Element child = null; 186 187 if(regObject == null) 188 regObject = this.getRegistryObject(); 189 190 handler.marshal(regObject,parent); 191 child = (Element )parent.getFirstChild(); 192 parent.removeChild(child); 193 194 return child; 195 } 196 197 public void testMarshal() 198 { 199 Element child = getMarshalledElement(null); 200 201 String marshalledString = this.getXMLString(child); 202 203 assertNotNull("Marshalled SaveBusiness ", marshalledString); 204 205 } 206 207 public void testUnMarshal() 208 { 209 210 Element child = getMarshalledElement(null); 211 RegistryObject regObject = handler.unmarshal(child); 212 213 assertNotNull("UnMarshalled SaveBusiness ", regObject); 214 215 } 216 217 public void testMarshUnMarshal() 218 { 219 Element child = getMarshalledElement(null); 220 221 String marshalledString = this.getXMLString(child); 222 223 assertNotNull("Marshalled SaveBusiness ", marshalledString); 224 225 RegistryObject regObject = handler.unmarshal(child); 226 227 child = getMarshalledElement(regObject); 228 229 String unMarshalledString = this.getXMLString(child); 230 231 assertNotNull("Unmarshalled SaveBusiness ", unMarshalledString); 232 233 boolean equals = marshalledString.equals(unMarshalledString); 234 235 assertEquals("Expected SaveBusiness: ", marshalledString, unMarshalledString ); 236 } 237 238 } 239 | Popular Tags |