Search in sources :

Example 6 with HttpTester

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());
    }
}
Also used : Node(org.w3c.dom.Node) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) HttpTester(org.eclipse.jetty.testing.HttpTester) Test(org.junit.Test)

Example 7 with HttpTester

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());
    }
}
Also used : TransExecutionConfiguration(org.pentaho.di.trans.TransExecutionConfiguration) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) HTMLDocument(org.w3c.dom.html.HTMLDocument) Trans(org.pentaho.di.trans.Trans) TransConfiguration(org.pentaho.di.trans.TransConfiguration) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) HttpTester(org.eclipse.jetty.testing.HttpTester) Test(org.junit.Test)

Example 8 with HttpTester

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());
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) HTMLDocument(org.w3c.dom.html.HTMLDocument) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) HttpTester(org.eclipse.jetty.testing.HttpTester) Test(org.junit.Test)

Aggregations

HttpTester (org.eclipse.jetty.testing.HttpTester)8 IOException (java.io.IOException)6 SAXException (org.xml.sax.SAXException)6 Test (org.junit.Test)5 Document (org.w3c.dom.Document)3 NodeList (org.w3c.dom.NodeList)3 HTMLDocument (org.w3c.dom.html.HTMLDocument)3 Trans (org.pentaho.di.trans.Trans)1 TransConfiguration (org.pentaho.di.trans.TransConfiguration)1 TransExecutionConfiguration (org.pentaho.di.trans.TransExecutionConfiguration)1 Node (org.w3c.dom.Node)1