Package org.apache.axiom.testutils

Examples of org.apache.axiom.testutils.InvocationCounter


            xml.append('x');
        }
        InputStream in = new ExceptionInputStream(new ByteArrayInputStream(xml.toString().getBytes("ASCII")));
       
        XMLStreamReader originalReader = StAXUtils.createXMLStreamReader(in);
        InvocationCounter invocationCounter = new InvocationCounter();
        XMLStreamReader reader = (XMLStreamReader)invocationCounter.createProxy(originalReader);
       
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(), reader);
       
        try {
            while (true) {
                builder.next();
            }
        } catch (Exception ex) {
            // Expected
        }

        assertTrue(invocationCounter.getInvocationCount() > 0);
        invocationCounter.reset();

        Exception exception;
        try {
            builder.next();
            exception = null;
        } catch (Exception ex) {
            exception = ex;
        }
        if (exception == null) {
            fail("Expected exception");
        }
       
        assertEquals(0, invocationCounter.getInvocationCount());
    }
View Full Code Here


        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        XMLStreamReader originalReader = StAXUtils.createXMLStreamReader(AbstractTestCase.getTestResource("invalid_xml.xml"));
        InvocationCounter invocationCounter = new InvocationCounter();
        XMLStreamReader reader = (XMLStreamReader)invocationCounter.createProxy(originalReader);
       
        OMXMLParserWrapper stAXOMBuilder =
                OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(),
                                                        reader);
       
        Exception exception = null;
        while (exception == null || stAXOMBuilder.isCompleted()) {
            try {
                stAXOMBuilder.next();
            } catch (Exception e) {
                exception =e;
            }
        }
       
        assertTrue("Expected an exception because invalid_xml.xml is wrong", exception != null);
       
        assertTrue(invocationCounter.getInvocationCount() > 0);
        invocationCounter.reset();
       
        // Intentionally call builder again to make sure the same error is returned.
        Exception exception2 = null;
        try {
            stAXOMBuilder.next();
        } catch (Exception e) {
            exception2 = e;
        }
       
        assertEquals(0, invocationCounter.getInvocationCount());
       
        assertTrue("Expected a second exception because invalid_xml.xml is wrong", exception2 != null);
        assertTrue("Expected the same exception. first=" + exception + " second=" + exception2,
                    exception.getMessage().equals(exception2.getMessage()));
    }
View Full Code Here

        assertTrue(childrenCount == 5);
    }
   
    public void testInvalidXML() throws Exception {
        XMLStreamReader originalReader = StAXUtils.createXMLStreamReader(getTestResource("invalid_xml.xml"));
        InvocationCounter invocationCounter = new InvocationCounter();
        XMLStreamReader reader = (XMLStreamReader)invocationCounter.createProxy(originalReader);
       
        StAXOMBuilder stAXOMBuilder =
                OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getSOAP11Factory(),
                                                        reader);
       
        Exception exception = null;
        while (exception == null || stAXOMBuilder.isCompleted()) {
            try {
                stAXOMBuilder.next();
            } catch (Exception e) {
                exception =e;
            }
        }
       
        assertTrue("Expected an exception because invalid_xml.xml is wrong", exception != null);
       
        assertTrue(invocationCounter.getInvocationCount() > 0);
        invocationCounter.reset();
       
        // Intentionally call builder again to make sure the same error is returned.
        Exception exception2 = null;
        try {
            stAXOMBuilder.next();
        } catch (Exception e) {
            exception2 = e;
        }
       
        assertEquals(0, invocationCounter.getInvocationCount());
       
        assertTrue("Expected a second exception because invalid_xml.xml is wrong", exception2 != null);
        assertTrue("Expected the same exception. first=" + exception + " second=" + exception2,
                    exception.getMessage().equals(exception2.getMessage()));
       
View Full Code Here

            xml.append('x');
        }
        InputStream in = new ExceptionInputStream(new ByteArrayInputStream(xml.toString().getBytes("ASCII")));
       
        XMLStreamReader originalReader = StAXUtils.createXMLStreamReader(in);
        InvocationCounter invocationCounter = new InvocationCounter();
        XMLStreamReader reader = (XMLStreamReader)invocationCounter.createProxy(originalReader);
       
        StAXOMBuilder builder = new StAXOMBuilder(reader);
       
        try {
            while (true) {
                builder.next();
            }
        } catch (Exception ex) {
            // Expected
        }

        assertTrue(invocationCounter.getInvocationCount() > 0);
        invocationCounter.reset();

        Exception exception;
        try {
            builder.next();
            exception = null;
        } catch (Exception ex) {
            exception = ex;
        }
        if (exception == null) {
            fail("Expected exception");
        }
       
        assertEquals(0, invocationCounter.getInvocationCount());
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.testutils.InvocationCounter

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.