org.springframework.boot.test.context.FilteredClassLoader Java Examples
The following examples show how to use
org.springframework.boot.test.context.FilteredClassLoader.
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: Neo4jRepositoriesAutoConfigurationTest.java From sdn-rx with Apache License 2.0 | 6 votes |
@Test void configurationOfRepositoryTypeShouldWork() { this.contextRunner .withPropertyValues("spring.data.neo4j.repositories.type=none") .withUserConfiguration(TestConfiguration.class) .withClassLoader(new FilteredClassLoader(Flux.class)) .run(ctx -> assertThat(ctx) .doesNotHaveBean(Neo4jTransactionManager.class) .doesNotHaveBean(ReactiveNeo4jClient.class) .doesNotHaveBean(Neo4jRepository.class) ); this.contextRunner .withPropertyValues("spring.data.neo4j.repositories.type=imperative") .withUserConfiguration(TestConfiguration.class) .run(ctx -> assertThat(ctx) .hasSingleBean(Neo4jTransactionManager.class) .hasSingleBean(Neo4jClient.class) .doesNotHaveBean(ReactiveNeo4jRepository.class) ); }
Example #2
Source File: GcpCloudSqlAutoConfigurationMockTests.java From spring-cloud-gcp with Apache License 2.0 | 6 votes |
@Test public void testPostgre() { this.contextRunner.withPropertyValues( "spring.cloud.gcp.sql.instanceConnectionName=tubular-bells:singapore:test-instance") .withClassLoader( new FilteredClassLoader("com.google.cloud.sql.mysql")) .run((context) -> { CloudSqlJdbcInfoProvider urlProvider = context.getBean(CloudSqlJdbcInfoProvider.class); assertThat(urlProvider.getJdbcUrl()).isEqualTo( "jdbc:postgresql://google/test-database?" + "socketFactory=com.google.cloud.sql.postgres.SocketFactory" + "&cloudSqlInstance=tubular-bells:singapore:test-instance"); assertThat(urlProvider.getJdbcDriverClass()).matches("org.postgresql.Driver"); }); }
Example #3
Source File: BlockingLoadBalancerClientAutoConfigurationTests.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@Test public void worksWithoutSpringWeb() { applicationContextRunner .withClassLoader(new FilteredClassLoader(RestTemplate.class)) .run(context -> { assertThat(context).doesNotHaveBean(BlockingLoadBalancerClient.class); }); }
Example #4
Source File: AutoConfigureMessageVerifierTests.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
@Test public void shouldConfigureForNoOpWhenMissingImplementation() { this.contextRunner .withClassLoader(new FilteredClassLoader(org.apache.camel.Message.class, org.springframework.messaging.Message.class, JmsTemplate.class, KafkaTemplate.class, RabbitTemplate.class, EnableBinding.class)) .run((context) -> { assertThat(context.getBeansOfType(MessageVerifierSender.class)) .hasSize(1); assertThat(context.getBeansOfType(NoOpStubMessages.class)).hasSize(1); }); }
Example #5
Source File: VaultReactiveBootstrapConfigurationTests.java From spring-cloud-vault with Apache License 2.0 | 5 votes |
@Test public void shouldNotConfigureIfHttpClientIsMissing() { this.contextRunner.withUserConfiguration(AuthenticationFactoryConfiguration.class) .withClassLoader( new FilteredClassLoader("reactor.netty.http.client.HttpClient")) .run(context -> { assertThat(context.getBeanNamesForType(ReactiveVaultOperations.class)) .isEmpty(); }); }
Example #6
Source File: FlowableJpaAutoConfigurationTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void withEntityManagerFactoryBeanAndMissingSpringProcessEngineConfigurationClass() { contextRunner .withConfiguration(AutoConfigurations.of( DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class )) .withClassLoader(new FilteredClassLoader(SpringProcessEngineConfiguration.class)) .run(context -> { assertThat(context).doesNotHaveBean(FlowableJpaAutoConfiguration.class); }); }
Example #7
Source File: FlowableSecurityAutoConfigurationTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void withMissingAuthenticationManager() { contextRunner .withConfiguration(IDM_CONFIGURATION) .withClassLoader(new FilteredClassLoader(AuthenticationManager.class)) .run(context -> assertThat(context) .hasSingleBean(IdmIdentityService.class) .doesNotHaveBean(FlowableSecurityAutoConfiguration.class)); }
Example #8
Source File: FlowableSecurityAutoConfigurationTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void withMissingIdmIdentityService() { contextRunner .withConfiguration(IDM_CONFIGURATION) .withClassLoader(new FilteredClassLoader(IdmIdentityService.class)) .run(context -> assertThat(context) .hasSingleBean(IdmIdentityService.class) .doesNotHaveBean(FlowableSecurityAutoConfiguration.class)); }
Example #9
Source File: FlowableSecurityAutoConfigurationTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void withMissingFlowableUserDetailsService() { contextRunner .withConfiguration(IDM_CONFIGURATION) .withClassLoader(new FilteredClassLoader(FlowableUserDetailsService.class)) .run(context -> assertThat(context) .hasSingleBean(IdmIdentityService.class) .doesNotHaveBean(FlowableSecurityAutoConfiguration.class)); }
Example #10
Source File: ZipkinAutoConfigurationTests.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test void should_apply_in_memory_metrics_when_meter_registry_class_missing() { this.contextRunner.withClassLoader(new FilteredClassLoader(MeterRegistry.class)) .run((context) -> { ReporterMetrics bean = context.getBean(ReporterMetrics.class); BDDAssertions.then(bean).isInstanceOf(InMemoryReporterMetrics.class); }); }
Example #11
Source File: TraceSchedulingAutoConfigurationTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test void shoud_not_create_TraceSchedulingAspect_without_aspectJ() { this.contextRunner .withClassLoader(new FilteredClassLoader(ProceedingJoinPoint.class)) .run(context -> assertThat(context) .doesNotHaveBean(TraceSchedulingAspect.class)); }
Example #12
Source File: ZookeeperReactiveDiscoveryClientConfigurationTests.java From spring-cloud-zookeeper with Apache License 2.0 | 5 votes |
@Test public void worksWithoutWebflux() { contextRunner .withClassLoader( new FilteredClassLoader("org.springframework.web.reactive")) .run(context -> { assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); }); }
Example #13
Source File: ZookeeperReactiveDiscoveryClientConfigurationTests.java From spring-cloud-zookeeper with Apache License 2.0 | 5 votes |
@Test public void worksWithoutActuator() { contextRunner .withClassLoader( new FilteredClassLoader("org.springframework.boot.actuate")) .run(context -> { assertThat(context).hasSingleBean(ReactiveDiscoveryClient.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); }); }
Example #14
Source File: KafkaBinderActuatorTests.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 5 votes |
@Test public void testKafkaBinderMetricsWhenNoMicrometer() { new ApplicationContextRunner().withUserConfiguration(KafkaMetricsTestConfig.class) .withClassLoader(new FilteredClassLoader("io.micrometer.core")) .run(context -> { assertThat(context.getBeanNamesForType(MeterRegistry.class)) .isEmpty(); assertThat(context.getBeanNamesForType(MeterBinder.class)).isEmpty(); DirectFieldAccessor channelBindingServiceAccessor = new DirectFieldAccessor( context.getBean(BindingService.class)); @SuppressWarnings("unchecked") Map<String, List<Binding<MessageChannel>>> consumerBindings = (Map<String, List<Binding<MessageChannel>>>) channelBindingServiceAccessor .getPropertyValue("consumerBindings"); assertThat(new DirectFieldAccessor( consumerBindings.get("input").get(0)).getPropertyValue( "lifecycle.messageListenerContainer.beanName")) .isEqualTo("setByCustomizer:input"); assertThat(new DirectFieldAccessor( consumerBindings.get("input").get(0)).getPropertyValue( "lifecycle.beanName")) .isEqualTo("setByCustomizer:input"); assertThat(new DirectFieldAccessor( consumerBindings.get("source").get(0)).getPropertyValue( "lifecycle.beanName")) .isEqualTo("setByCustomizer:source"); @SuppressWarnings("unchecked") Map<String, Binding<MessageChannel>> producerBindings = (Map<String, Binding<MessageChannel>>) channelBindingServiceAccessor .getPropertyValue("producerBindings"); assertThat(new DirectFieldAccessor( producerBindings.get("output")).getPropertyValue( "lifecycle.beanName")) .isEqualTo("setByCustomizer:output"); }); }
Example #15
Source File: ReactiveCommonsClientAutoConfigurationTests.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@Test public void worksWithoutActuator() { applicationContextRunner .withClassLoader( new FilteredClassLoader("org.springframework.boot.actuate")) .run(context -> { assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryCompositeHealthContributor.class); then(context.getBeansOfType(HasFeatures.class).values()).isEmpty(); }); }
Example #16
Source File: ReactiveCommonsClientAutoConfigurationTests.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@Test public void worksWithoutWebflux() { applicationContextRunner .withClassLoader( new FilteredClassLoader("org.springframework.web.reactive")) .run(context -> { assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryCompositeHealthContributor.class); assertThat(context).doesNotHaveBean(HasFeatures.class); }); }
Example #17
Source File: CommonsClientAutoConfigurationTests.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@Test public void worksWithoutActuator() { applicationContextRunner .withClassLoader( new FilteredClassLoader("org.springframework.boot.actuate")) .run(context -> { assertThat(context) .doesNotHaveBean(DiscoveryClientHealthIndicator.class); assertThat(context) .doesNotHaveBean(DiscoveryCompositeHealthContributor.class); then(context.getBeansOfType(HasFeatures.class).values()).isEmpty(); }); }
Example #18
Source File: EurekaReactiveDiscoveryClientConfigurationTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void worksWithoutWebflux() { contextRunner .withClassLoader( new FilteredClassLoader("org.springframework.web.reactive")) .run(context -> { assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); }); }
Example #19
Source File: EurekaReactiveDiscoveryClientConfigurationTests.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Test public void worksWithoutActuator() { contextRunner .withClassLoader( new FilteredClassLoader("org.springframework.boot.actuate")) .run(context -> { assertThat(context).hasSingleBean(ReactiveDiscoveryClient.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); }); }
Example #20
Source File: ConsulReactiveDiscoveryClientConfigurationTests.java From spring-cloud-consul with Apache License 2.0 | 5 votes |
@Test public void worksWithoutWebflux() { contextRunner .withClassLoader( new FilteredClassLoader("org.springframework.web.reactive")) .run(context -> { assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); }); }
Example #21
Source File: ConsulReactiveDiscoveryClientConfigurationTests.java From spring-cloud-consul with Apache License 2.0 | 5 votes |
@Test public void worksWithoutActuator() { contextRunner .withClassLoader( new FilteredClassLoader("org.springframework.boot.actuate")) .run(context -> { assertThat(context).hasSingleBean(ReactiveDiscoveryClient.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); }); }
Example #22
Source File: CloudFoundryReactiveDiscoveryClientConfigurationTests.java From spring-cloud-cloudfoundry with Apache License 2.0 | 5 votes |
@Test public void worksWithoutWebflux() { contextRunner .withClassLoader( new FilteredClassLoader("org.springframework.web.reactive")) .run(context -> { assertThat(context) .doesNotHaveBean(CloudFoundryReactiveHeartbeatSender.class); assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); }); }
Example #23
Source File: CloudFoundryReactiveDiscoveryClientConfigurationTests.java From spring-cloud-cloudfoundry with Apache License 2.0 | 5 votes |
@Test public void worksWithoutActuator() { contextRunner .withClassLoader( new FilteredClassLoader("org.springframework.boot.actuate")) .run(context -> { assertThat(context) .hasSingleBean(CloudFoundryReactiveHeartbeatSender.class); assertThat(context).hasSingleBean(ReactiveDiscoveryClient.class); assertThat(context).doesNotHaveBean( ReactiveDiscoveryClientHealthIndicator.class); }); }
Example #24
Source File: ConditionalOnClassIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void whenDependentClassIsNotPresent_thenBeanMissing() { this.contextRunner.withUserConfiguration(ConditionalOnClassConfiguration.class) .withClassLoader(new FilteredClassLoader(ConditionalOnClassIntegrationTest.class)) .run((context) -> { assertThat(context).doesNotHaveBean("created"); assertThat(context).doesNotHaveBean(ConditionalOnClassIntegrationTest.class); }); }
Example #25
Source File: ConditionalOnClassIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void whenDependentClassIsNotPresent_thenBeanCreated() { this.contextRunner.withUserConfiguration(ConditionalOnMissingClassConfiguration.class) .withClassLoader(new FilteredClassLoader(ConditionalOnClassIntegrationTest.class)) .run((context) -> { assertThat(context).hasBean("missed"); assertThat(context).getBean("missed") .isEqualTo("This is missed when ConditionalOnClassIntegrationTest is present on the classpath"); assertThat(context).doesNotHaveBean(ConditionalOnClassIntegrationTest.class); }); }
Example #26
Source File: ServiceInstanceLogStreamAutoConfigurationTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void servicesAreNotCreatedWithoutLoggingOnClasspath() { contextRunner .withClassLoader(new FilteredClassLoader(ApplicationLogStreamPublisher.class)) .withUserConfiguration(LoggingConfiguration.class) .run(context -> assertThat(context) .doesNotHaveBean(StreamingLogWebSocketHandler.class) .doesNotHaveBean(WebSocketHandlerAdapter.class) .doesNotHaveBean(HandlerMapping.class) .doesNotHaveBean(LogStreamPublisher.class) .doesNotHaveBean(ApplicationLogStreamPublisher.class)); }
Example #27
Source File: Neo4jDataAutoConfigurationTest.java From sdn-rx with Apache License 2.0 | 5 votes |
@Test @DisplayName("Should require all needed classes") void shouldRequireAllNeededClasses() { contextRunner .withClassLoader( new FilteredClassLoader(Neo4jTransactionManager.class, PlatformTransactionManager.class)) .run(ctx -> assertThat(ctx) .doesNotHaveBean(Neo4jClient.class) .doesNotHaveBean(Neo4jTemplate.class) .doesNotHaveBean(Neo4jTransactionManager.class) ); }
Example #28
Source File: Neo4jDataAutoConfigurationTest.java From sdn-rx with Apache License 2.0 | 5 votes |
@Test @DisplayName("Should require all needed classes") void shouldRequireAllNeededClasses() { contextRunner .withClassLoader( new FilteredClassLoader(ReactiveNeo4jTransactionManager.class, ReactiveTransactionManager.class, Flux.class)) .run(ctx -> assertThat(ctx) .doesNotHaveBean(ReactiveNeo4jClient.class) .doesNotHaveBean(ReactiveNeo4jTemplate.class) .doesNotHaveBean(ReactiveNeo4jTransactionManager.class) ); }
Example #29
Source File: BlockingAutoConfigurationTest.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@Test public void configurations_not_loaded_when_mvc_is_not_on_class_path() { contextRunner .withClassLoader(new FilteredClassLoader("org.springframework.web.context.support.GenericWebApplicationContext")) .run(context -> assertThat(context) .hasNotFailed() .doesNotHaveBean("openApiResource") .doesNotHaveBean("actuatorProvider") .doesNotHaveBean("multipleOpenApiResource") ); }
Example #30
Source File: ReactiveAutoConfigurationTest.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@Test public void configurations_not_loaded_when_reactor_is_not_on_class_path() { contextRunner .withClassLoader(new FilteredClassLoader("org.springframework.web.reactive.HandlerResult")) .run(context -> assertThat(context) .hasNotFailed() .doesNotHaveBean("openApiResource")); }