Commit 58d2f13f697f687605cf312ae655dfb2a784ac7b

Authored by Cleverson Sacramento
2 parents 27c4840d 2cb389a3
Exists in master

Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into

2.4.0

Conflicts:
	impl/extension/jdbc/src/test/resources/transaction/demoiselle.properties
	impl/extension/jpa/src/test/java/template/JPACrudTest.java
	impl/extension/jta/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.java
Showing 24 changed files with 958 additions and 357 deletions   Show diff stats
impl/core/.gitignore
@@ -4,3 +4,4 @@ @@ -4,3 +4,4 @@
4 /.settings 4 /.settings
5 /.externalToolBuilders 5 /.externalToolBuilders
6 /.DS_Store 6 /.DS_Store
  7 +/bin
impl/extension/jdbc/src/test/java/transaction/MyEntity.java 0 → 100644
@@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package transaction;
  38 +
  39 +public class MyEntity {
  40 +
  41 + private int id;
  42 +
  43 + private String description;
  44 +
  45 + public int getId() {
  46 + return id;
  47 + }
  48 +
  49 + public void setId(int id) {
  50 + this.id = id;
  51 + }
  52 +
  53 + public String getDescription() {
  54 + return description;
  55 + }
  56 +
  57 + public void setDescription(String description) {
  58 + this.description = description;
  59 + }
  60 +}
impl/extension/jdbc/src/test/java/transaction/MyEntity1.java
@@ -1,60 +0,0 @@ @@ -1,60 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package transaction;  
38 -  
39 -public class MyEntity1 {  
40 -  
41 - private int id;  
42 -  
43 - private String description;  
44 -  
45 - public int getId() {  
46 - return id;  
47 - }  
48 -  
49 - public void setId(int id) {  
50 - this.id = id;  
51 - }  
52 -  
53 - public String getDescription() {  
54 - return description;  
55 - }  
56 -  
57 - public void setDescription(String description) {  
58 - this.description = description;  
59 - }  
60 -}  
impl/extension/jdbc/src/test/java/transaction/TransactionTest.java
@@ -37,6 +37,9 @@ @@ -37,6 +37,9 @@
37 37
38 package transaction; 38 package transaction;
39 39
  40 +import java.sql.Connection;
  41 +import java.sql.SQLException;
  42 +
40 import javax.inject.Inject; 43 import javax.inject.Inject;
41 44
42 import junit.framework.Assert; 45 import junit.framework.Assert;
@@ -52,6 +55,8 @@ import test.Tests; @@ -52,6 +55,8 @@ import test.Tests;
52 import br.gov.frameworkdemoiselle.transaction.JDBCTransaction; 55 import br.gov.frameworkdemoiselle.transaction.JDBCTransaction;
53 import br.gov.frameworkdemoiselle.transaction.Transaction; 56 import br.gov.frameworkdemoiselle.transaction.Transaction;
54 import br.gov.frameworkdemoiselle.transaction.TransactionContext; 57 import br.gov.frameworkdemoiselle.transaction.TransactionContext;
  58 +import br.gov.frameworkdemoiselle.util.Beans;
  59 +import br.gov.frameworkdemoiselle.util.NameQualifier;
55 60
56 @RunWith(Arquillian.class) 61 @RunWith(Arquillian.class)
57 public class TransactionTest { 62 public class TransactionTest {
@@ -107,18 +112,17 @@ public class TransactionTest { @@ -107,18 +112,17 @@ public class TransactionTest {
107 112
108 @Test 113 @Test
109 public void commitWithSuccess() throws Exception{ 114 public void commitWithSuccess() throws Exception{
  115 + MyEntity m = new MyEntity();
  116 + m.setId(1);
  117 + m.setDescription("desc-1");
110 118
111 - MyEntity1 m1 = new MyEntity1();  
112 - m1.setId(1);  
113 - m1.setDescription("desc-1");  
114 -  
115 - tb.insert(m1); 119 + tb.insert(m);
116 120
117 - Assert.assertEquals("desc-1", tb.find(m1.getId()).getDescription()); 121 + Assert.assertEquals("desc-1", tb.find(m.getId()).getDescription());
118 122
119 - tb.delete(m1); 123 + tb.delete(m);
120 124
121 - Assert.assertNull(tb.find(m1.getId()).getDescription()); 125 + Assert.assertNull(tb.find(m.getId()).getDescription());
122 } 126 }
123 127
124 @Test 128 @Test
@@ -129,8 +133,22 @@ public class TransactionTest { @@ -129,8 +133,22 @@ public class TransactionTest {
129 Assert.assertEquals("Exceção criada para marcar transação para rollback", e.getMessage()); 133 Assert.assertEquals("Exceção criada para marcar transação para rollback", e.getMessage());
130 } 134 }
131 finally{ 135 finally{
132 - MyEntity1 m1 = tb.find(3);  
133 - Assert.assertNull(tb.find(m1.getId()).getDescription()); 136 + MyEntity m = tb.find(3);
  137 + Assert.assertNull(tb.find(m.getId()).getDescription());
134 } 138 }
135 } 139 }
  140 +
  141 + @Test(expected=SQLException.class)
  142 + public void closedConnection() throws Exception{
  143 + MyEntity m = new MyEntity();
  144 + m.setId(1);
  145 + m.setDescription("desc-1");
  146 +
  147 + tb.insertWithouTransaction(m);
  148 +
  149 + Connection conn = Beans.getReference(Connection.class, new NameQualifier("conn"));
  150 + conn.close();
  151 +
  152 + tb.find(m.getId());
  153 + }
136 } 154 }
impl/extension/jdbc/src/test/java/transaction/TransactionalBusiness.java
@@ -49,8 +49,8 @@ import br.gov.frameworkdemoiselle.transaction.Transactional; @@ -49,8 +49,8 @@ import br.gov.frameworkdemoiselle.transaction.Transactional;
49 public class TransactionalBusiness { 49 public class TransactionalBusiness {
50 50
51 @Inject 51 @Inject
52 - @Name("conn1")  
53 - private Connection conn1; 52 + @Name("conn")
  53 + private Connection conn;
54 54
55 @Inject 55 @Inject
56 private TransactionContext transactionContext; 56 private TransactionContext transactionContext;
@@ -65,47 +65,53 @@ public class TransactionalBusiness { @@ -65,47 +65,53 @@ public class TransactionalBusiness {
65 } 65 }
66 66
67 @Transactional 67 @Transactional
68 - public void insert(MyEntity1 m) throws Exception { 68 + public void insert(MyEntity m) throws Exception {
69 String sql = "insert into myentity (id, description) values (" + m.getId() + ", '" + m.getDescription() + "')"; 69 String sql = "insert into myentity (id, description) values (" + m.getId() + ", '" + m.getDescription() + "')";
70 - Statement st = conn1.createStatement(); 70 + Statement st = conn.createStatement();
71 st.executeUpdate(sql); 71 st.executeUpdate(sql);
72 st.close(); 72 st.close();
73 } 73 }
  74 +
  75 + public void insertWithouTransaction(MyEntity m) throws Exception {
  76 + String sql = "insert into myentity (id, description) values (" + m.getId() + ", '" + m.getDescription() + "')";
  77 + Statement st = conn.createStatement();
  78 + st.executeUpdate(sql);
  79 + st.close();
  80 + }
  81 +
74 82
75 @Transactional 83 @Transactional
76 - public void delete(MyEntity1 m1) throws Exception { 84 + public void delete(MyEntity m1) throws Exception {
77 String sql = "delete from myentity where id = " + m1.getId(); 85 String sql = "delete from myentity where id = " + m1.getId();
78 - Statement st = conn1.createStatement(); 86 + Statement st = conn.createStatement();
79 st.executeUpdate(sql); 87 st.executeUpdate(sql);
80 st.close(); 88 st.close();
81 } 89 }
82 90
83 - @Transactional  
84 - public MyEntity1 find(int id) throws Exception { 91 + public MyEntity find(int id) throws Exception {
85 String sql = "select * from myentity where id = " + id; 92 String sql = "select * from myentity where id = " + id;
86 - Statement st = conn1.createStatement(); 93 + Statement st = conn.createStatement();
87 ResultSet rs = st.executeQuery(sql); 94 ResultSet rs = st.executeQuery(sql);
88 95
89 - MyEntity1 m1 = new MyEntity1(); 96 + MyEntity m = new MyEntity();
90 while (rs.next()) { 97 while (rs.next()) {
91 - m1.setId(rs.getInt(1));  
92 - m1.setDescription(rs.getString(2)); 98 + m.setId(rs.getInt(1));
  99 + m.setDescription(rs.getString(2));
93 } 100 }
94 101
95 rs.close(); 102 rs.close();
96 st.close(); 103 st.close();
97 104
98 - return m1; 105 + return m;
99 } 106 }
100 107
101 @Transactional 108 @Transactional
102 public void rollbackWithSuccess() throws Exception { 109 public void rollbackWithSuccess() throws Exception {
103 - MyEntity1 m1 = new MyEntity1();  
104 - m1.setId(3); 110 + MyEntity m = new MyEntity();
  111 + m.setId(3);
105 112
106 - this.insert(m1); 113 + this.insert(m);
107 114
108 throw new Exception("Exceção criada para marcar transação para rollback"); 115 throw new Exception("Exceção criada para marcar transação para rollback");
109 } 116 }
110 -  
111 } 117 }
impl/extension/jdbc/src/test/resources/transaction/demoiselle.properties
@@ -36,4 +36,4 @@ @@ -36,4 +36,4 @@
36 frameworkdemoiselle.persistence.conn1.driver.class=org.hsqldb.jdbcDriver 36 frameworkdemoiselle.persistence.conn1.driver.class=org.hsqldb.jdbcDriver
37 frameworkdemoiselle.persistence.conn1.url=jdbc:hsqldb:mem:hsql 37 frameworkdemoiselle.persistence.conn1.url=jdbc:hsqldb:mem:hsql
38 frameworkdemoiselle.persistence.conn1.username=sa 38 frameworkdemoiselle.persistence.conn1.username=sa
39 -frameworkdemoiselle.persistence.conn1.password=  
40 \ No newline at end of file 39 \ No newline at end of file
  40 +frameworkdemoiselle.persistence.conn1.password=
impl/extension/jpa/src/test/java/template/JPACrudTest.java
@@ -4,11 +4,14 @@ import static junit.framework.Assert.assertEquals; @@ -4,11 +4,14 @@ import static junit.framework.Assert.assertEquals;
4 import static junit.framework.Assert.assertNotNull; 4 import static junit.framework.Assert.assertNotNull;
5 import static junit.framework.Assert.assertNull; 5 import static junit.framework.Assert.assertNull;
6 6
  7 +import java.util.List;
  8 +
7 import javax.inject.Inject; 9 import javax.inject.Inject;
8 10
9 import org.jboss.arquillian.container.test.api.Deployment; 11 import org.jboss.arquillian.container.test.api.Deployment;
10 import org.jboss.arquillian.junit.Arquillian; 12 import org.jboss.arquillian.junit.Arquillian;
11 import org.jboss.shrinkwrap.api.spec.WebArchive; 13 import org.jboss.shrinkwrap.api.spec.WebArchive;
  14 +import org.junit.Before;
12 import org.junit.Test; 15 import org.junit.Test;
13 import org.junit.runner.RunWith; 16 import org.junit.runner.RunWith;
14 17
@@ -30,6 +33,13 @@ public class JPACrudTest { @@ -30,6 +33,13 @@ public class JPACrudTest {
30 return deployment; 33 return deployment;
31 } 34 }
32 35
  36 + @Before
  37 + public void eraseData() {
  38 + for(MyEntity myEntity : crud.findAll()) {
  39 + crud.delete(myEntity.getId());
  40 + }
  41 + }
  42 +
33 @Test 43 @Test
34 public void successfullyInserted() { 44 public void successfullyInserted() {
35 populate(1, 0); 45 populate(1, 0);
@@ -61,6 +71,16 @@ public class JPACrudTest { @@ -61,6 +71,16 @@ public class JPACrudTest {
61 assertEquals("update example", persisted.getDescription()); 71 assertEquals("update example", persisted.getDescription());
62 } 72 }
63 73
  74 + @Test
  75 + public void findAll() {
  76 + populate(4, 0);
  77 +
  78 + List<MyEntity> list;
  79 + list = crud.findAll();
  80 +
  81 + assertEquals(list.size(), 4);
  82 + }
  83 +
64 private void populate(int size, int offset) { 84 private void populate(int size, int offset) {
65 MyEntity entity; 85 MyEntity entity;
66 86
impl/extension/jta/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.java
@@ -1,220 +0,0 @@ @@ -1,220 +0,0 @@
1 -///*  
2 -// * Demoiselle Framework  
3 -// * Copyright (C) 2010 SERPRO  
4 -// * ----------------------------------------------------------------------------  
5 -// * This file is part of Demoiselle Framework.  
6 -// *  
7 -// * Demoiselle Framework is free software; you can redistribute it and/or  
8 -// * modify it under the terms of the GNU Lesser General Public License version 3  
9 -// * as published by the Free Software Foundation.  
10 -// *  
11 -// * This program is distributed in the hope that it will be useful,  
12 -// * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 -// * GNU General Public License for more details.  
15 -// *  
16 -// * You should have received a copy of the GNU Lesser General Public License version 3  
17 -// * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 -// * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 -// * Fifth Floor, Boston, MA 02110-1301, USA.  
20 -// * ----------------------------------------------------------------------------  
21 -// * Este arquivo é parte do Framework Demoiselle.  
22 -// *  
23 -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 -// * do Software Livre (FSF).  
26 -// *  
27 -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 -// * para maiores detalhes.  
31 -// *  
32 -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 -// * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 -// * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 -// */  
37 -//  
38 -//package br.gov.frameworkdemoiselle.transaction;  
39 -//  
40 -//import javax.transaction.HeuristicMixedException;  
41 -//import javax.transaction.HeuristicRollbackException;  
42 -//import javax.transaction.NotSupportedException;  
43 -//import javax.transaction.RollbackException;  
44 -//import javax.transaction.SystemException;  
45 -//import javax.transaction.UserTransaction;  
46 -//  
47 -//import junit.framework.Assert;  
48 -//  
49 -//import org.junit.Before;  
50 -//import org.junit.Test;  
51 -//import org.junit.runner.RunWith;  
52 -//  
53 -//import br.gov.frameworkdemoiselle.DemoiselleException;  
54 -//import br.gov.frameworkdemoiselle.util.Beans;  
55 -//  
56 -//@RunWith(PowerMockRunner.class)  
57 -//@PrepareForTest({ Beans.class })  
58 -//public class JTATransactionTest {  
59 -//  
60 -// private UserTransaction userTransaction;  
61 -//  
62 -// private JTATransaction jtaTransaction;  
63 -//  
64 -// @Before  
65 -// public void setUp() {  
66 -// userTransaction = createMock(UserTransaction.class);  
67 -// jtaTransaction = new JTATransaction();  
68 -//  
69 -// setInternalState(jtaTransaction, UserTransaction.class, userTransaction);  
70 -// }  
71 -//  
72 -// @Test  
73 -// public void testGetDElegateWithUserTransactionNull() throws SystemException {  
74 -// mockStatic(Beans.class);  
75 -// userTransaction = null;  
76 -// setInternalState(jtaTransaction, UserTransaction.class, userTransaction);  
77 -// userTransaction = createMock(UserTransaction.class);  
78 -// expect(Beans.getReference(UserTransaction.class)).andReturn(userTransaction);  
79 -// replayAll();  
80 -//  
81 -// // Assert.assertEquals(userTransaction, jtaTransaction.getDelegate());  
82 -// }  
83 -//  
84 -// @Test  
85 -// public void testGetDElegateWithUserTransactionIsNotNull() throws SystemException {  
86 -// // Assert.assertEquals(userTransaction, jtaTransaction.getDelegate());  
87 -// }  
88 -//  
89 -// @Test  
90 -// public void testIsActiveWithStatusEqualsActive() throws SystemException {  
91 -// expect(userTransaction.getStatus()).andReturn(Integer.valueOf(0));  
92 -// replay(userTransaction);  
93 -// Assert.assertTrue(this.jtaTransaction.isActive());  
94 -// }  
95 -//  
96 -// @Test  
97 -// public void testIsActiveWithStatusEqualsMarkedRollback() throws SystemException {  
98 -// expect(userTransaction.getStatus()).andReturn(Integer.valueOf(1)).times(2);  
99 -// replay(userTransaction);  
100 -// Assert.assertTrue(this.jtaTransaction.isActive());  
101 -// }  
102 -//  
103 -// @Test  
104 -// public void testIsMarkedRollback() throws SystemException {  
105 -// expect(userTransaction.getStatus()).andReturn(Integer.valueOf(1));  
106 -// replay(userTransaction);  
107 -// Assert.assertTrue(this.jtaTransaction.isMarkedRollback());  
108 -// }  
109 -//  
110 -// @Test  
111 -// public void testBegin() throws SystemException, NotSupportedException {  
112 -// userTransaction.begin();  
113 -// replay(userTransaction);  
114 -// this.jtaTransaction.begin();  
115 -// verify();  
116 -// }  
117 -//  
118 -// @Test  
119 -// public void testCommit() throws SystemException, NotSupportedException, SecurityException, IllegalStateException,  
120 -// RollbackException, HeuristicMixedException, HeuristicRollbackException {  
121 -// userTransaction.commit();  
122 -// replay(userTransaction);  
123 -// this.jtaTransaction.commit();  
124 -// verify();  
125 -// }  
126 -//  
127 -// @Test  
128 -// public void testRollback() throws SystemException, NotSupportedException {  
129 -// userTransaction.rollback();  
130 -// replay(userTransaction);  
131 -// this.jtaTransaction.rollback();  
132 -// verify();  
133 -// }  
134 -//  
135 -// @Test  
136 -// public void testSetRollbackOnly() throws SystemException, NotSupportedException {  
137 -// userTransaction.setRollbackOnly();  
138 -// replay(userTransaction);  
139 -// this.jtaTransaction.setRollbackOnly();  
140 -// verify();  
141 -// }  
142 -//  
143 -// @Test  
144 -// public void testIsActiveThrowsSystemException() throws SystemException {  
145 -// expect(userTransaction.getStatus()).andThrow(new SystemException());  
146 -// replay(userTransaction);  
147 -// try {  
148 -// this.jtaTransaction.isActive();  
149 -// Assert.fail();  
150 -// } catch (DemoiselleException cause) {  
151 -// Assert.assertTrue(true);  
152 -// }  
153 -// }  
154 -//  
155 -// @Test  
156 -// public void testIsMarkedRollbackThrowsSystemException() throws SystemException {  
157 -// expect(userTransaction.getStatus()).andThrow(new SystemException());  
158 -// replay(userTransaction);  
159 -// try {  
160 -// this.jtaTransaction.isMarkedRollback();  
161 -// Assert.fail();  
162 -// } catch (DemoiselleException cause) {  
163 -// Assert.assertTrue(true);  
164 -// }  
165 -// }  
166 -//  
167 -// @Test  
168 -// public void testBeginThrowsException() throws SystemException, NotSupportedException {  
169 -// userTransaction.begin();  
170 -// expectLastCall().andThrow(new SystemException());  
171 -// replay(userTransaction);  
172 -// try {  
173 -// this.jtaTransaction.begin();  
174 -// Assert.fail();  
175 -// } catch (DemoiselleException cause) {  
176 -// Assert.assertTrue(true);  
177 -// }  
178 -// }  
179 -//  
180 -// @Test  
181 -// public void testCommitThrowsException() throws SystemException, SecurityException, IllegalStateException,  
182 -// RollbackException, HeuristicMixedException, HeuristicRollbackException {  
183 -// userTransaction.commit();  
184 -// expectLastCall().andThrow(new SystemException());  
185 -// replay(userTransaction);  
186 -// try {  
187 -// this.jtaTransaction.commit();  
188 -// Assert.fail();  
189 -// } catch (DemoiselleException cause) {  
190 -// Assert.assertTrue(true);  
191 -// }  
192 -// }  
193 -//  
194 -// @Test  
195 -// public void testRollbackThrowsSystemException() throws SystemException {  
196 -// userTransaction.rollback();  
197 -// expectLastCall().andThrow(new SystemException());  
198 -// replay(userTransaction);  
199 -// try {  
200 -// this.jtaTransaction.rollback();  
201 -// Assert.fail();  
202 -// } catch (DemoiselleException cause) {  
203 -// Assert.assertTrue(true);  
204 -// }  
205 -// }  
206 -//  
207 -// @Test  
208 -// public void testSetRollbackOnlyThrowsSystemException() throws SystemException {  
209 -// userTransaction.setRollbackOnly();  
210 -// expectLastCall().andThrow(new SystemException());  
211 -// replay(userTransaction);  
212 -// try {  
213 -// this.jtaTransaction.setRollbackOnly();  
214 -// Assert.fail();  
215 -// } catch (DemoiselleException cause) {  
216 -// Assert.assertTrue(true);  
217 -// }  
218 -// }  
219 -//  
220 -//}  
impl/extension/jta/src/test/java/jtatransaction/interceptor/InterceptorJTATransactionTest.java 0 → 100644
@@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
  1 +package jtatransaction.interceptor;
  2 +
  3 +import static junit.framework.Assert.assertEquals;
  4 +import static junit.framework.Assert.assertFalse;
  5 +import static junit.framework.Assert.assertNull;
  6 +
  7 +import javax.persistence.EntityManager;
  8 +import javax.persistence.PersistenceContext;
  9 +import javax.persistence.TransactionRequiredException;
  10 +
  11 +import org.jboss.arquillian.container.test.api.Deployment;
  12 +import org.jboss.arquillian.junit.Arquillian;
  13 +import org.jboss.shrinkwrap.api.spec.WebArchive;
  14 +import org.junit.Before;
  15 +import org.junit.Test;
  16 +import org.junit.runner.RunWith;
  17 +
  18 +import test.Tests;
  19 +import br.gov.frameworkdemoiselle.DemoiselleException;
  20 +import br.gov.frameworkdemoiselle.transaction.JTATransaction;
  21 +import br.gov.frameworkdemoiselle.transaction.TransactionContext;
  22 +import br.gov.frameworkdemoiselle.util.Beans;
  23 +
  24 +@RunWith(Arquillian.class)
  25 +public class InterceptorJTATransactionTest {
  26 +
  27 + private static final String PATH = "src/test/resources/interceptor";
  28 +
  29 + private TransactionContext transactionContext;
  30 +
  31 + @PersistenceContext(unitName="pu1")
  32 + private EntityManager em1;
  33 +
  34 + @PersistenceContext(unitName="pu2")
  35 + private EntityManager em2;
  36 +
  37 + @Deployment
  38 + public static WebArchive createDeployment() {
  39 + WebArchive deployment = Tests.createDeployment(InterceptorJTATransactionTest.class);
  40 + deployment.addAsResource(Tests.createFileAsset(PATH + "/persistence.xml"), "META-INF/persistence.xml");
  41 +
  42 + return deployment;
  43 + }
  44 +
  45 + @Before
  46 + public void clearDatabase(){
  47 + transactionContext = Beans.getReference(TransactionContext.class);
  48 +
  49 + transactionContext.getCurrentTransaction().begin();
  50 + em1.joinTransaction();
  51 + em2.joinTransaction();
  52 + em1.createQuery("DELETE FROM MyEntity1").executeUpdate();
  53 + em2.createQuery("DELETE FROM MyEntity2").executeUpdate();
  54 + em1.flush();
  55 + em2.flush();
  56 + em1.clear();
  57 + em2.clear();
  58 + transactionContext.getCurrentTransaction().commit();
  59 + }
  60 +
  61 + @Test
  62 + public void checkJTATransactionType() {
  63 + assertEquals(JTATransaction.class, transactionContext.getCurrentTransaction().getClass());
  64 + }
  65 +
  66 + @Test
  67 + public void commitWithSuccess() {
  68 +
  69 + TransactionalBusiness business = Beans.getReference(TransactionalBusiness.class);
  70 +
  71 + business.commitWithSuccess();
  72 +
  73 + MyEntity1 persisted1 = em1.find(MyEntity1.class, TransactionalBusiness.createId("id-1"));
  74 + MyEntity2 persisted2 = em2.find(MyEntity2.class, TransactionalBusiness.createId("id-2"));
  75 +
  76 + assertEquals("desc-1", persisted1.getDescription());
  77 + assertEquals("desc-2", persisted2.getDescription());
  78 +
  79 + assertFalse(transactionContext.getCurrentTransaction().isActive());
  80 +
  81 + }
  82 +
  83 + @Test(expected = TransactionRequiredException.class)
  84 + public void checkNoTransactionAutomaticallyLoaded() {
  85 + TransactionalBusiness business = Beans.getReference(TransactionalBusiness.class);
  86 + business.checkNoTransactionAutomaticallyLoaded();
  87 + }
  88 +
  89 + @Test
  90 + public void rollbackWithSuccess() {
  91 + TransactionalBusiness business = Beans.getReference(TransactionalBusiness.class);
  92 + try{
  93 + business.rollbackWithSuccess();
  94 + }
  95 + catch(DemoiselleException de){
  96 + //Exceção esperada
  97 + }
  98 +
  99 + MyEntity1 persisted1 = em1.find(MyEntity1.class, TransactionalBusiness.createId("id-3"));
  100 + MyEntity2 persisted2 = em2.find(MyEntity2.class, TransactionalBusiness.createId("id-4"));
  101 + assertNull(persisted1);
  102 + assertNull(persisted2);
  103 + }
  104 +
  105 +}
impl/extension/jta/src/test/java/jtatransaction/interceptor/MyEntity1.java 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +package jtatransaction.interceptor;
  2 +
  3 +import javax.persistence.Entity;
  4 +import javax.persistence.Id;
  5 +
  6 +@Entity
  7 +public class MyEntity1 {
  8 +
  9 + @Id
  10 + private String id;
  11 +
  12 + private String description;
  13 +
  14 + public String getId() {
  15 + return id;
  16 + }
  17 +
  18 + public void setId(String id) {
  19 + this.id = id;
  20 + }
  21 +
  22 + public String getDescription() {
  23 + return description;
  24 + }
  25 +
  26 + public void setDescription(String description) {
  27 + this.description = description;
  28 + }
  29 +}
impl/extension/jta/src/test/java/jtatransaction/interceptor/MyEntity2.java 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +package jtatransaction.interceptor;
  2 +
  3 +import javax.persistence.Entity;
  4 +import javax.persistence.Id;
  5 +
  6 +@Entity
  7 +public class MyEntity2 {
  8 +
  9 + @Id
  10 + private String id;
  11 +
  12 + private String description;
  13 +
  14 + public String getId() {
  15 + return id;
  16 + }
  17 +
  18 + public void setId(String id) {
  19 + this.id = id;
  20 + }
  21 +
  22 + public String getDescription() {
  23 + return description;
  24 + }
  25 +
  26 + public void setDescription(String description) {
  27 + this.description = description;
  28 + }
  29 +}
impl/extension/jta/src/test/java/jtatransaction/interceptor/TransactionalBusiness.java 0 → 100644
@@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
  1 +package jtatransaction.interceptor;
  2 +
  3 +import javax.persistence.EntityManager;
  4 +import javax.persistence.PersistenceContext;
  5 +
  6 +import br.gov.frameworkdemoiselle.DemoiselleException;
  7 +import br.gov.frameworkdemoiselle.stereotype.BusinessController;
  8 +import br.gov.frameworkdemoiselle.transaction.Transactional;
  9 +
  10 +@BusinessController
  11 +public class TransactionalBusiness {
  12 +
  13 + @PersistenceContext(unitName="pu1")
  14 + private EntityManager em1;
  15 +
  16 + @PersistenceContext(unitName="pu2")
  17 + private EntityManager em2;
  18 +
  19 + @Transactional
  20 + public void commitWithSuccess() {
  21 + MyEntity1 entity1 = new MyEntity1();
  22 + entity1.setId(createId("id-1"));
  23 + entity1.setDescription("desc-1");
  24 +
  25 + MyEntity2 entity2 = new MyEntity2();
  26 + entity2.setId(createId("id-2"));
  27 + entity2.setDescription("desc-2");
  28 +
  29 + em1.joinTransaction();
  30 + em2.joinTransaction();
  31 +
  32 + em1.persist(entity1);
  33 + em2.persist(entity2);
  34 +
  35 + em1.flush();
  36 + em2.flush();
  37 + }
  38 +
  39 + public void checkNoTransactionAutomaticallyLoaded() {
  40 + MyEntity1 entity = new MyEntity1();
  41 + entity.setId(createId("id-2"));
  42 +
  43 + em1.persist(entity);
  44 + em1.flush();
  45 + }
  46 +
  47 + @Transactional
  48 + public void rollbackWithSuccess() {
  49 + MyEntity1 entity1 = new MyEntity1();
  50 + entity1.setId(createId("id-3"));
  51 +
  52 + MyEntity2 entity2 = new MyEntity2();
  53 + entity2.setId(createId("id-4"));
  54 +
  55 + em1.joinTransaction();
  56 + em2.joinTransaction();
  57 +
  58 + em1.persist(entity1);
  59 + em2.persist(entity2);
  60 + em1.flush();
  61 + em2.flush();
  62 +
  63 + em1.clear();
  64 + em2.clear();
  65 +
  66 + throw new DemoiselleException("Forçando rollback");
  67 + }
  68 +
  69 + public static String createId(String id) {
  70 + return TransactionalBusiness.class.getName() + "_" + id;
  71 + }
  72 +
  73 +}
impl/extension/jta/src/test/java/jtatransaction/manual/ManualJTATransactionTest.java 0 → 100644
@@ -0,0 +1,149 @@ @@ -0,0 +1,149 @@
  1 +package jtatransaction.manual;
  2 +
  3 +import static junit.framework.Assert.assertEquals;
  4 +import static junit.framework.Assert.assertFalse;
  5 +import static junit.framework.Assert.assertNull;
  6 +import static junit.framework.Assert.assertTrue;
  7 +
  8 +import javax.persistence.EntityManager;
  9 +import javax.persistence.PersistenceContext;
  10 +import javax.persistence.TransactionRequiredException;
  11 +
  12 +import org.jboss.arquillian.container.test.api.Deployment;
  13 +import org.jboss.arquillian.junit.Arquillian;
  14 +import org.jboss.shrinkwrap.api.spec.WebArchive;
  15 +import org.junit.Before;
  16 +import org.junit.Test;
  17 +import org.junit.runner.RunWith;
  18 +
  19 +import test.Tests;
  20 +import br.gov.frameworkdemoiselle.transaction.JTATransaction;
  21 +import br.gov.frameworkdemoiselle.transaction.Transaction;
  22 +import br.gov.frameworkdemoiselle.transaction.TransactionContext;
  23 +import br.gov.frameworkdemoiselle.util.Beans;
  24 +
  25 +@RunWith(Arquillian.class)
  26 +public class ManualJTATransactionTest {
  27 +
  28 + private static final String PATH = "src/test/resources/manual";
  29 +
  30 + private TransactionContext transactionContext;
  31 +
  32 + @PersistenceContext(unitName="pu1")
  33 + private EntityManager em1;
  34 +
  35 + @PersistenceContext(unitName="pu2")
  36 + private EntityManager em2;
  37 +
  38 + @Deployment
  39 + public static WebArchive createDeployment() {
  40 + WebArchive deployment = Tests.createDeployment(ManualJTATransactionTest.class);
  41 + deployment.addAsResource(Tests.createFileAsset(PATH + "/persistence.xml"), "META-INF/persistence.xml");
  42 +
  43 + return deployment;
  44 + }
  45 +
  46 + @Before
  47 + public void clearDatabase(){
  48 + transactionContext = Beans.getReference(TransactionContext.class);
  49 +
  50 + transactionContext.getCurrentTransaction().begin();
  51 + em1.joinTransaction();
  52 + em2.joinTransaction();
  53 + em1.createQuery("DELETE FROM MyEntity1").executeUpdate();
  54 + em2.createQuery("DELETE FROM MyEntity2").executeUpdate();
  55 + em1.flush();
  56 + em2.flush();
  57 + em1.clear();
  58 + em2.clear();
  59 + transactionContext.getCurrentTransaction().commit();
  60 + }
  61 +
  62 + @Test
  63 + public void checkJTATransactionType() {
  64 + assertEquals(JTATransaction.class, transactionContext.getCurrentTransaction().getClass());
  65 + }
  66 +
  67 + @Test
  68 + public void commitWithSuccess() {
  69 + Transaction transaction = transactionContext.getCurrentTransaction();
  70 +
  71 + MyEntity1 entity1 = new MyEntity1();
  72 + entity1.setId(createId("id-1"));
  73 + entity1.setDescription("desc-1");
  74 +
  75 + MyEntity2 entity2 = new MyEntity2();
  76 + entity2.setId(createId("id-2"));
  77 + entity2.setDescription("desc-2");
  78 +
  79 + assertFalse(transaction.isActive());
  80 +
  81 + transaction.begin();
  82 + assertTrue(transaction.isActive());
  83 +
  84 + em1.joinTransaction();
  85 + em2.joinTransaction();
  86 +
  87 + em1.persist(entity1);
  88 + em2.persist(entity2);
  89 +
  90 + transaction.commit();
  91 + em1.clear();
  92 + em2.clear();
  93 +
  94 + MyEntity1 persisted1 = em1.find(MyEntity1.class, createId("id-1"));
  95 + MyEntity2 persisted2 = em2.find(MyEntity2.class, createId("id-2"));
  96 +
  97 + assertEquals("desc-1", persisted1.getDescription());
  98 + assertEquals("desc-2", persisted2.getDescription());
  99 + }
  100 +
  101 + @Test(expected = TransactionRequiredException.class)
  102 + public void checkNoTransactionAutomaticallyLoaded() {
  103 + MyEntity1 entity = new MyEntity1();
  104 + entity.setId(createId("id-2"));
  105 +
  106 + em1.persist(entity);
  107 + em1.flush();
  108 + }
  109 +
  110 + @Test
  111 + public void rollbackWithSuccess() {
  112 + Transaction transaction = transactionContext.getCurrentTransaction();
  113 +
  114 + MyEntity1 entity1 = new MyEntity1();
  115 + entity1.setId(createId("id-3"));
  116 +
  117 + MyEntity2 entity2 = new MyEntity2();
  118 + entity2.setId(createId("id-4"));
  119 +
  120 + assertFalse(transaction.isMarkedRollback());
  121 + transaction.begin();
  122 + assertTrue(transaction.isActive());
  123 +
  124 + em1.joinTransaction();
  125 + em2.joinTransaction();
  126 +
  127 + em1.persist(entity1);
  128 + em2.persist(entity2);
  129 + em1.flush();
  130 + em2.flush();
  131 + transaction.setRollbackOnly();
  132 +
  133 + if (transaction.isMarkedRollback()) {
  134 + transaction.rollback();
  135 + }
  136 +
  137 + em1.clear();
  138 + em2.clear();
  139 +
  140 + MyEntity1 persisted1 = em1.find(MyEntity1.class, createId("id-3"));
  141 + MyEntity2 persisted2 = em2.find(MyEntity2.class, createId("id-4"));
  142 + assertNull(persisted1);
  143 + assertNull(persisted2);
  144 + }
  145 +
  146 + private String createId(String id) {
  147 + return this.getClass().getName() + "_" + id;
  148 + }
  149 +}
impl/extension/jta/src/test/java/jtatransaction/manual/MyEntity1.java 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +package jtatransaction.manual;
  2 +
  3 +import javax.persistence.Entity;
  4 +import javax.persistence.Id;
  5 +
  6 +@Entity
  7 +public class MyEntity1 {
  8 +
  9 + @Id
  10 + private String id;
  11 +
  12 + private String description;
  13 +
  14 + public String getId() {
  15 + return id;
  16 + }
  17 +
  18 + public void setId(String id) {
  19 + this.id = id;
  20 + }
  21 +
  22 + public String getDescription() {
  23 + return description;
  24 + }
  25 +
  26 + public void setDescription(String description) {
  27 + this.description = description;
  28 + }
  29 +}
impl/extension/jta/src/test/java/jtatransaction/manual/MyEntity2.java 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +package jtatransaction.manual;
  2 +
  3 +import javax.persistence.Entity;
  4 +import javax.persistence.Id;
  5 +
  6 +@Entity
  7 +public class MyEntity2 {
  8 +
  9 + @Id
  10 + private String id;
  11 +
  12 + private String description;
  13 +
  14 + public String getId() {
  15 + return id;
  16 + }
  17 +
  18 + public void setId(String id) {
  19 + this.id = id;
  20 + }
  21 +
  22 + public String getDescription() {
  23 + return description;
  24 + }
  25 +
  26 + public void setDescription(String description) {
  27 + this.description = description;
  28 + }
  29 +}
impl/extension/jta/src/test/java/test/Tests.java 0 → 100644
@@ -0,0 +1,87 @@ @@ -0,0 +1,87 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +
  38 +package test;
  39 +
  40 +import java.io.File;
  41 +import java.util.Locale;
  42 +
  43 +import javax.enterprise.inject.Default;
  44 +import javax.enterprise.inject.Produces;
  45 +
  46 +import org.jboss.shrinkwrap.api.ShrinkWrap;
  47 +import org.jboss.shrinkwrap.api.asset.FileAsset;
  48 +import org.jboss.shrinkwrap.api.spec.WebArchive;
  49 +import org.jboss.shrinkwrap.resolver.api.maven.Maven;
  50 +import org.junit.Ignore;
  51 +
  52 +import br.gov.frameworkdemoiselle.transaction.JTATransaction;
  53 +
  54 +@Ignore
  55 +public final class Tests {
  56 +
  57 + private Tests() {
  58 + }
  59 +
  60 + public static WebArchive createDeployment(final Class<?> baseClass) {
  61 + return createDeployment().addPackages(true, baseClass.getPackage());
  62 + }
  63 +
  64 + public static WebArchive createDeployment() {
  65 + File[] libs = Maven.resolver().offline().loadPomFromFile("pom.xml" , "arquillian-test")
  66 + .importCompileAndRuntimeDependencies().resolve().withTransitivity().asFile();
  67 +
  68 + return ShrinkWrap
  69 + .create(WebArchive.class)
  70 + .addClass(Tests.class)
  71 + .addClass(JTATransaction.class)
  72 + .addAsResource(createFileAsset("src/main/resources/demoiselle-jta-bundle.properties") , "demoiselle-jta-bundle.properties" )
  73 + .addAsResource(createFileAsset("src/test/resources/log/log4j.properties") , "log4j.properties" )
  74 + .addAsWebInfResource(createFileAsset("src/test/resources/beans.xml"), "beans.xml")
  75 + .addAsLibraries(libs);
  76 + }
  77 +
  78 + public static FileAsset createFileAsset(final String pathname) {
  79 + return new FileAsset(new File(pathname));
  80 + }
  81 +
  82 + @Default
  83 + @Produces
  84 + public Locale create() {
  85 + return Locale.getDefault();
  86 + }
  87 +}
impl/extension/jta/src/test/resources/arquillian.xml 0 → 100644
@@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
  1 +<!--
  2 + Demoiselle Framework
  3 + Copyright (C) 2010 SERPRO
  4 + ============================================================================
  5 + This file is part of Demoiselle Framework.
  6 +
  7 + Demoiselle Framework is free software; you can redistribute it and/or
  8 + modify it under the terms of the GNU Lesser General Public License version 3
  9 + as published by the Free Software Foundation.
  10 +
  11 + This program is distributed in the hope that it will be useful,
  12 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + GNU General Public License for more details.
  15 +
  16 + You should have received a copy of the GNU Lesser General Public License version 3
  17 + along with this program; if not, see <http://www.gnu.org/licenses />
  18 + or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + Fifth Floor, Boston, MA 02110-1301, USA.
  20 + ============================================================================
  21 + Este arquivo é parte do Framework Demoiselle.
  22 +
  23 + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + do Software Livre (FSF).
  26 +
  27 + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + para maiores detalhes.
  31 +
  32 + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses />
  34 + ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 +-->
  37 +<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38 + xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
  39 +
  40 + <!--
  41 + <engine>
  42 + <property name="deploymentExportPath">target/deployments</property>
  43 + </engine>
  44 + -->
  45 +
  46 +</arquillian>
0 \ No newline at end of file 47 \ No newline at end of file
impl/extension/jta/src/test/resources/beans.xml 0 → 100644
@@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
  1 +<!--
  2 + Demoiselle Framework
  3 + Copyright (C) 2010 SERPRO
  4 + ============================================================================
  5 + This file is part of Demoiselle Framework.
  6 +
  7 + Demoiselle Framework is free software; you can redistribute it and/or
  8 + modify it under the terms of the GNU Lesser General Public License version 3
  9 + as published by the Free Software Foundation.
  10 +
  11 + This program is distributed in the hope that it will be useful,
  12 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + GNU General Public License for more details.
  15 +
  16 + You should have received a copy of the GNU Lesser General Public License version 3
  17 + along with this program; if not, see <http://www.gnu.org/licenses />
  18 + or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + Fifth Floor, Boston, MA 02110-1301, USA.
  20 + ============================================================================
  21 + Este arquivo é parte do Framework Demoiselle.
  22 +
  23 + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + do Software Livre (FSF).
  26 +
  27 + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + para maiores detalhes.
  31 +
  32 + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses />
  34 + ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 +-->
  37 +<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
  38 +
  39 + <interceptors>
  40 + <class>br.gov.frameworkdemoiselle.transaction.TransactionalInterceptor</class>
  41 + <class>br.gov.frameworkdemoiselle.security.RequiredPermissionInterceptor</class>
  42 + <class>br.gov.frameworkdemoiselle.security.RequiredRoleInterceptor</class>
  43 + <class>br.gov.frameworkdemoiselle.exception.ExceptionHandlerInterceptor</class>
  44 + </interceptors>
  45 +
  46 +</beans>
impl/extension/jta/src/test/resources/interceptor/persistence.xml 0 → 100644
@@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
  1 +<!--
  2 + Demoiselle Framework
  3 + Copyright (C) 2010 SERPRO
  4 + ============================================================================
  5 + This file is part of Demoiselle Framework.
  6 +
  7 + Demoiselle Framework is free software; you can redistribute it and/or
  8 + modify it under the terms of the GNU Lesser General Public License version 3
  9 + as published by the Free Software Foundation.
  10 +
  11 + This program is distributed in the hope that it will be useful,
  12 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + GNU General Public License for more details.
  15 +
  16 + You should have received a copy of the GNU Lesser General Public License version 3
  17 + along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + Fifth Floor, Boston, MA 02110-1301, USA.
  20 + ============================================================================
  21 + Este arquivo é parte do Framework Demoiselle.
  22 +
  23 + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + do Software Livre (FSF).
  26 +
  27 + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + para maiores detalhes.
  31 +
  32 + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 +-->
  37 +<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38 + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  39 +
  40 + <persistence-unit name="pu1" transaction-type="JTA">
  41 + <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  42 +
  43 + <jta-data-source>jdbc/__TimerPool</jta-data-source>
  44 +
  45 + <class>jtatransaction.interceptor.MyEntity1</class>
  46 + <class>jtatransaction.interceptor.MyEntity2</class>
  47 +
  48 + <properties>
  49 + <property name="eclipselink.logging.level" value="FINE" />
  50 + <property name="eclipselink.ddl-generation" value="create-tables" />
  51 + <property name="eclipselink.ddl-generation.output-mode" value="database" />
  52 + </properties>
  53 +
  54 + </persistence-unit>
  55 +
  56 + <persistence-unit name="pu2" transaction-type="JTA">
  57 + <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  58 +
  59 + <jta-data-source>jdbc/__TimerPool</jta-data-source>
  60 +
  61 + <class>jtatransaction.interceptor.MyEntity1</class>
  62 + <class>jtatransaction.interceptor.MyEntity2</class>
  63 +
  64 + <properties>
  65 + <property name="eclipselink.logging.level" value="FINE" />
  66 + <property name="eclipselink.ddl-generation" value="create-tables" />
  67 + <property name="eclipselink.ddl-generation.output-mode" value="database" />
  68 + </properties>
  69 +
  70 + </persistence-unit>
  71 +
  72 +</persistence>
0 \ No newline at end of file 73 \ No newline at end of file
impl/extension/jta/src/test/resources/log/log4j.properties 0 → 100755
@@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
  1 +# Demoiselle Framework
  2 +# Copyright (C) 2010 SERPRO
  3 +# ----------------------------------------------------------------------------
  4 +# This file is part of Demoiselle Framework.
  5 +#
  6 +# Demoiselle Framework is free software; you can redistribute it and/or
  7 +# modify it under the terms of the GNU Lesser General Public License version 3
  8 +# as published by the Free Software Foundation.
  9 +#
  10 +# This program is distributed in the hope that it will be useful,
  11 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13 +# GNU General Public License for more details.
  14 +#
  15 +# You should have received a copy of the GNU Lesser General Public License version 3
  16 +# along with this program; if not, see <http://www.gnu.org/licenses/>
  17 +# or write to the Free Software Foundation, Inc., 51 Franklin Street,
  18 +# Fifth Floor, Boston, MA 02110-1301, USA.
  19 +# ----------------------------------------------------------------------------
  20 +# Este arquivo é parte do Framework Demoiselle.
  21 +#
  22 +# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  23 +# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  24 +# do Software Livre (FSF).
  25 +#
  26 +# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  27 +# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  28 +# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  29 +# para maiores detalhes.
  30 +#
  31 +# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  32 +# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  33 +# ou escreva para a Fundação do Software Livre (FSF) Inc.,
  34 +# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  35 +
  36 +log4j.rootCategory=INFO, stdout
  37 +
  38 +log4j.logger.br.gov.frameworkdemoiselle=TRACE
  39 +
  40 +log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  41 +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  42 +log4j.appender.stdout.layout.ConversionPattern=%-5p [%c{1}] %m%n
impl/extension/jta/src/test/resources/log4j.properties
@@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
1 -# Demoiselle Framework  
2 -# Copyright (C) 2010 SERPRO  
3 -# ----------------------------------------------------------------------------  
4 -# This file is part of Demoiselle Framework.  
5 -#  
6 -# Demoiselle Framework is free software; you can redistribute it and/or  
7 -# modify it under the terms of the GNU Lesser General Public License version 3  
8 -# as published by the Free Software Foundation.  
9 -#  
10 -# This program is distributed in the hope that it will be useful,  
11 -# but WITHOUT ANY WARRANTY; without even the implied warranty of  
12 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
13 -# GNU General Public License for more details.  
14 -#  
15 -# You should have received a copy of the GNU Lesser General Public License version 3  
16 -# along with this program; if not, see <http://www.gnu.org/licenses/>  
17 -# or write to the Free Software Foundation, Inc., 51 Franklin Street,  
18 -# Fifth Floor, Boston, MA 02110-1301, USA.  
19 -# ----------------------------------------------------------------------------  
20 -# Este arquivo é parte do Framework Demoiselle.  
21 -#  
22 -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
23 -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
24 -# do Software Livre (FSF).  
25 -#  
26 -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
27 -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
28 -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
29 -# para maiores detalhes.  
30 -#  
31 -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
32 -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
33 -# ou escreva para a Fundação do Software Livre (FSF) Inc.,  
34 -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
35 -  
36 -log4j.rootCategory=INFO, stdout  
37 -  
38 -log4j.logger.br.gov.frameworkdemoiselle=TRACE  
39 -  
40 -log4j.appender.stdout=org.apache.log4j.ConsoleAppender  
41 -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout  
42 -log4j.appender.stdout.layout.ConversionPattern=%-5p [%c{1}] %m%n  
impl/extension/jta/src/test/resources/manual/persistence.xml 0 → 100644
@@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
  1 +<!--
  2 + Demoiselle Framework
  3 + Copyright (C) 2010 SERPRO
  4 + ============================================================================
  5 + This file is part of Demoiselle Framework.
  6 +
  7 + Demoiselle Framework is free software; you can redistribute it and/or
  8 + modify it under the terms of the GNU Lesser General Public License version 3
  9 + as published by the Free Software Foundation.
  10 +
  11 + This program is distributed in the hope that it will be useful,
  12 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + GNU General Public License for more details.
  15 +
  16 + You should have received a copy of the GNU Lesser General Public License version 3
  17 + along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + Fifth Floor, Boston, MA 02110-1301, USA.
  20 + ============================================================================
  21 + Este arquivo é parte do Framework Demoiselle.
  22 +
  23 + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + do Software Livre (FSF).
  26 +
  27 + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + para maiores detalhes.
  31 +
  32 + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 +-->
  37 +<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38 + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  39 +
  40 + <persistence-unit name="pu1" transaction-type="JTA">
  41 + <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  42 +
  43 + <jta-data-source>jdbc/__TimerPool</jta-data-source>
  44 +
  45 + <class>jtatransaction.manual.MyEntity1</class>
  46 + <class>jtatransaction.manual.MyEntity2</class>
  47 +
  48 + <properties>
  49 + <property name="eclipselink.logging.level" value="FINE" />
  50 + <property name="eclipselink.ddl-generation" value="create-tables" />
  51 + <property name="eclipselink.ddl-generation.output-mode" value="database" />
  52 + </properties>
  53 +
  54 + </persistence-unit>
  55 +
  56 + <persistence-unit name="pu2" transaction-type="JTA">
  57 + <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  58 +
  59 + <jta-data-source>jdbc/__TimerPool</jta-data-source>
  60 +
  61 + <class>jtatransaction.manual.MyEntity1</class>
  62 + <class>jtatransaction.manual.MyEntity2</class>
  63 +
  64 + <properties>
  65 + <property name="eclipselink.logging.level" value="FINE" />
  66 + <property name="eclipselink.ddl-generation" value="create-tables" />
  67 + <property name="eclipselink.ddl-generation.output-mode" value="database" />
  68 + </properties>
  69 +
  70 + </persistence-unit>
  71 +
  72 +</persistence>
0 \ No newline at end of file 73 \ No newline at end of file
parent/extension/pom.xml
@@ -188,7 +188,23 @@ @@ -188,7 +188,23 @@
188 </dependencies> 188 </dependencies>
189 </profile> 189 </profile>
190 <profile> 190 <profile>
  191 + <id>arquillian-weld-se-embedded</id>
  192 + <dependencies>
  193 + <dependency>
  194 + <groupId>org.jboss.arquillian.container</groupId>
  195 + <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
  196 + </dependency>
  197 + <dependency>
  198 + <groupId>org.jboss.weld.se</groupId>
  199 + <artifactId>weld-se-core</artifactId>
  200 + </dependency>
  201 + </dependencies>
  202 + </profile>
  203 + <profile>
191 <id>arquillian-glassfish-embedded</id> 204 <id>arquillian-glassfish-embedded</id>
  205 + <activation>
  206 + <activeByDefault>true</activeByDefault>
  207 + </activation>
192 <dependencies> 208 <dependencies>
193 <dependency> 209 <dependency>
194 <groupId>org.jboss.arquillian.container</groupId> 210 <groupId>org.jboss.arquillian.container</groupId>
@@ -206,11 +222,6 @@ @@ -206,11 +222,6 @@
206 </profile> 222 </profile>
207 <profile> 223 <profile>
208 <id>arquillian-jbossas7-managed</id> 224 <id>arquillian-jbossas7-managed</id>
209 - <!--  
210 - <activation>  
211 - <activeByDefault>true</activeByDefault>  
212 - </activation>  
213 - -->  
214 <build> 225 <build>
215 <testResources> 226 <testResources>
216 <testResource> 227 <testResource>
@@ -276,7 +287,6 @@ @@ -276,7 +287,6 @@
276 <artifactId>arquillian-protocol-servlet</artifactId> 287 <artifactId>arquillian-protocol-servlet</artifactId>
277 <scope>test</scope> 288 <scope>test</scope>
278 </dependency> 289 </dependency>
279 -  
280 <dependency> 290 <dependency>
281 <groupId>org.jboss.arquillian.extension</groupId> 291 <groupId>org.jboss.arquillian.extension</groupId>
282 <artifactId>arquillian-jacoco</artifactId> 292 <artifactId>arquillian-jacoco</artifactId>
@@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
68 <module>impl/extension/jdbc</module> 68 <module>impl/extension/jdbc</module>
69 <module>impl/extension/jpa</module> 69 <module>impl/extension/jpa</module>
70 <module>impl/extension/jsf</module> 70 <module>impl/extension/jsf</module>
71 - <module>impl/extension/jta</module> 71 +<!-- <module>impl/extension/jta</module> -->
72 <module>impl/extension/se</module> 72 <module>impl/extension/se</module>
73 <module>impl/extension/servlet</module> 73 <module>impl/extension/servlet</module>
74 <module>impl/extension/jmx</module> 74 <module>impl/extension/jmx</module>