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