You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by we...@apache.org on 2015/01/23 00:46:37 UTC

[04/51] [partial] incubator-reef git commit: [REEF-93] Move java sources to lang/java

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/examples/TestRetainedEvaluators.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/examples/TestRetainedEvaluators.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/examples/TestRetainedEvaluators.java
new file mode 100644
index 0000000..36397f5
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/examples/TestRetainedEvaluators.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.examples;
+
+import org.apache.reef.examples.library.Command;
+import org.apache.reef.examples.retained_eval.JobClient;
+import org.apache.reef.examples.retained_eval.Launch;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.Configurations;
+import org.apache.reef.tang.Tang;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tests.LocalTestEnvironment;
+import org.apache.reef.tests.TestEnvironment;
+import org.apache.reef.tests.TestEnvironmentFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * An integration test for retained evaluators: Run a simple `echo` on a couple of Evaluators a few times and make sure
+ * it comes back.
+ */
+public final class TestRetainedEvaluators {
+  /**
+   * Message to print in (remote) shells.
+   */
+  private static final String MESSAGE = "Hello REEF";
+
+  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
+
+  /**
+   * @return the Configuration for Launch for this test.
+   */
+  private static Configuration getLaunchConfiguration() {
+    return Tang.Factory.getTang().newConfigurationBuilder()
+        .bindNamedParameter(Launch.NumEval.class, "" + (LocalTestEnvironment.NUMBER_OF_THREADS - 1))
+        .bindNamedParameter(Launch.NumRuns.class, "2")
+        .bindNamedParameter(Command.class, "echo " + MESSAGE)
+        .build();
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    this.testEnvironment.setUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.testEnvironment.tearDown();
+  }
+
+  @Test
+  public void testRetainedEvaluators() throws InjectionException {
+    final Configuration clientConfiguration = Configurations.merge(
+        JobClient.getClientConfiguration(),        // The special job client.
+        getLaunchConfiguration(),                  // Specific configuration for this job
+        testEnvironment.getRuntimeConfiguration()  // The runtime we shall use
+    );
+
+    final String result = Launch.run(clientConfiguration);
+    Assert.assertNotNull(result);
+    Assert.assertTrue(result.contains(MESSAGE));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/examples/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/examples/package-info.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/examples/package-info.java
new file mode 100644
index 0000000..526a0af
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/examples/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Tests of the REEF Examples
+ */
+package org.apache.reef.tests.examples;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/DriverFailOnFailTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/DriverFailOnFailTest.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/DriverFailOnFailTest.java
new file mode 100644
index 0000000..060d04c
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/DriverFailOnFailTest.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.fail;
+
+import org.apache.reef.client.DriverConfiguration;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tests.TestDriverLauncher;
+import org.apache.reef.tests.TestEnvironment;
+import org.apache.reef.tests.TestEnvironmentFactory;
+import org.apache.reef.tests.TestUtils;
+import org.apache.reef.tests.fail.driver.DriverFailOnFail;
+import org.apache.reef.tests.library.exceptions.SimulatedDriverFailure;
+import org.apache.reef.util.EnvironmentUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Run FailDriver with different types of failures.
+ */
+public final class DriverFailOnFailTest {
+
+  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
+
+  @Before
+  public void setUp() throws Exception {
+    testEnvironment.setUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.testEnvironment.tearDown();
+  }
+
+  @Test
+  public void testDriverFailOnFail() throws BindException, InjectionException {
+
+    final Configuration runtimeConfiguration = this.testEnvironment.getRuntimeConfiguration();
+
+    final Configuration driverConfig = DriverConfiguration.CONF
+        .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(this.getClass()))
+        .set(DriverConfiguration.DRIVER_IDENTIFIER, "Fail2")
+        .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, DriverFailOnFail.AllocatedEvaluatorHandler.class)
+        .set(DriverConfiguration.ON_TASK_FAILED, DriverFailOnFail.FailedTaskHandler.class)
+        .set(DriverConfiguration.ON_DRIVER_STARTED, DriverFailOnFail.StartHandler.class)
+        .build();
+
+    TestUtils.assertLauncherFailure(
+        TestDriverLauncher.getLauncher(runtimeConfiguration).run(
+            driverConfig, this.testEnvironment.getTestTimeout()),
+        SimulatedDriverFailure.class);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailDriverDelayedMsgTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailDriverDelayedMsgTest.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailDriverDelayedMsgTest.java
new file mode 100644
index 0000000..125ceaf
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailDriverDelayedMsgTest.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.fail;
+
+import org.apache.reef.client.DriverConfiguration;
+import org.apache.reef.client.LauncherStatus;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tests.TestDriverLauncher;
+import org.apache.reef.tests.TestEnvironment;
+import org.apache.reef.tests.TestEnvironmentFactory;
+import org.apache.reef.tests.fail.driver.FailDriverDelayedMsg;
+import org.apache.reef.util.EnvironmentUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Run FailDriver with different types of failures.
+ */
+public class FailDriverDelayedMsgTest {
+
+  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
+
+  @Before
+  public void setUp() throws Exception {
+    testEnvironment.setUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.testEnvironment.tearDown();
+  }
+
+  @Test
+  public void testFailDriverTestMessage() throws BindException, InjectionException {
+
+    final Configuration runtimeConfiguration = this.testEnvironment.getRuntimeConfiguration();
+
+    final Configuration driverConfig = DriverConfiguration.CONF
+        .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(this.getClass()))
+        .set(DriverConfiguration.DRIVER_IDENTIFIER, "FailDriverDelayedMsg")
+        .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, FailDriverDelayedMsg.AllocatedEvaluatorHandler.class)
+        .set(DriverConfiguration.ON_CONTEXT_ACTIVE, FailDriverDelayedMsg.ActiveContextHandler.class)
+        .set(DriverConfiguration.ON_TASK_RUNNING, FailDriverDelayedMsg.RunningTaskHandler.class)
+        .set(DriverConfiguration.ON_TASK_MESSAGE, FailDriverDelayedMsg.TaskMessageHandler.class)
+        .set(DriverConfiguration.ON_DRIVER_STARTED, FailDriverDelayedMsg.StartHandler.class)
+        .build();
+
+    final LauncherStatus status = TestDriverLauncher.getLauncher(runtimeConfiguration)
+        .run(driverConfig, this.testEnvironment.getTestTimeout());
+
+    Assert.assertEquals(LauncherStatus.COMPLETED, status);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailDriverTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailDriverTest.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailDriverTest.java
new file mode 100644
index 0000000..1539e23
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailDriverTest.java
@@ -0,0 +1,133 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.fail;
+
+import org.apache.reef.client.LauncherStatus;
+import org.apache.reef.driver.context.ActiveContext;
+import org.apache.reef.driver.evaluator.AllocatedEvaluator;
+import org.apache.reef.driver.evaluator.CompletedEvaluator;
+import org.apache.reef.driver.task.CompletedTask;
+import org.apache.reef.driver.task.RunningTask;
+import org.apache.reef.driver.task.SuspendedTask;
+import org.apache.reef.driver.task.TaskMessage;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tests.TestEnvironment;
+import org.apache.reef.tests.TestEnvironmentFactory;
+import org.apache.reef.tests.TestUtils;
+import org.apache.reef.tests.fail.driver.FailClient;
+import org.apache.reef.tests.fail.driver.FailDriver;
+import org.apache.reef.tests.library.exceptions.SimulatedDriverFailure;
+import org.apache.reef.wake.time.event.Alarm;
+import org.apache.reef.wake.time.event.StartTime;
+import org.apache.reef.wake.time.event.StopTime;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Run FailDriver with different types of failures.
+ */
+public class FailDriverTest {
+
+  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
+
+  @Before
+  public void setUp() throws Exception {
+    testEnvironment.setUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.testEnvironment.tearDown();
+  }
+
+  private void failOn(final Class<?> clazz) throws BindException, InjectionException {
+    TestUtils.assertLauncherFailure(
+        FailClient.run(clazz,
+            this.testEnvironment.getRuntimeConfiguration(), this.testEnvironment.getTestTimeout()),
+        SimulatedDriverFailure.class);
+  }
+
+  @Test
+  public void testFailDriverConstructor() throws BindException, InjectionException {
+    failOn(FailDriver.class);
+  }
+
+  @Test
+  public void testFailDriverStart() throws BindException, InjectionException {
+    failOn(StartTime.class);
+  }
+
+  @Test
+  public void testFailDriverAllocatedEvaluator() throws BindException, InjectionException {
+    failOn(AllocatedEvaluator.class);
+  }
+
+  @Test
+  public void testFailDriverActiveContext() throws BindException, InjectionException {
+    failOn(ActiveContext.class);
+  }
+
+  @Test
+  public void testFailDriverRunningTask() throws BindException, InjectionException {
+    failOn(RunningTask.class);
+  }
+
+  @Test
+  public void testFailDriverTaskMessage() throws BindException, InjectionException {
+    failOn(TaskMessage.class);
+  }
+
+  @Test
+  public void testFailDriverSuspendedTask() throws BindException, InjectionException {
+    failOn(SuspendedTask.class);
+  }
+
+  @Test
+  public void testFailDriverCompletedTask() throws BindException, InjectionException {
+    failOn(CompletedTask.class);
+  }
+
+  @Test
+  public void testFailDriverCompletedEvaluator() throws BindException, InjectionException {
+    failOn(CompletedEvaluator.class);
+  }
+
+  @Test
+  public void testFailDriverAlarm() throws BindException, InjectionException {
+    failOn(Alarm.class);
+  }
+
+  @Test
+  public void testFailDriverStop() throws BindException, InjectionException {
+    failOn(StopTime.class);
+  }
+
+  @Test
+  public void testDriverCompleted() throws BindException, InjectionException {
+    final Configuration runtimeConfiguration = this.testEnvironment.getRuntimeConfiguration();
+    // FailDriverTest can be replaced with any other class never used in FailDriver
+    final LauncherStatus status = FailClient.run(
+        FailDriverTest.class, runtimeConfiguration, this.testEnvironment.getTestTimeout());
+    Assert.assertEquals(LauncherStatus.COMPLETED, status);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailTaskTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailTaskTest.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailTaskTest.java
new file mode 100644
index 0000000..41dd040
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailTaskTest.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.fail;
+
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.task.Task;
+import org.apache.reef.tests.TestEnvironment;
+import org.apache.reef.tests.TestEnvironmentFactory;
+import org.apache.reef.tests.TestUtils;
+import org.apache.reef.tests.fail.task.*;
+import org.apache.reef.tests.library.exceptions.SimulatedTaskFailure;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Run Driver with different types of failures in the Task.
+ */
+public final class FailTaskTest {
+
+  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
+
+  @Before
+  public void setUp() throws Exception {
+    testEnvironment.setUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.testEnvironment.tearDown();
+  }
+
+  private void failOn(
+      final Class<? extends Task> failTaskClass) throws BindException, InjectionException {
+    TestUtils.assertLauncherFailure(
+        Client.run(failTaskClass,
+            this.testEnvironment.getRuntimeConfiguration(),
+            this.testEnvironment.getTestTimeout()),
+        SimulatedTaskFailure.class);
+  }
+
+  @Test
+  public void testFailTask() throws BindException, InjectionException {
+    failOn(FailTask.class);
+  }
+
+  @Test
+  public void testFailTaskCall() throws BindException, InjectionException {
+    failOn(FailTaskCall.class);
+  }
+
+  @Test
+  public void testFailTaskMsg() throws BindException, InjectionException {
+    failOn(FailTaskMsg.class);
+  }
+
+  @Test
+  public void testFailTaskSuspend() throws BindException, InjectionException {
+    failOn(FailTaskSuspend.class);
+  }
+
+  @Test
+  public void testFailTaskStart() throws BindException, InjectionException {
+    failOn(FailTaskStart.class);
+  }
+
+  @Test
+  public void testFailTaskStop() throws BindException, InjectionException {
+    failOn(FailTaskStop.class);
+  }
+
+  @Test
+  public void testFailTaskClose() throws BindException, InjectionException {
+    failOn(FailTaskClose.class);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailTestSuite.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailTestSuite.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailTestSuite.java
new file mode 100644
index 0000000..eeddd9a
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailTestSuite.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.fail;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+//    FailTaskTest.class,
+    FailDriverTest.class,
+    FailDriverDelayedMsgTest.class,
+    DriverFailOnFailTest.class
+})
+public final class FailTestSuite {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTest.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTest.java
new file mode 100644
index 0000000..1eab054
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTest.java
@@ -0,0 +1,144 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.files;
+
+import org.apache.reef.client.DriverConfiguration;
+import org.apache.reef.client.DriverLauncher;
+import org.apache.reef.client.LauncherStatus;
+import org.apache.reef.io.TempFileCreator;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.Configurations;
+import org.apache.reef.tang.Tang;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tests.TestEnvironment;
+import org.apache.reef.tests.TestEnvironmentFactory;
+import org.apache.reef.util.EnvironmentUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Tests whether a set of files makes it to the Driver and from there to the Evaluator.
+ * <p/>
+ * The test is shallow: It only makes sure that files with the same (random) names exist. It doesn't check for file
+ * contents.
+ */
+public final class FileResourceTest {
+  private static final Logger LOG = Logger.getLogger(FileResourceTest.class.getName());
+  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
+  /**
+   * The number of files to generate.
+   */
+  private final int nFiles = 3;
+
+  /**
+   * Assembles the driver configuration using the DriverConfiguration class.
+   *
+   * @param theFiles
+   * @return
+   * @throws BindException
+   */
+  private static Configuration getDriverConfiguration(final Set<File> theFiles) throws BindException {
+    ConfigurationModule driverConfigurationModule = DriverConfiguration.CONF
+        .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(FileResourceTestDriver.class))
+        .set(DriverConfiguration.DRIVER_IDENTIFIER, "TEST_FileResourceTest")
+        .set(DriverConfiguration.ON_DRIVER_STARTED, FileResourceTestDriver.StartHandler.class)
+        .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, FileResourceTestDriver.EvaluatorAllocatedHandler.class);
+
+    for (final File f : theFiles) {
+      LOG.log(Level.FINEST, "Adding a file to the DriverConfiguration: " + f.getAbsolutePath());
+      driverConfigurationModule = driverConfigurationModule.set(DriverConfiguration.LOCAL_FILES, f.getAbsolutePath());
+    }
+    return driverConfigurationModule.build();
+  }
+
+  /**
+   * Assembles the configuration based on TestDriverConfiguration
+   *
+   * @param theFiles
+   * @return
+   * @throws BindException
+   * @throws IOException
+   */
+  private static Configuration getTestDriverConfiguration(final Set<File> theFiles) throws BindException, IOException {
+    ConfigurationModule testDriverConfigurationModule = FileResourceTestDriverConfiguration.CONF;
+    for (final File f : theFiles) {
+      LOG.log(Level.FINEST, "Adding a file to the TestDriverConfiguration: " + f.getName());
+      testDriverConfigurationModule = testDriverConfigurationModule.set(FileResourceTestDriverConfiguration.EXPECTED_FILE_NAME, f.getName());
+    }
+
+    final Configuration testDriverConfiguration = testDriverConfigurationModule.build();
+    return testDriverConfiguration;
+  }
+
+  /**
+   * Creates the given number of temp files.
+   *
+   * @param n
+   * @return
+   * @throws IOException
+   */
+  private Set<File> getTempFiles(final int n) throws IOException, InjectionException {
+    final TempFileCreator tempFileCreator = Tang.Factory.getTang()
+        .newInjector(testEnvironment.getRuntimeConfiguration())
+        .getInstance(TempFileCreator.class);
+    final Set<File> theFiles = new HashSet<>();
+    for (int i = 0; i < n; ++i) {
+      final File tempFile = tempFileCreator.createTempFile("REEF_TEST_", ".tmp");
+      tempFile.deleteOnExit();
+      theFiles.add(tempFile);
+    }
+    return theFiles;
+  }
+
+
+  @Before
+  public void setUp() throws Exception {
+    testEnvironment.setUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.testEnvironment.tearDown();
+  }
+
+  @Test
+  public void testDriverFiles() throws IOException, BindException, InjectionException {
+
+    final Set<File> theFiles = getTempFiles(this.nFiles);
+    final Configuration finalDriverConfiguration = Configurations.merge(
+        getDriverConfiguration(theFiles), getTestDriverConfiguration(theFiles));
+
+    final LauncherStatus status = DriverLauncher
+        .getLauncher(this.testEnvironment.getRuntimeConfiguration())
+        .run(finalDriverConfiguration, testEnvironment.getTestTimeout());
+
+    Assert.assertTrue("Job state after execution: " + status, status.isSuccess());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestDriver.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestDriver.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestDriver.java
new file mode 100644
index 0000000..ba88573
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestDriver.java
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.files;
+
+import org.apache.reef.driver.evaluator.AllocatedEvaluator;
+import org.apache.reef.driver.evaluator.EvaluatorRequest;
+import org.apache.reef.driver.evaluator.EvaluatorRequestor;
+import org.apache.reef.driver.task.TaskConfiguration;
+import org.apache.reef.runtime.common.files.REEFFileNames;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.Configurations;
+import org.apache.reef.tang.annotations.Parameter;
+import org.apache.reef.tang.annotations.Unit;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tests.library.exceptions.DriverSideFailure;
+import org.apache.reef.wake.EventHandler;
+import org.apache.reef.wake.time.event.StartTime;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+@Unit
+final class FileResourceTestDriver {
+
+  private static final Logger LOG = Logger.getLogger(FileResourceTestDriver.class.getName());
+
+  private final Set<String> fileNamesToExpect;
+  private final EvaluatorRequestor requestor;
+  private final REEFFileNames fileNames;
+  private final File localFolder;
+
+  @Inject
+  public FileResourceTestDriver(@Parameter(FileResourceTestDriverConfiguration.FileNamesToExpect.class) final Set<String> fileNamesToExpect,
+                                final EvaluatorRequestor requestor,
+                                final REEFFileNames fileNames) {
+    this.fileNamesToExpect = fileNamesToExpect;
+    this.requestor = requestor;
+    this.fileNames = fileNames;
+    this.localFolder = fileNames.getLocalFolder();
+  }
+
+  /**
+   * Check that all given files are accesible.
+   */
+  final class StartHandler implements EventHandler<StartTime> {
+    @Override
+    public void onNext(final StartTime startTime) {
+      LOG.log(Level.INFO, "StartTime: {0} Number of files in the set: {1}",
+          new Object[]{startTime, FileResourceTestDriver.this.fileNamesToExpect.size()});
+
+      // Check whether the files made it
+      for (final String fileName : FileResourceTestDriver.this.fileNamesToExpect) {
+        final File file = new File(localFolder, fileName);
+        LOG.log(Level.INFO, "Testing file: " + file.getAbsolutePath());
+        if (!file.exists()) {
+          throw new DriverSideFailure("Cannot find file: " + fileName);
+        } else if (!file.isFile()) {
+          throw new DriverSideFailure("Not a file: " + fileName);
+        } else if (!file.canRead()) {
+          throw new DriverSideFailure("Can't read: " + fileName);
+        }
+      }
+
+      // Ask for a single evaluator.
+      FileResourceTestDriver.this.requestor.submit(EvaluatorRequest.newBuilder()
+          .setNumber(1).setMemory(64).setNumberOfCores(1).build());
+    }
+  }
+
+  /**
+   * Copy files to the Evaluator and submit a Task that checks that they made it.
+   */
+  final class EvaluatorAllocatedHandler implements EventHandler<AllocatedEvaluator> {
+
+    @Override
+    public void onNext(final AllocatedEvaluator allocatedEvaluator) {
+      try {
+        // Add the files to the Evaluator.
+        for (final String fileName : FileResourceTestDriver.this.fileNamesToExpect) {
+          allocatedEvaluator.addFile(new File(localFolder, fileName));
+        }
+
+        // Filling out a TaskConfiguration
+        final Configuration taskConfiguration = TaskConfiguration.CONF
+            .set(TaskConfiguration.IDENTIFIER, "TestTask")
+            .set(TaskConfiguration.TASK, FileResourceTestTask.class)
+            .build();
+
+        // Adding the job-specific Configuration
+        ConfigurationModule testTaskConfigurationModule = FileResourceTestTaskConfiguration.CONF;
+        for (final String fileName : FileResourceTestDriver.this.fileNamesToExpect) {
+          testTaskConfigurationModule =
+              testTaskConfigurationModule.set(FileResourceTestTaskConfiguration.EXPECTED_FILE_NAME, fileName);
+        }
+
+        // Submit the context and the task config.
+        final Configuration finalTaskConfiguration =
+            Configurations.merge(taskConfiguration, testTaskConfigurationModule.build());
+
+        allocatedEvaluator.submitTask(finalTaskConfiguration);
+
+      } catch (final Exception e) {
+        // This fails the test.
+        throw new DriverSideFailure("Unable to submit context and task", e);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestDriverConfiguration.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestDriverConfiguration.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestDriverConfiguration.java
new file mode 100644
index 0000000..e198693
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestDriverConfiguration.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.files;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
+import org.apache.reef.tang.formats.RequiredParameter;
+
+import java.util.Set;
+
+public final class FileResourceTestDriverConfiguration extends ConfigurationModuleBuilder {
+
+  public static final RequiredParameter<String> EXPECTED_FILE_NAME = new RequiredParameter<>();
+  public static final ConfigurationModule CONF = new FileResourceTestDriverConfiguration()
+      .bindSetEntry(FileNamesToExpect.class, EXPECTED_FILE_NAME)
+      .build();
+
+  @NamedParameter(doc = "The names of the files to expect in the local filesystem.")
+  public static final class FileNamesToExpect implements Name<Set<String>> {
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestTask.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestTask.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestTask.java
new file mode 100644
index 0000000..a7a62a7
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestTask.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.files;
+
+import org.apache.reef.runtime.common.files.REEFFileNames;
+import org.apache.reef.tang.annotations.Parameter;
+import org.apache.reef.task.Task;
+import org.apache.reef.tests.library.exceptions.TaskSideFailure;
+import org.apache.reef.wake.time.Clock;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An Task that checks the presence of a set of files and throws TaskSideFailure if they cannot be found or read.
+ */
+final class FileResourceTestTask implements Task {
+  private final Logger LOG = Logger.getLogger(FileResourceTestTask.class.getName());
+  private final Set<String> expectedFileNames;
+  private final Clock clock;
+  private final File localFolder;
+
+  @Inject
+  FileResourceTestTask(@Parameter(FileResourceTestTaskConfiguration.FileNamesToExpect.class) final Set<String> expectedFileNames,
+                       final Clock clock,
+                       final REEFFileNames fileNames) {
+    this.expectedFileNames = expectedFileNames;
+    this.clock = clock;
+    this.localFolder = fileNames.getLocalFolder();
+  }
+
+  @Override
+  public byte[] call(byte[] memento) throws Exception {
+    for (final String fileName : expectedFileNames) {
+      final File file = new File(localFolder, fileName);
+      LOG.log(Level.INFO, "Testing file: " + file.getAbsolutePath());
+      if (!file.exists()) {
+        throw new TaskSideFailure("Cannot find file: " + fileName);
+      } else if (!file.isFile()) {
+        throw new TaskSideFailure("Not a file: " + fileName);
+      } else if (!file.canRead()) {
+        throw new TaskSideFailure("Can't read: " + fileName);
+      }
+    }
+
+    return new byte[0];  //To change body of implemented methods use File | Settings | File Templates.
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestTaskConfiguration.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestTaskConfiguration.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestTaskConfiguration.java
new file mode 100644
index 0000000..fd6b9e6
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/FileResourceTestTaskConfiguration.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.files;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
+import org.apache.reef.tang.formats.RequiredParameter;
+
+import java.util.Set;
+
+/**
+ * A ConfigurationModule for the TestTask.
+ */
+public final class FileResourceTestTaskConfiguration extends ConfigurationModuleBuilder {
+  /**
+   * the set of file names to expect present on the evaluator.
+   */
+  public static final RequiredParameter<String> EXPECTED_FILE_NAME = new RequiredParameter<>();
+  public static final ConfigurationModule CONF = new FileResourceTestTaskConfiguration()
+      .bindSetEntry(FileNamesToExpect.class, EXPECTED_FILE_NAME)
+      .build();
+
+  @NamedParameter(doc = "The names of the files to expect in the local filesystem.")
+  public static final class FileNamesToExpect implements Name<Set<String>> {
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/package-info.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/package-info.java
new file mode 100644
index 0000000..5e833fa
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/files/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Tests whether a set of files makes it to the Driver and from there to the Evaluator.
+ */
+package org.apache.reef.tests.files;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/driver/DriverMessagingTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/driver/DriverMessagingTest.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/driver/DriverMessagingTest.java
new file mode 100644
index 0000000..cf43a58
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/driver/DriverMessagingTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.messaging.driver;
+
+import org.apache.reef.client.LauncherStatus;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tests.TestEnvironment;
+import org.apache.reef.tests.TestEnvironmentFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public final class DriverMessagingTest {
+
+  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
+
+  @Before
+  public void setUp() throws Exception {
+    testEnvironment.setUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.testEnvironment.tearDown();
+  }
+
+  @Test
+  public void testDriverMessaging() throws BindException, InjectionException {
+    final LauncherStatus status = DriverMessaging.run(
+        this.testEnvironment.getRuntimeConfiguration(), this.testEnvironment.getTestTimeout());
+    Assert.assertTrue("Job state after execution: " + status, status.isSuccess());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/driver/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/driver/package-info.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/driver/package-info.java
new file mode 100644
index 0000000..b5016f5
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/driver/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Tests the messaging channel between client and driver.
+ */
+package org.apache.reef.tests.messaging.driver;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/task/TaskMessagingTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/task/TaskMessagingTest.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/task/TaskMessagingTest.java
new file mode 100644
index 0000000..4b656da
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/task/TaskMessagingTest.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.messaging.task;
+
+import org.apache.reef.client.DriverConfiguration;
+import org.apache.reef.client.DriverLauncher;
+import org.apache.reef.client.LauncherStatus;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tests.TestEnvironment;
+import org.apache.reef.tests.TestEnvironmentFactory;
+import org.apache.reef.tests.library.driver.OnDriverStartedAllocateOne;
+import org.apache.reef.util.EnvironmentUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test message exchange between the Task and the Driver.
+ */
+public final class TaskMessagingTest {
+
+  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
+
+  @Before
+  public void setUp() throws Exception {
+    testEnvironment.setUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.testEnvironment.tearDown();
+  }
+
+  @Test
+  public void testTaskMsg() throws BindException, InjectionException {
+
+    final Configuration runtimeConfiguration = this.testEnvironment.getRuntimeConfiguration();
+
+    final Configuration driverConfig = DriverConfiguration.CONF
+        .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(this.getClass()))
+        .set(DriverConfiguration.DRIVER_IDENTIFIER, "DriverTaskMsg")
+        .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, TaskMessagingDriver.EvaluatorAllocatedHandler.class)
+        .set(DriverConfiguration.ON_TASK_RUNNING, TaskMessagingDriver.TaskRunningHandler.class)
+        .set(DriverConfiguration.ON_TASK_MESSAGE, TaskMessagingDriver.TaskMessageHandler.class)
+        .set(DriverConfiguration.ON_DRIVER_STARTED, OnDriverStartedAllocateOne.class)
+        .build();
+
+    final LauncherStatus status = DriverLauncher.getLauncher(runtimeConfiguration)
+        .run(driverConfig, this.testEnvironment.getTestTimeout());
+
+    Assert.assertEquals(LauncherStatus.COMPLETED, status);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/task/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/task/package-info.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/task/package-info.java
new file mode 100644
index 0000000..c3b1c4b
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/messaging/task/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Tests the messaging channel between driver and task.
+ */
+package org.apache.reef.tests.messaging.task;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/ActiveContextHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/ActiveContextHandler.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/ActiveContextHandler.java
new file mode 100644
index 0000000..87b433f
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/ActiveContextHandler.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.multipleEventHandlerInstances;
+
+import org.apache.reef.driver.context.ActiveContext;
+import org.apache.reef.driver.task.TaskConfiguration;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tests.library.exceptions.DriverSideFailure;
+import org.apache.reef.wake.EventHandler;
+
+import javax.inject.Inject;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * The ActiveContext handler
+ */
+public final class ActiveContextHandler implements EventHandler<ActiveContext> {
+
+  private static final Logger LOG = Logger.getLogger(ActiveContextHandler.class.getName());
+
+  private static int countInstances = 0;
+
+  @Inject
+  public ActiveContextHandler() {
+    ++countInstances;
+    if (countInstances > 1) {
+      throw new DriverSideFailure("Expect ActiveContextHandler to be created only once");
+    }
+  }
+
+  @Override
+  public void onNext(ActiveContext activeContext) {
+    LOG.log(Level.FINEST, "ActiveContext received. Submitting empty task to it");
+    Configuration taskConfiguration;
+    try {
+      taskConfiguration = TaskConfiguration.CONF
+          .set(TaskConfiguration.IDENTIFIER, "EmptyREEFTask")
+          .set(TaskConfiguration.TASK, EmptyTask.class)
+          .build();
+    } catch (BindException e) {
+      throw new RuntimeException("Unable to setup Task configuration", e);
+    }
+    activeContext.submitTask(taskConfiguration);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/AllocatedEvaluatorHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/AllocatedEvaluatorHandler.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/AllocatedEvaluatorHandler.java
new file mode 100644
index 0000000..16ce4bb
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/AllocatedEvaluatorHandler.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.multipleEventHandlerInstances;
+
+import org.apache.reef.driver.context.ContextConfiguration;
+import org.apache.reef.driver.evaluator.AllocatedEvaluator;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tests.library.exceptions.DriverSideFailure;
+import org.apache.reef.wake.EventHandler;
+
+import javax.inject.Inject;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * The allocated evaluator handler
+ */
+public final class AllocatedEvaluatorHandler implements EventHandler<AllocatedEvaluator> {
+
+  private static final Logger LOG = Logger.getLogger(AllocatedEvaluatorHandler.class.getName());
+
+  private static int countInstances = 0;
+
+  @Inject
+  public AllocatedEvaluatorHandler() {
+    ++countInstances;
+    if (countInstances > 1)
+      throw new DriverSideFailure("Expect AllocatedEvaluatorHandler to be created only once");
+  }
+
+  @Override
+  public void onNext(final AllocatedEvaluator allocatedEvaluator) {
+    LOG.log(Level.INFO, "Submitting empty context to AllocatedEvaluator: {0}", allocatedEvaluator);
+    try {
+      final Configuration contextConfiguration = ContextConfiguration.CONF
+          .set(ContextConfiguration.IDENTIFIER, "EmptyREEFContext")
+          .build();
+      allocatedEvaluator.submitContext(contextConfiguration);
+    } catch (final BindException ex) {
+      throw new RuntimeException("Unable to setup Task or Context configuration.", ex);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/Client.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/Client.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/Client.java
new file mode 100644
index 0000000..5345fe6
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/Client.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.multipleEventHandlerInstances;
+
+import org.apache.reef.client.DriverConfiguration;
+import org.apache.reef.client.DriverLauncher;
+import org.apache.reef.client.LauncherStatus;
+import org.apache.reef.runtime.local.client.LocalRuntimeConfiguration;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.exceptions.BindException;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.util.EnvironmentUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.logging.Logger;
+
+/**
+ *
+ */
+public class Client {
+  private static final Logger LOG = Logger.getLogger(Client.class.getName());
+
+  /**
+   * Number of milliseconds to wait for the job to complete.
+   */
+  private static final int JOB_TIMEOUT = 300000; // 10 sec.
+
+  public static LauncherStatus runReefJob(final Configuration runtimeConf, final int timeOut)
+      throws BindException, InjectionException {
+
+    final Configuration driverConf = DriverConfiguration.CONF
+        .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(StartHandler.class))
+        .set(DriverConfiguration.DRIVER_IDENTIFIER, "MultipleHandlerInstances")
+        .set(DriverConfiguration.ON_DRIVER_STARTED, StartHandler.class)
+        .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, AllocatedEvaluatorHandler.class)
+        .set(DriverConfiguration.ON_CONTEXT_ACTIVE, ActiveContextHandler.class)
+        .set(DriverConfiguration.ON_TASK_RUNNING, RunningTaskHandler.class)
+        .set(DriverConfiguration.ON_TASK_COMPLETED, CompletedTaskHandler.class)
+        .set(DriverConfiguration.ON_CONTEXT_CLOSED, ClosedContextHandler.class)
+        .set(DriverConfiguration.ON_EVALUATOR_COMPLETED, CompletedEvaluatorHandler.class)
+        .build();
+
+    return DriverLauncher.getLauncher(runtimeConf).run(driverConf, timeOut);
+  }
+
+  /**
+   * @param args command line parameters.
+   * @throws BindException      configuration error.
+   * @throws InjectionException configuration error.
+   */
+  @Test
+  public void testMultipleInstances() throws BindException, InjectionException {
+    final Configuration runtimeConfiguration = LocalRuntimeConfiguration.CONF
+        .set(LocalRuntimeConfiguration.NUMBER_OF_THREADS, 2)
+        .build();
+    final LauncherStatus status = runReefJob(runtimeConfiguration, JOB_TIMEOUT);
+    Assert.assertTrue("Reef Job MultipleHandlerInstances failed: " + status, status.isSuccess());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/ClosedContextHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/ClosedContextHandler.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/ClosedContextHandler.java
new file mode 100644
index 0000000..1e245e9
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/ClosedContextHandler.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.multipleEventHandlerInstances;
+
+import org.apache.reef.driver.context.ClosedContext;
+import org.apache.reef.tests.library.exceptions.DriverSideFailure;
+import org.apache.reef.wake.EventHandler;
+
+import javax.inject.Inject;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ */
+public class ClosedContextHandler implements EventHandler<ClosedContext> {
+
+  private static final Logger LOG = Logger.getLogger(ClosedContextHandler.class.getName());
+
+  private static int countInstances = 0;
+
+  @Inject
+  public ClosedContextHandler() {
+    ++countInstances;
+    if (countInstances > 1) {
+      throw new DriverSideFailure("Expect ClosedContextHandler to be created only once");
+    }
+  }
+
+  @Override
+  public void onNext(ClosedContext closedContext) {
+    LOG.log(Level.FINEST, "Received a closed context");
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/CompletedEvaluatorHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/CompletedEvaluatorHandler.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/CompletedEvaluatorHandler.java
new file mode 100644
index 0000000..59c5134
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/CompletedEvaluatorHandler.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.multipleEventHandlerInstances;
+
+import org.apache.reef.driver.evaluator.CompletedEvaluator;
+import org.apache.reef.tests.library.exceptions.DriverSideFailure;
+import org.apache.reef.wake.EventHandler;
+
+import javax.inject.Inject;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ */
+public class CompletedEvaluatorHandler implements
+    EventHandler<CompletedEvaluator> {
+
+  private static final Logger LOG = Logger.getLogger(CompletedEvaluatorHandler.class.getName());
+
+  private static int countInstances = 0;
+
+  @Inject
+  public CompletedEvaluatorHandler() {
+    ++countInstances;
+    if (countInstances > 1) {
+      throw new DriverSideFailure("Expect CompletedEvaluatorHandler to be created only once");
+    }
+  }
+
+  @Override
+  public void onNext(CompletedEvaluator completedEvaluator) {
+    LOG.log(Level.FINEST, "Received a completed evaluator");
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/CompletedTaskHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/CompletedTaskHandler.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/CompletedTaskHandler.java
new file mode 100644
index 0000000..a85d48e
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/CompletedTaskHandler.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.multipleEventHandlerInstances;
+
+import org.apache.reef.driver.task.CompletedTask;
+import org.apache.reef.tests.library.exceptions.DriverSideFailure;
+import org.apache.reef.wake.EventHandler;
+
+import javax.inject.Inject;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ */
+public class CompletedTaskHandler implements EventHandler<CompletedTask> {
+
+  private static final Logger LOG = Logger.getLogger(CompletedTaskHandler.class.getName());
+
+  private static int countInstances = 0;
+
+  @Inject
+  public CompletedTaskHandler() {
+    ++countInstances;
+    if (countInstances > 1)
+      throw new DriverSideFailure("Expect CompletedTaskHandler to be created only once");
+  }
+
+  @Override
+  public void onNext(CompletedTask completedTask) {
+    LOG.log(Level.FINEST, "Received a completed task");
+    completedTask.getActiveContext().close();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/EmptyTask.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/EmptyTask.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/EmptyTask.java
new file mode 100644
index 0000000..d1a62d9
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/EmptyTask.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.multipleEventHandlerInstances;
+
+import org.apache.reef.task.Task;
+
+import javax.inject.Inject;
+
+/**
+ *
+ */
+public class EmptyTask implements Task {
+
+  @Inject
+  public EmptyTask() {
+  }
+
+  @Override
+  public byte[] call(byte[] memento) throws Exception {
+    return null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/RunningTaskHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/RunningTaskHandler.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/RunningTaskHandler.java
new file mode 100644
index 0000000..3995ad2
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/RunningTaskHandler.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.multipleEventHandlerInstances;
+
+import org.apache.reef.driver.task.RunningTask;
+import org.apache.reef.tests.library.exceptions.DriverSideFailure;
+import org.apache.reef.wake.EventHandler;
+
+import javax.inject.Inject;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ */
+public class RunningTaskHandler implements EventHandler<RunningTask> {
+
+  private static final Logger LOG = Logger.getLogger(RunningTaskHandler.class.getName());
+
+  private static int countInstances = 0;
+
+  @Inject
+  public RunningTaskHandler() {
+    ++countInstances;
+    if (countInstances > 1) {
+      throw new DriverSideFailure("Expect RunningTaskHandler to be created only once");
+    }
+  }
+
+  @Override
+  public void onNext(RunningTask runningTask) {
+    LOG.log(Level.FINEST, "Received a running task");
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/StartHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/StartHandler.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/StartHandler.java
new file mode 100644
index 0000000..ab0f779
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/multipleEventHandlerInstances/StartHandler.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.multipleEventHandlerInstances;
+
+import org.apache.reef.driver.evaluator.EvaluatorRequest;
+import org.apache.reef.driver.evaluator.EvaluatorRequestor;
+import org.apache.reef.tests.library.exceptions.DriverSideFailure;
+import org.apache.reef.wake.EventHandler;
+import org.apache.reef.wake.time.event.StartTime;
+
+import javax.inject.Inject;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * The start handler
+ */
+public final class StartHandler implements EventHandler<StartTime> {
+
+  private static final Logger LOG = Logger.getLogger(StartHandler.class.getName());
+  private static int countInstances = 0;
+  private final EvaluatorRequestor requestor;
+
+  /**
+   * Job driver constructor - instantiated via TANG.
+   *
+   * @param requestor evaluator requestor object used to create new evaluator containers.
+   */
+  @Inject
+  public StartHandler(final EvaluatorRequestor requestor) {
+    this.requestor = requestor;
+    ++countInstances;
+    if (countInstances > 1)
+      throw new DriverSideFailure("Expect StartHandler be created only once");
+  }
+
+  @Override
+  public void onNext(StartTime startTime) {
+    LOG.log(Level.INFO, "StartTime: ", startTime);
+    StartHandler.this.requestor.submit(EvaluatorRequest.newBuilder()
+        .setNumber(5)
+        .setMemory(64)
+        .setNumberOfCores(1)
+        .build());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadDriver.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadDriver.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadDriver.java
new file mode 100644
index 0000000..52f4d2f
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadDriver.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.roguethread;
+
+import org.apache.reef.driver.evaluator.AllocatedEvaluator;
+import org.apache.reef.driver.task.TaskConfiguration;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.annotations.Unit;
+import org.apache.reef.wake.EventHandler;
+
+import javax.inject.Inject;
+
+@Unit
+final class RogueThreadDriver {
+
+
+  @Inject
+  RogueThreadDriver() {
+  }
+
+
+  final class EvaluatorAllocationHandler implements EventHandler<AllocatedEvaluator> {
+
+    @Override
+    public void onNext(final AllocatedEvaluator allocatedEvaluator) {
+      final Configuration taskConfiguration = TaskConfiguration.CONF
+          .set(TaskConfiguration.IDENTIFIER, "RogueThreadTestTask")
+          .set(TaskConfiguration.TASK, RogueThreadTask.class)
+          .build();
+      allocatedEvaluator.submitTask(taskConfiguration);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadTask.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadTask.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadTask.java
new file mode 100644
index 0000000..b3a9f05
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadTask.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.roguethread;
+
+import org.apache.reef.task.Task;
+import org.apache.reef.tests.library.exceptions.ExpectedTaskException;
+
+import javax.inject.Inject;
+
+/**
+ * Spawns a thread that immediately throws a ExpectedTaskException.
+ */
+final class RogueThreadTask implements Task {
+  @Inject
+  RogueThreadTask() {
+  }
+
+  @Override
+  public byte[] call(final byte[] memento) throws Exception {
+    new Thread(new Runnable() {
+      @Override
+      public void run() {
+        throw new ExpectedTaskException("Exception from a Thread spawned by the Task.");
+      }
+    }).run();
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadTest.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadTest.java
new file mode 100644
index 0000000..5799df9
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/RogueThreadTest.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.tests.roguethread;
+
+import org.apache.reef.client.DriverConfiguration;
+import org.apache.reef.client.DriverLauncher;
+import org.apache.reef.client.LauncherStatus;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tests.TestEnvironment;
+import org.apache.reef.tests.TestEnvironmentFactory;
+import org.apache.reef.tests.library.driver.ExpectedTaskFailureHandler;
+import org.apache.reef.tests.library.driver.OnDriverStartedAllocateOne;
+import org.apache.reef.util.EnvironmentUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests whether an exception thrown by a thread spawned by Task.call() triggers a FailedTask in the Driver.
+ */
+public final class RogueThreadTest {
+
+  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
+
+  @Before
+  public void setUp() throws Exception {
+    this.testEnvironment.setUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.testEnvironment.tearDown();
+  }
+
+  @Test
+  public void testRogueThread() throws InjectionException {
+    final Configuration runtimeConfiguration = this.testEnvironment.getRuntimeConfiguration();
+    final Configuration driverConfiguration = DriverConfiguration.CONF
+        .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(this.getClass()))
+        .set(DriverConfiguration.DRIVER_IDENTIFIER, "Test_RogueThreadTest")
+        .set(DriverConfiguration.ON_DRIVER_STARTED, OnDriverStartedAllocateOne.class)
+        .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, RogueThreadDriver.EvaluatorAllocationHandler.class)
+        .set(DriverConfiguration.ON_TASK_FAILED, ExpectedTaskFailureHandler.class)
+        .build();
+    final LauncherStatus state = DriverLauncher.getLauncher(runtimeConfiguration)
+        .run(driverConfiguration, this.testEnvironment.getTestTimeout());
+
+    Assert.assertTrue("Job state after execution: " + state, state.isSuccess());
+
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/package-info.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/package-info.java
new file mode 100644
index 0000000..83bee40
--- /dev/null
+++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/roguethread/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Tests whether an exception thrown by a thread spawned by Task.call() triggers a FailedTask in the Driver.
+ */
+package org.apache.reef.tests.roguethread;
\ No newline at end of file