package com.ociweb.iot.examples;

import org.junit.Test;

import com.ociweb.iot.hardware.impl.test.TestHardware;
import com.ociweb.iot.maker.FogRuntime;
import com.ociweb.pronghorn.stage.scheduling.ScriptedNonThreadScheduler;

/**
 * Unit test for simple App.
 */
public class AppTest { 

	
	 @Test
	    public void testApp()
	    {
		 
		    IoTApp.RED_MS = 1000; //  1 SEC
		    IoTApp.GREEN_MS = 800; // .8 SEC
		    IoTApp.YELLOW_MS = 200; // .2 SEC 
				 
		 
	        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();
	    	
	    }
}

@@ -457,488 +457,88 @@
 %09%09%09 
-%0A
 %09%09 %0A%09
-  
+%09
     
-  FogRuntime runtime = FogRuntime.test(new IoTApp());%0A%0A%09%09%09ScriptedNonThreadScheduler scheduler = (ScriptedNonThreadScheduler)runtime.getScheduler();%0A%09    %0A%0A%09    %09TestHardware hardware = (TestHardware)runtime.getHardware();%0A%09    %0A%09    %09scheduler.startup();%0A%09    %09%0A%09    %09%0A%09    %09long next = System.currentTimeMillis()+5_000;%0A%09    %09%0A%09    %09while (System.currentTimeMillis() %3C next) %7B%0A%09    %09%09scheduler.run();%0A%09    %09%09Thread.yield();%0A%09    %09%7D%0A%09    %09%0A%09    %09scheduler.shutdown();
+FogRuntime.testConcurrentUntilShutdownRequested(new IoTApp(), 5_000);%0A
 %0A%09  

simplify test