Skip to content

Commit

Permalink
Disable ObjToMapTransformerParserTests.cycle test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
artembilan committed Sep 7, 2022
1 parent 2ecc33e commit 0e6b70c
Showing 1 changed file with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -17,14 +17,15 @@
package org.springframework.integration.config.xml;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -38,16 +39,15 @@
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

/**
* @author Oleg Zhurakousky
* @author Gunnar Hillert
* @author Mauro Franceschini
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
public class ObjectToMapTransformerParserTests {

@Autowired
Expand Down Expand Up @@ -89,15 +89,18 @@ public void testObjectToSpelMapTransformer() {
}
}

@Test(expected = MessageTransformationException.class)
@Disabled("StackOverflowError")
@Test
public void testObjectToSpelMapTransformerWithCycle() {
Employee employee = this.buildEmployee();
Child child = new Child();
Person parent = employee.getPerson();
parent.setChild(child);
child.setParent(parent);
Message<Employee> message = MessageBuilder.withPayload(employee).build();
directInput.send(message);
assertThatExceptionOfType(MessageTransformationException.class)
.isThrownBy(() -> directInput.send(message))
.withRootCauseInstanceOf(StackOverflowError.class);
}

@Test
Expand All @@ -124,9 +127,9 @@ public Employee buildEmployee() {
companyAddress.setStreet("1123 Main");
companyAddress.setZip("12345");

Map<String, Integer[]> coordinates = new HashMap<String, Integer[]>();
coordinates.put("latitude", new Integer[] { 1, 5, 13 });
coordinates.put("longitude", new Integer[] { 156 });
Map<String, Integer[]> coordinates = new HashMap<>();
coordinates.put("latitude", new Integer[]{ 1, 5, 13 });
coordinates.put("longitude", new Integer[]{ 156 });
companyAddress.setCoordinates(coordinates);

Employee employee = new Employee();
Expand All @@ -144,31 +147,31 @@ public Employee buildEmployee() {
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);
Expand Down Expand Up @@ -230,6 +233,7 @@ public List<String> getDepartments() {
public void setDepartments(List<String> departments) {
this.departments = departments;
}

}

public static class Person {
Expand Down Expand Up @@ -293,6 +297,7 @@ public Address getAddress() {
public void setAddress(Address address) {
this.address = address;
}

}

public static class Address {
Expand Down Expand Up @@ -346,6 +351,7 @@ public Map<String, Integer[]> getCoordinates() {
public void setCoordinates(Map<String, Integer[]> coordinates) {
this.coordinates = coordinates;
}

}

public static class Child {
Expand All @@ -359,6 +365,7 @@ public Person getParent() {
public void setParent(Person parent) {
this.parent = parent;
}

}

}

0 comments on commit 0e6b70c

Please sign in to comment.