Search in sources :

Example 1 with HttpTester

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;
}
Also used : HttpTester(org.eclipse.jetty.testing.HttpTester)

Example 2 with HttpTester

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;
}
Also used : HttpTester(org.eclipse.jetty.testing.HttpTester)

Example 3 with HttpTester

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());
    }
}
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)

Example 4 with HttpTester

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

Example 5 with HttpTester

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());
    }
}
Also used : 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