@Test public void run_adds_filter_and_joins_FilterPatterns_correctly() throws Exception { final Filter filter = mock(Filter.class); final EnumSet<DispatcherType> dispatcherTypesA = EnumSet.allOf(DispatcherType.class); final EnumSet<DispatcherType> dispatcherTypesB = EnumSet.of(DispatcherType.ASYNC); FilterRegistration.Dynamic filterDynamic = mock(FilterRegistration.Dynamic.class); when(servletEnvironment.addFilter(anyString(), any(TestFilter.class))).thenReturn(filterDynamic); Application application = buildApplication( new AbstractPlugin() { @Override protected void configure() { buildFilter(filter) .addPattern(FilterPattern.newInstance(dispatcherTypesA, true, "/a", "/b")) .addPattern(FilterPattern.newInstance(dispatcherTypesA, true, "/c", "/d")) .addPattern(FilterPattern.newInstance(dispatcherTypesB, true, "/e", "/f")) .addPattern(FilterPattern.newInstance(dispatcherTypesB, false, "/g", "/h")) .bind(); } } ); new Platform(application).run(configuration, environment); verify(filterDynamic).addMappingForUrlPatterns(eq(dispatcherTypesA), eq(true), eq("/a")); verify(filterDynamic).addMappingForUrlPatterns(eq(dispatcherTypesA), eq(true), eq("/b")); verify(filterDynamic).addMappingForUrlPatterns(eq(dispatcherTypesA), eq(true), eq("/c")); verify(filterDynamic).addMappingForUrlPatterns(eq(dispatcherTypesA), eq(true), eq("/d")); verify(filterDynamic).addMappingForUrlPatterns(eq(dispatcherTypesB), eq(true), eq("/e")); verify(filterDynamic).addMappingForUrlPatterns(eq(dispatcherTypesB), eq(true), eq("/f")); verify(filterDynamic).addMappingForUrlPatterns(eq(dispatcherTypesB), eq(false), eq("/g")); verify(filterDynamic).addMappingForUrlPatterns(eq(dispatcherTypesB), eq(false), eq("/h")); }
@Override public void run(PlatformConfiguration configuration, Environment environment) throws Exception { dropwizardModule.setup(configuration, environment); for (Configurator configurator : wrapper.getConfigurators()) { configurator.configure(configuration, environment); LOGGER.debug("Registered Configurator: {}", configurator.getClass().getCanonicalName()); } for (Object jerseyComponent : wrapper.getJerseyComponents()) { environment.jersey().register(jerseyComponent); LOGGER.debug("Registered Jersey Component: {}", jerseyComponent.getClass().getCanonicalName()); } for (Managed managed : wrapper.getManaged()) { environment.lifecycle().manage(managed); LOGGER.debug("Registered Managed Object: {}", managed.getClass().getCanonicalName()); } for (HealthCheck healthCheck : wrapper.getHealthChecks()) { environment.healthChecks().register(healthCheck.toString(), healthCheck); LOGGER.debug("Registered Health Check: {}", healthCheck.getClass().getCanonicalName()); } for (Task task : wrapper.getTasks()) { environment.admin().addTask(task); LOGGER.debug("Registered Task: {}", task.getClass().getCanonicalName()); } for (FilterSpec filterSpec : wrapper.getFilterSpecs()) { registerFilterSpec(environment, filterSpec); LOGGER.debug("Registered Filter {}: {}", filterSpec.getName(), filterSpec.getFilter().getClass().getCanonicalName()); } }
Platform extends io.dropwizard.Application<PlatformConfiguration> { @Override public void run(PlatformConfiguration configuration, Environment environment) throws Exception { dropwizardModule.setup(configuration, environment); for (Configurator configurator : wrapper.getConfigurators()) { configurator.configure(configuration, environment); LOGGER.debug("Registered Configurator: {}", configurator.getClass().getCanonicalName()); } for (Object jerseyComponent : wrapper.getJerseyComponents()) { environment.jersey().register(jerseyComponent); LOGGER.debug("Registered Jersey Component: {}", jerseyComponent.getClass().getCanonicalName()); } for (Managed managed : wrapper.getManaged()) { environment.lifecycle().manage(managed); LOGGER.debug("Registered Managed Object: {}", managed.getClass().getCanonicalName()); } for (HealthCheck healthCheck : wrapper.getHealthChecks()) { environment.healthChecks().register(healthCheck.toString(), healthCheck); LOGGER.debug("Registered Health Check: {}", healthCheck.getClass().getCanonicalName()); } for (Task task : wrapper.getTasks()) { environment.admin().addTask(task); LOGGER.debug("Registered Task: {}", task.getClass().getCanonicalName()); } for (FilterSpec filterSpec : wrapper.getFilterSpecs()) { registerFilterSpec(environment, filterSpec); LOGGER.debug("Registered Filter {}: {}", filterSpec.getName(), filterSpec.getFilter().getClass().getCanonicalName()); } } }
Platform extends io.dropwizard.Application<PlatformConfiguration> { @Override public void run(PlatformConfiguration configuration, Environment environment) throws Exception { dropwizardModule.setup(configuration, environment); for (Configurator configurator : wrapper.getConfigurators()) { configurator.configure(configuration, environment); LOGGER.debug("Registered Configurator: {}", configurator.getClass().getCanonicalName()); } for (Object jerseyComponent : wrapper.getJerseyComponents()) { environment.jersey().register(jerseyComponent); LOGGER.debug("Registered Jersey Component: {}", jerseyComponent.getClass().getCanonicalName()); } for (Managed managed : wrapper.getManaged()) { environment.lifecycle().manage(managed); LOGGER.debug("Registered Managed Object: {}", managed.getClass().getCanonicalName()); } for (HealthCheck healthCheck : wrapper.getHealthChecks()) { environment.healthChecks().register(healthCheck.toString(), healthCheck); LOGGER.debug("Registered Health Check: {}", healthCheck.getClass().getCanonicalName()); } for (Task task : wrapper.getTasks()) { environment.admin().addTask(task); LOGGER.debug("Registered Task: {}", task.getClass().getCanonicalName()); } for (FilterSpec filterSpec : wrapper.getFilterSpecs()) { registerFilterSpec(environment, filterSpec); LOGGER.debug("Registered Filter {}: {}", filterSpec.getName(), filterSpec.getFilter().getClass().getCanonicalName()); } } Platform(Application application); }
Platform extends io.dropwizard.Application<PlatformConfiguration> { @Override public void run(PlatformConfiguration configuration, Environment environment) throws Exception { dropwizardModule.setup(configuration, environment); for (Configurator configurator : wrapper.getConfigurators()) { configurator.configure(configuration, environment); LOGGER.debug("Registered Configurator: {}", configurator.getClass().getCanonicalName()); } for (Object jerseyComponent : wrapper.getJerseyComponents()) { environment.jersey().register(jerseyComponent); LOGGER.debug("Registered Jersey Component: {}", jerseyComponent.getClass().getCanonicalName()); } for (Managed managed : wrapper.getManaged()) { environment.lifecycle().manage(managed); LOGGER.debug("Registered Managed Object: {}", managed.getClass().getCanonicalName()); } for (HealthCheck healthCheck : wrapper.getHealthChecks()) { environment.healthChecks().register(healthCheck.toString(), healthCheck); LOGGER.debug("Registered Health Check: {}", healthCheck.getClass().getCanonicalName()); } for (Task task : wrapper.getTasks()) { environment.admin().addTask(task); LOGGER.debug("Registered Task: {}", task.getClass().getCanonicalName()); } for (FilterSpec filterSpec : wrapper.getFilterSpecs()) { registerFilterSpec(environment, filterSpec); LOGGER.debug("Registered Filter {}: {}", filterSpec.getName(), filterSpec.getFilter().getClass().getCanonicalName()); } } Platform(Application application); static Platform forApplication(Application application); void start(String[] args); @Override void initialize(Bootstrap<PlatformConfiguration> bootstrap); @Override void run(PlatformConfiguration configuration, Environment environment); }
Platform extends io.dropwizard.Application<PlatformConfiguration> { @Override public void run(PlatformConfiguration configuration, Environment environment) throws Exception { dropwizardModule.setup(configuration, environment); for (Configurator configurator : wrapper.getConfigurators()) { configurator.configure(configuration, environment); LOGGER.debug("Registered Configurator: {}", configurator.getClass().getCanonicalName()); } for (Object jerseyComponent : wrapper.getJerseyComponents()) { environment.jersey().register(jerseyComponent); LOGGER.debug("Registered Jersey Component: {}", jerseyComponent.getClass().getCanonicalName()); } for (Managed managed : wrapper.getManaged()) { environment.lifecycle().manage(managed); LOGGER.debug("Registered Managed Object: {}", managed.getClass().getCanonicalName()); } for (HealthCheck healthCheck : wrapper.getHealthChecks()) { environment.healthChecks().register(healthCheck.toString(), healthCheck); LOGGER.debug("Registered Health Check: {}", healthCheck.getClass().getCanonicalName()); } for (Task task : wrapper.getTasks()) { environment.admin().addTask(task); LOGGER.debug("Registered Task: {}", task.getClass().getCanonicalName()); } for (FilterSpec filterSpec : wrapper.getFilterSpecs()) { registerFilterSpec(environment, filterSpec); LOGGER.debug("Registered Filter {}: {}", filterSpec.getName(), filterSpec.getFilter().getClass().getCanonicalName()); } } Platform(Application application); static Platform forApplication(Application application); void start(String[] args); @Override void initialize(Bootstrap<PlatformConfiguration> bootstrap); @Override void run(PlatformConfiguration configuration, Environment environment);  }