Disable ObjectToMapTransformerTests.cycle test
The `ObjectToMapTransformerTests.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 determine stack overflow and avoid a build error
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.transformer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
@@ -28,7 +29,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.expression.MapAccessor;
|
||||
import org.springframework.expression.Expression;
|
||||
@@ -55,7 +57,7 @@ public class ObjectToMapTransformerTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testObjectToSpelMapTransformer() throws IOException {
|
||||
public void testObjectToSpelMapTransformer() {
|
||||
Employee employee = this.buildEmployee();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.addPropertyAccessor(new MapAccessor());
|
||||
@@ -68,9 +70,9 @@ public class ObjectToMapTransformerTests {
|
||||
Map<String, Object> transformedMap = (Map<String, Object>) transformedMessage.getPayload();
|
||||
assertThat(transformedMap).isNotNull();
|
||||
|
||||
Object valueFromTheMap = null;
|
||||
Object valueFromExpression = null;
|
||||
Expression expression = null;
|
||||
Object valueFromTheMap;
|
||||
Object valueFromExpression;
|
||||
Expression expression;
|
||||
|
||||
expression = parser.parseExpression("departments[0]");
|
||||
valueFromTheMap = transformedMap.get("departments[0]");
|
||||
@@ -149,7 +151,8 @@ public class ObjectToMapTransformerTests {
|
||||
assertThat(valueFromExpression).isEqualTo(valueFromTheMap);
|
||||
}
|
||||
|
||||
@Test(expected = MessageTransformationException.class)
|
||||
@Disabled("StackOverflowError")
|
||||
@Test
|
||||
public void testObjectToSpelMapTransformerWithCycle() {
|
||||
Employee employee = this.buildEmployee();
|
||||
Child child = new Child();
|
||||
@@ -158,11 +161,13 @@ public class ObjectToMapTransformerTests {
|
||||
child.setParent(parent);
|
||||
ObjectToMapTransformer transformer = new ObjectToMapTransformer();
|
||||
Message<Employee> message = MessageBuilder.withPayload(employee).build();
|
||||
transformer.transform(message);
|
||||
assertThatExceptionOfType(MessageTransformationException.class)
|
||||
.isThrownBy(() -> transformer.transform(message))
|
||||
.withRootCauseInstanceOf(StackOverflowError.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJacksonJSR310Support_PassInstantField_ReturnsMapWithOnlyOneEntryForInstantField() throws Exception {
|
||||
public void testJacksonJSR310Support_PassInstantField_ReturnsMapWithOnlyOneEntryForInstantField() {
|
||||
Person person = new Person();
|
||||
person.deathDate = Instant.now();
|
||||
|
||||
@@ -172,12 +177,12 @@ public class ObjectToMapTransformerTests {
|
||||
Map<String, Object> transformedMap = new ObjectToMapTransformer().transformPayload(employee);
|
||||
|
||||
// If JSR310 support is enabled by calling findAndRegisterModules() on the Jackson mapper,
|
||||
// Instant field should not be broken. Thus the count should exactly be 1 here.
|
||||
// Instant field should not be broken. Therefore, the count should exactly be 1 here.
|
||||
assertThat(transformedMap.values().stream().filter(Objects::nonNull).count()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomMapperSupport_DisableTimestampFlag_SerializesDateAsString() throws Exception {
|
||||
public void testCustomMapperSupport_DisableTimestampFlag_SerializesDateAsString() {
|
||||
Employee employee = buildEmployee();
|
||||
|
||||
ObjectMapper customMapper = new ObjectMapper();
|
||||
@@ -203,20 +208,20 @@ public class ObjectToMapTransformerTests {
|
||||
companyAddress.setStreet("1123 Main");
|
||||
companyAddress.setZip("12345");
|
||||
|
||||
Map<String, Long[]> coordinates = new HashMap<String, Long[]>();
|
||||
coordinates.put("latitude", new Long[] { (long) 1, (long) 5, (long) 13 });
|
||||
coordinates.put("longitude", new Long[] { (long) 156 });
|
||||
Map<String, Long[]> coordinates = new HashMap<>();
|
||||
coordinates.put("latitude", new Long[]{ (long) 1, (long) 5, (long) 13 });
|
||||
coordinates.put("longitude", new Long[]{ (long) 156 });
|
||||
companyAddress.setCoordinates(coordinates);
|
||||
|
||||
List<Date> datesA = new ArrayList<Date>();
|
||||
List<Date> datesA = new ArrayList<>();
|
||||
datesA.add(new Date(System.currentTimeMillis() + 10000));
|
||||
datesA.add(new Date(System.currentTimeMillis() + 20000));
|
||||
|
||||
List<Date> datesB = new ArrayList<Date>();
|
||||
List<Date> datesB = new ArrayList<>();
|
||||
datesB.add(new Date(System.currentTimeMillis() + 30000));
|
||||
datesB.add(new Date(System.currentTimeMillis() + 40000));
|
||||
|
||||
List<List<Date>> listOfDates = new ArrayList<List<Date>>();
|
||||
List<List<Date>> listOfDates = new ArrayList<>();
|
||||
listOfDates.add(datesA);
|
||||
listOfDates.add(datesB);
|
||||
|
||||
@@ -238,31 +243,31 @@ public class ObjectToMapTransformerTests {
|
||||
Address personAddress = new Address();
|
||||
personAddress.setCity("Philly");
|
||||
personAddress.setStreet("123 Main");
|
||||
List<String> listTestData = new ArrayList<String>();
|
||||
List<String> listTestData = new ArrayList<>();
|
||||
listTestData.add("hello");
|
||||
listTestData.add("blah");
|
||||
Map<String, List<String>> mapWithListTestData = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> mapWithListTestData = new HashMap<>();
|
||||
mapWithListTestData.put("mapWithListTestData", listTestData);
|
||||
personAddress.setMapWithListData(mapWithListTestData);
|
||||
person.setAddress(personAddress);
|
||||
|
||||
Map<String, Object> remarksA = new HashMap<String, Object>();
|
||||
Map<String, Object> remarksB = new HashMap<String, Object>();
|
||||
Map<String, Object> remarksA = new HashMap<>();
|
||||
Map<String, Object> remarksB = new HashMap<>();
|
||||
remarksA.put("foo", "foo");
|
||||
remarksA.put("bar", "bar");
|
||||
remarksB.put("baz", "baz");
|
||||
List<Map<String, Object>> remarks = new ArrayList<Map<String, Object>>();
|
||||
List<Map<String, Object>> remarks = new ArrayList<>();
|
||||
remarks.add(remarksA);
|
||||
remarks.add(remarksB);
|
||||
person.setRemarks(remarks);
|
||||
employee.setPerson(person);
|
||||
|
||||
Map<String, Map<String, Object>> testMapData = new HashMap<String, Map<String, Object>>();
|
||||
Map<String, Map<String, Object>> testMapData = new HashMap<>();
|
||||
|
||||
Map<String, Object> internalMapA = new HashMap<String, Object>();
|
||||
Map<String, Object> internalMapA = new HashMap<>();
|
||||
internalMapA.put("foo", "foo");
|
||||
internalMapA.put("bar", "bar");
|
||||
Map<String, Object> internalMapB = new HashMap<String, Object>();
|
||||
Map<String, Object> internalMapB = new HashMap<>();
|
||||
internalMapB.put("baz", "baz");
|
||||
|
||||
testMapData.put("internalMapA", internalMapA);
|
||||
|
||||
Reference in New Issue
Block a user