0 Replies Latest reply on Nov 3, 2018 9:08 AM by davidsonalexia

    Arquillian test cannot deploy with class with dependecy injections


      When I try to run the test with the SessionController class then I get the following error :

      Tests in error:

        service.SessionTest: Cannot deploy: test.war



      public class SessionTest {
      public static Archive<?> createTestArchive() {
      return ShrinkWrap.create(WebArchive.class, "test.war")
      // enable JPA
      .addAsResource(new File("src/main/resources/META-INF/persistence.xml"))
      // enable CDI
      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
      // Deploy our test datasource
      .addAsWebInfResource(new File("src/main/webapp/WEB-INF/el-ds.xml"));
      Session sess;


      However when I remove the SessionController and add any other package the tests run fine. I can't find the error in my code. Please help.

      Some bits of code were removed for confidentiality but here is the SessionController class.

      public class SessionController {
      private Logger logger = Logger.getLogger(this.getClass());
      TimerService timerService;
      @PersistenceUnit(unitName = "mssql")
      private EntityManagerFactory emf;
      private ArchiveService archiveService;
      private AppConfigService appConfigService;
      private DateTimeOffsetService dateTimeOffsetService;
      private AuthenticationService authenticationService;
      private AuthorisationService authorisationService;
      private CacheService cacheService;
      private ActionHandlerService actionHandlerService;
      private LoginService loginService;
      private CrmTranscriptService crmTranscriptService;
      private LockService lockService;
      public ObjectNode processSession(String sessionId, ObjectNode requestNode, HttpServletRequest httpServletRequest)
      throws IOException {
      // Get body of the requestNode. This is the HTTP request body.
      // Used for reading only.
      JsonNode requestBodyNode = requestNode.get("body");
      // Create responseNode to be returned. responseNodeDataNode is nested inside.
      ObjectMapper mapper = new ObjectMapper();
      ObjectNode responseNode = mapper.createObjectNode();
      ObjectNode responseDataNode = mapper.createObjectNode();
      String sessionType = requestBodyNode.get("sessionType").asText();
      logger.info("Handling sessionType '" + sessionType + "' for sessionId '" + sessionId + "'.");
      Session session = null;
      switch (sessionType) { }