Skip to content

Polish #43879

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 3 commits into from
Closed

Polish #43879

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 @@ -117,10 +117,12 @@ private String getPrefix(AnnotationAttributes annotationAttributes) {
private String[] getNames(AnnotationAttributes annotationAttributes) {
String[] value = (String[]) annotationAttributes.get("value");
String[] name = (String[]) annotationAttributes.get("name");
Assert.state(value.length > 0 || name.length > 0, "The name or value attribute of @%s must be specified"
.formatted(ClassUtils.getShortName(this.annotationType)));
Assert.state(value.length == 0 || name.length == 0, "The name and value attributes of @%s are exclusive"
.formatted(ClassUtils.getShortName(this.annotationType)));
Assert.state(value.length > 0 || name.length > 0,
() -> "The name or value attribute of @%s must be specified"
.formatted(ClassUtils.getShortName(this.annotationType)));
Assert.state(value.length == 0 || name.length == 0,
() -> "The name and value attributes of @%s are exclusive"
.formatted(ClassUtils.getShortName(this.annotationType)));
return (value.length > 0) ? value : name;
}

Expand Down
8 changes: 4 additions & 4 deletions spring-boot-project/spring-boot-dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2492,17 +2492,17 @@ bom {
]
}
}
library("WebJars Locator Lite", "1.0.1") {
library("WebJars Locator Core", "0.59") {
group("org.webjars") {
modules = [
"webjars-locator-lite"
"webjars-locator-core"
]
}
}
library("WebJars Locator Core", "0.59") {
library("WebJars Locator Lite", "1.0.1") {
group("org.webjars") {
modules = [
"webjars-locator-core"
"webjars-locator-lite"
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ private void checkDatabaseAccess(JdbcConnectionDetails connectionDetails) throws
}

@SuppressWarnings("unchecked")
private <T> T executeQuery(JdbcConnectionDetails connectionDetails, String sql, Class<T> result)
private <T> T executeQuery(JdbcConnectionDetails connectionDetails, String sql, Class<T> resultClass)
throws ClassNotFoundException {
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
dataSource.setUrl(connectionDetails.getJdbcUrl());
dataSource.setUsername(connectionDetails.getUsername());
dataSource.setPassword(connectionDetails.getPassword());
dataSource.setDriverClass((Class<? extends Driver>) ClassUtils.forName(connectionDetails.getDriverClassName(),
getClass().getClassLoader()));
return new JdbcTemplate(dataSource).queryForObject(sql, result);
return new JdbcTemplate(dataSource).queryForObject(sql, resultClass);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ private void checkDatabaseAccess(R2dbcConnectionDetails connectionDetails) {
.isEqualTo(1);
}

private <T> T executeQuery(R2dbcConnectionDetails connectionDetails, String sql, Class<T> result) {
private <T> T executeQuery(R2dbcConnectionDetails connectionDetails, String sql, Class<T> resultClass) {
ConnectionFactoryOptions connectionFactoryOptions = connectionDetails.getConnectionFactoryOptions();
return DatabaseClient.create(ConnectionFactories.get(connectionFactoryOptions))
.sql(sql)
.mapValue(result)
.mapValue(resultClass)
.first()
.block(Duration.ofSeconds(30));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ enum Type {
*/
record ComposeVersion(int major, int minor) {

public static final ComposeVersion UNKNOWN = new ComposeVersion(0, 0);
static final ComposeVersion UNKNOWN = new ComposeVersion(0, 0);

boolean isLessThan(int major, int minor) {
return major() < major || major() == major && minor() < minor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ NOTE: Using a javadoc:org.springframework.boot.testcontainers.service.connection


[[features.dev-services.testcontainers.at-development-time.importing-container-declarations]]
==== Importing Testcontainer Declaration Classes
==== Importing Testcontainers Declaration Classes

A common pattern when using Testcontainers is to declare javadoc:org.testcontainers.containers.Container[] instances as static fields.
Often these fields are defined directly on the test class.
Expand All @@ -402,7 +402,7 @@ You can also add javadoc:org.springframework.test.context.DynamicPropertySource[

When using devtools, you can annotate beans and bean methods with javadoc:org.springframework.boot.devtools.restart.RestartScope[format=annotation].
Such beans won't be recreated when the devtools restart the application.
This is especially useful for Testcontainer javadoc:org.testcontainers.containers.Container[] beans, as they keep their state despite the application restart.
This is especially useful for javadoc:org.testcontainers.containers.Container[] beans, as they keep their state despite the application restart.

include-code::MyContainersConfiguration[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ enum Replace {
* databases:
* <ul>
* <li>Any bean definition that includes {@link ContainerImageMetadata} (including
* {@code @ServiceConnection} annotated Testcontainer databases, and connections
* {@code @ServiceConnection} annotated Testcontainers databases, and connections
* created using Docker Compose)</li>
* <li>Any connection configured using a {@code spring.datasource.url} backed by a
* {@link DynamicPropertySource @DynamicPropertySource}</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void jdkBuilderCanBeSpecifiedWithSpecificRedirects() {
}

@Test
void httpComponentsAreBuildConsideringSettingsInRestTemplateBuilder() {
void httpComponentsAreBuiltConsideringSettingsInRestTemplateBuilder() {
RestTemplateBuilder builder = new RestTemplateBuilder()
.requestFactoryBuilder(ClientHttpRequestFactoryBuilder.httpComponents());
assertThat(getRequestConfig((RestTemplateBuilder) null).isRedirectsEnabled()).isFalse();
Expand Down Expand Up @@ -209,9 +209,8 @@ private RequestConfig getRequestConfig(TestRestTemplate template) {
return factory.createRequestConfig();
}

private HttpClient getJdkHttpClient(TestRestTemplate templateWithRedirects) {
JdkClientHttpRequestFactory requestFactory = (JdkClientHttpRequestFactory) templateWithRedirects
.getRestTemplate()
private HttpClient getJdkHttpClient(TestRestTemplate template) {
JdkClientHttpRequestFactory requestFactory = (JdkClientHttpRequestFactory) template.getRestTemplate()
.getRequestFactory();
return (HttpClient) ReflectionTestUtils.getField(requestFactory, "httpClient");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
@SpringJUnitConfig
@Testcontainers(disabledWithoutDocker = true)
class ServiceConnectionStartsConnectionOnceIntegrationTest {
class ServiceConnectionStartsConnectionOnceIntegrationTests {

@Container
@ServiceConnection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.springframework.context.annotation.Import;

/**
* Imports idiomatic Testcontainer declaration classes into the Spring
* Imports idiomatic Testcontainers declaration classes into the Spring
* {@link ApplicationContext}. The following elements will be considered from the imported
* classes:
* <ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ void getStatusReturnsStatus() {
}

@Test
void getProgressDetailsReturnsProgressDetails() {
void getProgressDetailReturnsProgressDetails() {
ProgressUpdateEvent event = createEvent();
assertThat(event.getProgressDetail().asPercentage()).isEqualTo(50);
}

@Test
void getProgressDetailsReturnsProgressDetailsForLongNumbers() {
void getProgressDetailReturnsProgressDetailsForLongNumbers() {
ProgressUpdateEvent event = createEvent("status", new ProgressDetail(4000000000L, 8000000000L), "progress");
assertThat(event.getProgressDetail().asPercentage()).isEqualTo(50);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* <li>Apache DBCP2 ({@code org.apache.commons.dbcp2.BasicDataSource})</li>
* <li>Oracle UCP ({@code oracle.ucp.jdbc.PoolDataSourceImpl})</li>
* <li>C3P0 ({@code com.mchange.v2.c3p0.ComboPooledDataSource})</li>
* <li>Vibur {@code org.vibur.dbcp.ViburDBCPDataSource}</li>
* <li>Vibur ({@code org.vibur.dbcp.ViburDBCPDataSource})</li>
* </ul>
* <p>
* The following non-pooling {@link DataSource} implementations can be used when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private ConnectionFactoryUnwrapper() {
}

/**
* Return the native {@link ConnectionFactory} by unwrapping ot from a
* Return the native {@link ConnectionFactory} by unwrapping from a
* {@link CachingConnectionFactory}. Return the given {@link ConnectionFactory} if no
* {@link CachingConnectionFactory} wrapper has been detected.
* @param connectionFactory a connection factory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ public String getEnvironmentVariableName() {
}

/**
* Return the name of the application property name that can be used to set this
* property.
* Return the application property name that can be used to set this property.
* @return the application property name
* @since 3.4.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ public void initialize(LoggingInitializationContext initializationContext, Strin

/**
* Reset the stream used by the fallback listener to the current system out. This
* allows the fallback lister to work with any captured output streams in a similar
* way to the {@code follow} attribute of the {@code literal Console} appender.
* allows the fallback listener to work with any captured output streams in a similar
* way to the {@code follow} attribute of the {@code Console} appender.
* @param statusLogger the status logger to update
*/
private void resetFallbackListenerStream(StatusLogger statusLogger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ <T extends Converter<?>> void conversionRule(String conversionWord, Class<T> con
}

@Override
public void appender(String name, Appender<?> appender) {
void appender(String name, Appender<?> appender) {
info("Adding appender '" + appender + "' named '" + name + "'");
super.appender(name, appender);
}

@Override
public void logger(String name, Level level, boolean additive, Appender<ILoggingEvent> appender) {
void logger(String name, Level level, boolean additive, Appender<ILoggingEvent> appender) {
info("Configuring logger '" + name + "' with level '" + level + "'. Additive: " + additive);
if (appender != null) {
info("Adding appender '" + appender + "' to logger '" + name + "'");
Expand All @@ -62,7 +62,7 @@ public void logger(String name, Level level, boolean additive, Appender<ILogging
}

@Override
public void start(LifeCycle lifeCycle) {
void start(LifeCycle lifeCycle) {
info("Starting '" + lifeCycle + "'");
super.start(lifeCycle);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FilteringStatusListener extends ContextAwareBase implements StatusListener

/**
* Creates a new {@link FilteringStatusListener}.
* @param delegate the {@link StatusListener} delegate to
* @param delegate the {@link StatusListener} to delegate to
* @param levelThreshold the minimum log level accepted for delegation
*/
FilteringStatusListener(StatusListener delegate, int levelThreshold) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void shouldFilterOutInfoStatus() {

@Test
void shouldStartUnderlyingStatusListener() {
FilteringStatusListener listener = createListener(Status.INFO);
FilteringStatusListener listener = createListener();
assertThat(this.delegate.isStarted()).isFalse();
listener.start();
assertThat(this.delegate.isStarted()).isTrue();
Expand Down
Loading