Package org.jboss.arquillian.spi

Examples of org.jboss.arquillian.spi.TestResult


        
         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);
         }
View Full Code Here


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

            // HttpSession with the current thread
            WebConversationFactory.setThreadLocals(request);
            try {
                MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
                ObjectName name = new ObjectName("jboss.arquillian:service=jmx-test-runner");
                TestResult testResult = (TestResult) mbeanServer.invoke(name, "runTestMethod", new Object[] { className,
                        methodName, new HashMap<String, String>() },
                        new String[] { String.class.getName(), String.class.getName(), Map.class.getName() });
                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

      Object testInstance = testMethodExecutor.getInstance();
      final String testClass = testInstance.getClass().getName();
      final String testMethod = testMethodExecutor.getMethod().getName();

      TestResult result = null;
      NotificationListener listener = null;
      try
      {
         final JMXTestRunnerMBean testRunner = getMBeanProxy(JMXTestRunnerMBean.OBJECT_NAME, JMXTestRunnerMBean.class);
         listener = registerNotificationListener(JMXTestRunnerMBean.OBJECT_NAME, testRunner, testInstance);

         if (executionType == ExecutionType.EMBEDDED)
         {
            InputStream resultStream = executor.submit(new Callable<InputStream>()
            {
               @Override
               public InputStream call() throws Exception
               {
                  return testRunner.runTestMethodEmbedded(testClass, testMethod, props);
               }
            }).get();

            try
            {
               result = Utils.deserialize(resultStream, TestResult.class);
            }
            finally
            {
               try
               {
                  resultStream.close();
               }
               catch (IOException ignore)
               {
               }
            }
         }
         else if (executionType == ExecutionType.REMOTE)
         {
            result = testRunner.runTestMethod(testClass, testMethod, props);
         }
      }
      catch (final Throwable e)
      {
         result = new TestResult(Status.FAILED);
         result.setThrowable(e);
      }
      finally
      {
         result.setEnd(System.currentTimeMillis());

         unregisterNotificationListener(JMXTestRunnerMBean.OBJECT_NAME, listener);
      }
      return result;
   }
View Full Code Here

      return runTestMethodInternal(className, methodName, props);
   }

   public InputStream runTestMethodEmbedded(String className, String methodName, Map<String, String> props)
   {
      TestResult result = runTestMethodInternal(className, methodName, props);

      // Marshall the TestResult
      try
      {
         return new ByteArrayInputStream(Utils.serialize(result));
View Full Code Here

      }
   }

   private TestResult runTestMethodInternal(String className, String methodName, Map<String, String> props)
   {
      TestResult testResult;
      try
      {
         // Associate the ExecutionType with the thread.
         // [TODO] Remove this hack when it becomes possible to pass data to the enrichers
         ResourceCallbackHandlerAssociation.setCallbackHandler(this);

         // Get the TestRunner
         ClassLoader serviceClassLoader = getTestClassLoader().getServiceClassLoader();
         TestRunner runner = TestRunners.getTestRunner(serviceClassLoader);
         Class<?> testClass = getTestClassLoader().loadTestClass(className);

         ClassLoader oldThreadContextCL = SecurityActions.getThreadContextClassLoader();
         try
         {
            DynamicServiceLoader.setClassLoaderAssociation(serviceClassLoader);
            SecurityActions.setThreadContextClassLoader(SecurityActions.getClassLoader(testClass));
            testResult = runner.execute(testClass, methodName);
         }
         finally
         {
            SecurityActions.setThreadContextClassLoader(oldThreadContextCL);
            DynamicServiceLoader.setClassLoaderAssociation(null);
         }
      }
      catch (Throwable th)
      {
          testResult = new TestResult(Status.FAILED, th);
      }

      if (testResult.getThrowable() != null)
          log.log(Level.SEVERE, "Error in test method: " + methodName, testResult.getThrowable());

      return testResult;
   }
View Full Code Here

      ObjectName oname = jmxTestRunner.registerMBean(mbeanServer);
     
      try
      {
         JMXTestRunnerMBean testRunner = getMBeanProxy(mbeanServer, oname, JMXTestRunnerMBean.class);
         TestResult result = testRunner.runTestMethodLocal(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 shouldReturnTestResult() throws Exception
   {
      MockTestRunner.add(new TestResult(Status.PASSED, null));
     
      ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
      TestResult result = executor.invoke(new MockTestExecutor());
     
      Assert.assertEquals(
            "Should have returned a passed test",
            MockTestRunner.wantedResults.getStatus(),
            result.getStatus());
     
      Assert.assertNull(
            "No Exception should have been thrown",
            result.getThrowable());
   }
View Full Code Here

   }
  
   @Test
   public void shouldReturnThrownException() throws Exception
   {
      MockTestRunner.add(new TestResult(Status.FAILED, new Exception().fillInStackTrace()));
     
      ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
      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());
     
   }
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.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.