Examples of ServletRunner


Examples of com.volantis.testtools.servletunit.ServletRunner

    /**
     * This tests the retrieval operation using a GET request
     */

    public void testRetrieve() throws Exception {
        ServletRunner runner = new ServletRunner(createDefaultWebXML());
        ServletUnitClient client = runner.newClient();

        WebRequest request = createPostRequest(VALID_TEST_XML, READER_TEST_URL);
        WebResponse response = client.getResponse(request);
        String id = response.getHeaderField(
                MessageStoreServlet.MESSAGE_RESPONSE_HEADER_NAME);

        // Check the ID has been returned OK
        assertNotNull("ID should exist in the headers", id);

        // Use a fake servlet class to avoid the need to initialise and run
        // an entire MCS session.
        request = new GetMethodWebRequest(PARTIAL_TEST_URL);
        request.setHeaderField("User-Agent", "Mozilla/5.0 Firefox...");
        request.setParameter(MessageStoreServlet.MESSAGE_RETRIEVE_PARAM_NAME,
                             id);

        client = runner.newClient();
        response = client.getResponse(request);
        assertEquals("The response code should indicate success",
                     MessageStoreMessageEnumeration.SUCCESS.getValue(),
                     response.getResponseCode());
        String message = response.getText();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.