diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..c5f3f6b9
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "java.configuration.updateBuildConfiguration": "interactive"
+}
\ No newline at end of file
diff --git a/src/test/java/aeminium/runtime/tests/TestAtomicTaskDeadLock.java b/src/test/java/aeminium/runtime/tests/TestAtomicTaskDeadLock.java
new file mode 100644
index 00000000..43271dc7
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestAtomicTaskDeadLock.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import aeminium.runtime.DataGroup;
+import aeminium.runtime.ErrorHandler;
+import aeminium.runtime.Runtime;
+import aeminium.runtime.Task;
+import aeminium.runtime.implementations.Factory;
+
+public class TestAtomicTaskDeadLock extends BaseTest {
+
+ @Test(timeout=2000)
+ public void createAtomicTaskDeadLock() {
+ final AtomicBoolean deadlock = new AtomicBoolean(false);
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+
+ rt.addErrorHandler(new ErrorHandler() {
+
+ @Override
+ public void handleTaskException(Task task, Throwable t) {
+ }
+
+ @Override
+ public void handleTaskDuplicatedSchedule(Task task) {
+ }
+
+ @Override
+ public void handleLockingDeadlock() {
+ deadlock.set(true);
+ }
+
+ @Override
+ public void handleInternalError(Error err) {
+ }
+
+ @Override
+ public void handleDependencyCycle(Task task) {
+ }
+ });
+
+ DataGroup dg1 = rt.createDataGroup();
+ DataGroup dg2 = rt.createDataGroup();
+
+ Task t1 = createAtomicTask(rt, dg1, dg2);
+ rt.schedule(t1, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ Task t2 = createAtomicTask(rt, dg2, dg1);
+ rt.schedule(t2, Runtime.NO_PARENT, Runtime.NO_DEPS);
+
+ try {
+ Thread.sleep(1500);
+ } catch (InterruptedException e1) {}
+
+ if ( deadlock.get() ) {
+ Assert.fail("Could not find deadlock");
+ rt.shutdown();
+ }
+ }
+
+ private Task createAtomicTask(final Runtime rt, final DataGroup dg1, final DataGroup dg2) {
+ return rt.createAtomicTask((Runtime rt1, Task current) -> {
+ getLogger().log(Level.INFO, "Atomic Task for data group : {0}", dg1);
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ }
+ rt1.schedule(createAtomicTask(rt1, dg2), current, Runtime.NO_DEPS);
+ }, dg1, Runtime.NO_HINTS);
+ }
+
+ private Task createAtomicTask(final Runtime rt, final DataGroup dg) {
+ return rt.createAtomicTask((Runtime rt1, Task current) -> {
+ getLogger().log(Level.INFO, "Atomic Sub-Task for data group : {0}", dg);
+ }, dg, Runtime.NO_HINTS);
+
+ }
+}
diff --git a/src/test/java/aeminium/runtime/tests/TestAtomicTaskWaiting.java b/src/test/java/aeminium/runtime/tests/TestAtomicTaskWaiting.java
new file mode 100644
index 00000000..e897027f
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestAtomicTaskWaiting.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import java.util.Arrays;
+
+import org.junit.Test;
+
+import aeminium.runtime.Body;
+import aeminium.runtime.DataGroup;
+import aeminium.runtime.Runtime;
+import aeminium.runtime.Task;
+import aeminium.runtime.implementations.Factory;
+
+public class TestAtomicTaskWaiting extends BaseTest {
+
+ @Test
+ public void runAtomicTaskWaitingTest() {
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+
+ DataGroup dg = rt.createDataGroup();
+ Task t1 = createAtomicTask(rt, dg, 10);
+ rt.schedule(t1, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ Task t2 = createAtomicTask(rt, dg, 20);
+ rt.schedule(t2, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ Task t3 = createAtomicTask(rt, dg, 30);
+ rt.schedule(t3, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ Task t4 = createAtomicTask(rt, dg, 40);
+ rt.schedule(t4, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ Task t5 = createAtomicTask(rt, dg, 50);
+ rt.schedule(t5, Runtime.NO_PARENT, Runtime.NO_DEPS);
+
+ rt.shutdown();
+ }
+
+ public Task createAtomicTask(final Runtime rt, DataGroup group, final int delay) {
+ return rt.createAtomicTask(new Body() {
+ @Override
+ public void execute(Runtime rt, Task current) {
+ // let's create some sub tasks
+ Task t1 = rt.createNonBlockingTask(new Body() {
+ @Override
+ public void execute(Runtime rt, Task current) {
+ getLogger().info("Sub Task waiting for "+ (delay+1) + " ms");
+ }
+ @Override
+ public String toString() {
+ return ""+(delay+1);
+ }
+ }, Runtime.NO_HINTS);
+ rt.schedule(t1, current, Runtime.NO_DEPS);
+
+ Task t2 = rt.createNonBlockingTask(new Body() {
+ @Override
+ public void execute(Runtime rt, Task current) {
+ getLogger().info("Sub Task waiting for "+ (delay+2) + " ms");
+ }
+ @Override
+ public String toString() {
+ return ""+(delay+2);
+ }
+
+ }, Runtime.NO_HINTS);
+ rt.schedule(t2, current, Arrays.asList(t1));
+
+ getLogger().info("Task waiting for "+delay + " ms");
+
+ }
+
+ @Override
+ public String toString() {
+ return ""+delay;
+ }
+ } , group, Runtime.NO_HINTS);
+ }
+}
diff --git a/src/test/java/aeminium/runtime/tests/TestChildTasks.java b/src/test/java/aeminium/runtime/tests/TestChildTasks.java
new file mode 100644
index 00000000..f635607a
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestChildTasks.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import org.junit.Test;
+
+import aeminium.runtime.Body;
+import aeminium.runtime.Runtime;
+import aeminium.runtime.Task;
+import aeminium.runtime.implementations.Factory;
+
+public class TestChildTasks extends BaseTest {
+ @Test
+ public void childTasks() {
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+
+ Task t1 = createTask(rt, 2);
+ rt.schedule(t1, Runtime.NO_PARENT, Runtime.NO_DEPS);
+
+ rt.shutdown();
+ }
+
+ public Task createTask(final Runtime rt, final int level ) {
+ return rt.createNonBlockingTask((Runtime rt1, Task current) -> {
+ if (level > 0) {
+ rt1.schedule(createTask(rt1, level-1), current, Runtime.NO_DEPS);
+ }
+ }, Runtime.NO_HINTS);
+ }
+}
diff --git a/src/test/java/aeminium/runtime/tests/TestCycle.java b/src/test/java/aeminium/runtime/tests/TestCycle.java
new file mode 100644
index 00000000..421f24dd
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestCycle.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import aeminium.runtime.Body;
+import aeminium.runtime.ErrorHandler;
+import aeminium.runtime.Runtime;
+import aeminium.runtime.Task;
+import aeminium.runtime.implementations.Factory;
+
+public class TestCycle extends BaseTest {
+
+ @Test(timeout=2000)
+ public void testRoundDeadlock() {
+ final AtomicBoolean cycle = new AtomicBoolean();
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+
+ rt.addErrorHandler(new ErrorHandler() {
+
+ @Override
+ public void handleTaskException(Task task, Throwable t) {
+
+
+ }
+
+ @Override
+ public void handleTaskDuplicatedSchedule(Task task) {
+
+
+ }
+
+ @Override
+ public void handleLockingDeadlock() {
+
+
+ }
+
+ @Override
+ public void handleInternalError(Error err) {
+
+
+ }
+
+ @Override
+ public void handleDependencyCycle(Task task) {
+ cycle.set(true);
+
+ }
+ });
+
+ Task t1 = rt.createNonBlockingTask(createBody(1), Runtime.NO_HINTS);
+ Task t2 = rt.createNonBlockingTask(createBody(2), Runtime.NO_HINTS);
+ Task t3 = rt.createNonBlockingTask(createBody(3), Runtime.NO_HINTS);
+ Task t4 = rt.createNonBlockingTask(createBody(4), Runtime.NO_HINTS);
+
+ rt.schedule(t1, Runtime.NO_PARENT, Arrays.asList(t4));
+ rt.schedule(t2, Runtime.NO_PARENT, Arrays.asList(t1));
+ rt.schedule(t3, Runtime.NO_PARENT, Arrays.asList(t2));
+ rt.schedule(t4, Runtime.NO_PARENT, Arrays.asList(t3));
+
+ if ( !cycle.get() ) {
+ Assert.fail("Did not detect self cylcle.");
+ rt.shutdown();
+ }
+ }
+
+ public Body createBody(final int i) {
+ return new Body() {
+ @Override
+ public void execute(Runtime rt, Task parent) {
+ System.out.println("Task " + i);
+ }
+
+ public String toString() {
+ return "" + i;
+ }
+ };
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/aeminium/runtime/tests/TestDoubleScheduleTask.java b/src/test/java/aeminium/runtime/tests/TestDoubleScheduleTask.java
new file mode 100644
index 00000000..04d5d78f
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestDoubleScheduleTask.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.junit.Test;
+
+import aeminium.runtime.ErrorHandler;
+import aeminium.runtime.Runtime;
+import aeminium.runtime.Task;
+import aeminium.runtime.implementations.Factory;
+
+public class TestDoubleScheduleTask extends BaseTest {
+
+ @Test()
+ public void scheduleTaskTwice() {
+ final AtomicBoolean twice = new AtomicBoolean(false);
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+
+ rt.addErrorHandler(new ErrorHandler() {
+
+ @Override
+ public void handleTaskException(Task task, Throwable t) {
+
+ }
+
+ @Override
+ public void handleTaskDuplicatedSchedule(Task task) {
+ twice.set(true);
+
+ }
+
+ @Override
+ public void handleLockingDeadlock() {
+
+ }
+
+ @Override
+ public void handleInternalError(Error err) {
+
+ }
+
+ @Override
+ public void handleDependencyCycle(Task task) {
+
+ }
+ });
+
+ Task t = rt.createNonBlockingTask((Runtime rt1, Task current) -> {}, Runtime.NO_HINTS);
+
+ rt.schedule(t, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ rt.schedule(t, Runtime.NO_PARENT, Runtime.NO_DEPS);
+
+ if ( !twice.get() ) {
+ System.out.println("not twice");
+ fail("Did not detect doubly scheduled task");
+ }
+
+ rt.shutdown();
+ }
+}
diff --git a/src/test/java/aeminium/runtime/tests/TestInitShutdown.java b/src/test/java/aeminium/runtime/tests/TestInitShutdown.java
new file mode 100644
index 00000000..75074fc1
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestInitShutdown.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import org.junit.Test;
+
+import aeminium.runtime.Runtime;
+import aeminium.runtime.implementations.Factory;
+
+public class TestInitShutdown extends BaseTest {
+ @Test
+ public void initShutdownSingle() {
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+ rt.shutdown();
+ }
+
+ @Test
+ public void initShutdownMultiple() {
+ for (int i = 0; i < 100; i++ ) {
+ initShutdownSingle();
+ }
+ }
+}
diff --git a/src/test/java/aeminium/runtime/tests/TestLinearDependencies.java b/src/test/java/aeminium/runtime/tests/TestLinearDependencies.java
new file mode 100644
index 00000000..adc64460
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestLinearDependencies.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import java.util.Arrays;
+
+import org.junit.Test;
+
+import aeminium.runtime.Body;
+import aeminium.runtime.Runtime;
+import aeminium.runtime.Task;
+import aeminium.runtime.implementations.Factory;
+
+public class TestLinearDependencies extends BaseTest {
+ @Test
+ public void linearDependenciesTest() {
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+
+ Task t1 = rt.createNonBlockingTask(new Body() {
+ @Override
+ public void execute(Runtime rt, Task current) {
+ // wait some time to allow other task to be inserted
+ try {
+ Thread.sleep(300);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "t1";
+ }
+ }, Runtime.NO_HINTS);
+
+ Task t2 = rt.createNonBlockingTask(new Body() {
+ @Override
+ public void execute(Runtime rt, Task current) {
+ }
+ @Override
+ public String toString() {
+ return "t2";
+ }
+ }, Runtime.NO_HINTS);
+
+ rt.schedule(t1, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ rt.schedule(t2, Runtime.NO_PARENT, Arrays.asList(t1));
+
+ rt.shutdown();
+ }
+}
diff --git a/src/test/java/aeminium/runtime/tests/TestNestedAtomicTaskWaiting.java b/src/test/java/aeminium/runtime/tests/TestNestedAtomicTaskWaiting.java
new file mode 100644
index 00000000..80cc2403
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestNestedAtomicTaskWaiting.java
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import org.junit.Test;
+
+import aeminium.runtime.Body;
+import aeminium.runtime.DataGroup;
+import aeminium.runtime.Runtime;
+import aeminium.runtime.Task;
+import aeminium.runtime.implementations.Configuration;
+import aeminium.runtime.implementations.Factory;
+import aeminium.runtime.implementations.implicitworkstealing.ImplicitWorkStealingRuntime;
+
+public class TestNestedAtomicTaskWaiting extends BaseTest {
+
+ @Test
+ public void runAtomicTaskWaitingTest() {
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+
+ if ( Configuration.getProperty(ImplicitWorkStealingRuntime.class, "nestedAtomicTasks", false) ) {
+ System.out.println("nested");
+ DataGroup dg = rt.createDataGroup();
+ Task t1 = createAtomicTask(rt, dg, "TASK-1", 3);
+ rt.schedule(t1, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ Task t2 = createAtomicTask(rt, dg, "TASK-2", 5);
+ rt.schedule(t2, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ Task t3 = createAtomicTask(rt, dg, "TASK-3", 2);
+ rt.schedule(t3, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ Task t4 = createAtomicTask(rt, dg, "TASK-4", 4);
+ rt.schedule(t4, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ Task t5 = createAtomicTask(rt, dg, "TASK-5", 2);
+ rt.schedule(t5, Runtime.NO_PARENT, Runtime.NO_DEPS);
+ }
+ rt.shutdown();
+ }
+
+ public Task createAtomicTask(final Runtime rt, final DataGroup group, final String prefix, final int level) {
+ final int delay = 20*(level+1);
+ return rt.createAtomicTask(new Body() {
+ @Override
+ public void execute(Runtime rt, Task current) {
+ if ( 0 < level ) {
+ // let's create some sub tasks
+ Task t1 = createAtomicTask(rt, group, prefix+".1", level-1);
+ rt.schedule(t1, current, Runtime.NO_DEPS);
+
+ Task t2 = createAtomicTask(rt, group, prefix+".2", level-1);
+ rt.schedule(t2, current, Runtime.NO_DEPS);
+ }
+ getLogger().info(prefix + " waiting for " + delay + " ms");
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Override
+ public String toString() {
+ return ""+delay;
+ }
+ } , group, Runtime.NO_HINTS);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/aeminium/runtime/tests/TestObjectCreation.java b/src/test/java/aeminium/runtime/tests/TestObjectCreation.java
new file mode 100644
index 00000000..f351b469
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestObjectCreation.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import org.junit.Test;
+
+import aeminium.runtime.DataGroup;
+import aeminium.runtime.Runtime;
+import aeminium.runtime.implementations.Factory;
+
+public class TestObjectCreation extends BaseTest {
+ @Test
+ public void createDataGroup() {
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+
+ @SuppressWarnings("unused")
+ DataGroup dg = rt.createDataGroup();
+ // to calm findbugs
+ dg = null;
+
+ rt.shutdown();
+ }
+}
diff --git a/src/test/java/aeminium/runtime/tests/TestSelfCycle.java b/src/test/java/aeminium/runtime/tests/TestSelfCycle.java
new file mode 100644
index 00000000..ac59cc3e
--- /dev/null
+++ b/src/test/java/aeminium/runtime/tests/TestSelfCycle.java
@@ -0,0 +1,97 @@
+/**
+ * Copyright (c) 2010-11 The AEminium Project (see AUTHORS file)
+ *
+ * This file is part of Plaid Programming Language.
+ *
+ * Plaid Programming Language is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plaid Programming Language is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Plaid Programming Language. If not, see .
+ */
+
+package aeminium.runtime.tests;
+
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import aeminium.runtime.Body;
+import aeminium.runtime.ErrorHandler;
+import aeminium.runtime.Runtime;
+import aeminium.runtime.Task;
+import aeminium.runtime.implementations.Factory;
+
+public class TestSelfCycle extends BaseTest {
+ @Test(timeout=2000)
+ public void testSelfDeadlock() {
+ final AtomicBoolean cycle = new AtomicBoolean(false);
+ Runtime rt = Factory.getRuntime();
+ rt.init();
+
+ rt.addErrorHandler(new ErrorHandler() {
+
+ @Override
+ public void handleTaskException(Task task, Throwable t) {
+
+
+ }
+
+ @Override
+ public void handleTaskDuplicatedSchedule(Task task) {
+
+
+ }
+
+ @Override
+ public void handleLockingDeadlock() {
+
+
+ }
+
+ @Override
+ public void handleInternalError(Error err) {
+
+
+ }
+
+ @Override
+ public void handleDependencyCycle(Task task) {
+ cycle.set(true);
+
+ }
+ });
+
+ Task t1 = rt.createNonBlockingTask(createBody(1), Runtime.NO_HINTS);
+ rt.schedule(t1, Runtime.NO_PARENT, Arrays.asList(t1));
+
+ if ( !cycle.get() ) {
+ Assert.fail("Did not detect self cylcle.");
+ rt.shutdown();
+ }
+
+ }
+
+ public Body createBody(final int i) {
+ return new Body() {
+ @Override
+ public void execute(Runtime rt, Task parent) {
+ System.out.println("Task " + i);
+ }
+
+ @Override
+ public String toString() {
+ return "" + i;
+ }
+ };
+ }
+}