actually test the pipeline (#4)

diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index b93db98..98e851c 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -8,7 +8,7 @@
 
 name: Test
 
-on: push
+on: [push, pull_request]
 
 jobs:
   Gradle:
diff --git a/build.gradle b/build.gradle
index a8bd176..2f368ec 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,11 +19,11 @@
 }
 
 test {
-    // JUnit 5 testing integration.
-    useJUnitPlatform()
+    // JUnit 4.
+    useJUnit()
 }
 
-def beamVersion = '2.33.0'
+def beamVersion = '2.39.0'
 dependencies {
     // App dependencies.
     implementation "org.apache.beam:beam-sdks-java-core:${beamVersion}"
@@ -31,7 +31,8 @@
     implementation "org.slf4j:slf4j-jdk14:1.7.32"
 
     // Tests dependencies.
-    testImplementation "org.junit.jupiter:junit-jupiter:5.8.1"
+    testImplementation "junit:junit:4.13.2"
+    testImplementation 'org.hamcrest:hamcrest:2.2'
 }
 
 // Package a self-contained jar file.
diff --git a/build.sbt b/build.sbt
index 5e94af5..357158b 100644
--- a/build.sbt
+++ b/build.sbt
@@ -8,7 +8,7 @@
 
 mainClass := Some("com.example.App")
 
-val beamVersion = "2.33.0"
+val beamVersion = "2.39.0"
 libraryDependencies ++= Seq(
   // App dependencies.
   "org.apache.beam" % "beam-sdks-java-core" % beamVersion,
@@ -16,8 +16,9 @@
   "org.slf4j" % "slf4j-jdk14" % "1.7.32",
 
   // Test dependencies.
-  "net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test,
-  "org.junit.jupiter" % "junit-jupiter" % "5.8.1" % Test
+  "junit" % "junit" % "4.13.2" % Test,
+  "com.novocode" % "junit-interface" % "0.11" % Test,
+  "org.hamcrest" % "hamcrest" % "2.2" % Test
 )
 
 // Package self-contained jar file.
diff --git a/pom.xml b/pom.xml
index c0e15fe..31a1b3f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,8 +21,8 @@
     <maven.compiler.target>11</maven.compiler.target>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 
-    <beam.version>2.33.0</beam.version>
-    <junit.version>5.8.1</junit.version>
+    <beam.version>2.39.0</beam.version>
+    <junit.version>4.13.2</junit.version>
   </properties>
 
   <build>
@@ -44,18 +44,11 @@
         </configuration>
       </plugin>
 
-      <!-- JUnit 5 testing integration. -->
+      <!-- JUnit 4 testing integration. -->
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <version>3.0.0-M5</version>
-        <dependencies>
-          <dependency>
-            <groupId>org.junit.jupiter</groupId>
-            <artifactId>junit-jupiter-engine</artifactId>
-            <version>${junit.version}</version>
-          </dependency>
-        </dependencies>
       </plugin>
 
       <!-- Package self-contained jar file. -->
@@ -108,10 +101,17 @@
 
     <!-- Test dependencies -->
     <dependency>
-      <groupId>org.junit.jupiter</groupId>
-      <artifactId>junit-jupiter</artifactId>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
       <version>${junit.version}</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest</artifactId>
+      <version>2.2</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>
\ No newline at end of file
diff --git a/src/main/java/com/example/App.java b/src/main/java/com/example/App.java
index 20e7afe..f5f8a14 100644
--- a/src/main/java/com/example/App.java
+++ b/src/main/java/com/example/App.java
@@ -8,13 +8,18 @@
 
 package com.example;
 
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.coders.StringUtf8Coder;
 import org.apache.beam.sdk.options.Default;
 import org.apache.beam.sdk.options.Description;
 import org.apache.beam.sdk.options.PipelineOptionsFactory;
 import org.apache.beam.sdk.options.StreamingOptions;
 import org.apache.beam.sdk.transforms.Create;
 import org.apache.beam.sdk.transforms.MapElements;
+import org.apache.beam.sdk.values.PCollection;
 import org.apache.beam.sdk.values.TypeDescriptors;
 
 public class App {
@@ -26,15 +31,20 @@
 		void setInputText(String value);
 	}
 
+	public static PCollection<String> buildPipeline(Pipeline pipeline, String inputText) {
+		return pipeline
+				.apply("Create elements", Create.of(Arrays.asList("Hello", "World!", inputText)))
+				.apply("Print elements",
+						MapElements.into(TypeDescriptors.strings()).via(x -> {
+							System.out.println(x);
+							return x;
+						}));
+	}
+
 	public static void main(String[] args) {
 		var options = PipelineOptionsFactory.fromArgs(args).withValidation().as(Options.class);
-
 		var pipeline = Pipeline.create(options);
-		pipeline.apply("Create elements", Create.of("Hello", "World!", options.getInputText())).apply("Print elements",
-				MapElements.into(TypeDescriptors.strings()).via(x -> {
-					System.out.println(x);
-					return x;
-				}));
-		pipeline.run();
+		App.buildPipeline(pipeline, options.getInputText());
+		pipeline.run().waitUntilFinish();
 	}
 }
\ No newline at end of file
diff --git a/src/test/java/com/example/AppTest.java b/src/test/java/com/example/AppTest.java
index c7a47e3..a259d12 100644
--- a/src/test/java/com/example/AppTest.java
+++ b/src/test/java/com/example/AppTest.java
@@ -8,13 +8,25 @@
 
 package com.example;
 
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.testing.PAssert;
+import org.apache.beam.sdk.testing.TestPipeline;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
 
+@RunWith(JUnit4.class)
 public class AppTest {
+	@Rule
+	public final transient TestPipeline pipeline = TestPipeline.create();
+
 	@Test
 	public void appRuns() {
-		App.main(new String[] {});
-		assertEquals(1 + 1, 2);
+		var elements = App.buildPipeline(pipeline, "Test");
+
+		// Note that the order of the elements doesn't matter.
+		PAssert.that(elements).containsInAnyOrder("Test", "Hello", "World!");
+		pipeline.run().waitUntilFinish();
 	}
 }