Search in sources :

Example 6 with MockServletConfig

use of org.springframework.mock.web.MockServletConfig in project druid by alibaba.

the class StatViewServletTest_resetEnable method test_resetEnable_error.

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());
}
Also used : MockServletConfig(org.springframework.mock.web.MockServletConfig) StatViewServlet(com.alibaba.druid.support.http.StatViewServlet)

Example 7 with MockServletConfig

use of org.springframework.mock.web.MockServletConfig in project druid by alibaba.

the class StatViewServletTest_resetEnable method test_resetEnable_none.

public void test_resetEnable_none() throws Exception {
    Assert.assertTrue(DruidStatService.getInstance().isResetEnable());
    MockServletConfig servletConfig = new MockServletConfig();
    StatViewServlet servlet = new StatViewServlet();
    servlet.init(servletConfig);
    Assert.assertTrue(DruidStatService.getInstance().isResetEnable());
}
Also used : MockServletConfig(org.springframework.mock.web.MockServletConfig) StatViewServlet(com.alibaba.druid.support.http.StatViewServlet)

Example 8 with MockServletConfig

use of org.springframework.mock.web.MockServletConfig in project druid by alibaba.

the class StatViewServletTest_resetEnable method test_resetEnable_false.

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());
}
Also used : MockServletConfig(org.springframework.mock.web.MockServletConfig) StatViewServlet(com.alibaba.druid.support.http.StatViewServlet)

Example 9 with MockServletConfig

use of org.springframework.mock.web.MockServletConfig in project pinpoint by naver.

the class SpringWebMvcIT method testRequest.

@Test
public void testRequest() throws Exception {
    MockServletConfig config = new MockServletConfig();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse res = new MockHttpServletResponse();
    config.addInitParameter("contextConfigLocation", "classpath:spring-web-test.xml");
    req.setMethod("GET");
    req.setRequestURI("/");
    req.setRemoteAddr("1.2.3.4");
    DispatcherServlet servlet = new DispatcherServlet();
    servlet.init(config);
    servlet.service(req, res);
    Method method = FrameworkServlet.class.getDeclaredMethod("doGet", HttpServletRequest.class, HttpServletResponse.class);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(Expectations.event(SPRING_MVC, method));
    verifier.verifyTraceCount(0);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) MockServletConfig(org.springframework.mock.web.MockServletConfig) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 10 with MockServletConfig

use of org.springframework.mock.web.MockServletConfig in project spring-security by spring-projects.

the class AbstractSecurityWebSocketMessageBrokerConfigurerDocTests method loadConfig.

private void loadConfig(Class<?>... configs) {
    context = new AnnotationConfigWebApplicationContext();
    context.register(configs);
    context.register(WebSocketConfig.class, SyncExecutorConfig.class);
    context.setServletConfig(new MockServletConfig());
    context.refresh();
}
Also used : MockServletConfig(org.springframework.mock.web.MockServletConfig) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext)

Aggregations

MockServletConfig (org.springframework.mock.web.MockServletConfig)26 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)12 StatViewServlet (com.alibaba.druid.support.http.StatViewServlet)10 ServletContext (javax.servlet.ServletContext)8 Decorator (com.opensymphony.module.sitemesh.Decorator)7 Page (com.opensymphony.module.sitemesh.Page)7 HTMLPageParser (com.opensymphony.module.sitemesh.parser.HTMLPageParser)7 Config (grails.config.Config)7 PropertySourcesConfig (org.grails.config.PropertySourcesConfig)7 MockApplicationContext (org.grails.support.MockApplicationContext)7 GrailsWebRequest (org.grails.web.servlet.mvc.GrailsWebRequest)7 GroovyClassLoader (groovy.lang.GroovyClassLoader)5 GroovyObject (groovy.lang.GroovyObject)5 Test (org.junit.Test)4 MockServletContext (org.springframework.mock.web.MockServletContext)4 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)3 ServletContextEvent (javax.servlet.ServletContextEvent)2 ServletException (javax.servlet.ServletException)2 MockDatabase (org.opennms.core.test.db.MockDatabase)2 DaoTestConfigBean (org.opennms.test.DaoTestConfigBean)2