FileDocCategorySizeDatePackage
TestJAXMSamples.javaAPI DocApache Axis 1.46134Sat Apr 22 18:57:28 BST 2006test.functional

TestJAXMSamples

public class TestJAXMSamples extends junit.framework.TestCase
Test the JAX-RPC compliance samples.

Fields Summary
static Log
log
Constructors Summary
public TestJAXMSamples(String name)


       
        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        TestJAXMSamples tester = new TestJAXMSamples("tester");
        //tester.testUddiPing();
    
public voidtestDelayedStockQuote()

        try {
            log.info("Testing JAXM DelayedStockQuote sample.");
            DelayedStockQuote stockQuote = new DelayedStockQuote();
            System.out.print("The last price for SUNW is " + stockQuote.getStockQuote("SUNW"));
            log.info("Test complete.");
        } catch (javax.xml.soap.SOAPException e) {
            Throwable t = e.getCause();
            if (t != null) {
                t.printStackTrace();
                if (t instanceof AxisFault) {
                  AxisFault af = (AxisFault) t;
                  if ((af.detail instanceof SocketException)
							|| (af.getFaultCode().getLocalPart().equals("HTTP"))) {
						System.out.println("Connect failure caused JAXM DelayedStockQuote to be skipped.");
						return;
					}
                }
                throw new Exception("Fault returned from test: " + t);
            } else {
                e.printStackTrace();
                throw new Exception("Exception returned from test: " + e);
            }
        } catch (Throwable t) {
            t.printStackTrace();
            throw new Exception("Fault returned from test: " + t);
        }
    
public voidtestJWSFault()

        try {
	        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
	        SOAPConnection con = scFactory.createConnection();
	
	        MessageFactory factory = MessageFactory.newInstance();
	        SOAPMessage message = factory.createMessage();
	
	        SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
	        SOAPBody body = envelope.getBody();
	
	        Name bodyName = envelope.createName("echo");
	        SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
	
	        Name name = envelope.createName("arg0");
	        SOAPElement symbol = bodyElement.addChildElement(name);
	        symbol.addTextNode("Hello");
	
	        URLEndpoint endpoint = new URLEndpoint("http://localhost:8080/jws/FaultTest.jws");
	        SOAPMessage response = con.call(message, endpoint);
	        SOAPBody respBody = response.getSOAPPart().getEnvelope().getBody();
	        assertTrue(respBody.hasFault());
        } catch (javax.xml.soap.SOAPException e) {
            Throwable t = e.getCause();
            if (t != null) {
                t.printStackTrace();
                if (t instanceof AxisFault) {
                  AxisFault af = (AxisFault) t;
                  if ((af.detail instanceof SocketException)
							|| (af.getFaultCode().getLocalPart().equals("HTTP"))) {
						System.out.println("Connect failure caused testJWSFault to be skipped.");
						return;
					}
                }
                throw new Exception("Fault returned from test: " + t);
            } else {
                e.printStackTrace();
                throw new Exception("Exception returned from test: " + e);
            }
        } catch (Throwable t) {
            t.printStackTrace();
            throw new Exception("Fault returned from test: " + t);
        }