Browse Source

Polish "Disable auto-detection in tests that start Hazelcast"

See gh-31863
pull/31958/head
Stephane Nicoll 3 years ago
parent
commit
59139e632b
  1. 17
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java
  2. 1
      spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml

17
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.hazelcast; @@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.hazelcast;
import java.util.Map;
import com.hazelcast.config.Config;
import com.hazelcast.config.JoinConfig;
import com.hazelcast.config.QueueConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
@ -130,8 +131,7 @@ class HazelcastAutoConfigurationServerTests { @@ -130,8 +131,7 @@ class HazelcastAutoConfigurationServerTests {
@Test
void configInstanceWithName() {
Config config = new Config("my-test-instance");
config.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false);
Config config = createTestConfig("my-test-instance");
HazelcastInstance existing = Hazelcast.newHazelcastInstance(config);
try {
this.contextRunner.withUserConfiguration(HazelcastConfigWithName.class)
@ -165,6 +165,14 @@ class HazelcastAutoConfigurationServerTests { @@ -165,6 +165,14 @@ class HazelcastAutoConfigurationServerTests {
});
}
private static Config createTestConfig(String instanceName) {
Config config = new Config(instanceName);
JoinConfig join = config.getNetworkConfig().getJoin();
join.getAutoDetectionConfig().setEnabled(false);
join.getMulticastConfig().setEnabled(false);
return config;
}
@Configuration(proxyBeanMethods = false)
static class HazelcastConfigWithName {
@ -180,8 +188,7 @@ class HazelcastAutoConfigurationServerTests { @@ -180,8 +188,7 @@ class HazelcastAutoConfigurationServerTests {
@Bean
Config anotherHazelcastConfig() {
Config config = new Config();
config.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false);
Config config = createTestConfig("another-test-instance");
config.addQueueConfig(new QueueConfig("another-queue"));
return config;
}

1
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
<network>
<join>
<auto-detection enabled="false"/>
<multicast enabled="false"/>
</join>
</network>

Loading…
Cancel
Save