org.h2.server.web.WebServlet Java Examples

The following examples show how to use org.h2.server.web.WebServlet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: H2Application.java    From spring-cloud-cli with Apache License 2.0 5 votes vote down vote up
@Bean
public ServletRegistrationBean h2Console() {
	String urlMapping = "/*";
	ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet(), urlMapping);
	registration.addInitParameter("-webAllowOthers", "");
	return registration;
}
 
Example #2
Source File: WebConfigurerTest.java    From jhipster-microservices-example with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #3
Source File: WebConfigurerTest.java    From jhipster-microservices-example with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #4
Source File: WebConfiguration.java    From patient-batch-loader with GNU General Public License v3.0 5 votes vote down vote up
@Bean
  @SuppressWarnings({"rawtypes", "unchecked"})
  public ServletRegistrationBean h2servletRegistration(){
ServletRegistrationBean registrationBean = new ServletRegistrationBean(new WebServlet());
      registrationBean.addUrlMappings("/console/*");
      return registrationBean;
  }
 
Example #5
Source File: DataSourceConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 * Access the H2 Console:
 * http://localhost:8080/admin/h2/
 * @return
 */
@Bean
public ServletRegistrationBean h2servletRegistration(){
    ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());
    registrationBean.addUrlMappings("/admin/h2/*");
    return registrationBean;

}
 
Example #6
Source File: WebConfigurerTest.java    From ehcache3-samples with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #7
Source File: WebConfigurerTest.java    From ehcache3-samples with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #8
Source File: WebConfigurerTest.java    From 21-points with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #9
Source File: WebConfigurerTest.java    From 21-points with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #10
Source File: WebConfigurerTest.java    From alchemy with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #11
Source File: WebConfigurerUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #12
Source File: WebConfigurerUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #13
Source File: WebConfigurerTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #14
Source File: WebConfigurerTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #15
Source File: WebConfigurerTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #16
Source File: WebConfigurerTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #17
Source File: WebConfigurerTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #18
Source File: WebConfigurerTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #19
Source File: WebConfigurerTest.java    From e-commerce-microservice with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #20
Source File: WebConfigurerTest.java    From alchemy with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #21
Source File: WebConfigurerTest.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #22
Source File: WebConfigurerTest.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #23
Source File: WebConfigurerTest.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #24
Source File: WebConfigurerTest.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #25
Source File: WebConfigurerTest.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #26
Source File: WebConfigurerTest.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #27
Source File: WebConfigurerTest.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpProdServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #28
Source File: WebConfigurerTest.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #29
Source File: WebConfigurerTest.java    From Full-Stack-Development-with-JHipster with MIT License 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
 
Example #30
Source File: WebConfigurerTest.java    From e-commerce-microservice with Apache License 2.0 5 votes vote down vote up
@Test
public void testStartUpDevServletContext() throws ServletException {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
    webConfigurer.onStartup(servletContext);

    assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
    assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
    verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
    verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class));
    verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}