Package com.meterware.servletunit

Examples of com.meterware.servletunit.ServletRunner


    protected final ServletContextEvent     event;

    public AbstractLogConfiguratorListenerTests() throws Exception {
        listener = new LogConfiguratorListener();

        ServletRunner runner = new ServletRunner(new File(webxml()), "");
        ServletUnitClient client = runner.newClient();
        InvocationContext ic = client.newInvocation("http://localhost/servlet");
        servletContext = ic.getServlet().getServletConfig().getServletContext();
        event = new ServletContextEvent(servletContext);
    }
View Full Code Here


            url = "http://www.taobao.com/app1/" + url;
        }

        requestContexts = (RequestContextChainingService) factory.getBean("requestContexts");

        ServletRunner servletRunner = new ServletRunner();
        servletRunner.registerServlet("/app1/*", MyServlet.class.getName());
        ServletUnitClient client = servletRunner.newClient();
        InvocationContext ic = client.newInvocation(url);
        MyServlet servlet = (MyServlet) ic.getServlet();

        rc = requestContexts.getRequestContext(servlet.getServletContext(), ic.getRequest(), ic.getResponse());
    }
View Full Code Here

    @Before
    public void init() throws Exception {
        File webInf = new File(srcdir, "app3/WEB-INF");
        File webXml = new File(webInf, "web.xml");

        ServletRunner servletRunner = new PatchedServletRunner(webXml, "");
        client = servletRunner.newClient();

        filter = (WebxFrameworkFilter) client.newInvocation("http://www.taobao.com/app1").getFilter();
        assertNotNull(filter);

        components = filter.getWebxComponents();
View Full Code Here

public class InheritableBeanFactoryTests {
    private XmlWebApplicationContext parentContext;
    private XmlWebApplicationContext thisContext;

    private void initContext(boolean withMockRequest) throws Exception {
        ServletContext servletContext = new ServletRunner(new File(srcdir, "WEB-INF/web.xml"), "").newClient()
                                                                                                  .newInvocation("http://localhost/servlet").getServlet().getServletConfig().getServletContext();

        // parent context,如果withMockRequest,则注册并覆盖原有的request
        parentContext = new XmlWebApplicationContext();
        parentContext.setConfigLocation(withMockRequest ? "beans-autowire-parent.xml" : "beans.xml");
View Full Code Here

    @BeforeClass
    public static void initFactory() throws Exception {
        factory = new XmlWebApplicationContext();
        factory.setConfigLocation("beans.xml");
        factory.setServletContext(new ServletRunner(new File(srcdir, "WEB-INF/web.xml"), "").newClient()
                                                                                            .newInvocation("http://localhost/servlet").getServlet().getServletConfig().getServletContext());
        factory.refresh();
    }
View Full Code Here

        createBeanFactory("services.xml");

        // sub context - web context将会试图重新注册request等对象,但是由于parent中已经存在,被忽略
        subFactory = new XmlWebApplicationContext();
        subFactory.setConfigLocation("empty.xml");
        subFactory.setServletContext(new ServletRunner(new File(srcdir, "WEB-INF/web.xml"), "").newClient()
                                                                                               .newInvocation("http://localhost/servlet").getServlet().getServletConfig().getServletContext());
        subFactory.setParent((ApplicationContext) factory);
        subFactory.refresh();

        // init global before request,parent context中的singleton proxy将被注入
View Full Code Here

        // XmlWebApplicationContext
        prototype = data.newPrototype();
        XmlWebApplicationContext factory = new XmlWebApplicationContext();
        factory.setConfigLocation("beans.xml");
        factory.setServletContext(createServletContextWrapper(new ServletRunner(new File(srcdir, "WEB-INF/web.xml"), "")
                                                                      .newClient().newInvocation("http://localhost/servlet").getServlet().getServletConfig()
                                                                      .getServletContext()));
        factory.refresh();
        prototype.context = factory;
        prototype.defaultServletResource = true;
View Full Code Here

    static {
        Servlet3Util.setDisableServlet3Features(true); // 禁用servlet3,因为httpunit还不支持
    }

    protected void initServlet(String webXml) throws Exception {
        ServletRunner runner = new ServletRunner(new File(srcdir, webXml), "");
        client = runner.newClient();
        ic = client.newInvocation("http://localhost:8080/app1");

        originalServletContext = ic.getServlet().getServletConfig().getServletContext();
        servletContext = createServletContextWrapper(true);
        request = ic.getRequest();
View Full Code Here

    @Before
    public void init() throws Exception {
        upload = (UploadService) factory.getBean("uploadService");

        // Servlet container
        ServletRunner servletRunner = new FilterServletRunner();

        servletRunner.registerServlet("myservlet", MyServlet.class.getName());

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

        // 取得初始页面form.html
        WebResponse response = client.getResponse(new GetMethodWebRequest("http://localhost/myservlet"));

        WebForm form = response.getFormWithName("myform");
View Full Code Here

        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

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.