1 Reply Latest reply on Nov 10, 2015 11:57 AM by Rafael Neves

    Arquillian Suite Extension Error

    nek b Newbie

      0down votefavorite

       

       

      I am having issue with integrating Arquillian Suite Extension.

      I am following steps from this link https://github.com/ingwarsw/arquillian-suite-extension#easiest-way-to-move-to-suite

      And I have added the required Deployment class and the run class.

      Here is my error.

      java.lang.RuntimeException: Could not invoke operation at org.eu.ingwar.tools.arquillian.extension.suite.ArquillianSuiteExtension$SuiteDeployer.executeInClassScope(ArquillianSuiteExtension.java:210) at org.eu.ingwar.tools.arquillian.extension.suite.ArquillianSuiteExtension$SuiteDeployer.startup(ArquillianSuiteExtension.java:176) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:65) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116) at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeSuite(EventTestRunnerAdaptor.java:68) at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:104) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

      Thanks

      Nek

        • 1. Re: Arquillian Suite Extension Error
          Rafael Neves Newbie

          Hi nek, how are you? fine? me too.

           

          I try using this extension too and don't have success in my project.

          I search the solution and found this discussion of arquillians developers. so arquillian will native supports for Suite class in version 1.2.0.Alpha1 of Core api.

          For now I create my solution for this problem (workaround), creating a Suite Class like that:

           

          Suite class api

           

          /**
          *
          * @author Rafael Jesus
          *
          *         Data de criação: 29/10/2015</br>
          *
          *         Descrição do arquivo ApplicationSuiteAPITest.java:</br> This application suite class is a workaround for suite all arquillian tests that doesn't supports suite</br>
           *         see more in this <a href="http://discuss.arquillian.org/t/arquillian-core-suite-subsuite-how-to-define-the-suite/163/27">discussion</a></br>
          *         When this code are merged in 1.2.0.Alpha1 version of core, this interface will be deprecated.
          *
          *         ---------------------------------------------
          *
          *         ---------------------------------------------
          */
          @RunWith(Arquillian.class)
          @RunAsClient
          public class ApplicationSuiteAPITest {
            
              @ArquillianResource
              private URL contextPath;
            
              public URL getContextPath() {
                  return contextPath;
              }
          
              public void setContextPath(URL contextPath) {
                  this.contextPath = contextPath;
              }
              private List<ISuiteAPITest> tests = null;
            
              @Deployment(testable = true, managed = true, name = "simple")
              @OverProtocol("Servlet 2.5")
                 public static Archive<?> createTestArchive() {
                  return ShrinkWrap.create(WebArchive.class, "app.war")
                          .addAsWebInfResource("applicationContext-arquillian-test.xml", "applicationContext.xml" )
                          ... //all files your application needs
                          .setWebXML("in-container-web.xml");
              }
            
              /**
               * After load all tests class.
               *
               * @author Rafael Jesus
               */
              @Before
              public void setUp() {
                  tests = loadAllTests();
              }
            
              /**
               * This code was adapted of following discussion:</br>
               * <a href="http://stackoverflow.com/questions/3949260/java-class-isinstance-vs-class-isassignablefrom">Class.isInstance vs Class.isAssignableFrom</a>
               * @return List of class for tests with arquillian
               * @author Rafael Jesus
               */
              private List<ISuiteAPITest> loadAllTests() {
          
                  List<ISuiteAPITest> tests = new ArrayList<ISuiteAPITest>();
          
                  try {
                      // create scanner and disable default filters (that is the 'false' argument)
                      ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(
                              false);
                      // add include filters which matches all the classes (or use your own)
                      provider.addIncludeFilter(new RegexPatternTypeFilter(Pattern.compile(".*")));
          
                      // get matching classes defined in the package
                      final Set<BeanDefinition> classes = provider.findCandidateComponents("com.app.app.api");
          
                      // this is how you can load the class type from BeanDefinition instance
                      for (BeanDefinition bean : classes) {
                          Class<?> clazz = Class.forName(bean.getBeanClassName());
                          if (!Modifier.isAbstract(clazz.getModifiers()) && !clazz.isMemberClassa !clazz.isAnonymousClass()) {
                              Object obj = clazz.newInstance();
                              if (ISuiteAPITest.class.isInstance(obj)) {
                                  tests.add((ISuiteAPITest) obj);
                              }
                          }
                      }
                  } catch (Exception e) {
                      Assert.fail(e.getMessage());
                  }
          
                  return tests;
              }
          
              /**
               * Runing all tests for each test class loaded in List<ISuiteAPITest> before.
               *
               * @author Rafael Jesus
               */
              @Test
              public void testApplicationAPI() {
                
                  for (ISuiteAPITest test : tests) {
                      test.setContextPath(getContextPath());
          
                      test.runingSetUps();
                      test.runTests();
                      test.runningTearDowns();
                  }
                
                  System.out.println("number of api tests running in suite application: " + tests.size());
              }
          
          
          

           

          Interface:

           

          /**
          *
          * @author Rafael Jesus
          *
          *         Data de criação: 29/10/2015</br>
          *
          *         Descrição do arquivo ISuiteAPITest.java:</br> This application suite interface is a workaround for suite all arquillian tests that doesn't supports suite</br>
           *         see more in this <a href="http://discuss.arquillian.org/t/arquillian-core-suite-subsuite-how-to-define-the-suite/163/27">discussion</a></br>. 
          *         When this code are merged in 1.2.0.Alpha1 version of core, this interface will be deprecated.
          *
          *         ---------------------------------------------
          *
          *         ---------------------------------------------
          */
          public interface ISuiteAPITest {
            
          
              /**
               * runing all setUp tests.
               *
               * @author Rafael Jesus
               */
              public void runingSetUps();
            
              /**
               * Runing all tests
               *
               * @author Rafael Jesus
               */
              public void runTests();
            
              /**
               * runing all tearDown tests.
               *
               * @author Rafael Jesus
               */
              public void runningTearDowns();
            
              /**
               * inject contextPath for <b>BaseAPITest</b> class
               *
               * @author Rafael Jesus
               */
              public void setContextPath(URL contextPath);
          }
          
          
          

           

          test class example using suite api.

          /**
          *
          * @author Rafael Jesus
          *
          *         Data de criação: 28/04/2015
          *
          *         Descrição do arquivo UserLogControllerAPITest.java: Integration tests for controller UserLogController.java class
          *
          *         ---------------------------------------------
          *
          *
          *         ---------------------------------------------
          */
          @Ignore
          public class UserLogControllerAPITest extends BaseAPITest<UserLogDTO> implements ISuiteAPITest {
          
              private static final String CONTROLLER_PATH = UserLogController.CONTROLLER_PATH;
              private Long createdProjectId = null;
          
              @Override
              public void injectClazzBaseDTO() {
                  setClazzBaseDTO(UserLogDTO.class);
              }
            
              /**
               *  Set up all information needed
               * @author Rafael Jesus
               */
              @Before
              public void setUp(){
                  //all methods needed
              }
            
            
          
              /**
               *  retrieves log for project base(BaseAPITest.PROJECT_ID = 36)
               * @author Rafael Jesus
               */
              @Test
              public void testGetUserLogProjectBaseAPI() {
          
                  //your test implementation
              }
          
              @Override
              public boolean requireAuthentication() {
                  return true;
              }
          
              @Override
              public void runingSetUps() {
                  injectClazzBaseDTO();
                  setUp();
              }
          
              @Override
              public void runTests() {
                  testGetUserLogProjectBaseAPI();      
              }
          
              @Override
              public void runningTearDowns() {
            
              }
          
          }