0 Replies Latest reply on Oct 19, 2014 1:43 AM by huyang

    how Arquillian Supports multiple JavaArchive Deployments?


      I'm using Arquillian and TestNG to test java CDI components,such as DB service layer based on Mybatis.

      Hope that one TestNG unit correspond to one DB service.

      Use maven command: mvn test -Dtest=XXXService ,it worked fine.

      But use command: mvn test, run all tests, not worked.

      I tried some methods,for example,using singleton JavaArchive Deployment and different named @Deployment(name="xxxTest"),still failed.

      the dos error output as follow:




      ): Singleton is not set. Is your Thread.currentThread().getContextClassLoader()

      set correctly?



      Any one can help me?

      example code here.

      public abstract class TestNGBase<T> extends Arquillian {





          protected List<T> objs = new ArrayList<T>();





          protected T obj = null;





         /* @Deployment

          public static JavaArchive createDeployment() {

            return DeploymentSingleton.getInstance();







          public abstract void checked();





          public abstract void testCreate();





          public abstract void testUpdate();





          public abstract void testFind();





          public abstract void testDelete();








      public class UserServiceTest extends TestNGBase<User> {






          private UserService userService = null;





          @Deployment(name = "userServiceTest",order = 15)

          public static JavaArchive createDeployment() {

              return ShrinkWrap.create(JavaArchive.class, "test1.jar")







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









          public void checked() {








          @Test(dependsOnMethods = "checked")

          public void testCreate() {

              createOneUser("zhangsan", "zhangsan", "zhangsan@qq.com", "salt1");





              createOneUser("lisi", "lisi", "lisi@qq.com", "salt2");





              createOneUser("wangwu", "wangwu", "wangwu@qq.com", "salt3");












          @Test(dependsOnMethods = "testCreate")

          public void testUpdate() {











          @Test(dependsOnMethods = "testUpdate")

          public void testFind() {

              for (User u : objs) {







              for (User u : objs) {









          @Test(dependsOnMethods = "testFind")

          public void testDelete() {


              int mid = objs.size() / 2;

              for (int i = objs.size() - 1; i > mid; i--) {

                  boolean flag = userService.remove(objs.get(i).getId());

                  Assert.assertEquals(flag, true);


              for (int i = mid; i >= 0; i--) {

                  boolean flag = userService.remove(objs.get(i).getUsername());

                  Assert.assertEquals(flag, true);











              for (User user : objs) {








          private void createOneUser(String username, String password, String email, String salt) {

              User.UserBuilder builder = new User.UserBuilder();

              builder = builder.username(username).password(password).email(email).salt(salt);

              User user = builder.build();