Skip to content

Commit

Permalink
Fix second async test, add a reporting for test status.
Browse files Browse the repository at this point in the history
  • Loading branch information
MDosky committed Oct 4, 2017
1 parent 3c2d589 commit 87a3590
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -210,6 +211,9 @@ public void testAsyncCall() throws Exception {
local.setAsyncVal(n);
local.asyncCheck(m);
local.setAsyncVal(m);
assertFalse(local.getAsyncReport());
TimeUnit.MILLISECONDS.sleep(500);
assertTrue(local.getAsyncReport());
}

@Test
Expand All @@ -222,5 +226,8 @@ public void testAsyncCallWithThis() throws Exception {
local.setAsyncVal(n);
local.asyncCheck(m);
local.setAsyncVal(m);
assertFalse(local.getAsyncReport());
TimeUnit.MILLISECONDS.sleep(500);
assertTrue(local.getAsyncReport());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import popjava.annotation.POPSyncSeq;
import popjava.annotation.POPConfig.Type;
import popjava.annotation.POPSyncConc;
import popjava.base.POPException;
import popjava.base.POPObject;

@POPClass
Expand Down Expand Up @@ -75,6 +76,7 @@ public void createReference(String url, boolean local){
}

private int asyncVal;
private boolean report;
@POPSyncConc
public void setAsyncVal(int n) {
asyncVal = n;
Expand All @@ -86,8 +88,15 @@ public int getAsyncVal() {
}

@POPAsyncConc
public void asyncCheck(int m) throws Exception {
public void asyncCheck(int m) throws POPException, Exception {
TimeUnit.MILLISECONDS.sleep(500);
org.junit.Assert.assertEquals(m, asyncVal);
report = m == asyncVal;
}

@POPSyncSeq
public boolean getAsyncReport() {
System.out.println(asyncVal);
return report;
}
}

0 comments on commit 87a3590

Please sign in to comment.