use of com.alibaba.druid.support.http.StatViewServlet in project springboot_op by SnailFastGo.
the class DruidConfiguration method statViewServlet.
@Bean
public ServletRegistrationBean statViewServlet() {
// 创建servlet注册实体
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
// 设置ip白名单
servletRegistrationBean.addInitParameter("allow", "127.0.0.1");
// 设置ip黑名单,如果allow与deny共同存在时,deny优先于allow
servletRegistrationBean.addInitParameter("deny", "192.168.0.19");
// 设置控制台管理用户
servletRegistrationBean.addInitParameter("loginUsername", "druid");
servletRegistrationBean.addInitParameter("loginPassword", "123456");
// 是否可以重置数据
servletRegistrationBean.addInitParameter("resetEnable", "false");
return servletRegistrationBean;
}
use of com.alibaba.druid.support.http.StatViewServlet 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());
}
use of com.alibaba.druid.support.http.StatViewServlet 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());
}
use of com.alibaba.druid.support.http.StatViewServlet 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());
}
use of com.alibaba.druid.support.http.StatViewServlet in project druid by alibaba.
the class StatViewServletTest_resetEnable method test_resetEnable_empty.
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());
}
Aggregations