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