FileDocCategorySizeDatePackage
TestSimpleChain.javaAPI DocApache Axis 1.42665Sat Apr 22 18:57:28 BST 2006test.chains

TestSimpleChain

public class TestSimpleChain extends junit.framework.TestCase

Fields Summary
Constructors Summary
public TestSimpleChain(String name)

        super(name);
    
Methods Summary
protected voidsetup()

    
public static junit.framework.Testsuite()

        return new TestSuite(TestSimpleChain.class);
    
public voidtestSimpleChainAddHandler()

        SimpleChain c = new SimpleChain();

        Handler h1 = new TestHandler();
        assertTrue("Empty chain has a handler", !c.contains(h1));

        c.addHandler(h1);
        assertTrue("Added handler not in chain", c.contains(h1));
    
public voidtestSimpleChainAddHandlerAfterInvoke()

        try {
            SimpleChain c = new SimpleChain();
            Handler h1 = new TestHandler();
            c.addHandler(h1);

            // A null engine is good enough for this test
            MessageContext mc = new MessageContext(null);
            c.invoke(mc);

            // while testing, disable noise
            boolean oldLogging = InternalException.getLogging();
            InternalException.setLogging(false);

            try {
                Handler h2 = new TestHandler();
                c.addHandler(h2);
                assertTrue("Handler added after chain invoked", false);
            } catch (Exception e) {
                // Correct behaviour. Exact exception isn't critical
            }

            // resume noise
            InternalException.setLogging(oldLogging);
        } catch (AxisFault af) {
            assertTrue("Unexpected exception", false);
        }