X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2Ftree%2FAsynchronousTreeTestResultListener.java;fp=org.argeo.slc%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2Ftree%2FAsynchronousTreeTestResultListener.java;h=c22c1102972cc02be8edd9aa684a90fa783c1345;hb=7ec4252e8a8ec055b9310c3db0233e217b7e43c0;hp=0773e409ff3f9b08759f99c9c81e92d11fc9cc78;hpb=7f6f9bb0384b7fd9b708773d5aec8903cdfb467f;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/AsynchronousTreeTestResultListener.java b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/AsynchronousTreeTestResultListener.java index 0773e409f..c22c11029 100644 --- a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/AsynchronousTreeTestResultListener.java +++ b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/AsynchronousTreeTestResultListener.java @@ -19,10 +19,22 @@ public abstract class AsynchronousTreeTestResultListener implements private Vector partStructs = new Vector(); private Thread thread; + private Boolean synchronous = false; + + protected AsynchronousTreeTestResultListener(){ + this(false); + } + + protected AsynchronousTreeTestResultListener(Boolean synchronousByDefault){ + synchronous = synchronousByDefault; + } + /** Starts the underlying thread. */ public void init() { - thread = new Thread(this); - thread.start(); + if (!synchronous) { + thread = new Thread(this); + thread.start(); + } } /** Finish the remaining and destroy */ @@ -47,11 +59,16 @@ public abstract class AsynchronousTreeTestResultListener implements public final void resultPartAdded(TestResult testResult, TestResultPart testResultPart) { TreeTestResult result = (TreeTestResult) testResult; - synchronized (partStructs) { - partStructs.add(new PartStruct(result.getCurrentPath(), - (NumericTRId) result.getTestResultId(), testResultPart, - result)); - partStructs.notifyAll(); + PartStruct partStruct = new PartStruct(result.getCurrentPath(), + (NumericTRId) result.getTestResultId(), testResultPart, result); + + if (!synchronous) { + synchronized (partStructs) { + partStructs.add(partStruct); + partStructs.notifyAll(); + } + } else { + resultPartAdded(partStruct); } } @@ -109,4 +126,12 @@ public abstract class AsynchronousTreeTestResultListener implements } + public Boolean getSynchronous() { + return synchronous; + } + + public void setSynchronous(Boolean synchronous) { + this.synchronous = synchronous; + } + }