Testing api with Karate: mocks and queue implementation: Error TestRunner.testParallel:15 Multi threaded access requested by thread Thread[pool-1-thread-1,3,main] but is not allowed for language(s) js. is produced when try to consume a queue with multiple messages. Flow: Call a messageMock.feature :
Background:
* def QueueUtils = Java.type('mocks.QueueUtils')
* configure cors = true
* configure responseHeaders = { 'Content-Type': 'application/json' }
Scenario: pathMatches('/message') && methodIs('post')
* def response = read('../../responses/message/message.json')
* def responseStatus = 200
* QueueUtils.send(response.data, JSON.stringify(read('test.json')), 25)
* QueueUtils.send(response.data, JSON.stringify(read('test1.json')), 25)
* QueueUtils.send(response.data, JSON.stringify(read('test2.json')), 25)
From feature:
Scenario: Send message
* def QueueConsumer = Java.type('mocks.QueueConsumer')
* def port = karate.start('messageMock.feature').port
* url baseUrl + port
Given path '/message';
And request read('req.json')
When method post
Then status 200
* def queue = new QueueConsumer(response.data)
* def handler = function(msg){ karate.signal(msg) }
* queue.listen(karate.toJava(handler))
* listen 2000
* json response = listenResult
* print '### received:', listenResult
And match response == read('test.json')
* listen 2000
* json response1 = listenResult
* print '### received1:', listenResult
And match response1 == read('test1.json')
* listen 2000
* json response2 = listenResult
* print '### received2:', listenResult
And match response2 == read('test2.json')
The error message is given on line:
* json response = listenResult
is it a bug or incorrectly created test? What I am trying to test is a queue that have several enqueued messages before consumption. Is this possible to do with Karate?