Skip to content

Commit 0e6b70c

Browse files
committed
Disable ObjToMapTransformerParserTests.cycle test
The `ObjectToMapTransformerParserTests.testObjectToSpelMapTransformerWithCycle()` causes a `StackOverflowError` according to the parent-child-parent cycle in the model under test. This ends up with an error in the Gradle logs: ``` *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at s\src\java.instrument\share\native\libinstrument\JPLISAgent.c line: 873 ``` * Disable this test to avoid memory overhead and CPU time to let Java to determine stack overflow and avoid a build error
1 parent 2ecc33e commit 0e6b70c

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

spring-integration-core/src/test/java/org/springframework/integration/config/xml/ObjectToMapTransformerParserTests.java

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -17,14 +17,15 @@
1717
package org.springframework.integration.config.xml;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2021

2122
import java.util.ArrayList;
2223
import java.util.HashMap;
2324
import java.util.List;
2425
import java.util.Map;
2526

26-
import org.junit.Test;
27-
import org.junit.runner.RunWith;
27+
import org.junit.jupiter.api.Disabled;
28+
import org.junit.jupiter.api.Test;
2829

2930
import org.springframework.beans.factory.annotation.Autowired;
3031
import org.springframework.beans.factory.annotation.Qualifier;
@@ -38,16 +39,15 @@
3839
import org.springframework.messaging.Message;
3940
import org.springframework.messaging.MessageChannel;
4041
import org.springframework.messaging.PollableChannel;
41-
import org.springframework.test.context.ContextConfiguration;
42-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
42+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4343

4444
/**
4545
* @author Oleg Zhurakousky
4646
* @author Gunnar Hillert
4747
* @author Mauro Franceschini
48+
* @author Artem Bilan
4849
*/
49-
@ContextConfiguration
50-
@RunWith(SpringJUnit4ClassRunner.class)
50+
@SpringJUnitConfig
5151
public class ObjectToMapTransformerParserTests {
5252

5353
@Autowired
@@ -89,15 +89,18 @@ public void testObjectToSpelMapTransformer() {
8989
}
9090
}
9191

92-
@Test(expected = MessageTransformationException.class)
92+
@Disabled("StackOverflowError")
93+
@Test
9394
public void testObjectToSpelMapTransformerWithCycle() {
9495
Employee employee = this.buildEmployee();
9596
Child child = new Child();
9697
Person parent = employee.getPerson();
9798
parent.setChild(child);
9899
child.setParent(parent);
99100
Message<Employee> message = MessageBuilder.withPayload(employee).build();
100-
directInput.send(message);
101+
assertThatExceptionOfType(MessageTransformationException.class)
102+
.isThrownBy(() -> directInput.send(message))
103+
.withRootCauseInstanceOf(StackOverflowError.class);
101104
}
102105

103106
@Test
@@ -124,9 +127,9 @@ public Employee buildEmployee() {
124127
companyAddress.setStreet("1123 Main");
125128
companyAddress.setZip("12345");
126129

127-
Map<String, Integer[]> coordinates = new HashMap<String, Integer[]>();
128-
coordinates.put("latitude", new Integer[] { 1, 5, 13 });
129-
coordinates.put("longitude", new Integer[] { 156 });
130+
Map<String, Integer[]> coordinates = new HashMap<>();
131+
coordinates.put("latitude", new Integer[]{ 1, 5, 13 });
132+
coordinates.put("longitude", new Integer[]{ 156 });
130133
companyAddress.setCoordinates(coordinates);
131134

132135
Employee employee = new Employee();
@@ -144,31 +147,31 @@ public Employee buildEmployee() {
144147
Address personAddress = new Address();
145148
personAddress.setCity("Philly");
146149
personAddress.setStreet("123 Main");
147-
List<String> listTestData = new ArrayList<String>();
150+
List<String> listTestData = new ArrayList<>();
148151
listTestData.add("hello");
149152
listTestData.add("blah");
150-
Map<String, List<String>> mapWithListTestData = new HashMap<String, List<String>>();
153+
Map<String, List<String>> mapWithListTestData = new HashMap<>();
151154
mapWithListTestData.put("mapWithListTestData", listTestData);
152155
personAddress.setMapWithListData(mapWithListTestData);
153156
person.setAddress(personAddress);
154157

155-
Map<String, Object> remarksA = new HashMap<String, Object>();
156-
Map<String, Object> remarksB = new HashMap<String, Object>();
158+
Map<String, Object> remarksA = new HashMap<>();
159+
Map<String, Object> remarksB = new HashMap<>();
157160
remarksA.put("foo", "foo");
158161
remarksA.put("bar", "bar");
159162
remarksB.put("baz", "baz");
160-
List<Map<String, Object>> remarks = new ArrayList<Map<String, Object>>();
163+
List<Map<String, Object>> remarks = new ArrayList<>();
161164
remarks.add(remarksA);
162165
remarks.add(remarksB);
163166
person.setRemarks(remarks);
164167
employee.setPerson(person);
165168

166-
Map<String, Map<String, Object>> testMapData = new HashMap<String, Map<String, Object>>();
169+
Map<String, Map<String, Object>> testMapData = new HashMap<>();
167170

168-
Map<String, Object> internalMapA = new HashMap<String, Object>();
171+
Map<String, Object> internalMapA = new HashMap<>();
169172
internalMapA.put("foo", "foo");
170173
internalMapA.put("bar", "bar");
171-
Map<String, Object> internalMapB = new HashMap<String, Object>();
174+
Map<String, Object> internalMapB = new HashMap<>();
172175
internalMapB.put("baz", "baz");
173176

174177
testMapData.put("internalMapA", internalMapA);
@@ -230,6 +233,7 @@ public List<String> getDepartments() {
230233
public void setDepartments(List<String> departments) {
231234
this.departments = departments;
232235
}
236+
233237
}
234238

235239
public static class Person {
@@ -293,6 +297,7 @@ public Address getAddress() {
293297
public void setAddress(Address address) {
294298
this.address = address;
295299
}
300+
296301
}
297302

298303
public static class Address {
@@ -346,6 +351,7 @@ public Map<String, Integer[]> getCoordinates() {
346351
public void setCoordinates(Map<String, Integer[]> coordinates) {
347352
this.coordinates = coordinates;
348353
}
354+
349355
}
350356

351357
public static class Child {
@@ -359,6 +365,7 @@ public Person getParent() {
359365
public void setParent(Person parent) {
360366
this.parent = parent;
361367
}
368+
362369
}
363370

364371
}

0 commit comments

Comments
 (0)