From 59139e632b88659b39744819d7b5751305b870f2 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 27 Jul 2022 08:11:24 +0200 Subject: [PATCH] Polish "Disable auto-detection in tests that start Hazelcast" See gh-31863 --- .../HazelcastAutoConfigurationServerTests.java | 17 ++++++++++++----- .../src/main/resources/hazelcast.xml | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java index 143641b961..a1b92afa59 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java @@ -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; } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml index 6781e5a224..608cf7d9b0 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-hazelcast/src/main/resources/hazelcast.xml @@ -11,6 +11,7 @@ +