@Override @CheckReturnValue @SafeVarargs public final AbstractListAssert<?, List<? extends Object>, Object, ObjectAssert<Object>> extracting(Function<? super ACTUAL, Object>... extractors) { return super.extracting(extractors); }
@Override @CheckReturnValue @SafeVarargs public final AbstractListAssert<?, List<? extends Object>, Object, ObjectAssert<Object>> extracting(Function<? super ACTUAL, Object>... extractors) { return super.extracting(extractors); }
@Test public void csrfServerLogoutHandlerAppliedIfCsrfIsEnabled() { SecurityWebFilterChain securityWebFilterChain = this.http.csrf().csrfTokenRepository(this.csrfTokenRepository).and().build(); assertThat(getWebFilter(securityWebFilterChain, CsrfWebFilter.class)) .get() .extracting(csrfWebFilter -> ReflectionTestUtils.getField(csrfWebFilter, "csrfTokenRepository")) .isEqualTo(this.csrfTokenRepository); Optional<ServerLogoutHandler> logoutHandler = getWebFilter(securityWebFilterChain, LogoutWebFilter.class) .map(logoutWebFilter -> (ServerLogoutHandler) ReflectionTestUtils.getField(logoutWebFilter, LogoutWebFilter.class, "logoutHandler")); assertThat(logoutHandler) .get() .isExactlyInstanceOf(DelegatingServerLogoutHandler.class) .extracting(delegatingLogoutHandler -> ((List<ServerLogoutHandler>) ReflectionTestUtils.getField(delegatingLogoutHandler, DelegatingServerLogoutHandler.class, "delegates")).stream() .map(ServerLogoutHandler::getClass) .collect(Collectors.toList())) .isEqualTo(Arrays.asList(SecurityContextServerLogoutHandler.class, CsrfServerLogoutHandler.class)); }
@Test public void shouldRegisterWebRequestTrackingFilter() { WebRequestTrackingFilter webRequestTrackingFilter = context.getBean(WebRequestTrackingFilter.class); assertThat(webRequestTrackingFilter).extracting("appName").contains("test-application"); assertThat(QuickPulse.INSTANCE).extracting("initialized").contains(true); }
@Test public void shouldBeAbleToConfigureInprocessTelemetryChannel() throws IllegalConfigurationException { EnvironmentTestUtils.addEnvironment(context, "azure.application-insights.instrumentation-key: 00000000-0000-0000-0000-000000000000", "azure.application-insights.channel.in-process.developer-mode=false", "azure.application-insights.channel.in-process.flush-interval-in-seconds=123", "azure.application-insights.channel.in-process.max-telemetry-buffer-capacity=10"); context.register(PropertyPlaceholderAutoConfiguration.class, ApplicationInsightsTelemetryAutoConfiguration.class); context.refresh(); TelemetryConfiguration telemetryConfiguration = context.getBean(TelemetryConfiguration.class); TelemetryChannel channel = telemetryConfiguration.getChannel(); assertThat(channel).isInstanceOf(InProcessTelemetryChannel.class); assertThat(channel.isDeveloperMode()).isFalse(); assertThat(channel).extracting("telemetryBuffer").extracting("transmitBufferTimeoutInSeconds").contains(123); assertThat(channel).extracting("telemetryBuffer").extracting("maxTelemetriesInBatch").contains(10); }
@Test public void shouldBeAbleToConfigureSamplingTelemetryProcessor() { EnvironmentTestUtils.addEnvironment(context, "azure.application-insights.instrumentation-key: 00000000-0000-0000-0000-000000000000", "azure.application-insights.telemetry-processor.sampling.percentage=50", "azure.application-insights.telemetry-processor.sampling.include=Request", "azure.application-insights.telemetry-processor.sampling.enabled=true"); context.register(PropertyPlaceholderAutoConfiguration.class, ApplicationInsightsTelemetryAutoConfiguration.class); context.refresh(); TelemetryConfiguration telemetryConfiguration = context.getBean(TelemetryConfiguration.class); FixedRateSamplingTelemetryProcessor fixedRateSamplingTelemetryProcessor = context.getBean(FixedRateSamplingTelemetryProcessor.class); assertThat(telemetryConfiguration.getTelemetryProcessors()).extracting("class").contains(FixedRateSamplingTelemetryProcessor.class); assertThat(fixedRateSamplingTelemetryProcessor).extracting("samplingPercentage").contains(50.); assertThat(fixedRateSamplingTelemetryProcessor.getIncludedTypes()).contains(RequestTelemetry.class); assertThat(fixedRateSamplingTelemetryProcessor.getExcludedTypes()).isEmpty(); }
assertThat(baseConfig).extracting("wingtipsProperties") .containsExactly(baseProps);
@Test public void testCustomListeners() { ApplicationContextRunner contextRunner = this.contextRunner.withUserConfiguration(CustomListenerConfiguration.class); contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); JdbcEventListenerFactory jdbcEventListenerFactory = context.getBean(JdbcEventListenerFactory.class); GetCountingListener getCountingListener = context.getBean(GetCountingListener.class); ClosingCountingListener closingCountingListener = context.getBean(ClosingCountingListener.class); P6DataSource p6DataSource = (P6DataSource) ((DecoratedDataSource) dataSource).getDecoratedDataSource(); assertThat(p6DataSource).extracting("jdbcEventListenerFactory").containsOnly(jdbcEventListenerFactory); CompoundJdbcEventListener jdbcEventListener = (CompoundJdbcEventListener) jdbcEventListenerFactory.createJdbcEventListener(); assertThat(jdbcEventListener.getEventListeners()).contains(getCountingListener, closingCountingListener); assertThat(getCountingListener.connectionCount).isEqualTo(0); Connection connection1 = p6DataSource.getConnection(); assertThat(getCountingListener.connectionCount).isEqualTo(1); assertThat(closingCountingListener.connectionCount).isEqualTo(0); Connection connection2 = p6DataSource.getConnection(); assertThat(getCountingListener.connectionCount).isEqualTo(2); connection1.close(); assertThat(closingCountingListener.connectionCount).isEqualTo(1); connection2.close(); assertThat(closingCountingListener.connectionCount).isEqualTo(2); }); }
@Test public void testCanSetCustomLoggingFormat() { ApplicationContextRunner contextRunner = this.contextRunner.withPropertyValues("decorator.datasource.p6spy.log-format:test %{connectionId}"); contextRunner.run(context -> { JdbcEventListenerFactory jdbcEventListenerFactory = context.getBean(JdbcEventListenerFactory.class); CompoundJdbcEventListener jdbcEventListener = (CompoundJdbcEventListener) jdbcEventListenerFactory.createJdbcEventListener(); assertThat(jdbcEventListener.getEventListeners()).extracting("class").contains(LoggingEventListener.class); assertThat(P6LogQuery.getLogger()).extracting("strategy").extracting("class").contains(CustomLineFormat.class); }); }