1 16 17 18 package test.httpunit; 19 20 import com.meterware.httpunit.WebRequest; 21 import com.meterware.httpunit.GetMethodWebRequest; 22 import com.meterware.httpunit.WebResponse; 23 24 29 30 public class ServicesTest extends HttpUnitTestBase { 31 32 private String services; 33 34 private String invalid_service; 35 36 37 public ServicesTest(String name) { 38 super(name); 39 } 40 41 45 public void setUp() throws Exception { 46 super.setUp(); 47 services=url+"/services/"; 48 invalid_service=services+"invalid-name"; 49 } 50 51 54 private final static String services_text="Some Services"; 55 56 private final static String hi_there="Hi there, this is an AXIS service!"; 57 61 public void testServlet() throws Exception { 62 WebRequest request = new GetMethodWebRequest(url+"/servlet/AxisServlet"); 63 assertStringInBody(request,services_text); 64 } 65 66 69 public void testServices() throws Exception { 70 WebRequest request = new GetMethodWebRequest(services); 71 expectErrorCode(request,404, null); 72 } 73 74 79 public void testInvalidServiceRaisesError() throws Exception { 80 WebRequest request = new GetMethodWebRequest(invalid_service); 81 expectErrorCode(request,404, null); 82 } 83 84 88 public void testInvalidServiceWsdlRaisesError() throws Exception { 89 WebRequest request = new GetMethodWebRequest(invalid_service+"?wsdl"); 90 expectErrorCode(request,404, null); 92 } 93 94 98 public void testVersionWSDL() throws Exception { 99 WebRequest request = new GetMethodWebRequest(services 100 +"Version?wsdl"); 101 assertStringInBody(request,"<wsdl:definitions"); 102 } 103 104 108 public void testVersionMethod() throws Exception { 109 WebRequest request = new GetMethodWebRequest(services 110 + "Version?method=getVersion"); 111 WebResponse response=makeRequest(request); 112 String body = response.getText(); 113 assertTrue(body.indexOf("<?xml") ==0); 114 assertTrue(body.indexOf("<getVersionReturn")>0); 115 } 116 117 121 public void testVersionNoMethod() throws Exception { 122 WebRequest request = new GetMethodWebRequest(services 123 + "Version?arg1=foo&arg2=bar"); 124 expectErrorCode(request, 400, null); 125 } 126 127 128 } 129 | Popular Tags |