Package org.jboss.arquillian.test.spi

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


   }

   private TestResult runTestMethodInternal(String className, String methodName)
   {
      currentCall.set(className + methodName);
      TestResult result = new TestResult();
      try
      {
         TestRunner runner = mockTestRunner;
         if (runner == null)
         {
            runner = TestRunners.getTestRunner(getClass().getClassLoader());
         }

         log.fine("Load test class: " + className);
         Class<?> testClass = testClassLoader.loadTestClass(className);
         log.fine("Test class loaded from: " + testClass.getClassLoader());

         log.fine("Execute: " + className + "." + methodName);
         result = runner.execute(testClass, methodName);
      }
      catch (Throwable th)
      {
         result.setStatus(Status.FAILED);
         result.setEnd(System.currentTimeMillis());
         result.setThrowable(th);
      }
      finally
      {
         log.fine("Result: " + result);
         if (result.getStatus() == Status.FAILED)
            log.log(Level.SEVERE, "Failed: " + className + "." + methodName, result.getThrowable());
      }
      return result;
   }
View Full Code Here


        JMXTestRunner jmxTestRunner = new JMXTestRunner(null);
        ObjectName oname = jmxTestRunner.registerMBean(mbeanServer);

        try {
            JMXTestRunnerMBean testRunner = getMBeanProxy(mbeanServer, oname, JMXTestRunnerMBean.class);
            TestResult result = Serializer.toObject(TestResult.class, testRunner.runTestMethod(DummyTestCase.class.getName(), "testMethod"));

            assertNotNull("TestResult not null", result);
            assertNotNull("Status not null", result.getStatus());
            if (result.getStatus() == Status.FAILED)
                throw result.getThrowable();
        } finally {
            mbeanServer.unregisterMBean(oname);
        }
    }
View Full Code Here

    @Test
    public void shouldBeAbleToSendReceiveCommands() throws Throwable
    {
       Object[] results = new Object[]{"Success", 100};
       MockTestRunner.add(new TestResult(Status.PASSED));
       MockTestRunner.add(new TestStringCommand());
       MockTestRunner.add(new TestIntegerCommand());
      
       MBeanServer mbeanServer = getMBeanServer();
       JMXTestRunner jmxTestRunner = new JMXTestTestRunner(null);

       jmxTestRunner.setExposedTestRunnerForTest(new MockTestRunner());
       ObjectName oname = jmxTestRunner.registerMBean(mbeanServer);
      
       try
       {
          JMXMethodExecutor executor = new JMXMethodExecutor(mbeanServer, new TestCommandCallback(results));
         
          TestResult result = executor.invoke(new TestMethodExecutor()
          {
             @Override
             public void invoke(Object... parameters) throws Throwable { }
            
             @Override
             public Method getMethod() { return testMethod(); }
            
             @Override
             public Object getInstance()
             {
                return JMXTestRunnerTestCase.this;
             }
          });
          
          assertNotNull("TestResult not null", result);
          assertNotNull("Status not null", result.getStatus());
          if (result.getStatus() == Status.FAILED)
             throw result.getThrowable();
         
         
          for(int i = 0 ; i < results.length; i++)
          {
             Assert.assertEquals(
View Full Code Here

   public void executeTest(HttpServletResponse response, String outputMode, String className, String methodName)
         throws ClassNotFoundException, IOException
   {
      Class<?> testClass = SecurityActions.getThreadContextClassLoader().loadClass(className);
      TestRunner runner = TestRunners.getTestRunner();
      TestResult testResult = runner.execute(testClass, methodName);
      if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
      {
         writeObject(testResult, response);
      }
      else
View Full Code Here

      }
   }

   private TestResult createFailedResult(Throwable throwable)
   {
      return new TestResult(Status.FAILED, 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

      return Collections.emptyList();
   }

   public TestResult execute(Class<?> testClass, String methodName)
   {
      TestResult testResult = TestResult.passed(); // = new TestResult(Status.PASSED);
      ExpectedExceptionHolder exceptionHolder = new ExpectedExceptionHolder();
      try
      {
          JUnitCore runner = new JUnitCore();

          runner.addListener(exceptionHolder);

          for (RunListener listener : getRunListeners())
             runner.addListener(listener);

          Result result = runner.run(Request.method(testClass, methodName));

          if (result.getFailureCount() > 0)
          {
             testResult = TestResult.failed(result.getFailures().get(0).getException());
          }
          else if (result.getIgnoreCount() > 0)
          {
              testResult = TestResult.skipped(null); // Will this ever happen incontainer?
          }
          else {
              testResult = TestResult.passed();
          }

          testResult.setThrowable(exceptionHolder.getException());
      }
      catch (Throwable th) {
          testResult = TestResult.failed(th);
      }
      // AssumptionViolatedException might not be Serializable. Recreate with only String message.
      if(testResult.getThrowable() instanceof AssumptionViolatedException) {
          testResult = TestResult.skipped(new AssumptionViolatedException(testResult.getThrowable().getMessage()));
      }
      testResult.setEnd(System.currentTimeMillis());
      return testResult;
   }
View Full Code Here

            {
                comparePerformanceSuiteResults(suiteResult, eventContext.getEvent().getTestMethod().getName());
            }
            catch (PerformanceException pe)
            {
                TestResult result = testResultInst.get();
                if (result != null)
                {
                    result.setThrowable(pe);
                }
            }
        }
    }
View Full Code Here

     *
     * @param event, the test
     * @throws PerformanceException if the test did not end within the specified time
     */
    private void verifyPerformance(Test event) throws PerformanceException {
        TestResult result = testResultInst.get();
        if(result != null)
        {
            //check if we have set a threshold
            Performance performance = null;
            Annotation[] annotations =  event.getTestMethod().getDeclaredAnnotations();
            for(Annotation a : annotations)
                if(a.annotationType().getName().equals(Performance.class.getCanonicalName()))
                    performance = (Performance) a;

            if(performance != null)
            {
                //System.out.println("For test: "+event.toString()+", it took: "+(result.getEnd()-result.getStart()));
                if(performance.time() > 0 &&
                        performance.time() < (result.getEnd()-result.getStart()))
                {
                    result.setStatus(TestResult.Status.FAILED);
                    result.setThrowable(
                            new PerformanceException("The test didnt finish within the specified time: "
                                    +performance.time()+"ms, it took "+(result.getEnd()-result.getStart())+"ms."));
                }

                // fetch suiteResult, get the correct classResult and append the test to that
                // classResult.
                PerformanceSuiteResult suiteResult = suiteResultInst.get();
                if(suiteResult != null) {
                    suiteResult.getResult(event.getTestClass().getName()).addMethodResult(
                            new PerformanceMethodResult(
                                    performance.time(),
                                    (result.getEnd()-result.getStart()),
                                    event.getTestMethod()));
                }
            }
        }
    }
View Full Code Here

   public void executeTest(HttpServletResponse response, String outputMode, String className, String methodName)
         throws ClassNotFoundException, IOException
   {
      Class<?> testClass = SecurityActions.getThreadContextClassLoader().loadClass(className);
      TestRunner runner = TestRunners.getTestRunner();
      TestResult testResult = runner.execute(testClass, methodName);
      if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
      {
         writeObject(testResult, response);
      }
      else
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.