1 Reply Latest reply on Dec 19, 2012 2:53 AM by Stefan B

    java.lang.NullPointerException      at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:290)

    Stefan B Newbie

      Hi all

       

      I am a newbie to Arquillian and started to build up an environment to execute some basic "hello" world tests.

       

      My classpath:

       


      M2_REPO/org/jboss/shrinkwrap/shrinkwrap-api/1.0.1/shrinkwrap-api-1.0.1.jar

      M2_REPO/junit/junit/4.8.1/junit-4.8.1.jar

      M2_REPO/org/jboss/arquillian/container/arquillian-container-test-api/1.0.3.Final/arquillian-container-test-api-1.0.3.Final.jar

      M2_REPO/org/jboss/arquillian/junit/arquillian-junit-core/1.0.0.Final/arquillian-junit-core-1.0.0.Final.jar"

      M2_REPO/org/jboss/arquillian/test/arquillian-test-spi/1.0.3.Final/arquillian-test-spi-1.0.3.Final.jar"

      M2_REPO/org/jboss/arquillian/core/arquillian-core-spi/1.0.3.Final/arquillian-core-spi-1.0.3.Final.jar

      M2_REPO/org/jboss/arquillian/core/arquillian-core-impl-base/1.0.0.Final/arquillian-core-impl-base-1.0.0.Final.jar"

      M2_REPO/org/jboss/arquillian/test/arquillian-test-impl-base/1.0.0.Final/arquillian-test-impl-base-1.0.0.Final.jar"

      M2_REPO/org/jboss/arquillian/container/arquillian-container-spi/1.0.3.Final/arquillian-container-spi-1.0.3.Final.jar

      M2_REPO/org/jboss/arquillian/test/arquillian-test-api/1.0.3.Final/arquillian-test-api-1.0.3.Final.jar

       

      I am using the WAS (Websphere) 8 Container, taken from Git and compiled and installed to my local repo without any problems. For running the tests I have added the following to my junit run configuration

       

      config for my adapter (taken as -d arg ...): arquillian.launch=src/main/resources/arquillian.xml

       

      classpath:

      M2_REPO/org/jboss/arquillian/core/arquillian-core-spi/1.0.3.Final/arquillian-core-spi-1.0.3.Final.jar

      M2_REPO/org/jboss/arquillian/container/arquillian-container-spi/1.0.3.Final/arquillian-container-spi-1.0.3.Final.jar

      M2_REPO/org/jboss/arquillian/container/arquillian-was-embedded-8/1.0.0-Snapshot/arquillian-container-was-embedded-8.Final-Snapshot.jar

       

      If I start the test it IMMEDIATE fails with a nullPointer:

       

      com.daimler.mbcpos.sm.atmsvc.whoisonlinesvc.arquillian.GreeterTest 0.036 s:

       

       

      java.lang.NullPointerException

          at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:290)

          at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226)

          at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

          at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

          at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)

          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)

          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

          at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)

          at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)

          at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)

          at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)

          at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)

          at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)

          at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

          at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

          at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)

          at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

          at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)

          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

       

       

       

      The Test is quite easy and should be fine from my point of view:

       

       

      package com.daimler.mbcpos.sm.atmsvc.whoisonlinesvc.arquillian;

       

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.container.test.api.RunAsClient;

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.asset.EmptyAsset;

      import org.jboss.shrinkwrap.api.spec.JavaArchive;

      import org.junit.Assert;

      import org.junit.Test;

      import org.junit.runner.RunWith;

       

      @RunWith(Arquillian.class)

      public class GreeterTest {

       

          @Deployment

          public static JavaArchive createDeployment() {

              return ShrinkWrap.create(JavaArchive.class)

                  .addClass(Greeter.class)

                  .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

          }

       

          @Test

          public void should_create_greeting() {

       

              Assert.fail("Not yet implemented");

       

       

          }

      }

       

      If checked the code Arquillian.class top to bottom :

       

       

         public TestResult test(TestMethodExecutor testMethodExecutor) throws Exception

         {

            Validate.notNull(testMethodExecutor, "TestMethodExecutor must be specified");

       

            final List<TestResult> result = new ArrayList<TestResult>();

            manager.fire(new Test(testMethodExecutor), new NonManagedObserver<Test>()

            {

               @Inject

               private Instance<TestResult> testResult;

       

               @Override

               public void fired(Test event)

               {

                  result.add(testResult.get());

               }

            });

            return result.get(0);

         }

       

      result.get(0) (and all other entries) are always null and causing the NPE afterwards - so from my point of view tests are not executed? right? but why? :-) Am I missing someting?

       

      Thanks in advance.