use of org.eclipse.jetty.testing.HttpTester in project pentaho-kettle by pentaho.
the class CarteIT method testGetRootServlet.
@Test
public void testGetRootServlet() {
HttpTester request = new HttpTester();
HttpTester response = new HttpTester();
request.setMethod("GET");
request.setHeader("Host", "tester");
request.setURI(GetRootServlet.CONTEXT_PATH);
request.setVersion("HTTP/1.0");
try {
response.parse(tester.getResponses(request.generate()));
Node document = parse(response.getContent());
String title = BaseMessages.getString(GetRootServlet.class, "GetRootServlet.KettleSlaveServer.Title");
Assert.assertEquals(title, findTextNode(document, "TITLE").getTextContent());
String menu = BaseMessages.getString(GetRootServlet.class, "GetRootServlet.SlaveServerMenu");
Assert.assertEquals(menu, findTextNode(document, "H2").getTextContent());
String status = BaseMessages.getString(GetRootServlet.class, "GetRootServlet.ShowStatus");
Assert.assertEquals(status, findTextNode(document, "A").getTextContent());
} 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 testAddTransServlet.
@Test
public void testAddTransServlet() {
HttpTester request = new HttpTester();
HttpTester response = new HttpTester();
request.setMethod("GET");
request.setHeader("Host", "tester");
request.setURI(RegisterTransServlet.CONTEXT_PATH + "?xml=Y");
request.setVersion("HTTP/1.0");
try {
TransExecutionConfiguration transExecConfig = new TransExecutionConfiguration();
Trans trans = CarteIT.generateTestTransformation();
TransConfiguration transConfig = new TransConfiguration(trans.getTransMeta(), transExecConfig);
request.setContent(transConfig.getXML());
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();
// find the first one
SlaveServerTransStatus transStatus = status.findTransStatus(trans.getName(), null);
Assert.assertNotNull(transStatus);
Assert.assertFalse(transStatus.isPaused());
Assert.assertFalse(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 testPauseTransServlet.
@Test
public void testPauseTransServlet() {
// add our test transformation
testAddTransServlet();
// start our test transformation
testStartTransServlet();
HttpTester request = new HttpTester();
HttpTester response = new HttpTester();
request.setMethod("GET");
request.setHeader("Host", "tester");
request.setURI(PauseTransServlet.CONTEXT_PATH + "?xml=Y&name=CarteUnitTest");
request.setVersion("HTTP/1.0");
try {
SlaveServerStatus status = getStatus();
SlaveServerTransStatus transStatus = status.findTransStatus("CarteUnitTest", null);
Assert.assertNotNull(transStatus);
// let's make sure that it is not paused
Assert.assertFalse(transStatus.isPaused());
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());
status = getStatus();
transStatus = status.findTransStatus("CarteUnitTest", null);
Assert.assertNotNull(transStatus);
// now check to be sure it is paused
Assert.assertTrue(transStatus.isPaused());
} catch (Exception ex) {
ex.printStackTrace();
Assert.fail(ex.getMessage());
}
}
Aggregations