Repository: reef
Updated Branches:
  refs/heads/REEF-335 3b1651917 -> 8f3dafa9f


http://git-wip-us.apache.org/repos/asf/reef/blob/8f3dafa9/lang/java/reef-tests/pom.xml
----------------------------------------------------------------------
diff --git a/lang/java/reef-tests/pom.xml b/lang/java/reef-tests/pom.xml
index b096e39..d39734b 100644
--- a/lang/java/reef-tests/pom.xml
+++ b/lang/java/reef-tests/pom.xml
@@ -34,6 +34,7 @@ under the License.
 
     <properties>
         <rootPath>${basedir}/../../..</rootPath>
+        <protobuf.version>3.5.1</protobuf.version>
     </properties>
 
     <dependencies>
@@ -79,6 +80,16 @@ under the License.
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>reef-bridge-proto-java</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.protobuf</groupId>
+            <artifactId>protobuf-java</artifactId>
+            <version>${protobuf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>vortex</artifactId>
             <version>${project.version}</version>
         </dependency>

http://git-wip-us.apache.org/repos/asf/reef/blob/8f3dafa9/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/driver/FailBridgeClient.java
----------------------------------------------------------------------
diff --git 
a/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/driver/FailBridgeClient.java
 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/driver/FailBridgeClient.java
new file mode 100644
index 0000000..84653bd
--- /dev/null
+++ 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/driver/FailBridgeClient.java
@@ -0,0 +1,103 @@
+/*
+ * 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.driver;
+
+
+import org.apache.reef.annotations.audience.ClientSide;
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.bridge.driver.client.DriverClientConfiguration;
+import org.apache.reef.bridge.proto.ClientProtocol;
+import org.apache.reef.client.LauncherStatus;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.Tang;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tests.TestDriverLauncher;
+import org.apache.reef.tests.fail.util.FailBridgeClientUtils;
+import org.apache.reef.util.EnvironmentUtils;
+import org.apache.reef.util.OSUtils;
+
+import java.io.IOException;
+
+/**
+ * fail bridge client.
+ */
+@Private
+@ClientSide
+public final class FailBridgeClient {
+
+  private static final Tang TANG = Tang.Factory.getTang();
+
+  private static Configuration buildDriverConfig(final Class<?> failMsgClass) {
+
+    final Configuration driverConfig = DriverClientConfiguration.CONF
+        .set(DriverClientConfiguration.ON_DRIVER_STARTED, 
FailDriver.StartHandler.class)
+        .set(DriverClientConfiguration.ON_DRIVER_STOP, 
FailDriver.StopHandler.class)
+        .set(DriverClientConfiguration.ON_EVALUATOR_ALLOCATED, 
FailDriver.AllocatedEvaluatorHandler.class)
+        .set(DriverClientConfiguration.ON_EVALUATOR_COMPLETED, 
FailDriver.CompletedEvaluatorHandler.class)
+        .set(DriverClientConfiguration.ON_EVALUATOR_FAILED, 
FailDriver.FailedEvaluatorHandler.class)
+        .set(DriverClientConfiguration.ON_CONTEXT_ACTIVE, 
FailDriver.ActiveContextHandler.class)
+        .set(DriverClientConfiguration.ON_CONTEXT_MESSAGE, 
FailDriver.ContextMessageHandler.class)
+        .set(DriverClientConfiguration.ON_CONTEXT_CLOSED, 
FailDriver.ClosedContextHandler.class)
+        .set(DriverClientConfiguration.ON_CONTEXT_FAILED, 
FailDriver.FailedContextHandler.class)
+        .set(DriverClientConfiguration.ON_TASK_RUNNING, 
FailDriver.RunningTaskHandler.class)
+        .set(DriverClientConfiguration.ON_TASK_SUSPENDED, 
FailDriver.SuspendedTaskHandler.class)
+        .set(DriverClientConfiguration.ON_TASK_MESSAGE, 
FailDriver.TaskMessageHandler.class)
+        .set(DriverClientConfiguration.ON_TASK_FAILED, 
FailDriver.FailedTaskHandler.class)
+        .set(DriverClientConfiguration.ON_TASK_COMPLETED, 
FailDriver.CompletedTaskHandler.class)
+        .build();
+
+    return TANG.newConfigurationBuilder(driverConfig)
+        .bindNamedParameter(FailDriver.FailMsgClassName.class, 
failMsgClass.getName())
+        .build();
+  }
+
+  public static LauncherStatus runClient(
+      final Class<?> failMsgClass,
+      final Configuration runtimeConfig,
+      final int timeOut) throws IOException, InjectionException {
+    ClientProtocol.DriverClientConfiguration.Builder builder =
+        ClientProtocol.DriverClientConfiguration.newBuilder()
+        .setJobid("Fail_" + failMsgClass.getSimpleName())
+        
.addGlobalLibraries(EnvironmentUtils.getClassLocation(FailDriver.class));
+    builder.setOperatingSystem(
+        OSUtils.isWindows() ?
+            ClientProtocol.DriverClientConfiguration.OS.WINDOWS :
+            ClientProtocol.DriverClientConfiguration.OS.LINUX);
+
+    return runClient(failMsgClass, runtimeConfig, builder.build(), timeOut);
+  }
+
+  public static LauncherStatus runClient(
+      final Class<?> failMsgClass,
+      final Configuration runtimeConfig,
+      final ClientProtocol.DriverClientConfiguration driverClientConfiguration,
+      final int timeOut) throws InjectionException, IOException {
+    final Configuration driverServiceConfiguration =
+        FailBridgeClientUtils.setupDriverService(
+            runtimeConfig,
+            buildDriverConfig(failMsgClass),
+            driverClientConfiguration);
+    return 
TestDriverLauncher.getLauncher(runtimeConfig).run(driverServiceConfiguration, 
timeOut);
+  }
+
+
+  private FailBridgeClient() {
+  }
+}

http://git-wip-us.apache.org/repos/asf/reef/blob/8f3dafa9/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/driver/FailDriver.java
----------------------------------------------------------------------
diff --git 
a/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/driver/FailDriver.java
 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/driver/FailDriver.java
index 8b4c8de..1bd19f1 100644
--- 
a/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/driver/FailDriver.java
+++ 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/driver/FailDriver.java
@@ -281,6 +281,7 @@ public final class FailDriver {
         throw new DriverSideFailure("Unexpected state: " + state);
       }
       // After a delay, send message or suspend the task:
+      LOG.log(Level.INFO, "Schedule alarm on state {0}", state.name());
       clock.scheduleAlarm(MSG_DELAY, new AlarmHandler());
     }
   }

http://git-wip-us.apache.org/repos/asf/reef/blob/8f3dafa9/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/task/BridgeClient.java
----------------------------------------------------------------------
diff --git 
a/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/task/BridgeClient.java
 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/task/BridgeClient.java
new file mode 100644
index 0000000..5317a7b
--- /dev/null
+++ 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/task/BridgeClient.java
@@ -0,0 +1,92 @@
+/*
+ * 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.task;
+
+import org.apache.reef.annotations.audience.ClientSide;
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.bridge.driver.client.DriverClientConfiguration;
+import org.apache.reef.bridge.proto.ClientProtocol;
+import org.apache.reef.client.LauncherStatus;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.JavaConfigurationBuilder;
+import org.apache.reef.tang.Tang;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.task.Task;
+import org.apache.reef.tests.TestDriverLauncher;
+import org.apache.reef.tests.fail.util.FailBridgeClientUtils;
+import org.apache.reef.util.EnvironmentUtils;
+import org.apache.reef.util.OSUtils;
+
+import java.io.IOException;
+
+/**
+ * Fail task bridge client.
+ */
+@Private
+@ClientSide
+public final class BridgeClient  {
+
+  /**
+   * Empty private constructor to prohibit instantiation of utility class.
+   */
+  private BridgeClient() {
+  }
+
+  public static LauncherStatus run(
+      final Class<? extends Task> failTaskClass,
+      final Configuration runtimeConfig,
+      final int timeOut) throws IOException, InjectionException {
+    ClientProtocol.DriverClientConfiguration.Builder builder =
+        ClientProtocol.DriverClientConfiguration.newBuilder()
+            .setJobid("Fail_" + failTaskClass.getSimpleName())
+            
.addGlobalLibraries(EnvironmentUtils.getClassLocation(Driver.class));
+    builder.setOperatingSystem(
+        OSUtils.isWindows() ?
+            ClientProtocol.DriverClientConfiguration.OS.WINDOWS :
+            ClientProtocol.DriverClientConfiguration.OS.LINUX);
+
+    return run(failTaskClass, runtimeConfig, builder.build(), timeOut);
+  }
+
+  public static LauncherStatus run(
+      final Class<? extends Task> failTaskClass,
+      final Configuration runtimeConfig,
+      final ClientProtocol.DriverClientConfiguration driverClientConfiguration,
+      final int timeOut) throws InjectionException, IOException {
+
+    final Configuration driverConfig = DriverClientConfiguration.CONF
+        .set(DriverClientConfiguration.ON_EVALUATOR_ALLOCATED, 
Driver.AllocatedEvaluatorHandler.class)
+        .set(DriverClientConfiguration.ON_TASK_RUNNING, 
Driver.RunningTaskHandler.class)
+        .set(DriverClientConfiguration.ON_CONTEXT_ACTIVE, 
Driver.ActiveContextHandler.class)
+        .set(DriverClientConfiguration.ON_DRIVER_STARTED, 
Driver.StartHandler.class)
+        .build();
+
+    final JavaConfigurationBuilder cb = 
Tang.Factory.getTang().newConfigurationBuilder();
+    cb.addConfiguration(driverConfig);
+    cb.bindNamedParameter(Driver.FailTaskName.class, 
failTaskClass.getSimpleName());
+
+    final Configuration driverServiceConfiguration =
+        FailBridgeClientUtils.setupDriverService(
+            runtimeConfig,
+            cb.build(),
+            driverClientConfiguration);
+    return 
TestDriverLauncher.getLauncher(runtimeConfig).run(driverServiceConfiguration, 
timeOut);
+  }
+}

http://git-wip-us.apache.org/repos/asf/reef/blob/8f3dafa9/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/util/FailBridgeClientUtils.java
----------------------------------------------------------------------
diff --git 
a/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/util/FailBridgeClientUtils.java
 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/util/FailBridgeClientUtils.java
new file mode 100644
index 0000000..b8c7811
--- /dev/null
+++ 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/util/FailBridgeClientUtils.java
@@ -0,0 +1,103 @@
+/*
+ * 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.util;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.reef.annotations.audience.ClientSide;
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.bridge.driver.client.JavaDriverClientLauncher;
+import 
org.apache.reef.bridge.driver.service.IDriverServiceConfigurationProvider;
+import 
org.apache.reef.bridge.driver.service.grpc.GRPCDriverServiceConfigurationProvider;
+import org.apache.reef.bridge.proto.ClientProtocol;
+import org.apache.reef.runtime.common.files.ClasspathProvider;
+import org.apache.reef.runtime.common.files.REEFFileNames;
+import org.apache.reef.runtime.common.launch.JavaLaunchCommandBuilder;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.Injector;
+import org.apache.reef.tang.Tang;
+import org.apache.reef.tang.exceptions.InjectionException;
+import org.apache.reef.tang.formats.ConfigurationSerializer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Fail bridge client utilities.
+ */
+@Private
+@ClientSide
+public final class FailBridgeClientUtils {
+
+  private static final Tang TANG = Tang.Factory.getTang();
+
+  /**
+   * Setup the bridge service configuration.
+   * @param runtimeConfiguration runtime configuration
+   * @param driverClientConfiguration driver client configuration
+   * @param driverClientConfigurationProto protocol arguments
+   * @return bridge service configuration
+   * @throws IOException
+   * @throws InjectionException
+   */
+  public static Configuration setupDriverService(
+      final Configuration runtimeConfiguration,
+      final Configuration driverClientConfiguration,
+      final ClientProtocol.DriverClientConfiguration 
driverClientConfigurationProto)
+      throws IOException, InjectionException {
+    ClientProtocol.DriverClientConfiguration.Builder builder =
+        
ClientProtocol.DriverClientConfiguration.newBuilder(driverClientConfigurationProto);
+    final File driverClientConfigurationFile = 
File.createTempFile("driverclient", ".conf");
+    // Write driver client configuration to a file
+    final Injector driverClientInjector = 
Tang.Factory.getTang().newInjector(driverClientConfiguration);
+    final ConfigurationSerializer configurationSerializer =
+        driverClientInjector.getInstance(ConfigurationSerializer.class);
+    configurationSerializer.toFile(driverClientConfiguration, 
driverClientConfigurationFile);
+
+    final Injector runtimeInjector = TANG.newInjector(runtimeConfiguration);
+    final REEFFileNames fileNames = 
runtimeInjector.getInstance(REEFFileNames.class);
+    final ClasspathProvider classpathProvider = 
runtimeInjector.getInstance(ClasspathProvider.class);
+    final List<String> launchCommand = new 
JavaLaunchCommandBuilder(JavaDriverClientLauncher.class, null)
+        .setConfigurationFilePaths(
+            Collections.singletonList("./" + fileNames.getLocalFolderPath() + 
"/" +
+                driverClientConfigurationFile.getName()))
+        .setJavaPath("java")
+        .setClassPath(driverClientConfigurationProto.getOperatingSystem() ==
+            ClientProtocol.DriverClientConfiguration.OS.WINDOWS ?
+            "\"" + StringUtils.join(classpathProvider.getDriverClasspath(), 
";") + "\"" :
+            StringUtils.join(classpathProvider.getDriverClasspath(), ":"))
+        .build();
+    final String cmd = StringUtils.join(launchCommand, ' ');
+    builder.setDriverClientLaunchCommand(cmd);
+    builder.addLocalFiles(driverClientConfigurationFile.getAbsolutePath());
+
+    final IDriverServiceConfigurationProvider 
driverServiceConfigurationProvider = TANG.newInjector(
+        TANG.newConfigurationBuilder()
+            .bindImplementation(IDriverServiceConfigurationProvider.class,
+                GRPCDriverServiceConfigurationProvider.class)
+            .build())
+        .getInstance(IDriverServiceConfigurationProvider.class);
+    return 
driverServiceConfigurationProvider.getDriverServiceConfiguration(builder.build());
+  }
+
+  private FailBridgeClientUtils() {
+  }
+}

http://git-wip-us.apache.org/repos/asf/reef/blob/8f3dafa9/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/util/package-info.java
----------------------------------------------------------------------
diff --git 
a/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/util/package-info.java
 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/util/package-info.java
new file mode 100644
index 0000000..d271af2
--- /dev/null
+++ 
b/lang/java/reef-tests/src/main/java/org/apache/reef/tests/fail/util/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.
+ */
+/**
+ * Utilities for Driver-side failures.
+ */
+package org.apache.reef.tests.fail.util;

http://git-wip-us.apache.org/repos/asf/reef/blob/8f3dafa9/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailBridgeDriverTest.java
----------------------------------------------------------------------
diff --git 
a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailBridgeDriverTest.java
 
b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailBridgeDriverTest.java
new file mode 100644
index 0000000..cf81007
--- /dev/null
+++ 
b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailBridgeDriverTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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.FailBridgeClient;
+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;
+
+import java.io.IOException;
+
+/**
+ * Run FailDriver with different types of failures.
+ */
+public class FailBridgeDriverTest {
+
+  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 {
+    try {
+      TestUtils.assertLauncherFailure(
+          FailBridgeClient.runClient(clazz,
+              this.testEnvironment.getRuntimeConfiguration(), 
this.testEnvironment.getTestTimeout()),
+          SimulatedDriverFailure.class);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  @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.runClient(
+        FailDriverTest.class, runtimeConfiguration, 
this.testEnvironment.getTestTimeout());
+    Assert.assertEquals(LauncherStatus.COMPLETED, status);
+  }
+}

http://git-wip-us.apache.org/repos/asf/reef/blob/8f3dafa9/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailBridgeTaskTest.java
----------------------------------------------------------------------
diff --git 
a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailBridgeTaskTest.java
 
b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailBridgeTaskTest.java
new file mode 100644
index 0000000..001b2a6
--- /dev/null
+++ 
b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/fail/FailBridgeTaskTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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;
+
+import java.io.IOException;
+
+/**
+ * Run Driver with different types of failures in the Task.
+ */
+public final class FailBridgeTaskTest {
+
+  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, IOException {
+    TestUtils.assertLauncherFailure(
+        BridgeClient.run(failTaskClass,
+            this.testEnvironment.getRuntimeConfiguration(),
+            this.testEnvironment.getTestTimeout()),
+        SimulatedTaskFailure.class);
+  }
+
+  @Test
+  public void testFailTask() throws BindException, InjectionException, 
IOException {
+    failOn(FailTask.class);
+  }
+
+  @Test
+  public void testFailTaskCall() throws BindException, InjectionException, 
IOException {
+    failOn(FailTaskCall.class);
+  }
+
+  @Test
+  public void testFailTaskMsg() throws BindException, InjectionException, 
IOException {
+    failOn(FailTaskMsg.class);
+  }
+
+  @Test
+  public void testFailTaskSuspend() throws BindException, InjectionException, 
IOException {
+    failOn(FailTaskSuspend.class);
+  }
+
+  @Test
+  public void testFailTaskStart() throws BindException, InjectionException, 
IOException {
+    failOn(FailTaskStart.class);
+  }
+
+  @Test
+  public void testFailTaskStop() throws BindException, InjectionException, 
IOException {
+    failOn(FailTaskStop.class);
+  }
+
+  @Test
+  public void testFailTaskClose() throws BindException, InjectionException, 
IOException {
+    failOn(FailTaskClose.class);
+  }
+}

http://git-wip-us.apache.org/repos/asf/reef/blob/8f3dafa9/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
index 9967d9b..a3481e4 100644
--- 
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
@@ -29,7 +29,9 @@ import org.junit.runners.Suite;
 //    FailTaskTest.class,
     FailDriverTest.class,
     FailDriverDelayedMsgTest.class,
-    DriverFailOnFailTest.class
+    DriverFailOnFailTest.class,
+    FailBridgeDriverTest.class,
+    FailBridgeTaskTest.class
     })
 public final class FailTestSuite {
 }

Reply via email to