2 Replies Latest reply on Dec 8, 2014 10:37 AM by jingram

    Switchyard EntityManager MixIn Contribution

    jingram

      Hi


      I had a requirement to test SwitchYard services using an Entity Manager.

      I ended up writing our own Entity Manager MixIn that we would like to contribute back to SwitchYard.

      The Entity Manager MixIn is transaction boundary aware for both threads and transactions within a thread.

      It also utilises the transaction manager from the Transaction

       

      I would like to find out if this is something that can be contributed back to the community and if so please could a community member assist me in the best practice for contributing this MixIn to the project including level of test cases to be passed.

       

      Example of code

      @SwitchYardTestCaseConfig(config = SwitchYardTestCaseConfig.SWITCHYARD_XML, exclude = "jms", mixins = { CDIMixIn.class, NamingMixIn.class, TransactionMixIn.class, EntityManagerMixIn.class })

      public class AccessRouteTest  {

         protected EntityManagerMixIn entityManagerMixIn;

       

        @BeforeDeploy

        public void beforeDeploy() throws NamingException {

           JdbcDataSource ds = new JdbcDataSource();

           ds.setURL("jdbc:h2:mem:oracle-brm-service");

           ds.setUser("sa");

           ds.setPassword("sa");

       

       

          InitialContext initialContext = namingMixIn.getInitialContext();

          initialContext.bind("java:jboss/datasources/OracleBRM", ds);

       

          EntityManagerFactory emf = Persistence.createEntityManagerFactory("oracle-brm-service");

          entityManagerMixIn.setEntityManagerFactory("oracle-brm-service", emf);

        }

       

      }