Merge pull request #44747 from quaff
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run
Details
Build and Deploy Snapshot / Trigger Docs Build (push) Blocked by required conditions
Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:22], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:22], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:false version:17]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:21]) (push) Waiting to run
Details
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run
Details
Build and Deploy Snapshot / Trigger Docs Build (push) Blocked by required conditions
Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:22], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:22], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:false version:17]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:21]) (push) Waiting to run
Details
* pr/44747: Udate copyright year of changed file Remove workaround for Java Records in tests Closes gh-44747
This commit is contained in:
commit
86d08fb76f
|
@ -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.
|
||||
|
@ -36,14 +36,11 @@ import org.springframework.boot.context.properties.source.MockConfigurationPrope
|
|||
import org.springframework.core.DefaultParameterNameDiscoverer;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.test.tools.SourceFile;
|
||||
import org.springframework.core.test.tools.TestCompiler;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Tests for {@link ValueObjectBinder}.
|
||||
|
@ -51,6 +48,7 @@ import static org.assertj.core.api.Assertions.fail;
|
|||
* @author Madhura Bhave
|
||||
* @author Phillip Webb
|
||||
* @author Pavel Anisimov
|
||||
* @author Yanming Zhou
|
||||
*/
|
||||
class ValueObjectBinderTests {
|
||||
|
||||
|
@ -390,25 +388,12 @@ class ValueObjectBinderTests {
|
|||
@Test
|
||||
void bindToRecordWithDefaultValue() {
|
||||
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
|
||||
source.put("test.record.property1", "value-from-config-1");
|
||||
source.put("test.property1", "value-from-config-1");
|
||||
this.sources.add(source);
|
||||
String recordProperties = """
|
||||
public record RecordProperties(
|
||||
@org.springframework.boot.context.properties.bind.DefaultValue("default-value-1") String property1,
|
||||
@org.springframework.boot.context.properties.bind.DefaultValue("default-value-2") String property2) {
|
||||
}
|
||||
""";
|
||||
TestCompiler.forSystem().withSources(SourceFile.of(recordProperties)).compile((compiled) -> {
|
||||
try {
|
||||
ClassLoader cl = compiled.getClassLoader();
|
||||
Object bean = this.binder.bind("test.record", Class.forName("RecordProperties", true, cl)).get();
|
||||
assertThat(bean).hasFieldOrPropertyWithValue("property1", "value-from-config-1")
|
||||
.hasFieldOrPropertyWithValue("property2", "default-value-2");
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
fail("Expected generated class 'RecordProperties' not found", ex);
|
||||
}
|
||||
});
|
||||
Bindable<RecordProperties> target = Bindable.of(RecordProperties.class);
|
||||
RecordProperties bound = this.binder.bindOrCreate("test", target);
|
||||
assertThat(bound.property1()).isEqualTo("value-from-config-1");
|
||||
assertThat(bound.property2()).isEqualTo("default-value-2");
|
||||
}
|
||||
|
||||
@Test // gh-38201
|
||||
|
@ -912,6 +897,10 @@ class ValueObjectBinderTests {
|
|||
record NamedRecordComponent(@Name("import") String importName) {
|
||||
}
|
||||
|
||||
record RecordProperties(@DefaultValue("default-value-1") String property1,
|
||||
@DefaultValue("default-value-2") String property2) {
|
||||
}
|
||||
|
||||
static class NonExtractableParameterName {
|
||||
|
||||
private String value;
|
||||
|
|
Loading…
Reference in New Issue