FileDocCategorySizeDatePackage
ServicesTest.javaAPI DocApache Axis 1.43705Sat Apr 22 18:57:26 BST 2006test.httpunit

ServicesTest

public class ServicesTest extends HttpUnitTestBase
test the services
author
Steve Loughran
created
Jul 10, 2002 12:09:06 AM

Fields Summary
private String
services
private String
invalid_service
private static final String
services_text
what string do we take as meaning services are present.
private static final String
hi_there
Constructors Summary
public ServicesTest(String name)

        super(name);
    
Methods Summary
public voidsetUp()
The JUnit setup method

        super.setUp();
        services=url+"/services/";
        invalid_service=services+"invalid-name";
    
public voidtestInvalidServiceRaisesError()

todo
decide on the exception to throw in the servlet, write the test then fix the servlet
throws
Exception

        WebRequest request = new GetMethodWebRequest(invalid_service);
        expectErrorCode(request,404, null);
    
public voidtestInvalidServiceWsdlRaisesError()
A missing wsdl page should be a 404 error;

throws
Exception

        WebRequest request = new GetMethodWebRequest(invalid_service+"?wsdl");
        // "The AXIS engine could not find a target service to invoke!");
        expectErrorCode(request,404, null);
    
public voidtestServices()
verify the services url works

        WebRequest request = new GetMethodWebRequest(services);
        expectErrorCode(request,404, null);
    
public voidtestServlet()
verify the /servlet url is there

throws
Exception

                 
         
        WebRequest request = new GetMethodWebRequest(url+"/servlet/AxisServlet");
        assertStringInBody(request,services_text);
    
public voidtestVersionMethod()
test version call

throws
Exception

        WebRequest request = new GetMethodWebRequest(services
                + "Version?method=getVersion");
        WebResponse response=makeRequest(request);
        String body = response.getText();
        assertTrue(body.indexOf("<?xml") ==0);
        assertTrue(body.indexOf("<getVersionReturn")>0);
    
public voidtestVersionNoMethod()
test a get without any method

throws
Exception

        WebRequest request = new GetMethodWebRequest(services
                + "Version?arg1=foo&arg2=bar");
        expectErrorCode(request, 400, null);
    
public voidtestVersionWSDL()
test version call

throws
Exception

        WebRequest request = new GetMethodWebRequest(services
                +"Version?wsdl");
        assertStringInBody(request,"<wsdl:definitions");