Return-Path: X-Original-To: apmail-deltaspike-users-archive@www.apache.org Delivered-To: apmail-deltaspike-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 932DE179F0 for ; Mon, 6 Apr 2015 20:14:48 +0000 (UTC) Received: (qmail 5817 invoked by uid 500); 6 Apr 2015 20:14:48 -0000 Delivered-To: apmail-deltaspike-users-archive@deltaspike.apache.org Received: (qmail 5780 invoked by uid 500); 6 Apr 2015 20:14:48 -0000 Mailing-List: contact users-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@deltaspike.apache.org Delivered-To: mailing list users@deltaspike.apache.org Received: (qmail 5764 invoked by uid 99); 6 Apr 2015 20:14:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 20:14:48 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rmpestano@gmail.com designates 209.85.192.176 as permitted sender) Received: from [209.85.192.176] (HELO mail-pd0-f176.google.com) (209.85.192.176) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 20:14:23 +0000 Received: by pdbni2 with SMTP id ni2so54770747pdb.1 for ; Mon, 06 Apr 2015 13:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=Nx7kDa2tAlnZadVDzT4rFbh+40IahgtpNm5F+zmLLjQ=; b=BdQojRraOos2gbNRK3wtIZE3dmvgaykH3+sZ30H1qWM2NmJE3uX0FbtpswEet7iT8P 6emv1Db3kDSqsGgrNOnAiIFJjnTvjKbSjJZvopNaRr5dSWrRDL/IOe7eDx4J8P3vPpX0 hOj0fuUOQwBkM9U+YLfdqD21yGcKkrqwFgNS7iZleJDEw5Sv3DUbaREkb4//hw/PlrgE r12TbNGSgLypCGft94/urpYGNy5sDwRDcfNZkwtFw4FjMcd9B+hb1lFk/ot6EghqYn1B Tzcs1kc1SbbwV2DYVqaSI4FdTN5zk4cBT89WSoa/XusEgstO46/GD+yoI3Uegu441wMl E9UQ== X-Received: by 10.70.55.8 with SMTP id n8mr30429902pdp.167.1428351171355; Mon, 06 Apr 2015 13:12:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.16.161 with HTTP; Mon, 6 Apr 2015 13:12:31 -0700 (PDT) From: Rafael Pestano Date: Mon, 6 Apr 2015 17:12:31 -0300 Message-ID: Subject: Best approach for testing repositories To: users@deltaspike.apache.org Content-Type: multipart/alternative; boundary=089e0160c2822eeb90051313ec65 X-Virus-Checked: Checked by ClamAV on apache.org --089e0160c2822eeb90051313ec65 Content-Type: text/plain; charset=UTF-8 Hi everyone, besides OpenEJB and cdi-control-ejb used in [1] what are the alternatives (in terms of Destaspike) for testing JPA based repositories? For out container integration tests i usually use something like this: @Before public void inicializarCenario() throws Exception { startConnection(); } @After public void finalizarCenario() { closeConnection(); } public void startConnection() { emf = Persistence.createEntityManagerFactory("TEST_PU"); em = emf.createEntityManager(); em.getTransaction().begin(); } public void closeConnection() { em.getTransaction().commit(); emf.close(); } TEST_PU is in test resources and usually uses in memory db, something like below: org.hibernate.ejb.HibernatePersistence The idea is to be "lighweight" and boot only JPA container so my repositories can use the "test entityManager? I think of something like this: @RunWith(CdiTestRunner.class) @TestControl(startPersistentUnits("TEST_PU")) public class UserRepositoryTest { @Inject UserRepository userRepository; @Test public void shouldInserUser(){ User u = new User(); userRepository.save(u); assertFalse(user.isTransient()); } } Can we reach somethink like that with Deltaspike test control? I also would like to integrate with dbunit so I can feed this test datasource but thats another story WDYT? [1] https://github.com/os890/ee6-ds-demo/blob/master/src/test/java/org/os890/demo/ee6/test/PageBeanTest.java -- Att, Rafael M. Pestano Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul http://rpestano.wordpress.com/ @realpestano --089e0160c2822eeb90051313ec65--