Package org.apache.cactus

Examples of org.apache.cactus.WebTestResult


    /**
     * Verify parsing when the test result contains no exception.
     */
    public void testParseNoException()
    {
        WebTestResult initialResult = new WebTestResult();
        WebTestResultParser parser = new WebTestResultParser();
        WebTestResult result = parser.parse(initialResult.toXml());

        assertNotNull(result);
        assertTrue(!result.hasException());
        assertNull(result.getExceptionClassName());
        assertNull(result.getExceptionMessage());
        assertNull(result.getExceptionStackTrace());
    }
View Full Code Here


     * Verify parsing when the test result contains an exception.
     */
    public void testParseWithException()
    {
        Exception e = new Exception("test exception");
        WebTestResult initialResult = new WebTestResult(e);
        WebTestResultParser parser = new WebTestResultParser();
        WebTestResult result = parser.parse(initialResult.toXml());

        assertNotNull(result);
        assertTrue("There is no exception in the test result !",
            result.hasException());
        assertEquals("java.lang.Exception", result.getExceptionClassName());
        assertEquals("test exception", result.getExceptionMessage());
        assertTrue("Should not be empty",
            result.getExceptionStackTrace().length() > 0);
    }
View Full Code Here

     * Verify the correct parsing behaviour to extract the ROOT element when
     * there is no exception returned in the test result.
     */
    public void testReadRootElementEmpty()
    {
        WebTestResult initialResult = new WebTestResult();
        WebTestResultParser parser = new WebTestResultParser();

        String buffer = parser.readRootElement(initialResult.toXml());
        assertEquals("", buffer);
    }
View Full Code Here

            "java.lang.Exception\"><message><![CDATA[test exception]]>" +
            "</message><stacktrace><![CDATA[";
        String expectedEnd = "]]></stacktrace></exception>";

        Exception e = new Exception("test exception");
        WebTestResult initialResult = new WebTestResult(e);
        WebTestResultParser parser = new WebTestResultParser();

        String buffer = parser.readRootElement(initialResult.toXml());
        assertTrue("Should have started with [" + expectedStart + "]",
            buffer.startsWith(expectedStart));
        assertTrue("Should have ended with [" + expectedEnd + "]",
            buffer.endsWith(expectedEnd));
    }
View Full Code Here

        String expectedStart = "<message><![CDATA[test exception]]>" +
            "</message><stacktrace><![CDATA[";
        String expectedEnd = "]]></stacktrace>";

        Exception e = new Exception("test exception");
        WebTestResult initialResult = new WebTestResult(e);
        WebTestResultParser parser = new WebTestResultParser();
        String buffer = parser.readRootElement(initialResult.toXml());

        buffer = parser.readExceptionClassname(buffer);
        assertEquals("java.lang.Exception", parser.exceptionClassname);
        assertTrue("Should have started with [" + expectedStart + "]",
            buffer.startsWith(expectedStart));
View Full Code Here

    {
        String expectedStart = "<stacktrace><![CDATA[";
        String expectedEnd = "]]></stacktrace>";

        Exception e = new Exception("test exception");
        WebTestResult initialResult = new WebTestResult(e);
        WebTestResultParser parser = new WebTestResultParser();
        String buffer = parser.readRootElement(initialResult.toXml());
        buffer = parser.readExceptionClassname(buffer);

        buffer = parser.readExceptionMessage(buffer);
        assertEquals("test exception", parser.exceptionMessage);
        assertTrue("Should have started with [" + expectedStart + "]",
View Full Code Here

     *
     * @exception ServletException if an unexpected error occurred
     */
    public void doTest() throws ServletException
    {
        WebTestResult result = null;

        try {

            // Create an instance of the test class
            AbstractTestCase testInstance = getTestClassInstance(
                getTestClassName(), getTestMethodName());

            // Set its fields (implicit objects)
            setTestCaseFields(testInstance);

            // Call it's method corresponding to the current test case
            testInstance.runBareServerTest();

            // Return an instance of <code>WebTestResult</code> with a
            // positive result.
            result = new WebTestResult();

        } catch (Throwable e) {
            // An error occurred, return an instance of
            // <code>WebTestResult</code> with an exception.
            result = new WebTestResult(e);

        }

        LOGGER.debug("Test result : [" + result + "]");

View Full Code Here

        // However this will not happend because on the client side, once the
        // first request is done to execute the test, all the result is read
        // by the AutoReadHttpURLConnection class, thus ensuring that the
        // request is fully finished and the resukt has been committed ...

        WebTestResult result =
            (WebTestResult) (this.webImplicitObjects.getServletContext().
            getAttribute(TEST_RESULTS));

        LOGGER.debug("Test Result = [" + result + "]");

        // Write back the results to the outgoing stream as an XML string.
        try {

            Writer writer = getResponseWriter();
            writer.write(result.toXml());
            writer.close();

        } catch (IOException e) {
            String message = "Error writing WebTestResult instance to output " +
                "stream";
View Full Code Here

TOP

Related Classes of org.apache.cactus.WebTestResult

Copyright © 2018 www.massapicom. 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.