You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by am...@apache.org on 2016/04/23 00:23:14 UTC

[2/5] incubator-beam git commit: Add a unit test for the SparkRunnerRegistrar

Add a unit test for the SparkRunnerRegistrar


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/f424b8d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/f424b8d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/f424b8d8

Branch: refs/heads/master
Commit: f424b8d87aa491a29cf3c5cc3c162ee3e38aaf01
Parents: 8840047
Author: Sela <an...@paypal.com>
Authored: Fri Apr 22 14:36:33 2016 +0300
Committer: Sela <an...@paypal.com>
Committed: Sat Apr 23 01:11:24 2016 +0300

----------------------------------------------------------------------
 .../runners/spark/SparkRunnerRegistrarTest.java | 70 ++++++++++++++++++++
 1 file changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/f424b8d8/runners/spark/src/test/java/org/apache/beam/runners/spark/SparkRunnerRegistrarTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/SparkRunnerRegistrarTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/SparkRunnerRegistrarTest.java
new file mode 100644
index 0000000..d51403f
--- /dev/null
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/SparkRunnerRegistrarTest.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.beam.runners.spark;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import org.apache.beam.sdk.options.PipelineOptionsRegistrar;
+import org.apache.beam.sdk.runners.PipelineRunnerRegistrar;
+import org.junit.Test;
+
+import java.util.ServiceLoader;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Test {@link SparkRunnerRegistrar}.
+ */
+public class SparkRunnerRegistrarTest {
+  @Test
+  public void testOptions() {
+    assertEquals(
+	    ImmutableList.of(SparkPipelineOptions.class, SparkStreamingPipelineOptions.class),
+    	 new SparkRunnerRegistrar.Options().getPipelineOptions());
+  }
+
+  @Test
+  public void testRunners() {
+    assertEquals(ImmutableList.of(SparkPipelineRunner.class),
+        new SparkRunnerRegistrar.Runner().getPipelineRunners());
+  }
+
+  @Test
+  public void testServiceLoaderForOptions() {
+    for (PipelineOptionsRegistrar registrar :
+        Lists.newArrayList(ServiceLoader.load(PipelineOptionsRegistrar.class).iterator())) {
+      if (registrar instanceof SparkRunnerRegistrar.Options) {
+      	return;
+      }
+    }
+    fail("Expected to find " + SparkRunnerRegistrar.Options.class);
+  }
+
+  @Test
+  public void testServiceLoaderForRunner() {
+    for (PipelineRunnerRegistrar registrar :
+        Lists.newArrayList(ServiceLoader.load(PipelineRunnerRegistrar.class).iterator())) {
+      if (registrar instanceof SparkRunnerRegistrar.Runner) {
+      	return;
+      }
+    }
+    fail("Expected to find " + SparkRunnerRegistrar.Runner.class);
+  }
+}