Skip to content

Polish #42457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Polish #42457

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static class ConnectionDetails {
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "management.otlp.logging", name = "endpoint")
OtlpLoggingConnectionDetails otlpLogsConnectionDetails(OtlpLoggingProperties properties) {
OtlpLoggingConnectionDetails otlpLoggingConnectionDetails(OtlpLoggingProperties properties) {
return new PropertiesOtlpLoggingConnectionDetails(properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import org.springframework.boot.actuate.autoconfigure.opentelemetry.OpenTelemetryAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
Expand All @@ -50,9 +51,8 @@ class OpenTelemetryLoggingAutoConfigurationTests {
private final ApplicationContextRunner contextRunner;

OpenTelemetryLoggingAutoConfigurationTests() {
this.contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(
org.springframework.boot.actuate.autoconfigure.opentelemetry.OpenTelemetryAutoConfiguration.class,
OpenTelemetryLoggingAutoConfiguration.class));
this.contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations
.of(OpenTelemetryAutoConfiguration.class, OpenTelemetryLoggingAutoConfiguration.class));
}

@Test
Expand Down Expand Up @@ -82,8 +82,8 @@ void shouldBackOffOnCustomBeans() {
}

@Test
void shouldAllowMultipleLogRecordExporter() {
this.contextRunner.withUserConfiguration(MultipleLogRecordExporterConfig.class).run((context) -> {
void shouldAllowMultipleLogRecordExporters() {
this.contextRunner.withUserConfiguration(MultipleLogRecordExportersConfig.class).run((context) -> {
assertThat(context).hasSingleBean(BatchLogRecordProcessor.class);
assertThat(context.getBeansOfType(LogRecordExporter.class)).hasSize(2);
assertThat(context).hasBean("customLogRecordExporter1");
Expand All @@ -92,8 +92,8 @@ void shouldAllowMultipleLogRecordExporter() {
}

@Test
void shouldAllowMultipleLogRecordProcessorInAdditionToBatchLogRecordProcessor() {
this.contextRunner.withUserConfiguration(MultipleLogRecordProcessorConfig.class).run((context) -> {
void shouldAllowMultipleLogRecordProcessorsInAdditionToBatchLogRecordProcessor() {
this.contextRunner.withUserConfiguration(MultipleLogRecordProcessorsConfig.class).run((context) -> {
assertThat(context).hasSingleBean(BatchLogRecordProcessor.class);
assertThat(context).hasSingleBean(SdkLoggerProvider.class);
assertThat(context.getBeansOfType(LogRecordProcessor.class)).hasSize(3);
Expand All @@ -104,11 +104,11 @@ void shouldAllowMultipleLogRecordProcessorInAdditionToBatchLogRecordProcessor()
}

@Test
void shouldAllowMultipleSdkLoggerProviderBuilderCustomizer() {
this.contextRunner.withUserConfiguration(MultipleSdkLoggerProviderBuilderCustomizerConfig.class)
void shouldAllowMultipleSdkLoggerProviderBuilderCustomizers() {
this.contextRunner.withUserConfiguration(MultipleSdkLoggerProviderBuilderCustomizersConfig.class)
.run((context) -> {
assertThat(context).hasSingleBean(SdkLoggerProvider.class);
assertThat(context.getBeansOfType(NoopSdkLoggerProviderBuilderCustomizer.class)).hasSize(2);
assertThat(context.getBeansOfType(SdkLoggerProviderBuilderCustomizer.class)).hasSize(2);
assertThat(context).hasBean("customSdkLoggerProviderBuilderCustomizer1");
assertThat(context).hasBean("customSdkLoggerProviderBuilderCustomizer2");
assertThat(context
Expand Down Expand Up @@ -136,7 +136,7 @@ public SdkLoggerProvider customSdkLoggerProvider() {
}

@Configuration(proxyBeanMethods = false)
public static class MultipleLogRecordExporterConfig {
public static class MultipleLogRecordExportersConfig {

@Bean
public LogRecordExporter customLogRecordExporter1() {
Expand All @@ -151,7 +151,7 @@ public LogRecordExporter customLogRecordExporter2() {
}

@Configuration(proxyBeanMethods = false)
public static class MultipleLogRecordProcessorConfig {
public static class MultipleLogRecordProcessorsConfig {

@Bean
public LogRecordProcessor customLogRecordProcessor1() {
Expand All @@ -166,7 +166,7 @@ public LogRecordProcessor customLogRecordProcessor2() {
}

@Configuration(proxyBeanMethods = false)
public static class MultipleSdkLoggerProviderBuilderCustomizerConfig {
public static class MultipleSdkLoggerProviderBuilderCustomizersConfig {

@Bean
public SdkLoggerProviderBuilderCustomizer customSdkLoggerProviderBuilderCustomizer1() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ void shouldBackOffWhenCustomGrpcExporterIsDefined() {
}

@Test
void shouldBackOffWhenCustomOtlpLogsConnectionDetailsIsDefined() {
this.contextRunner.withUserConfiguration(CustomOtlpLogsConnectionDetails.class).run((context) -> {
void shouldBackOffWhenCustomOtlpLoggingConnectionDetailsIsDefined() {
this.contextRunner.withUserConfiguration(CustomOtlpLoggingConnectionDetails.class).run((context) -> {
assertThat(context).hasSingleBean(OtlpLoggingConnectionDetails.class)
.doesNotHaveBean(PropertiesOtlpLoggingConnectionDetails.class);
OtlpHttpLogRecordExporter otlpHttpLogRecordExporter = context.getBean(OtlpHttpLogRecordExporter.class);
Expand Down Expand Up @@ -121,10 +121,10 @@ public OtlpGrpcLogRecordExporter customOtlpGrpcLogRecordExporter() {
}

@Configuration(proxyBeanMethods = false)
public static class CustomOtlpLogsConnectionDetails {
public static class CustomOtlpLoggingConnectionDetails {

@Bean
public OtlpLoggingConnectionDetails customOtlpLogsConnectionDetails() {
public OtlpLoggingConnectionDetails customOtlpLoggingConnectionDetails() {
return (transport) -> "https://otel.example.com/v1/logs";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class OnEnabledTracingConditionTests {
@Test
void shouldMatchIfNoPropertyIsSet() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(), mockMetaData(""));
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(), mockMetadata(""));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracing tracing is enabled by default");
}
Expand All @@ -49,7 +49,7 @@ void shouldMatchIfNoPropertyIsSet() {
void shouldNotMatchIfGlobalPropertyIsFalse() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "false")), mockMetaData(""));
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "false")), mockMetadata(""));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracing management.tracing.enabled is false");
}
Expand All @@ -58,7 +58,7 @@ void shouldNotMatchIfGlobalPropertyIsFalse() {
void shouldMatchIfGlobalPropertyIsTrue() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "true")), mockMetaData(""));
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "true")), mockMetadata(""));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracing management.tracing.enabled is true");
}
Expand All @@ -68,7 +68,7 @@ void shouldNotMatchIfExporterPropertyIsFalse() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of("management.zipkin.tracing.export.enabled", "false")),
mockMetaData("zipkin"));
mockMetadata("zipkin"));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is false");
Expand All @@ -79,7 +79,7 @@ void shouldMatchIfExporterPropertyIsTrue() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(
mockConditionContext(Map.of("management.zipkin.tracing.export.enabled", "true")),
mockMetaData("zipkin"));
mockMetadata("zipkin"));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is true");
Expand All @@ -90,7 +90,7 @@ void exporterPropertyShouldOverrideGlobalPropertyIfTrue() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(
Map.of("management.tracing.enabled", "false", "management.zipkin.tracing.export.enabled", "true")),
mockMetaData("zipkin"));
mockMetadata("zipkin"));
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is true");
Expand All @@ -101,7 +101,7 @@ void exporterPropertyShouldOverrideGlobalPropertyIfFalse() {
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(
Map.of("management.tracing.enabled", "true", "management.zipkin.tracing.export.enabled", "false")),
mockMetaData("zipkin"));
mockMetadata("zipkin"));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage())
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is false");
Expand All @@ -119,7 +119,7 @@ private ConditionContext mockConditionContext(Map<String, String> properties) {
return context;
}

private AnnotatedTypeMetadata mockMetaData(String exporter) {
private AnnotatedTypeMetadata mockMetadata(String exporter) {
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
given(metadata.getAnnotationAttributes(ConditionalOnEnabledTracing.class.getName()))
.willReturn(Map.of("value", exporter));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public interface JCachePropertiesCustomizer {
/**
* Customize the properties.
* @param properties the current properties
*
*/
void customize(Properties properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static class Pageable {
private int maxPageSize = 2000;

/**
* Configures how to render spring data Pageable instances.
* Configures how to render Spring Data Pageable instances.
*/
private PageSerializationMode serializationMode = PageSerializationMode.DIRECT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ void expressionEvaluationWithNoBeanFactoryDoesNotMatch() {
MockEnvironment environment = new MockEnvironment();
ConditionContext conditionContext = mock(ConditionContext.class);
given(conditionContext.getEnvironment()).willReturn(environment);
ConditionOutcome outcome = condition.getMatchOutcome(conditionContext, mockMetaData("invalid-spel"));
ConditionOutcome outcome = condition.getMatchOutcome(conditionContext, mockMetadata("invalid-spel"));
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage()).contains("invalid-spel").contains("no BeanFactory available");
}

private AnnotatedTypeMetadata mockMetaData(String value) {
private AnnotatedTypeMetadata mockMetadata(String value) {
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
given(metadata.getAnnotationAttributes(ConditionalOnExpression.class.getName()))
.willReturn(Collections.singletonMap("value", value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ void jndiLocationBound() {

@Test
void jndiLocationNotFound() {
ConditionOutcome outcome = this.condition.getMatchOutcome(null, mockMetaData("java:/a"));
ConditionOutcome outcome = this.condition.getMatchOutcome(null, mockMetadata("java:/a"));
assertThat(outcome.isMatch()).isFalse();
}

@Test
void jndiLocationFound() {
this.condition.setFoundLocation("java:/b");
ConditionOutcome outcome = this.condition.getMatchOutcome(null, mockMetaData("java:/a", "java:/b"));
ConditionOutcome outcome = this.condition.getMatchOutcome(null, mockMetadata("java:/a", "java:/b"));
assertThat(outcome.isMatch()).isTrue();
}

Expand All @@ -117,7 +117,7 @@ private void setupJndi() {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, TestableInitialContextFactory.class.getName());
}

private AnnotatedTypeMetadata mockMetaData(String... value) {
private AnnotatedTypeMetadata mockMetadata(String... value) {
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
Map<String, Object> attributes = new HashMap<>();
attributes.put("value", value);
Expand Down
1 change: 0 additions & 1 deletion spring-boot-project/spring-boot-dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,6 @@ bom {
group("com.oracle.database.security") {
modules = [
"oraclepki"

]
}
group("com.oracle.database.xml") {
Expand Down
Loading