Improve property defaults
See gh-41851
This commit is contained in:
@@ -311,17 +311,15 @@ public class PulsarProperties {
|
||||
|
||||
/**
|
||||
* Default tenant to use when producing or consuming messages against a
|
||||
* non-fully-qualified topic URL. When not specified Pulsar uses a default
|
||||
* tenant of 'public'.
|
||||
* non-fully-qualified topic URL.
|
||||
*/
|
||||
private String tenant;
|
||||
private String tenant = "public";
|
||||
|
||||
/**
|
||||
* Default namespace to use when producing or consuming messages against a
|
||||
* non-fully-qualified topic URL. When not specified Pulsar uses a default
|
||||
* namespace of 'default'.
|
||||
* non-fully-qualified topic URL.
|
||||
*/
|
||||
private String namespace;
|
||||
private String namespace = "default";
|
||||
|
||||
public String getTenant() {
|
||||
return this.tenant;
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.apache.pulsar.client.api.SubscriptionInitialPosition;
|
||||
import org.apache.pulsar.client.api.SubscriptionMode;
|
||||
import org.apache.pulsar.client.api.SubscriptionType;
|
||||
import org.apache.pulsar.common.schema.SchemaType;
|
||||
import org.assertj.core.extractor.Extractors;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -40,6 +41,7 @@ import org.springframework.boot.autoconfigure.pulsar.PulsarProperties.Failover.B
|
||||
import org.springframework.boot.context.properties.bind.BindException;
|
||||
import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
|
||||
import org.springframework.pulsar.core.PulsarTopicBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
@@ -247,9 +249,12 @@ class PulsarPropertiesTests {
|
||||
|
||||
@Test
|
||||
void bindWhenValuesNotSpecified() {
|
||||
PulsarTopicBuilder defaultTopicBuilder = new PulsarTopicBuilder();
|
||||
assertThat(new PulsarProperties().getDefaults().getTopic()).satisfies((defaults) -> {
|
||||
assertThat(defaults.getTenant()).isNull();
|
||||
assertThat(defaults.getNamespace()).isNull();
|
||||
assertThat(defaults.getTenant())
|
||||
.isEqualTo(Extractors.byName("defaultTenant").apply(defaultTopicBuilder));
|
||||
assertThat(defaults.getNamespace())
|
||||
.isEqualTo(Extractors.byName("defaultNamespace").apply(defaultTopicBuilder));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user