package pl.edu.mimuw.cloudatlas.agent; import org.junit.Test; import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage; import pl.edu.mimuw.cloudatlas.agent.modules.Module; import pl.edu.mimuw.cloudatlas.agent.modules.TimerScheduler; import java.util.ArrayList; import java.util.HashMap; import static org.junit.Assert.assertEquals; public class SchedulerTest { public HashMap initializeModule() { HashMap modules = new HashMap(); modules.put(AgentMessage.AgentModule.TIMER_SCHEDULER, new TimerScheduler(AgentMessage.AgentModule.RMI)); return modules; } @Test void scheduleTask() { } @Test void scheduleTwoTasks() { HashMap modules = ini(); HashMap executors = Agent.initializeExecutors(modules); ArrayList executorThreads = Agent.initializeExecutorThreads(executors); EventBus eventBus = new EventBus(executors); Thread eventBusThread = new Thread(eventBus); eventBusThread.start(); eventBus.addMessage(new AgentMessage( "0", AgentMessage.AgentModule.RMI, System.currentTimeMillis() / 1000L)); Thread.sleep(1000); eventBusThread.interrupt(); Agent.closeExecutors(executorThreads); assertEquals(1, ((EventBusTest.MessageCounterModule) modules.get(AgentMessage.AgentModule.RMI)).counter); } }