Package org.jboss.arquillian.test.spi

Examples of org.jboss.arquillian.test.spi.TestResult


      }
   }
  
   private TestResult createFailedResult(Throwable throwable)
   {
      return new TestResult(Status.FAILED, throwable);
   }
View Full Code Here


{
   @Test
   public void shouldNotCallAnyMethodsWithoutLifecycleHandlers() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      when(adaptor.test(isA(TestMethodExecutor.class))).thenReturn(new TestResult(Status.PASSED));
     
      Result result = run(adaptor, ArquillianClass1.class);

      Assert.assertTrue(result.wasSuccessful());
      assertCycle(0, Cycle.values());
View Full Code Here

      return new Statement()
      {
         @Override
         public void evaluate() throws Throwable
         {
            TestResult result = deployableTest.get().test(new TestMethodExecutor()
            {
               @Override
               public void invoke(Object... parameters) throws Throwable
               {
                  try
                  {
                     //Object parameterValues = TestEnrichers.enrich(deployableTest.get().getActiveContext(), getMethod());
                     method.invokeExplosively(test, parameters); //, (Object[])parameterValues);
                  }
                  catch (Throwable e)
                  {
                     // Force a way to return the thrown Exception from the Container the client.
                     caughtTestException.set(e);
                     throw e;
                  }
               }
              
               public Method getMethod()
               {
                  return method.getMethod();
               }
              
               public Object getInstance()
               {
                  return test;
               }
            });
            if(result.getThrowable() != null)
            {
               throw result.getThrowable();
            }
         }
      };
   }
View Full Code Here

      }
      if (result.getIgnoreCount() > 0)
      {
         status = Status.SKIPPED;
      }
      return new TestResult(status, throwable);
   }
View Full Code Here

         return new ContainerMethodExecutor()
         {
            @Override
            public TestResult invoke(TestMethodExecutor arg0)
            {
               return new TestResult(Status.SKIPPED);
            }
         };
      }

      Collection<FurnaceHolder> contexts = metaData.getContexts(FurnaceHolder.class);
View Full Code Here

         if (testInstance != null)
         {
            try
            {
               TestResult result = null;
               try
               {
                  try
                  {
                     testInstance = ClassLoaderAdapterCallback.enhance(getClass().getClassLoader(),
                              testInstance.getClass().getClassLoader(), testInstance, testClass);
                     testInstance.getClass();
                  }
                  catch (Exception e)
                  {
                     System.out.println("Could not enhance test class. Falling back to un-proxied invocation.");
                  }

                  Method method = testInstance.getClass().getMethod(testMethodExecutor.getMethod().getName());
                  Annotation[] annotations = method.getAnnotations();

                  for (Annotation annotation : annotations)
                  {
                     if ("org.junit.Ignore".equals(annotation.getClass().getName()))
                     {
                        result = new TestResult(Status.SKIPPED);
                     }
                  }

                  if (result == null)
                  {
                     try
                     {
                        System.out.println("Executing test method: "
                                 + testMethodExecutor.getInstance().getClass().getName() + "."
                                 + testMethodExecutor.getMethod().getName() + "()");

                        try
                        {
                           invokeBefore(testInstance.getClass(), testInstance);
                           method.invoke(testInstance);
                        }
                        catch (Exception e)
                        {
                           throw e;
                        }
                        finally
                        {
                           invokeAfter(testInstance.getClass(), testInstance);
                        }

                        result = new TestResult(Status.PASSED);
                     }
                     catch (InvocationTargetException e)
                     {
                        if (e.getCause() != null && e.getCause() instanceof Exception)
                           throw (Exception) e.getCause();
                        else
                           throw e;
                     }
                  }
               }
               catch (AssertionError e)
               {
                  result = new TestResult(Status.FAILED, e);
               }
               catch (Exception e)
               {
                  result = new TestResult(Status.FAILED, e);

                  Throwable cause = e.getCause();
                  while (cause != null)
                  {
                     if (cause instanceof AssertionError)
                     {
                        result = new TestResult(Status.FAILED, cause);
                        break;
                     }
                     cause = cause.getCause();
                  }
               }
View Full Code Here

  
   @Test
   public void shouldReturnExceptionWhenMissingMethodParameter() throws Exception
   {
      URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", null);
      TestResult result = (TestResult)TestUtil.execute(url);
     
      Assert.assertEquals(
            "Should have returned a passed test",
            Status.FAILED,
            result.getStatus());
     
      Assert.assertTrue(
            "No Exception should have been thrown",
            result.getThrowable() instanceof IllegalArgumentException);
   }
View Full Code Here

  
   @Test
   public void shouldReturnExceptionWhenErrorLoadingClass() throws Exception
   {
      URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", "test");
      TestResult result = (TestResult)TestUtil.execute(url);
     
      Assert.assertEquals(
            "Should have returned a passed test",
            Status.FAILED,
            result.getStatus());
     
      Assert.assertTrue(
            "No Exception should have been thrown",
            result.getThrowable() instanceof ClassNotFoundException);
   }
View Full Code Here

   @Test
   public void shouldBeAbleToTransfereCommand() throws Exception
   {
      Object[] results = new Object[] {"Wee", 100};

      MockTestRunner.add(new TestResult(Status.PASSED, null));
      MockTestRunner.add(new TestStringCommand());
      MockTestRunner.add(new TestIntegerCommand());

      ServletMethodExecutor executor = new ServletMethodExecutor(
              new ServletProtocolConfiguration(),
              createContexts(),
              new TestCommandCallback(results));

      TestResult result = executor.invoke(new MockTestExecutor());

      Assert.assertEquals(
            "Should have returned a passed test",
            MockTestRunner.wantedResults.getStatus(),
            result.getStatus());

      Assert.assertNull(
            "Exception should have been thrown",
            result.getThrowable());

      Assert.assertEquals(
            "Should have returned command",
            results[0],
            MockTestRunner.commandResults.get(0));
View Full Code Here

      ServletProtocolConfiguration config = new ServletProtocolConfiguration();
      config.setPullInMilliSeconds(0);

      Object[] results = new Object[] {"Wee", 100};

      MockTestRunner.add(new TestResult(Status.FAILED, null));
      MockTestRunner.add(new TestStringCommand());

      ServletMethodExecutor executor = new ServletMethodExecutor(
              config,
              createContexts(),
              new TestCommandCallback(results));

      TestResult result = executor.invoke(new MockTestExecutor());

      Assert.assertEquals(
            "Should have returned a passed test",
            MockTestRunner.wantedResults.getStatus(),
            result.getStatus());

      Assert.assertNotNull(
            "Exception should have been thrown",
            result.getThrowable());

      Assert.assertTrue(
            "Timeout exception should have been thrown",
            result.getThrowable().getMessage().contains("timeout"));
   }
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.test.spi.TestResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.