Skip to content

Commit

Permalink
Corrections for running at Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rgudwin committed Jul 7, 2023
1 parent 8a5ef50 commit 06ab2da
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ configurations {
dependencies {
configurations.implementation.extendsFrom(configurations.extraLibs)

api 'com.google.code.gson:gson:2.8.9'
api 'com.google.code.gson:gson:2.10.1'
api 'net.openhft:compiler:2.3.0' // Used by representation/owrl/CodeBuilder.java
api group: 'org.json', name: 'json', version: '20230227'
api group: 'org.opt4j', name: 'opt4j-core', version: '3.1' // Used in GLAS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ public void pintStatusTest(){
System.setOut(new PrintStream(outputStreamCaptor));

memoryBuffer.printStatus();
String s = outputStreamCaptor.toString().trim().replaceAll("\r\n", "\n");

assertTrue(outputStreamCaptor.toString().trim().contains(expectedMessage));
assertTrue(outputStreamCaptor.toString().replaceAll("\r\n", "\n").trim().contains(expectedMessage));
}

}
30 changes: 23 additions & 7 deletions src/test/java/br/unicamp/cst/core/profiler/TestMemoryObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import br.unicamp.cst.core.entities.MemoryObject;
import br.unicamp.cst.core.entities.Mind;
import br.unicamp.cst.core.exceptions.CodeletActivationBoundsException;
import br.unicamp.cst.support.TimeStamp;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;

class CodeletToTest extends Codelet {
Expand Down Expand Up @@ -367,18 +367,26 @@ public void proc() {
//setI in Memory Container and verify if Codelet was notified
long ts = output.getTimestamp();
input.setI(0);
while(ts == output.getTimestamp());
long startwait = System.currentTimeMillis();
while(ts == output.getTimestamp()) {
if (System.currentTimeMillis() - startwait > 2000) {
System.out.println("Restarting timer due to inactivity");
c.start();
}
if (System.currentTimeMillis() - startwait > 5000) fail("Some problem have occurred 3 !");
}
int nout = (int) output.getI();
System.out.println("Result: "+output.getI());
assertEquals(nout,1);
c.setPublishSubscribe(false);
ts = output.getTimestamp();
long startwait = System.currentTimeMillis();
startwait = System.currentTimeMillis();
while(ts == output.getTimestamp()) {
if (System.currentTimeMillis() - startwait > 2000) {
System.out.println("Restarting timer due to inactivity");
c.start();
m.start();
}
if (System.currentTimeMillis() - startwait > 5000) fail("Some problem have occurred 4 !");
}
System.out.println("Result: "+output.getI()+" "+c.getActivation());
m.shutDown();
Expand Down Expand Up @@ -432,18 +440,26 @@ public void proc() {
//setI in Memory Container and verify if Codelet was notified
long ts = output.getTimestamp();
input.setI(0,0);
while(ts == output.getTimestamp());
while(ts == output.getTimestamp()) System.out.print(".");
long startwait = System.currentTimeMillis();
while(ts == output.getTimestamp()) {
if (System.currentTimeMillis() - startwait > 2000) {
System.out.println("I am waiting too long ... something wrong happened");
}
if (System.currentTimeMillis() - startwait > 5000) fail("Some problem have occurred 1 !");
}
int nout = (int) output.getI();
System.out.println("Result: "+output.getI()+" "+c.getActivation());
assertEquals(nout,1);
c.setPublishSubscribe(false);
ts = output.getTimestamp();
long startwait = System.currentTimeMillis();
startwait = System.currentTimeMillis();
while(ts == output.getTimestamp()) {
if (System.currentTimeMillis() - startwait > 2000) {
System.out.println("Restarting timer due to inactivity");
c.start();
m.start();
}
if (System.currentTimeMillis() - startwait > 5000) fail("Some problem have occurred 2 !");
}
System.out.println("Result: "+output.getI()+" "+c.getActivation());

Expand Down
31 changes: 20 additions & 11 deletions src/test/java/br/unicamp/cst/io/rest/TestREST.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ public void testRest1() {
tr.StartTimer();
System.out.println("Creating a server in port "+port);
RESTServer rs = new RESTServer(tr.m,port,true);
try {Thread.sleep(500);} catch (Exception e){};
processTest();
}

Expand All @@ -339,6 +340,7 @@ public void testRest2() {
tr.StartTimer();
System.out.println("Creating a server in port "+port);
RESTServer rs = new RESTServer(tr.m,port);
try {Thread.sleep(500);} catch (Exception e){};
processTest();
}

Expand All @@ -353,6 +355,7 @@ public void testRest3() {
tr.StartTimer();
System.out.println("Creating a server in port "+port);
RESTServer rs = new RESTServer(tr.m,port,true,"*");
try {Thread.sleep(500);} catch (Exception e){};
processTest();
}

Expand All @@ -367,6 +370,7 @@ public void testRest4() {
tr.StartTimer();
System.out.println("Creating a server in port "+port);
RESTServer rs = new RESTServer(tr.m,port,true);
try {Thread.sleep(500);} catch (Exception e){};
processTestWithoutGroups();
}

Expand All @@ -381,6 +385,7 @@ public void testRest5() {
tr.StartTimer();
System.out.println("Creating a server in port "+port);
RESTServer rs = new RESTServer(tr.m,port);
try {Thread.sleep(500);} catch (Exception e){};
processTestWithoutGroups();
}

Expand All @@ -395,6 +400,7 @@ public void testRest6() {
tr.StartTimer();
System.out.println("Creating a server in port "+port);
RESTServer rs = new RESTServer(tr.m,port,true,"*");
try {Thread.sleep(500);} catch (Exception e){};
processTestWithoutGroups();
}

Expand All @@ -409,6 +415,7 @@ public void testRest7() {
tr.StartTimer();
System.out.println("Creating a server in port "+port);
RESTServer rs = new RESTServer(tr.m,port,true,"*",500L);
try {Thread.sleep(500);} catch (Exception e){};
processTest();
}

Expand All @@ -423,6 +430,7 @@ public void testRest8() {
tr.StartTimer();
System.out.println("Creating a server in port "+port);
RESTServer rs = new RESTServer(tr.m,port,true,"*",500L);
try {Thread.sleep(500);} catch (Exception e){};
processTestWithoutGroups();
}

Expand All @@ -437,42 +445,43 @@ public void testRestRawMemory() {
tr.StartTimer();
System.out.println("Creating a server in port "+port);
RESTServer rs = new RESTServer(tr.m,port,true,"*",500L);
try {Thread.sleep(500);} catch (Exception e){};
String mes = sendGET();
System.out.println(mes);
System.out.println("Test 1: "+mes);
long m0 = tr.m.getRawMemory().getAllMemoryObjects().get(0).getId();
GET_URL = "http://localhost:"+port+"/rawmemory/"+m0;
mes = sendGET();
System.out.println(mes);
System.out.println("Test 2: "+mes);
GET_URL = "http://localhost:"+port+"/rawmemory/"+m0+"/I";
mes = sendGET();
System.out.println(mes);
System.out.println("Test 3: "+mes);
GET_URL = "http://localhost:"+port+"/rawmemory/"+m0+"/timestamp";
mes = sendGET();
System.out.println(mes);
System.out.println("Test 4: "+mes);
GET_URL = "http://localhost:"+port+"/rawmemory/"+m0+"/evaluation";
mes = sendGET();
System.out.println(mes);
System.out.println("Test 5: "+mes);
GET_URL = "http://localhost:"+port+"/rawmemory/"+m0+"/name";
mes = sendGET();
System.out.println(mes);
System.out.println("Test 6: "+mes);
GET_URL = "http://localhost:"+port+"/rawmemory/"+m0+"/id";
mes = sendGET();
System.out.println(mes);
System.out.println("Test 7: "+mes);
GET_URL = "http://localhost:"+port+"/rawmemory/7";
mes = sendGET();
System.out.println(mes);
System.out.println("Test 8: "+mes);
assertEquals(mes,"Not Found");
GET_URL = "http://localhost:"+port+"/rawmemory/whatever";
mes = sendGET();
System.out.println(mes);
System.out.println("Test 9: "+mes);
assertEquals(mes,"Not Found");
GET_URL = "http://localhost:"+port+"/rawmemory/"+m0+"/whatever";
mes = sendGET();
System.out.println(mes);
System.out.println("Test 10: "+mes);
assertEquals(mes,"Not Found");
GET_URL = "http://localhost:"+port+"/rawmemory/whatever/whatever";
mes = sendGET();
System.out.println(mes);
System.out.println("Test 11: "+mes);
assertEquals(mes,"Not Found");
//processTestWithoutGroups();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import br.unicamp.cst.core.profiler.TestComplexMemoryObjectInfo;
import br.unicamp.cst.support.TimeStamp;
import java.util.HashMap;
import java.util.Locale;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -85,6 +86,7 @@ public void testGet() {

@Test
public void testIdea() {
Locale.setDefault(Locale.US);
System.out.println("\n Starting the testIdea ...");
Idea ln = new Idea("a");
Idea ln2 = new Idea("b");
Expand Down Expand Up @@ -260,6 +262,7 @@ public void testIdea2() {

@Test
public void testIsMethods() {
Locale.setDefault(Locale.US);
Idea i = new Idea();
i.setName("test");
assertEquals(i.getName(),"test");
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/br/unicamp/cst/support/ToStringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* **********************************************************************************************/
package br.unicamp.cst.support;
import java.util.Date;
import java.util.Locale;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

Expand All @@ -21,6 +22,7 @@ public class ToStringTest {

@Test
public void testFrom() {
Locale.setDefault(Locale.US);
Object o = null;
String s = ToString.from(o);
assertEquals(s,"<NULL>");
Expand Down

0 comments on commit 06ab2da

Please sign in to comment.