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