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

See gh-31863
This commit is contained in:
Stephane Nicoll 2022-07-27 08:11:24 +02:00
parent aad9c8906a
commit 59139e632b
2 changed files with 13 additions and 5 deletions

View File

@ -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;
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 {
@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 {
});
}
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 {
@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;
}

View File

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