Package com.meterware.servletunit

Examples of com.meterware.servletunit.ServletRunner


        return factory;
    }

    @Before
    public final void prepareRequest() throws Exception {
        ServletRunner servletRunner = new ServletRunner(new File(srcdir, "WEB-INF/web.xml"), "/myapp");
        ServletUnitClient client = servletRunner.newClient();
        InvocationContext invocationContext = client.newInvocation("http://localhost/myapp/myservlet");

        HttpServletRequest request = invocationContext.getRequest();
        HttpServletResponse response = invocationContext.getResponse();
        ServletConfig config = invocationContext.getServlet().getServletConfig();
View Full Code Here


    }

    @Before
    public final void createWebClient() throws Exception {
        // Servlet container
        ServletRunner servletRunner = new ServletRunner();
        servletRunner.registerServlet("/*", NoopServlet.class.getName());

        // Servlet client
        client = servletRunner.newClient();

        // Charset
        HttpUnitOptions.setDefaultCharacterSet("GBK");
    }
View Full Code Here

    protected final void prepareWebClient(String webXmlName, String contextPath) throws Exception {
        // Servlet container
        File webInf = new File(srcdir, "WEB-INF");
        File webXml = new File(webInf, defaultIfEmpty(webXmlName, "web.xml"));

        ServletRunner servletRunner = new PatchedServletRunner(webXml, contextPath);

        // Servlet client
        client = servletRunner.newClient();
        client.setExceptionsThrownOnErrorStatus(false);
        client.getClientProperties().setAutoRedirect(false);

        // Ignore script error
        JavaScript.setThrowExceptionsOnError(false);
View Full Code Here

    protected static ApplicationContext createContext(String name, ApplicationContext parent) {
        return new XmlApplicationContext(new FileSystemResource(new File(srcdir, name)), parent);
    }

    protected static void prepareServlet() throws Exception {
        ServletRunner servletRunner = new ServletRunner();

        servletRunner.registerServlet("/app1/*", MyServlet.class.getName());

        client = servletRunner.newClient();
        client.setExceptionsThrownOnErrorStatus(false);
        client.getClientProperties().setAutoRedirect(false);

        MyServlet servlet = (MyServlet) client.newInvocation("http://www.taobao.com/app1").getServlet();
        assertNotNull(servlet);
View Full Code Here

    protected static ApplicationContext createContext(String name, ApplicationContext parent) {
        return new XmlApplicationContext(new FileSystemResource(new File(srcdir, name)), parent);
    }

    protected static void prepareServlet() throws Exception {
        ServletRunner servletRunner = new ServletRunner();

        servletRunner.registerServlet("/app1/*", MyServlet.class.getName());

        client = servletRunner.newClient();
        client.setExceptionsThrownOnErrorStatus(false);
        client.getClientProperties().setAutoRedirect(false);

        MyServlet servlet = (MyServlet) client.newInvocation("http://www.taobao.com/app1").getServlet();
        assertNotNull(servlet);
View Full Code Here

    private ErrorHandlerHelper helper;
    private Logger             log;

    @Before
    public void init() throws Exception {
        ServletRunner servletRunner = new ServletRunner();
        servletRunner.registerServlet("/app1/*", HttpServlet.class.getName());
        ServletUnitClient client = servletRunner.newClient();

        request = client.newInvocation("http://localhost/app1").getRequest();
        helper = ErrorHandlerHelper.getInstance(request);
        log = createMock(Logger.class);
    }
View Full Code Here

        log = createMock(Logger.class);
    }

    @Test
    public void getInstance() throws Exception {
        ServletRunner servletRunner = new ServletRunner();
        servletRunner.registerServlet("/app1/*", HttpServlet.class.getName());
        ServletUnitClient client = servletRunner.newClient();

        request = client.newInvocation("http://localhost/app1").getRequest();

        assertNull(request.getAttribute("_webx_errorHandlerHelper_"));
        helper = ErrorHandlerHelper.getInstance(request);
View Full Code Here

    }

    protected static void prepareServlet(String app) throws Exception {
        // Servlet container
        File webXml = new File(srcdir, "WEB-INF/web.xml");
        ServletRunner servletRunner = new PatchedServletRunner(webXml, "");

        // Servlet client
        client = servletRunner.newClient();
        client.setExceptionsThrownOnErrorStatus(false);
        client.getClientProperties().setAutoRedirect(false);

        // Filter
        WebxFrameworkFilter filter = (WebxFrameworkFilter) client.newInvocation("http://www.taobao.com/" + app)
View Full Code Here

    private void initServletContainer(String webxml) throws Exception {
        // Servlet container
        File webInf = new File(srcdir, "WEB-INF");
        File webXml = new File(webInf, webxml);

        ServletRunner servletRunner = new ServletRunner(webXml, "");

        // Servlet client
        client = servletRunner.newClient();
        client.setExceptionsThrownOnErrorStatus(false);
        client.getClientProperties().setAutoRedirect(false);

        // Ignore script error
        JavaScript.setThrowExceptionsOnError(false);
View Full Code Here

    /** 创建web client,注册servlets。 */
    @Before
    public final void prepareWebClient() throws Exception {
        // Servlet container
        ServletRunner servletRunner = new PatchedServletRunner();

        registerServlets(servletRunner);
        servletRunner.registerServlet("/readfile/*", ReadFileServlet.class.getName());
        servletRunner.registerServlet("/servlet/*", NoopServlet.class.getName());
        servletRunner.registerServlet("*.do", NoopServlet.class.getName());

        // Servlet client
        client = servletRunner.newClient();
    }
View Full Code Here

TOP

Related Classes of com.meterware.servletunit.ServletRunner

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.