use of com.meterware.servletunit.ServletUnitClient in project cxf by apache.
the class CXFServletTest method testServiceListWithLoopAddress.
@Test
public void testServiceListWithLoopAddress() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse res = client.getResponse(CONTEXT_URL + "/services");
assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter3"));
assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter2"));
assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter"));
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter?wsdl");
res = client.getResponse(req);
req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter2?wsdl");
res = client.getResponse(req);
req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?wsdl");
res = client.getResponse(req);
String loopAddr = "http://127.0.0.1/mycontext";
res = client.getResponse(loopAddr + "/services");
assertFalse(res.getText().contains("http://127.0.0.1/mycontext/serviceshttp://localhost/mycontext/services/greeter"));
}
use of com.meterware.servletunit.ServletUnitClient in project cxf by apache.
the class ExternalServicesServletTest method testGetServiceList.
@Test
public void testGetServiceList() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
// test the '/' context get service list
WebResponse res = client.getResponse(CONTEXT_URL + "/");
WebLink[] links = res.getLinks();
assertEquals("Wrong number of service links", 6, links.length);
Set<String> links2 = new HashSet<>();
for (WebLink l : links) {
links2.add(l.getURLString());
}
assertTrue(links2.contains(FORCED_BASE_ADDRESS + "/greeter?wsdl"));
assertTrue(links2.contains(FORCED_BASE_ADDRESS + "/greeter2?wsdl"));
assertEquals("text/html", res.getContentType());
// HTTPUnit do not support require url with ""
/*
res = client.getResponse(CONTEXT_URL);
links = res.getLinks();
assertEquals("There should get two links for the services", 1, links.length);
assertEquals(CONTEXT_URL + "/greeter?wsdl", links[0].getURLString());
assertEquals(CONTEXT_URL + "/greeter2?wsdl", links[1].getURLString());
assertEquals("text/html", res.getContentType());*/
}
use of com.meterware.servletunit.ServletUnitClient in project cxf by apache.
the class JaxRsServletTest method testInvokingBookService.
private void testInvokingBookService(String serviceAddress) throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + serviceAddress);
WebResponse response = client.getResponse(req);
InputStream in = response.getInputStream();
InputStream expected = JaxRsServletTest.class.getResourceAsStream("resources/expected_get_book123.txt");
assertEquals(" Can't get the expected result ", getStringFromInputStream(expected), getStringFromInputStream(in));
}
Aggregations