1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.IRegistry; 19 import org.apache.juddi.datatype.RegistryObject; 20 import org.apache.juddi.datatype.response.DispositionReport; 21 import org.apache.juddi.datatype.response.ErrInfo; 22 import org.apache.juddi.datatype.response.Result; 23 import org.apache.juddi.util.xml.XMLUtils; 24 import org.w3c.dom.Element ; 25 26 29 public class DispositionReportHandlerTests extends HandlerTestCase 30 { 31 private static final String TEST_ID = "juddi.handler.DeletePublisher.test"; 32 private DispositionReportHandler handler = null; 33 34 public DispositionReportHandlerTests(String arg0) 35 { 36 super(arg0); 37 } 38 39 public static void main(String [] args) 40 { 41 junit.textui.TestRunner.run( DispositionReportHandlerTests.class); 42 } 43 44 public void setUp() 45 { 46 HandlerMaker maker = HandlerMaker.getInstance(); 47 handler = ( DispositionReportHandler)maker.lookup( DispositionReportHandler.TAG_NAME); 48 } 49 50 private RegistryObject getRegistryObject() 51 { 52 ErrInfo errInfo = new ErrInfo(); 53 errInfo.setErrCode("E_accountLimitExceeded"); 54 errInfo.setErrMsg("Authentication token information has timed out."); 55 56 Result result = new Result(); 57 result.setErrno(10160); 58 result.setErrInfo(errInfo); 59 60 ErrInfo errInfo2 = new ErrInfo(); 61 errInfo2.setErrCode("E_success"); 62 errInfo2.setErrMsg(null); 63 64 Result result2 = new Result(); 65 result2.setErrno(Result.E_SUCCESS); 66 result2.setErrInfo(errInfo2); 67 68 DispositionReport object = new DispositionReport(); 69 object.setGeneric(IRegistry.UDDI_V2_GENERIC); 70 object.setOperator("jUDDI.org"); 71 object.addResult(result); 72 object.addResult(result2); 73 74 return object; 75 76 } 77 78 private Element getMarshalledElement(RegistryObject regObject) 79 { 80 Element parent = XMLUtils.newRootElement(); 81 Element child = null; 82 83 if(regObject == null) 84 regObject = this.getRegistryObject(); 85 86 handler.marshal(regObject,parent); 87 child = (Element )parent.getFirstChild(); 88 parent.removeChild(child); 89 90 return child; 91 } 92 93 public void testMarshal() 94 { 95 Element child = getMarshalledElement(null); 96 97 String marshalledString = this.getXMLString(child); 98 99 assertNotNull("Marshalled DispositionReport ", marshalledString); 100 101 } 102 103 public void testUnMarshal() 104 { 105 106 Element child = getMarshalledElement(null); 107 RegistryObject regObject = handler.unmarshal(child); 108 109 assertNotNull("UnMarshalled DispositionReport ", regObject); 110 111 } 112 113 public void testMarshUnMarshal() 114 { 115 Element child = getMarshalledElement(null); 116 117 String marshalledString = this.getXMLString(child); 118 119 assertNotNull("Marshalled DispositionReport ", marshalledString); 120 121 RegistryObject regObject = handler.unmarshal(child); 122 123 child = getMarshalledElement(regObject); 124 125 String unMarshalledString = this.getXMLString(child); 126 127 assertNotNull("Unmarshalled DispositionReport ", unMarshalledString); 128 129 boolean equals = marshalledString.equals(unMarshalledString); 130 131 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 132 } 133 134 } 135 | Popular Tags |