Skip to content

Commit bd7f0db

Browse files
committed
Migrate Hazelcast module from JUnit 4
1 parent 8f1ed20 commit bd7f0db

16 files changed

+124
-413
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2022 the original author or authors.
2+
* Copyright 2015-2025 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.
@@ -22,16 +22,15 @@
2222
import com.hazelcast.collection.IList;
2323
import com.hazelcast.core.DistributedObject;
2424
import com.hazelcast.instance.impl.HazelcastInstanceFactory;
25-
import org.junit.AfterClass;
26-
import org.junit.Test;
27-
import org.junit.runner.RunWith;
25+
import org.junit.jupiter.api.AfterAll;
26+
import org.junit.jupiter.api.Test;
2827

2928
import org.springframework.beans.factory.annotation.Autowired;
3029
import org.springframework.test.annotation.DirtiesContext;
31-
import org.springframework.test.context.ContextConfiguration;
32-
import org.springframework.test.context.junit4.SpringRunner;
30+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3331

3432
import static org.assertj.core.api.Assertions.assertThat;
33+
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
3534

3635
/**
3736
* Hazelcast Integration Definition Validator Test Class
@@ -41,16 +40,15 @@
4140
*
4241
* @since 6.0
4342
*/
44-
@RunWith(SpringRunner.class)
45-
@ContextConfiguration
43+
@SpringJUnitConfig
4644
@DirtiesContext
4745
@SuppressWarnings({"rawtypes"})
4846
public class HazelcastIntegrationDefinitionValidatorTests {
4947

5048
@Autowired
5149
private IList distList;
5250

53-
@AfterClass
51+
@AfterAll
5452
public static void shutdown() {
5553
HazelcastInstanceFactory.terminateAll();
5654
}
@@ -67,11 +65,11 @@ public void testValidateEnumType() {
6765
}
6866
}
6967

70-
@Test(expected = IllegalArgumentException.class)
68+
@Test
7169
public void testValidateEnumTypeWithInvalidValue() {
72-
final String cacheEventTypes = "Invalid_Enum_Type";
73-
HazelcastIntegrationDefinitionValidator
74-
.validateEnumType(CacheEventType.class, cacheEventTypes);
70+
assertThatIllegalArgumentException()
71+
.isThrownBy(() -> HazelcastIntegrationDefinitionValidator
72+
.validateEnumType(CacheEventType.class, "Invalid_Enum_Type"));
7573
}
7674

7775
@Test
@@ -83,12 +81,13 @@ public void testValidateCacheEventsByDistributedObject() {
8381
.validateCacheEventsByDistributedObject(this.distList, cacheEventTypeSet);
8482
}
8583

86-
@Test(expected = IllegalArgumentException.class)
84+
@Test
8785
public void testValidateCacheEventsByDistributedObjectWithInvalidValue() {
8886
Set<String> cacheEventTypeSet = new HashSet<>(1);
8987
cacheEventTypeSet.add("Invalid_Cache_Event_Type");
90-
HazelcastIntegrationDefinitionValidator
91-
.validateCacheEventsByDistributedObject(this.distList, cacheEventTypeSet);
88+
assertThatIllegalArgumentException()
89+
.isThrownBy(() -> HazelcastIntegrationDefinitionValidator
90+
.validateCacheEventsByDistributedObject(this.distList, cacheEventTypeSet));
9291
}
9392

9493
@Test
@@ -97,32 +96,35 @@ public void testValidateCacheTypeForEventDrivenMessageProducer() {
9796
.validateCacheTypeForEventDrivenMessageProducer(this.distList);
9897
}
9998

100-
@Test(expected = IllegalArgumentException.class)
99+
@Test
101100
public void testValidateCacheTypeForEventDrivenMessageProducerWithUnexpectedDistObject() {
102-
HazelcastIntegrationDefinitionValidator
103-
.validateCacheTypeForEventDrivenMessageProducer(new DistributedObject() {
101+
DistributedObject distributedObject = new DistributedObject() {
102+
103+
@Override
104+
public String getPartitionKey() {
105+
return null;
106+
}
104107

105-
@Override
106-
public String getPartitionKey() {
107-
return null;
108-
}
108+
@Override
109+
public String getName() {
110+
return null;
111+
}
109112

110-
@Override
111-
public String getName() {
112-
return null;
113-
}
113+
@Override
114+
public String getServiceName() {
115+
return null;
116+
}
114117

115-
@Override
116-
public String getServiceName() {
117-
return null;
118-
}
118+
@Override
119+
public void destroy() {
119120

120-
@Override
121-
public void destroy() {
121+
}
122122

123-
}
123+
};
124124

125-
});
125+
assertThatIllegalArgumentException()
126+
.isThrownBy(() -> HazelcastIntegrationDefinitionValidator
127+
.validateCacheTypeForEventDrivenMessageProducer(distributedObject));
126128
}
127129

128130
}

spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastCQDistributedMapInboundChannelAdapterTests.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2022 the original author or authors.
2+
* Copyright 2015-2025 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.
@@ -18,8 +18,7 @@
1818

1919
import com.hazelcast.core.EntryEventType;
2020
import com.hazelcast.map.IMap;
21-
import org.junit.Test;
22-
import org.junit.runner.RunWith;
21+
import org.junit.jupiter.api.Test;
2322

2423
import org.springframework.beans.factory.annotation.Autowired;
2524
import org.springframework.integration.hazelcast.HazelcastHeaders;
@@ -29,8 +28,7 @@
2928
import org.springframework.messaging.Message;
3029
import org.springframework.messaging.PollableChannel;
3130
import org.springframework.test.annotation.DirtiesContext;
32-
import org.springframework.test.context.ContextConfiguration;
33-
import org.springframework.test.context.junit4.SpringRunner;
31+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3432

3533
import static org.assertj.core.api.Assertions.assertThat;
3634

@@ -40,8 +38,7 @@
4038
* @author Eren Avsarogullari
4139
* @since 6.0
4240
*/
43-
@RunWith(SpringRunner.class)
44-
@ContextConfiguration
41+
@SpringJUnitConfig
4542
@DirtiesContext
4643
@SuppressWarnings({"unchecked", "rawtypes"})
4744
public class HazelcastCQDistributedMapInboundChannelAdapterTests {

spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/HazelcastClusterMonitorInboundChannelAdapterTests-context.xml

Lines changed: 0 additions & 170 deletions
This file was deleted.

0 commit comments

Comments
 (0)