You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ec...@apache.org on 2019/01/09 15:51:27 UTC

[beam] branch spark-runner_structured-streaming updated: Refactor SourceTest to a UTest instaed of a main

This is an automated email from the ASF dual-hosted git repository.

echauchot pushed a commit to branch spark-runner_structured-streaming
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/spark-runner_structured-streaming by this push:
     new 9cd96e8  Refactor SourceTest to a UTest instaed of a main
9cd96e8 is described below

commit 9cd96e805c8dafd593feac93ea64a67e8ea8c224
Author: Etienne Chauchot <ec...@apache.org>
AuthorDate: Wed Jan 9 16:35:00 2019 +0100

    Refactor SourceTest to a UTest instaed of a main
---
 .../runners/spark/structuredstreaming/SourceTest.java    | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/runners/spark-structured-streaming/src/test/java/org/apache/beam/runners/spark/structuredstreaming/SourceTest.java b/runners/spark-structured-streaming/src/test/java/org/apache/beam/runners/spark/structuredstreaming/SourceTest.java
index 5b4957d..8263718 100644
--- a/runners/spark-structured-streaming/src/test/java/org/apache/beam/runners/spark/structuredstreaming/SourceTest.java
+++ b/runners/spark-structured-streaming/src/test/java/org/apache/beam/runners/spark/structuredstreaming/SourceTest.java
@@ -4,14 +4,24 @@ import org.apache.beam.sdk.Pipeline;
 import org.apache.beam.sdk.options.PipelineOptions;
 import org.apache.beam.sdk.options.PipelineOptionsFactory;
 import org.apache.beam.sdk.transforms.Create;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Test class for beam to spark source translation.
  */
 public class SourceTest {
-  public static void main(String[] args) {
-    PipelineOptions options = PipelineOptionsFactory.fromArgs(args).create();
-    Pipeline pipeline = Pipeline.create(options);
+  private static Pipeline pipeline;
+
+  @BeforeClass
+  public static void beforeClass(){
+    PipelineOptions options = PipelineOptionsFactory.create().as(SparkPipelineOptions.class);
+    options.setRunner(SparkRunner.class);
+    pipeline = Pipeline.create(options);
+  }
+
+  @Test
+  public void testBoundedSource(){
     pipeline.apply(Create.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
     pipeline.run();
   }