Merge branch '3.3.x' into 3.4.x
Closes gh-44634
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy;
|
||||
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -36,6 +37,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@WithResource(name = "db/migration/V1__init.sql", content = "DROP TABLE IF EXISTS TEST;")
|
||||
@WithResource(name = "db/migration/V2__update.sql", content = "DROP TABLE IF EXISTS TEST;")
|
||||
@WithResource(name = "db/migration/V3__update.sql", content = "DROP TABLE IF EXISTS TEST;")
|
||||
class FlywayEndpointTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,6 +25,7 @@ import org.springframework.boot.actuate.health.Status;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@@ -40,6 +41,21 @@ import static org.mockito.Mockito.mock;
|
||||
class HazelcastHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
@WithResource(name = "hazelcast.xml", content = """
|
||||
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.hazelcast.com/schema/config
|
||||
http://www.hazelcast.com/schema/config/hazelcast-config-5.0.xsd">
|
||||
<instance-name>actuator-hazelcast</instance-name>
|
||||
<map name="defaultCache" />
|
||||
<network>
|
||||
<join>
|
||||
<auto-detection enabled="false"/>
|
||||
<multicast enabled="false"/>
|
||||
</join>
|
||||
</network>
|
||||
</hazelcast>
|
||||
""")
|
||||
void hazelcastUp() {
|
||||
new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(HazelcastAutoConfiguration.class))
|
||||
.withPropertyValues("spring.hazelcast.config=hazelcast.xml")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,6 +35,7 @@ import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
|
||||
import org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer;
|
||||
import org.springframework.boot.sql.init.DatabaseInitializationSettings;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -50,6 +51,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Stephane Nicoll
|
||||
* @author Leo Li
|
||||
*/
|
||||
@WithResource(name = "db/changelog/db.changelog-master.yaml", content = """
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 1
|
||||
author: test
|
||||
""")
|
||||
class LiquibaseEndpointTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
@@ -83,6 +90,7 @@ class LiquibaseEndpointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithResource(name = "db/create-custom-schema.sql", content = "CREATE SCHEMA CUSTOMSCHEMA;")
|
||||
void invokeWithCustomSchema() {
|
||||
this.contextRunner.withUserConfiguration(Config.class, DataSourceWithSchemaConfiguration.class)
|
||||
.withPropertyValues("spring.liquibase.default-schema=CUSTOMSCHEMA")
|
||||
@@ -122,6 +130,12 @@ class LiquibaseEndpointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithResource(name = "db/changelog/db.changelog-master-backup.yaml", content = """
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 1
|
||||
author: test
|
||||
""")
|
||||
void whenMultipleLiquibaseBeansArePresentChangeSetsAreCorrectlyReportedForEachBean() {
|
||||
this.contextRunner.withUserConfiguration(Config.class, MultipleDataSourceLiquibaseConfiguration.class)
|
||||
.run((context) -> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,7 @@ class SbomEndpointCycloneDxWebIntegrationTests {
|
||||
@Bean
|
||||
SbomProperties sbomProperties() {
|
||||
SbomProperties properties = new SbomProperties();
|
||||
properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
|
||||
properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,7 @@ class SbomEndpointSpdxWebIntegrationTests {
|
||||
@Bean
|
||||
SbomProperties sbomProperties() {
|
||||
SbomProperties properties = new SbomProperties();
|
||||
properties.getApplication().setLocation("classpath:sbom/spdx.json");
|
||||
properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/spdx.json");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,7 @@ class SbomEndpointSyftWebIntegrationTests {
|
||||
@Bean
|
||||
SbomProperties sbomProperties() {
|
||||
SbomProperties properties = new SbomProperties();
|
||||
properties.getApplication().setLocation("classpath:sbom/syft.json");
|
||||
properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/syft.json");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,9 +48,11 @@ class SbomEndpointTests {
|
||||
|
||||
@Test
|
||||
void shouldListSboms() {
|
||||
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
|
||||
this.properties.getAdditional().put("alpha", sbom("classpath:sbom/cyclonedx.json"));
|
||||
this.properties.getAdditional().put("beta", sbom("classpath:sbom/cyclonedx.json"));
|
||||
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
|
||||
this.properties.getAdditional()
|
||||
.put("alpha", sbom("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json"));
|
||||
this.properties.getAdditional()
|
||||
.put("beta", sbom("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json"));
|
||||
Sboms sboms = createEndpoint().sboms();
|
||||
assertThat(sboms.ids()).containsExactly("alpha", "application", "beta");
|
||||
}
|
||||
@@ -58,15 +60,16 @@ class SbomEndpointTests {
|
||||
@Test
|
||||
void shouldFailIfDuplicateSbomIdIsRegistered() {
|
||||
// This adds an SBOM with id 'application'
|
||||
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
|
||||
this.properties.getAdditional().put("application", sbom("classpath:sbom/cyclonedx.json"));
|
||||
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
|
||||
this.properties.getAdditional()
|
||||
.put("application", sbom("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json"));
|
||||
assertThatIllegalStateException().isThrownBy(this::createEndpoint)
|
||||
.withMessage("Duplicate SBOM registration with id 'application'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldUseLocationFromProperties() throws IOException {
|
||||
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
|
||||
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
|
||||
String content = createEndpoint().sbom("application").getContentAsString(StandardCharsets.UTF_8);
|
||||
assertThat(content).contains("\"bomFormat\" : \"CycloneDX\"");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,7 @@ import org.junit.jupiter.params.provider.EnumSource.Mode;
|
||||
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
||||
import org.springframework.boot.actuate.sbom.SbomEndpointWebExtension.SbomType;
|
||||
import org.springframework.boot.actuate.sbom.SbomProperties.Sbom;
|
||||
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -53,7 +54,7 @@ class SbomEndpointWebExtensionTests {
|
||||
|
||||
@Test
|
||||
void shouldReturnHttpOk() {
|
||||
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
|
||||
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
|
||||
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
@@ -66,26 +67,27 @@ class SbomEndpointWebExtensionTests {
|
||||
|
||||
@Test
|
||||
void shouldAutoDetectContentTypeForCycloneDx() {
|
||||
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
|
||||
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
|
||||
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
|
||||
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("application/vnd.cyclonedx+json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAutoDetectContentTypeForSpdx() {
|
||||
this.properties.getApplication().setLocation("classpath:sbom/spdx.json");
|
||||
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/spdx.json");
|
||||
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
|
||||
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("application/spdx+json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAutoDetectContentTypeForSyft() {
|
||||
this.properties.getApplication().setLocation("classpath:sbom/syft.json");
|
||||
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/syft.json");
|
||||
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
|
||||
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("application/vnd.syft+json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithResource(name = "git.properties", content = "git.commit.id.abbrev=e02a4f3")
|
||||
void shouldSupportUnknownFiles() {
|
||||
this.properties.getApplication().setLocation("classpath:git.properties");
|
||||
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
|
||||
@@ -94,7 +96,7 @@ class SbomEndpointWebExtensionTests {
|
||||
|
||||
@Test
|
||||
void shouldUseContentTypeIfSet() {
|
||||
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
|
||||
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
|
||||
this.properties.getApplication().setMediaType(MimeType.valueOf("text/plain"));
|
||||
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
|
||||
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("text/plain"));
|
||||
@@ -103,7 +105,8 @@ class SbomEndpointWebExtensionTests {
|
||||
@Test
|
||||
void shouldUseContentTypeForAdditionalSbomsIfSet() {
|
||||
this.properties.getAdditional()
|
||||
.put("alpha", sbom("classpath:sbom/cyclonedx.json", MediaType.valueOf("text/plain")));
|
||||
.put("alpha", sbom("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json",
|
||||
MediaType.valueOf("text/plain")));
|
||||
WebEndpointResponse<Resource> response = createWebExtension().sbom("alpha");
|
||||
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("text/plain"));
|
||||
}
|
||||
@@ -120,9 +123,9 @@ class SbomEndpointWebExtensionTests {
|
||||
|
||||
private String getSbomContent(SbomType type) throws IOException {
|
||||
return switch (type) {
|
||||
case CYCLONE_DX -> readResource("/sbom/cyclonedx.json");
|
||||
case SPDX -> readResource("/sbom/spdx.json");
|
||||
case SYFT -> readResource("/sbom/syft.json");
|
||||
case CYCLONE_DX -> readResource("cyclonedx.json");
|
||||
case SPDX -> readResource("spdx.json");
|
||||
case SYFT -> readResource("syft.json");
|
||||
case UNKNOWN -> throw new IllegalArgumentException("UNKNOWN is not supported");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,7 @@ class SbomEndpointWebIntegrationTests {
|
||||
@Bean
|
||||
SbomProperties sbomProperties() {
|
||||
SbomProperties properties = new SbomProperties();
|
||||
properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
|
||||
properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 1
|
||||
author: leoli
|
||||
changes:
|
||||
- createTable:
|
||||
tableName: customerbackup
|
||||
columns:
|
||||
- column:
|
||||
name: id
|
||||
type: int
|
||||
autoIncrement: true
|
||||
constraints:
|
||||
primaryKey: true
|
||||
nullable: false
|
||||
- column:
|
||||
name: name
|
||||
type: varchar(50)
|
||||
constraints:
|
||||
nullable: false
|
||||
@@ -1,20 +0,0 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 1
|
||||
author: marceloverdijk
|
||||
changes:
|
||||
- createTable:
|
||||
tableName: customer
|
||||
columns:
|
||||
- column:
|
||||
name: id
|
||||
type: int
|
||||
autoIncrement: true
|
||||
constraints:
|
||||
primaryKey: true
|
||||
nullable: false
|
||||
- column:
|
||||
name: name
|
||||
type: varchar(50)
|
||||
constraints:
|
||||
nullable: false
|
||||
@@ -1 +0,0 @@
|
||||
CREATE SCHEMA CUSTOMSCHEMA;
|
||||
@@ -1 +0,0 @@
|
||||
DROP TABLE IF EXISTS TEST;
|
||||
@@ -1 +0,0 @@
|
||||
DROP TABLE IF EXISTS TEST;
|
||||
@@ -1 +0,0 @@
|
||||
DROP TABLE IF EXISTS TEST;
|
||||
@@ -1,13 +0,0 @@
|
||||
#Generated by Git-Commit-Id-Plugin
|
||||
#Thu May 23 09:26:42 BST 2013
|
||||
git.commit.id.abbrev=e02a4f3
|
||||
git.commit.user.email=dsyer@vmware.com
|
||||
git.commit.message.full=Update Spring
|
||||
git.commit.id=e02a4f3b6f452cdbf6dd311f1362679eb4c31ced
|
||||
git.commit.message.short=Update Spring
|
||||
git.commit.user.name=Dave Syer
|
||||
git.build.user.name=Dave Syer
|
||||
git.build.user.email=dsyer@vmware.com
|
||||
git.branch=develop
|
||||
git.commit.time=2013-04-24T08\:42\:13+0100
|
||||
git.build.time=2013-05-23T09\:26\:42+0100
|
||||
@@ -1,13 +0,0 @@
|
||||
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.hazelcast.com/schema/config
|
||||
http://www.hazelcast.com/schema/config/hazelcast-config-5.0.xsd">
|
||||
<instance-name>actuator-hazelcast</instance-name>
|
||||
<map name="defaultCache" />
|
||||
<network>
|
||||
<join>
|
||||
<auto-detection enabled="false"/>
|
||||
<multicast enabled="false"/>
|
||||
</join>
|
||||
</network>
|
||||
</hazelcast>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="warn" name="test" packages="">
|
||||
<Properties>
|
||||
<Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
|
||||
<Property name="LOG_LEVEL_PATTERN">%5p</Property>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT" follow="true">
|
||||
<PatternLayout pattern="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{${LOG_LEVEL_PATTERN}} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="STDOUT"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Binary file not shown.
Reference in New Issue
Block a user