use of com.ociweb.iot.hardware.impl.test.TestHardware in project FogLight-Examples by oci-pronghorn.
the class AppTest method testApp.
@Ignore
public void testApp() {
FogRuntime runtime = FogRuntime.test(new IoTApp());
ScriptedNonThreadScheduler scheduler = (ScriptedNonThreadScheduler) runtime.getScheduler();
scheduler.startup();
TestHardware hardware = (TestHardware) runtime.getHardware();
int iterations = 10;
while (--iterations >= 0) {
scheduler.run();
// test application here
}
}
use of com.ociweb.iot.hardware.impl.test.TestHardware in project FogLight-Examples by oci-pronghorn.
the class AppTest method testApp.
// this test reqires network connectivity of some kind
// HZ may end up hanging this test if it can not find what it is lookoing for.
@Ignore
public void testApp() {
FogRuntime runtime = FogRuntime.test(new IoTApp());
ScriptedNonThreadScheduler scheduler = (ScriptedNonThreadScheduler) runtime.getScheduler();
scheduler.startup();
TestHardware hardware = (TestHardware) runtime.getHardware();
int iterations = 10;
while (--iterations >= 0) {
scheduler.run();
// test application here
}
}
use of com.ociweb.iot.hardware.impl.test.TestHardware in project FogLight-Examples by oci-pronghorn.
the class AppTest method testApp.
@Test
public void testApp() {
FogRuntime runtime = FogRuntime.test(new IoTApp());
TestHardware hardware = (TestHardware) runtime.getHardware();
}
use of com.ociweb.iot.hardware.impl.test.TestHardware in project FogLight-Examples by oci-pronghorn.
the class AppTest method testApp.
@Test
public void testApp() {
FogRuntime runtime = FogRuntime.test(new IoTApp());
ScriptedNonThreadScheduler scheduler = (ScriptedNonThreadScheduler) runtime.getScheduler();
scheduler.startup();
TestHardware hardware = (TestHardware) runtime.getHardware();
hardware.portReader = new BasicTestPortReader();
int iterations = 4;
boolean isFirst = true;
int expected = 0;
long lastTime = 0;
while (iterations > 0) {
scheduler.run();
long time = hardware.getLastTime(IoTApp.LED_PORT);
if (0 != time) {
iterations--;
assertEquals(expected, 1 & hardware.read(IoTApp.LED_PORT));
expected = 1 & (expected + 1);
if (0 != lastTime) {
long durationMs = (time - lastTime);
if (!isFirst) {
assertTrue(Long.toString(durationMs), // first difference may be short because first transition is later due to startup.
durationMs >= 400);
} else {
isFirst = false;
}
assertTrue(durationMs <= 750);
}
lastTime = time;
hardware.clearCaputuredLastTimes();
hardware.clearCaputuredHighs();
}
}
}
use of com.ociweb.iot.hardware.impl.test.TestHardware in project FogLight-Examples by oci-pronghorn.
the class AppTest method testApp.
@Test
public void testApp() {
// 1 SEC
IoTApp.RED_MS = 1000;
// .8 SEC
IoTApp.GREEN_MS = 800;
// .2 SEC
IoTApp.YELLOW_MS = 200;
FogRuntime runtime = FogRuntime.test(new IoTApp());
ScriptedNonThreadScheduler scheduler = (ScriptedNonThreadScheduler) runtime.getScheduler();
TestHardware hardware = (TestHardware) runtime.getHardware();
scheduler.startup();
long next = System.currentTimeMillis() + 5_000;
while (System.currentTimeMillis() < next) {
scheduler.run();
Thread.yield();
}
scheduler.shutdown();
}
Aggregations