Hil created BEAM-7152:
-------------------------

             Summary: public class TestPipeline fails with 
java.lang.IllegalStateException
                 Key: BEAM-7152
                 URL: https://issues.apache.org/jira/browse/BEAM-7152
             Project: Beam
          Issue Type: Bug
          Components: testing
    Affects Versions: 2.11.0
         Environment: hil@xeon:~/mavenwave/mw-finack/deploy$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
hil@xeon:~/mavenwave/mw-finack/deploy$ uname -a
Linux xeon 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 
x86_64 x86_64 GNU/Linux
hil@xeon:~/mavenwave/mw-finack/deploy$
            Reporter: Hil


I tried version 2.12 and 2.11 for [creating unit 
tests|[https://cwiki.apache.org/confluence/display/BEAM/Contribution+Testing+Guide#ContributionTestingGuide-EffectiveuseoftheTestPipelineJUnitrule]]:

 
{code:java}
public class FinackPipelineTest {

@Rule
public final TestPipeline pipeline = TestPipeline.create();

@Test
@Category(NeedsRunner.class)
public void myPipelineTest() throws Exception {
    String WORDS = "words";
    String WHATEVER = "whatever";
    final PCollection<String> pCollection =
            pipeline
                    .apply("Create", 
Create.of(WORDS).withCoder(StringUtf8Coder.of()))
                    .apply(
                            "Map1",
                            MapElements.via(
                                    new SimpleFunction<String, String>() {

                                        @Override
                                        public String apply(final String input) 
{
                                            return WHATEVER;
                                        }
                                    }));

    PAssert.that(pCollection).containsInAnyOrder(WHATEVER);

    pipeline.run();
}
}{code}
When I run the unit tests in Intellij, I got the following error:

 

{color:#FF0000}java.lang.IllegalStateException: Is your TestPipeline 
declaration missing a @Rule annotation? Usage: @Rule public final transient 
TestPipeline pipeline = TestPipeline.create();{color}

{color:#FF0000}at 
org.apache.beam.vendor.guava.v20_0.com.google.common.base.Preconditions.checkState(Preconditions.java:444){color}
{color:#FF0000} at 
org.apache.beam.sdk.testing.TestPipeline.run(TestPipeline.java:337){color}
{color:#FF0000} at 
org.apache.beam.sdk.testing.TestPipeline.run(TestPipeline.java:331){color}
{color:#FF0000} at 
com.finack.app.FinackPipelineTest.myPipelineTest(FinackPipelineTest.java:86){color}
{color:#FF0000} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method){color}
{color:#FF0000} at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62){color}
{color:#FF0000} at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43){color}
{color:#FF0000} at java.lang.reflect.Method.invoke(Method.java:498){color}
{color:#FF0000} at 
org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:628){color}
{color:#FF0000} at 
org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:117){color}
{color:#FF0000} at 
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:184){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73){color}
{color:#FF0000} at 
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:180){color}
{color:#FF0000} at 
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:127){color}
{color:#FF0000} at 
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80){color}
{color:#FF0000} at java.util.ArrayList.forEach(ArrayList.java:1257){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80){color}
{color:#FF0000} at java.util.ArrayList.forEach(ArrayList.java:1257){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57){color}
{color:#FF0000} at 
org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51){color}
{color:#FF0000} at 
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229){color}
{color:#FF0000} at 
org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197){color}
{color:#FF0000} at 
org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211){color}
{color:#FF0000} at 
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191){color}
{color:#FF0000} at 
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128){color}
{color:#FF0000} at 
com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74){color}
{color:#FF0000} at 
com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47){color}
{color:#FF0000} at 
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242){color}
{color:#FF0000} at 
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70){color}

{color:#FF0000}Disconnected from the target VM, address: '127.0.0.1:41883', 
transport: 'socket'{color}

{color:#FF0000}Process finished with exit code 255{color}

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to