use of org.eclipse.jetty.testing.HttpTester in project elasticsearch-jetty by sonian.
the class RestConstraintSecurityHandlerTests method request.
protected HttpTester request(String method, String url) {
HttpTester request = new HttpTester();
request.setMethod(method);
request.setURI(url);
request.setVersion("HTTP/1.0");
return request;
}
use of org.eclipse.jetty.testing.HttpTester in project elasticsearch-jetty by sonian.
the class RestConstraintSecurityHandlerTests method execute.
protected HttpTester execute(HttpTester request) throws Exception {
HttpTester response = new HttpTester();
response.parse(connector.getResponses(request.generate()));
return response;
}
use of org.eclipse.jetty.testing.HttpTester in project pentaho-kettle by pentaho.
the class CarteIT method testStartTransServlet.
@Test
public void testStartTransServlet() {
// add our test transformation
testAddTransServlet();
HttpTester request = new HttpTester();
HttpTester response = new HttpTester();
request.setMethod("GET");
request.setHeader("Host", "tester");
request.setURI(StartTransServlet.CONTEXT_PATH + "?xml=Y&name=CarteUnitTest");
request.setVersion("HTTP/1.0");
try {
response.parse(tester.getResponses(request.generate()));
Document document = XMLHandler.loadXMLString(response.getContent());
NodeList nodes = document.getElementsByTagName("result");
Assert.assertEquals(1, nodes.getLength());
Assert.assertEquals(WebResult.STRING_OK, nodes.item(0).getTextContent());
SlaveServerStatus status = getStatus();
SlaveServerTransStatus transStatus = status.findTransStatus("CarteUnitTest", null);
Assert.assertNotNull(transStatus);
Assert.assertFalse(transStatus.isPaused());
Assert.assertTrue(transStatus.isRunning());
} catch (Exception ex) {
ex.printStackTrace();
Assert.fail(ex.getMessage());
}
}
use of org.eclipse.jetty.testing.HttpTester in project pentaho-kettle by pentaho.
the class CarteIT method getStatus.
public SlaveServerStatus getStatus() {
HttpTester request = new HttpTester();
HttpTester response = new HttpTester();
request.setMethod("GET");
request.setHeader("Host", "tester");
request.setURI(GetStatusServlet.CONTEXT_PATH + "?xml=Y");
request.setVersion("HTTP/1.0");
try {
response.parse(tester.getResponses(request.generate()));
return SlaveServerStatus.fromXML(response.getContent());
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
use of org.eclipse.jetty.testing.HttpTester in project pentaho-kettle by pentaho.
the class CarteIT method testGetStatusServlet.
@Test
public void testGetStatusServlet() {
HttpTester request = new HttpTester();
HttpTester response = new HttpTester();
request.setMethod("GET");
request.setHeader("Host", "tester");
request.setURI(GetStatusServlet.CONTEXT_PATH + "?xml=Y");
request.setVersion("HTTP/1.0");
try {
response.parse(tester.getResponses(request.generate()));
// just test if we actually can create a SlaveServerStatus from the webservice
// and that it is the same going in as out
String xml = XMLHandler.getXMLHeader(Const.XML_ENCODING) + SlaveServerStatus.fromXML(response.getContent()).getXML();
Assert.assertEquals(response.getContent().trim(), xml.trim());
} catch (Exception ex) {
ex.printStackTrace();
Assert.fail(ex.getMessage());
}
}
Aggregations