1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.BusinessKey; 19 import org.apache.juddi.datatype.RegistryObject; 20 import org.apache.juddi.datatype.response.RelatedBusinessInfo; 21 import org.apache.juddi.datatype.response.RelatedBusinessesList; 22 import org.apache.juddi.util.xml.XMLUtils; 23 import org.w3c.dom.Element ; 24 25 28 public class RelatedBusinessesListHandlerTests extends HandlerTestCase 29 { 30 private static final String TEST_ID = "juddi.handler.DeleteRelatedBusinessesList.test"; 31 private RelatedBusinessesListHandler handler = null; 32 33 public RelatedBusinessesListHandlerTests(String arg0) 34 { 35 super(arg0); 36 } 37 38 public static void main(String [] args) 39 { 40 junit.textui.TestRunner.run( RelatedBusinessesListHandlerTests.class); 41 } 42 43 public void setUp() 44 { 45 HandlerMaker maker = HandlerMaker.getInstance(); 46 handler = ( RelatedBusinessesListHandler)maker.lookup( RelatedBusinessesListHandler.TAG_NAME); 47 } 48 49 private RegistryObject getRegistryObject() 50 { 51 RelatedBusinessesList object = new RelatedBusinessesList(); 52 object.setGeneric("2.0"); 53 object.setOperator("jUDDI.org"); 54 object.setTruncated(true); 55 object.setBusinessKey(new BusinessKey("f9f0c35f-06ab-4bec-9c7d-b1469e73f0eb")); 56 object.addRelatedBusinessInfo(new RelatedBusinessInfo("abc")); 57 object.addRelatedBusinessInfo(new RelatedBusinessInfo("xyz")); 58 59 60 return object; 61 62 } 63 64 private Element getMarshalledElement(RegistryObject regObject) 65 { 66 Element parent = XMLUtils.newRootElement(); 67 Element child = null; 68 69 if(regObject == null) 70 regObject = this.getRegistryObject(); 71 72 handler.marshal(regObject,parent); 73 child = (Element )parent.getFirstChild(); 74 parent.removeChild(child); 75 76 return child; 77 } 78 79 public void testMarshal() 80 { 81 Element child = getMarshalledElement(null); 82 83 String marshalledString = this.getXMLString(child); 84 85 assertNotNull("Marshalled RelatedBusinessesList ", marshalledString); 86 87 } 88 89 public void testUnMarshal() 90 { 91 92 Element child = getMarshalledElement(null); 93 RegistryObject regObject = handler.unmarshal(child); 94 95 assertNotNull("UnMarshalled RelatedBusinessesList ", regObject); 96 97 } 98 99 public void testMarshUnMarshal() 100 { 101 Element child = getMarshalledElement(null); 102 103 String marshalledString = this.getXMLString(child); 104 105 assertNotNull("Marshalled RelatedBusinessesList ", marshalledString); 106 107 RegistryObject regObject = handler.unmarshal(child); 108 109 child = getMarshalledElement(regObject); 110 111 String unMarshalledString = this.getXMLString(child); 112 113 assertNotNull("Unmarshalled RelatedBusinessesList ", unMarshalledString); 114 115 boolean equals = marshalledString.equals(unMarshalledString); 116 117 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 118 } 119 120 } 121 | Popular Tags |