Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockServletConfig.addInitParameter()


        Assert.assertFalse(servlet.isPermittedRequest("128.242.127.3"));
    }

    public void test_allow_1() throws Exception {
        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_ALLOW, "128.242.127.2,xx");

        StatViewServlet servlet = new StatViewServlet();
        servlet.init(servletConfig);

        MockHttpServletRequest request = new MockHttpServletRequest();
View Full Code Here


        Assert.assertFalse(servlet.isPermittedRequest("128.242.127.3"));
    }

    public void test_allow_2() throws Exception {
        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_ALLOW, "128.242.127.2,,, ");

        StatViewServlet servlet = new StatViewServlet();
        servlet.init(servletConfig);

        MockHttpServletRequest request = new MockHttpServletRequest();
View Full Code Here

        Assert.assertFalse(servlet.isPermittedRequest("128.242.127.3"));
    }

    public void test_allow_3() throws Exception {
        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_ALLOW, "128.242.127.2/24");

        StatViewServlet servlet = new StatViewServlet();
        servlet.init(servletConfig);

        for (int i = 1; i <= 255; ++i) {
View Full Code Here

        Assert.assertFalse(servlet.isPermittedRequest("128.242.128.1"));
    }
   
    public void test_allow_4() throws Exception {
        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_ALLOW, "128.242.127.2/24");
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_DENY, "128.242.127.4");

        StatViewServlet servlet = new StatViewServlet();
        servlet.init(servletConfig);
View Full Code Here

    }
   
    public void test_allow_4() throws Exception {
        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_ALLOW, "128.242.127.2/24");
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_DENY, "128.242.127.4");

        StatViewServlet servlet = new StatViewServlet();
        servlet.init(servletConfig);

        Assert.assertTrue(servlet.isPermittedRequest("128.242.127.1"));
View Full Code Here

    public void test_resetEnable_true() throws Exception {
        Assert.assertTrue(DruidStatService.getInstance().isResetEnable());

        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_RESET_ENABLE, "true");

        StatViewServlet servlet = new StatViewServlet();
        servlet.init(servletConfig);

        Assert.assertTrue(DruidStatService.getInstance().isResetEnable());
View Full Code Here

    public void test_resetEnable_empty() throws Exception {
        Assert.assertTrue(DruidStatService.getInstance().isResetEnable());

        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_RESET_ENABLE, "");

        StatViewServlet servlet = new StatViewServlet();
        servlet.init(servletConfig);

        Assert.assertTrue(DruidStatService.getInstance().isResetEnable());
View Full Code Here

    public void test_resetEnable_false() throws Exception {
        Assert.assertTrue(DruidStatService.getInstance().isResetEnable());

        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_RESET_ENABLE, "false");

        StatViewServlet servlet = new StatViewServlet();
        servlet.init(servletConfig);

        Assert.assertFalse(DruidStatService.getInstance().isResetEnable());
View Full Code Here

    public void test_resetEnable_error() throws Exception {
        Assert.assertTrue(DruidStatService.getInstance().isResetEnable());

        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter(StatViewServlet.PARAM_NAME_RESET_ENABLE, "xxx");

        StatViewServlet servlet = new StatViewServlet();
        servlet.init(servletConfig);

        Assert.assertFalse(DruidStatService.getInstance().isResetEnable());
View Full Code Here

        servlet =
            (HttpServlet)Class.forName("org.apache.wink.server.internal.servlet.RestServlet")
                .newInstance();
        MockServletConfig servletConfig = new MockServletConfig();
        servletConfig.addInitParameter("javax.ws.rs.Application", getApplicationClassName());

        String propertiesFile = getPropertiesFile();
        if (propertiesFile != null) {
            servletConfig.addInitParameter("propertiesLocation", propertiesFile);
        }
View Full Code Here

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.