1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.Description; 19 import org.apache.juddi.datatype.KeyedReference; 20 import org.apache.juddi.datatype.Name; 21 import org.apache.juddi.datatype.RegistryObject; 22 import org.apache.juddi.datatype.response.RelatedBusinessInfo; 23 import org.apache.juddi.util.xml.XMLUtils; 24 import org.w3c.dom.Element ; 25 26 29 public class RelatedBusinessInfoHandlerTests extends HandlerTestCase 30 { 31 private static final String TEST_ID = "juddi.handler.DeleteRelatedBusinessInfo.test"; 32 private RelatedBusinessInfoHandler handler = null; 33 34 public RelatedBusinessInfoHandlerTests(String arg0) 35 { 36 super(arg0); 37 } 38 39 public static void main(String [] args) 40 { 41 junit.textui.TestRunner.run( RelatedBusinessInfoHandlerTests.class); 42 } 43 44 public void setUp() 45 { 46 HandlerMaker maker = HandlerMaker.getInstance(); 47 handler = ( RelatedBusinessInfoHandler)maker.lookup( RelatedBusinessInfoHandler.TAG_NAME); 48 } 49 50 private RegistryObject getRegistryObject() 51 { 52 RelatedBusinessInfo object = new RelatedBusinessInfo(); 53 object.setBusinessKey(""); 54 object.setBusinessKey("6c0ac186-d36b-4b81-bd27-066a5fe0fc1f"); 55 object.addName(new Name("businessNm")); 56 object.addName(new Name("businessNm2","en")); 57 object.addDescription(new Description("business whatever")); 58 object.addDescription(new Description("business whatever too","fr")); 59 object.addKeyedReference(new KeyedReference("idBagKeyName","idBagkeyValue")); 60 object.addKeyedReference(new KeyedReference("uuid:f78a135a-4769-4e79-8604-54d440314bc0","idBagKeyName2","idBagkeyValue2")); 61 62 return object; 63 64 } 65 66 private Element getMarshalledElement(RegistryObject regObject) 67 { 68 Element parent = XMLUtils.newRootElement(); 69 Element child = null; 70 71 if(regObject == null) 72 regObject = this.getRegistryObject(); 73 74 handler.marshal(regObject,parent); 75 child = (Element )parent.getFirstChild(); 76 parent.removeChild(child); 77 78 return child; 79 } 80 81 public void testMarshal() 82 { 83 Element child = getMarshalledElement(null); 84 85 String marshalledString = this.getXMLString(child); 86 87 assertNotNull("Marshalled RelatedBusinessInfo ", marshalledString); 88 89 } 90 91 public void testUnMarshal() 92 { 93 94 Element child = getMarshalledElement(null); 95 RegistryObject regObject = handler.unmarshal(child); 96 97 assertNotNull("UnMarshalled RelatedBusinessInfo ", regObject); 98 99 } 100 101 public void testMarshUnMarshal() 102 { 103 Element child = getMarshalledElement(null); 104 105 String marshalledString = this.getXMLString(child); 106 107 assertNotNull("Marshalled RelatedBusinessInfo ", marshalledString); 108 109 RegistryObject regObject = handler.unmarshal(child); 110 111 child = getMarshalledElement(regObject); 112 113 String unMarshalledString = this.getXMLString(child); 114 115 assertNotNull("Unmarshalled RelatedBusinessInfo ", unMarshalledString); 116 117 boolean equals = marshalledString.equals(unMarshalledString); 118 119 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 120 } 121 122 } 123 | Popular Tags |