Package net.jsunit.interceptor

Source Code of net.jsunit.interceptor.BrowserTestRunnerInterceptorTest

package net.jsunit.interceptor;

import junit.framework.TestCase;
import net.jsunit.BrowserTestRunner;
import net.jsunit.MockBrowserTestRunner;
import net.jsunit.XmlRenderable;
import net.jsunit.action.JsUnitBrowserTestRunnerAction;

public class BrowserTestRunnerInterceptorTest extends TestCase {

    public void testSimple() throws Exception {
        MockBrowserTestRunnerAction action = new MockBrowserTestRunnerAction();
        final BrowserTestRunner mockRunner = new MockBrowserTestRunner();
        BrowserTestRunnerInterceptor.setBrowserTestRunnerSource(new BrowserTestRunnerSource() {
            public BrowserTestRunner getRunner() {
                return mockRunner;
            }

        });
        assertNull(action.getBrowserTestRunner());
        BrowserTestRunnerInterceptor interceptor = new BrowserTestRunnerInterceptor();

        MockActionInvocation mockInvocation = new MockActionInvocation(action);
        interceptor.intercept(mockInvocation);

        assertSame(mockRunner, action.getBrowserTestRunner());
        assertTrue(mockInvocation.wasInvokeCalled);
    }

    public void tearDown() throws Exception {
        BrowserTestRunnerInterceptor.setBrowserTestRunnerSource(new DefaultBrowserTestRunnerSource());
        super.tearDown();
    }

    static class MockBrowserTestRunnerAction extends JsUnitBrowserTestRunnerAction {

        public String execute() throws Exception {
            return null;
        }

        public XmlRenderable getXmlRenderable() {
            return null;
        }

    }

}
TOP

Related Classes of net.jsunit.interceptor.BrowserTestRunnerInterceptorTest

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.