Skip to content

Commit

Permalink
turn back on the async / listen tests #2009 #1883
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Aug 4, 2022
1 parent 0e877c9 commit 271f537
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 58 deletions.
34 changes: 0 additions & 34 deletions karate-core/src/main/java/com/intuit/karate/EventContext.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package com.intuit.karate.core;

import com.intuit.karate.EventContext;
import com.intuit.karate.FileUtils;
import com.intuit.karate.Json;
import com.intuit.karate.JsonUtils;
Expand Down Expand Up @@ -68,7 +67,7 @@
*
* @author pthomas3
*/
public class ScenarioBridge implements PerfContext, EventContext {
public class ScenarioBridge implements PerfContext {

private final ScenarioEngine ENGINE;

Expand Down Expand Up @@ -764,10 +763,11 @@ public void setXml(String name, String path, String xml) {
getEngine().set(name, path, new Variable(XmlUtils.toXmlDoc(xml)));
}

@Override
public void signal(Object o) {
Value v = Value.asValue(o);
getEngine().signal(JsValue.toJava(v));
synchronized (JsValue.LOCK) {
Value v = Value.asValue(o);
getEngine().signal(JsValue.toJava(v));
}
}

public Object sizeOf(Value v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,8 @@ public WebSocketClient webSocket(WebSocketOptions options) {
return webSocketClient;
}

public synchronized void signal(Object result) {
SIGNAL.complete(result);
public void signal(Object result) {
SIGNAL.complete(result);
}

public void listen(String exp) {
Expand All @@ -759,10 +759,11 @@ public void listen(String exp) {
Object listenResult = null;
try {
listenResult = SIGNAL.get(timeout, TimeUnit.MILLISECONDS);
Thread.sleep(100); // IMPORTANT, else graal js complains
} catch (Exception e) {
logger.error("listen timed out: {}", e + "");
}
synchronized (JS.context) {
}
synchronized (JsValue.LOCK) {
setHiddenVariable(LISTEN_RESULT, listenResult);
logger.debug("exit listen state with result: {}", listenResult);
SIGNAL = new CompletableFuture();
Expand Down
2 changes: 0 additions & 2 deletions karate-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@
<configuration>
<includes>
<include>demo/DemoTestParallel.java</include>
<!-- TODO broke after graal upgrade to 22
<include>mock/contract/*Test.java</include>
<include>mock/async/*Test.java</include>
-->
<include>mock/micro/*Runner.java</include>
<include>mock/proxy/*Runner.java</include>
<include>ssl/*Test.java</include>
Expand Down
14 changes: 1 addition & 13 deletions karate-demo/src/test/java/mock/contract/QueueConsumer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package mock.contract;

import com.intuit.karate.EventContext;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
Expand Down Expand Up @@ -46,18 +45,7 @@ public void listen(java.util.function.Consumer<String> handler) {
throw new RuntimeException(e);
}
});
}

public void bind(EventContext context) {
setMessageListener(message -> {
TextMessage tm = (TextMessage) message;
try {
context.signal(tm.getText());
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
}

public void setMessageListener(MessageListener ml) {
try {
Expand Down
1 change: 1 addition & 0 deletions karate-demo/src/test/java/mock/contract/QueueUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static Connection getConnection() {

static {
try {
logger.debug("waiting for activemq connection ...");
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false&waitForStart=10000");
connection = connectionFactory.createConnection();
connection.start();
Expand Down

0 comments on commit 271f537

Please sign in to comment.