Skip to content

Commit 41dc701

Browse files
committed
Polish "Prevent warnings when running embedded Artemis"
Closes gh-12680
1 parent 19818b7 commit 41dc701

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedConfigurationFactory.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -70,29 +70,22 @@ public Configuration createConfiguration() {
7070
+ this.properties.getClusterPassword());
7171
}
7272
configuration.setClusterPassword(this.properties.getClusterPassword());
73+
configuration.addAddressConfiguration(createAddressConfiguration("DLQ"));
74+
configuration.addAddressConfiguration(createAddressConfiguration("ExpiryQueue"));
7375
configuration.addAddressesSetting("#",
74-
new AddressSettings()
75-
.setDeadLetterAddress(SimpleString.toSimpleString("DLQ"))
76-
.setExpiryAddress(SimpleString.toSimpleString("ExpiryQueue")));
77-
configuration.addAddressConfiguration(
78-
new CoreAddressConfiguration()
79-
.setName("DLQ")
80-
.addRoutingType(RoutingType.ANYCAST)
81-
.addQueueConfiguration(
82-
new CoreQueueConfiguration()
83-
.setName("DLQ")
84-
.setRoutingType(RoutingType.ANYCAST)));
85-
configuration.addAddressConfiguration(
86-
new CoreAddressConfiguration()
87-
.setName("ExpiryQueue")
88-
.addRoutingType(RoutingType.ANYCAST)
89-
.addQueueConfiguration(
90-
new CoreQueueConfiguration()
91-
.setName("ExpiryQueue")
92-
.setRoutingType(RoutingType.ANYCAST)));
76+
new AddressSettings()
77+
.setDeadLetterAddress(SimpleString.toSimpleString("DLQ"))
78+
.setExpiryAddress(SimpleString.toSimpleString("ExpiryQueue")));
9379
return configuration;
9480
}
9581

82+
private CoreAddressConfiguration createAddressConfiguration(String name) {
83+
return new CoreAddressConfiguration().setName(name)
84+
.addRoutingType(RoutingType.ANYCAST)
85+
.addQueueConfiguration(new CoreQueueConfiguration().setName(name)
86+
.setRoutingType(RoutingType.ANYCAST));
87+
}
88+
9689
private String getDataDir() {
9790
if (this.properties.getDataDirectory() != null) {
9891
return this.properties.getDataDirectory();

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedConfigurationFactoryTests.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -78,18 +78,22 @@ public void specificClusterPassword() {
7878
public void hasDlqExpiryQueueAddressSettingsConfigured() {
7979
ArtemisProperties properties = new ArtemisProperties();
8080
Configuration configuration = new ArtemisEmbeddedConfigurationFactory(properties)
81-
.createConfiguration();
82-
Map<String, AddressSettings> addressesSettings = configuration.getAddressesSettings();
83-
assertThat((CharSequence) addressesSettings.get("#").getDeadLetterAddress()).isEqualTo(SimpleString.toSimpleString("DLQ"));
84-
assertThat((CharSequence) addressesSettings.get("#").getExpiryAddress()).isEqualTo(SimpleString.toSimpleString("ExpiryQueue"));
81+
.createConfiguration();
82+
Map<String, AddressSettings> addressesSettings = configuration
83+
.getAddressesSettings();
84+
assertThat((Object) addressesSettings.get("#").getDeadLetterAddress())
85+
.isEqualTo(SimpleString.toSimpleString("DLQ"));
86+
assertThat((Object) addressesSettings.get("#").getExpiryAddress())
87+
.isEqualTo(SimpleString.toSimpleString("ExpiryQueue"));
8588
}
8689

8790
@Test
8891
public void hasDlqExpiryQueueConfigured() {
8992
ArtemisProperties properties = new ArtemisProperties();
9093
Configuration configuration = new ArtemisEmbeddedConfigurationFactory(properties)
91-
.createConfiguration();
92-
List<CoreAddressConfiguration> addressConfigurations = configuration.getAddressConfigurations();
94+
.createConfiguration();
95+
List<CoreAddressConfiguration> addressConfigurations = configuration
96+
.getAddressConfigurations();
9397
assertThat(addressConfigurations).hasSize(2);
9498
}
9599
}

0 commit comments

Comments
 (0)