io.github.jhipster.web.filter.CachingHttpHeadersFilter Java Examples

The following examples show how to use io.github.jhipster.web.filter.CachingHttpHeadersFilter. 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: WebConfigurer.java    From jhipster-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #2
Source File: WebConfigurerTest.java    From Full-Stack-Development-with-JHipster 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 #3
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 #4
Source File: WebConfigurer.java    From jhipster-microservices-example with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #5
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 #6
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 #7
Source File: WebConfigurer.java    From jhipster-microservices-example with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #8
Source File: WebConfigurer.java    From jhipster-online with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #9
Source File: WebConfigurerTest.java    From jhipster-online 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));
}
 
Example #10
Source File: WebConfigurerTest.java    From jhipster-online 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));
}
 
Example #11
Source File: WebConfigurer.java    From ehcache3-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #12
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 #13
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 #14
Source File: WebConfigurer.java    From Full-Stack-Development-with-JHipster with MIT License 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #15
Source File: WebConfigurer.java    From 21-points with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #16
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 #17
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 #18
Source File: WebConfigurer.java    From tutorials with MIT License 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #19
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 #20
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 #21
Source File: WebConfigurer.java    From tutorials with MIT License 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #22
Source File: WebConfigurer.java    From tutorials with MIT License 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #23
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 #24
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 #25
Source File: WebConfigurer.java    From tutorials with MIT License 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #26
Source File: WebConfigurer.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #27
Source File: WebConfigurer.java    From flair-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}
 
Example #28
Source File: WebConfigurerTest.java    From flair-engine 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));
}
 
Example #29
Source File: WebConfigurerTest.java    From flair-engine 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));
}
 
Example #30
Source File: WebConfigurer.java    From alchemy with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the caching HTTP Headers Filter.
 */
private void initCachingHttpHeadersFilter(ServletContext servletContext,
                                          EnumSet<DispatcherType> disps) {
    log.debug("Registering Caching HTTP Headers Filter");
    FilterRegistration.Dynamic cachingHttpHeadersFilter =
        servletContext.addFilter("cachingHttpHeadersFilter",
            new CachingHttpHeadersFilter(jHipsterProperties));

    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
    cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
    cachingHttpHeadersFilter.setAsyncSupported(true);
}