Methods Summary |
---|
private void | checkDetailAgainstTestDetail(org.apache.axis.AxisFault axisFault)Checks if the AxisFault contains the expected detail elements
Element[] details = axisFault.getFaultDetails();
assertEquals("wrong name for detail element", "MyDetails", details[0].getNodeName());
assertEquals("wrong node value for detail element", "hossa", ((Text) details[0].getChildNodes().item(0)).getData());
assertEquals("wrong name for foo element", "foo", details[1].getNodeName());
boolean found = false;
NodeList childs = details[1].getChildNodes();
for (int i = 0; i < childs.getLength(); i++) {
if ("baz".equals(childs.item(i).getNodeName()))
found = true;
}
assertTrue("subelement baz not found in details", found);
|
public void | doSth()Service method which is called with an axis engine. Its used to test if a service
can throw an SOAPFaultException and all the information as faultcode and faultactor
is passed to the caller
throw new SOAPFaultException(QNAME_FAULT_SERVER_USER, "MyFaultString", "http://myactor", getTestDetail());
|
private javax.xml.soap.Detail | getTestDetail()Produces a Detail object filled with test data
Detail detail = null;
try {
detail = SOAPFactory.newInstance().createDetail();
detail.addChildElement("MyDetails").addTextNode("hossa");
detail.addChildElement("foo").addChildElement("baz");
} catch (SOAPException e) {
fail("Can't create detail");
}
return detail;
|
public static junit.framework.Test | suite()
return new TestSuite(TestSOAPFaultException.class);
|
public void | testDefaults()Tests the defaults generated from a SOAPFaultException
SOAPFaultException soapFaultException = new SOAPFaultException(null, null, null, null);
AxisFault axisFault = AxisFault.makeFault(soapFaultException);
assertEquals(QNAME_FAULT_SERVER_USER, axisFault.getFaultCode());
assertNotNull(axisFault.getFaultString());
|
public void | testDetails()Tests if SOAP fault details are passed to AxisFault objects
SOAPFaultException soapFaultException = new SOAPFaultException(QNAME_FAULT_SERVER_USER, "MyFaultString", "http://myactor", getTestDetail());
AxisFault axisFault = AxisFault.makeFault(soapFaultException);
assertNotNull(axisFault.getFaultDetails());
checkDetailAgainstTestDetail(axisFault);
|
public void | testMakeFaultOutOfSOAPFaultException()Tests if an AxisFault is initialized with the values from a SOAPFaultException
QName faultcode = new QName(soapConsts.getEnvelopeURI(), "Server.MySubClass");
SOAPFaultException soapFaultException = new SOAPFaultException(faultcode, "MyFaultString", "http://myactor", null);
AxisFault axisFault = AxisFault.makeFault(soapFaultException);
assertEquals(faultcode, axisFault.getFaultCode());
|
public void | testThrowingSOAPFaultExceptionFromServiceMethod()Tests if a SOAPFaultException can be thrown from within a service
method and the faultcode, faultstring and detail are passed to
the AxisFault object.
WSDDDeployment conf = new WSDDDeployment();
WSDDService service = new WSDDService();
service.setName(SERVICE_NAME);
service.setProviderQName(new QName(WSDDConstants.URI_WSDD_JAVA, "RPC"));
service.setParameter("className", this.getClass().getName());
service.setParameter("allowedMethods", "doSth");
service.deployToRegistry(conf);
AxisServer engine = new AxisServer(conf);
LocalTransport transport = new LocalTransport(engine);
transport.setRemoteService(SERVICE_NAME);
// create messageContext
MessageContext mc = new MessageContext(engine);
mc.setService((SOAPService) service.getInstance(conf));
mc.setProperty(MessageContext.TRANS_URL, "local");
// create SOAP envelope
SOAPEnvelope env = new SOAPEnvelope();
SOAPBody body = (SOAPBody) env.getBody();
body.addChildElement(new RPCElement("doSth"));
Message reqMsg = new Message(env);
mc.setRequestMessage(reqMsg);
// invoke the engine and test if the fault contains everything as
try {
engine.invoke(mc);
} catch (AxisFault af) {
checkDetailAgainstTestDetail(af);
}
|