При использовании Citrus 2.8.0 для макетирования нескольких компонентов Camel MLLP я случайно получаю эту ConcurrentModificationException
ошибку:
10:59:20,322 DEBUG pServerConsumer.6661| validateConsumer(Socket[addr=/127.0.0.1,port=60907,localport=6661]) - submitting client for validation
10:59:20,322 DEBUG erValidationRunnable| Checking /127.0.0.1:60907 => /127.0.0.1:6661 for data
10:59:20,323 INFO pServerConsumer.6661| startConsumer(Socket[addr=/127.0.0.1,port=60907,localport=6661]) - starting consumer
10:59:20,323 DEBUG cketConsumerRunnable| Starting TcpSocketConsumerRunnable for /127.0.0.1:60907 => /127.0.0.1:6661
10:59:20,323 DEBUG pServerConsumer.6661| processMessage(hl7MessageBytes[1180], Socket[addr=/127.0.0.1,port=60907,localport=6661]) - populating the exchange with received payload
10:59:20,323 DEBUG pServerConsumer.6661| Populating the HL7 message headers
10:59:20,324 DEBUG pServerConsumer.6661| processMessage(hl7MessageBytes[1180], Socket[addr=/127.0.0.1,port=60907,localport=6661]) - calling processor
10:59:20,324 INFO nt.CamelSyncConsumer| Received message from camel endpoint: 'mllp:localhost:6661?reuseAddress=true'
10:59:20,324 DEBUG pServerConsumer.6661| sendAcknowledgement(originalHl7MessageBytes[1180], Exchange[ID-GTLCSIE24-1583920724960-4-3], Socket[addr=/127.0.0.1,port=60907,localport=6661]) - Sending Acknowledgement: MSH|^~\&|MIRTH||OPALE|400|20200311105920324+0100||ACK^A04^ADT_A01|27755867A|P|2.5<0x0D CR>MSA|AA|27755867<0x0D CR>
10:59:20,324 DEBUG cketConsumerRunnable| Checking for data ....
10:59:20,324 INFO port.LoggingReporter|
10:59:20,325 ERROR port.LoggingReporter| TEST FAILED MLLP endpoints should receive some data <com.gtlcsie.mirth.tests.citrus> Nested exception is:
java.util.ConcurrentModificationException
at java.base/java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1208)
at java.base/java.util.TreeMap$EntryIterator.next(TreeMap.java:1244)
at java.base/java.util.TreeMap$EntryIterator.next(TreeMap.java:1239)
at java.base/java.util.HashMap.putMapEntries(HashMap.java:507)
at java.base/java.util.HashMap.putAll(HashMap.java:780)
at com.consol.citrus.message.DefaultMessage.<init>(DefaultMessage.java:82)
at com.consol.citrus.camel.message.CamelMessageConverter.convertInbound(CamelMessageConverter.java:65)
at com.consol.citrus.camel.endpoint.CamelSyncConsumer.receive(CamelSyncConsumer.java:75)
at com.consol.citrus.actions.ReceiveMessageAction.receive(ReceiveMessageAction.java:141)
at com.consol.citrus.actions.ReceiveMessageAction.doExecute(ReceiveMessageAction.java:120)
at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
at com.consol.citrus.dsl.actions.DelegatingTestAction.doExecute(DelegatingTestAction.java:54)
at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
at com.consol.citrus.TestCase.executeAction(TestCase.java:220)
at com.consol.citrus.TestCase.doExecute(TestCase.java:152)
at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
at com.consol.citrus.Citrus.run(Citrus.java:403)
at com.consol.citrus.testng.AbstractTestNGCitrusTest.invokeTestMethod(AbstractTestNGCitrusTest.java:131)
at com.consol.citrus.dsl.testng.TestNGCitrusTest.invokeTestMethod(TestNGCitrusTest.java:121)
at com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner.invokeTestMethod(TestNGCitrusTestDesigner.java:73)
at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:110)
at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:56)
at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:221)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:657)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)
10:59:20,325 INFO port.LoggingReporter| ------------------------------------------------------------------------
10:59:20,325 INFO port.LoggingReporter|
10:59:20,325 DEBUG nal.MllpSocketBuffer| Resetting socket Socket[addr=/127.0.0.1,port=60907,localport=6661]
10:59:20,325 DEBUG cketConsumerRunnable| Ignoring exception encountered checking for data
org.apache.camel.component.mllp.MllpSocketException: readSocketInputStream(socketInputStream, Socket[addr=/127.0.0.1,port=60907,localport=6661]) - END_OF_STREAM returned from SocketInputStream.read(byte[2048], 0, 2048)
at org.apache.camel.component.mllp.internal.MllpSocketBuffer.readSocketInputStream(MllpSocketBuffer.java:622)
at org.apache.camel.component.mllp.internal.MllpSocketBuffer.readFrom(MllpSocketBuffer.java:187)
at org.apache.camel.component.mllp.internal.MllpSocketBuffer.readFrom(MllpSocketBuffer.java:174)
at org.apache.camel.component.mllp.internal.TcpSocketConsumerRunnable.run(TcpSocketConsumerRunnable.java:166)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:835)
10:59:20,326 DEBUG cketConsumerRunnable| TcpSocketConsumerRunnable for /127.0.0.1:60907 => /127.0.0.1:6661 completed
Вот мой тест:
@Test(enabled = true, groups = {"Unit Test"})
public class OpaleADT_TestIT extends TestNGCitrusTestDesigner {
// Data used by the test below, each new object does a new test iteration
@DataProvider(name = "dataProvider")
public Object[][] dataProvider() {
return new Object[][] {
new Object[] { Arrays.asList(0, 0, 0, 1, 0, 1), new File("target/test-classes/messages/input/ADT_A02.hl7") },
new Object[] { Arrays.asList(0, 0, 0, 1, 0, 0), new File("target/test-classes/messages/input/ADT_A03.hl7") },
new Object[] { Arrays.asList(0, 0, 0, 1, 1, 1), new File("target/test-classes/messages/input/ADT_A04.hl7") },
new Object[] { Arrays.asList(0, 0, 0, 1, 1, 1), new File("target/test-classes/messages/input/ADT_A11.hl7") },
new Object[] { Arrays.asList(0, 0, 0, 1, 0, 1), new File("target/test-classes/messages/input/ADT_A13.hl7") },
new Object[] { Arrays.asList(0, 0, 0, 1, 1, 1), new File("target/test-classes/messages/input/ADT_A31.hl7") },
};
}
@Test(enabled = true, dataProvider = "dataProvider")
@CitrusTest(name = "MLLP endpoints should receive some data")
@CitrusParameters( { "list", "file" } )
public void mllpEndpointsShouldReceiveOrNotSomeData(List<Integer> list, File file) throws IOException {
// List of Mock
String[] mockNames = {"mllp7003", "mllp12800", "mllp2575", "mllp6661", "mllp2577", "mllp2250"};
// Input file. Input file is given to the channel
String inputFile = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
// Send input file to location in endpoint so it can be eaten by the channel
send("inputFileEndpoint")
.messageType(MessageType.PLAINTEXT)
.payload(inputFile);
for (int i = 0; i < list.size(); i++) {
// (If 0, no message should be received, else, the mock should receive a message n times)
if (list.get(i) > 0)
for (int n = 0; n < list.get(i); n++) {
receive(mockNames[i]);
}
else
receiveTimeout(mockNames[i]);
}
}
}
И все компоненты даются так:
<camelContext id="mllpContext7003" xmlns="http://camel.apache.org/schema/spring"/>
<citrus-camel:sync-endpoint id="mllp7003"
camel-context="mllpContext7003"
endpoint-uri="mllp:localhost:7003?reuseAddress=true"
timeout="300000"/>
Если я запускаю тест для своих объектов в моем поставщике данных один за другим, он работает. Но если попытаться запустить мой поставщик данных один раз, я получаю эту ошибку случайным образом (ошибка никогда не бывает той же проверкой). Я также пытаюсь изменить значение Threshold на INFO в log4j.xml
, но все равно получаю ошибку. Есть идеи?