use of com.meterware.httpunit.WebResponse in project geode by apache.
the class TestSessionsBase method testRegionInvalidate.
/**
* Test that a session attribute gets removed from the region when the session is invalidated.
*/
@Test
public void testRegionInvalidate() throws Exception {
String key = "value_testRegionInvalidate";
String value = "Foo";
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
// Set an attribute
req.setParameter("cmd", QueryCommand.SET.name());
req.setParameter("param", key);
req.setParameter("value", value);
WebResponse response = wc.getResponse(req);
String sessionId = response.getNewCookieValue("JSESSIONID");
// Invalidate the session
req.removeParameter("param");
req.removeParameter("value");
req.setParameter("cmd", QueryCommand.INVALIDATE.name());
wc.getResponse(req);
assertNull("The region should not have an entry for this session", region.get(sessionId));
}
use of com.meterware.httpunit.WebResponse in project geode by apache.
the class TestSessionsBase method testExtraSessionsNotCreated.
/**
* Test for issue #45 Sessions are being created for every request
*/
@Test
public void testExtraSessionsNotCreated() throws Exception {
Callback c = new Callback() {
@Override
public void call(HttpServletRequest request, HttpServletResponse response) throws IOException {
// Do nothing with sessions
response.getWriter().write("done");
}
};
servlet.getServletContext().setAttribute("callback", c);
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
// Execute the callback
req.setParameter("cmd", QueryCommand.CALLBACK.name());
req.setParameter("param", "callback");
WebResponse response = wc.getResponse(req);
assertEquals("done", response.getText());
assertEquals("The region should be empty", 0, region.size());
}
use of com.meterware.httpunit.WebResponse in project cxf by apache.
the class CXFFilterTest 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", 3, links.length);
Set<String> links2 = new HashSet<>();
for (WebLink l : links) {
links2.add(l.getURLString());
}
assertEquals("text/html", res.getContentType());
}
use of com.meterware.httpunit.WebResponse in project cxf by apache.
the class CXFServletTest method testGetImportedXSD.
@Test
public void testGetImportedXSD() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(true);
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter?wsdl");
WebResponse res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
String text = res.getText();
assertEquals("text/xml", res.getContentType());
assertTrue(text.contains(CONTEXT_URL + "/services/greeter?wsdl=test_import.xsd"));
req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter?wsdl=test_import.xsd");
res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
text = res.getText();
assertEquals("text/xml", res.getContentType());
assertTrue("the xsd should contain the completType SimpleStruct", text.contains("<complexType name=\"SimpleStruct\">"));
}
use of com.meterware.httpunit.WebResponse in project cxf by apache.
the class CXFServletTest method testGetWSDLWithIncludes.
@Test
public void testGetWSDLWithIncludes() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(true);
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?wsdl");
WebResponse res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
Document doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
assertXPathEquals("//xsd:include/@schemaLocation", "http://localhost/mycontext/services/greeter3?xsd=hello_world_includes2.xsd", doc.getDocumentElement());
req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?xsd=hello_world_includes2.xsd");
res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
assertValid("//xsd:complexType[@name='ErrorCode']", doc);
}
Aggregations