Commit 5b064238f72da1de182ed183e3316007a5ee3de5
Exists in
master
Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0
Showing
16 changed files
with
880 additions
and
310 deletions
Show diff stats
impl/extension/jta/pom.xml
| 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 | -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
| 1 | +<!-- Demoiselle Framework Copyright (C) 2010 SERPRO ============================================================================ | |
| 2 | + This file is part of Demoiselle Framework. Demoiselle Framework is free software; | |
| 3 | + you can redistribute it and/or modify it under the terms of the GNU Lesser | |
| 4 | + General Public License version 3 as published by the Free Software Foundation. | |
| 5 | + This program is distributed in the hope that it will be useful, but WITHOUT | |
| 6 | + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 7 | + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
| 8 | + You should have received a copy of the GNU Lesser General Public License | |
| 9 | + version 3 along with this program; if not, see <http://www.gnu.org/licenses | |
| 10 | + /> or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth | |
| 11 | + Floor, Boston, MA 02110-1301, USA. ============================================================================ | |
| 12 | + Este arquivo é parte do Framework Demoiselle. O Framework Demoiselle é um | |
| 13 | + software livre; você pode redistribuí-lo e/ou modificá-lo dentro dos termos | |
| 14 | + da GNU LGPL versão 3 como publicada pela Fundação do Software Livre (FSF). | |
| 15 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 16 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO | |
| 17 | + EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português para maiores | |
| 18 | + detalhes. Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 19 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses | |
| 20 | + /> ou escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, | |
| 21 | + Fifth Floor, Boston, MA 02111-1301, USA. --> | |
| 22 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 23 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
| 38 | 24 | |
| 39 | 25 | <modelVersion>4.0.0</modelVersion> |
| 40 | 26 | |
| ... | ... | @@ -71,8 +57,91 @@ |
| 71 | 57 | <groupId>javax.transaction</groupId> |
| 72 | 58 | <artifactId>jta</artifactId> |
| 73 | 59 | </dependency> |
| 60 | + | |
| 61 | + <!-- TESTS --> | |
| 62 | + <dependency> | |
| 63 | + <groupId>junit</groupId> | |
| 64 | + <artifactId>junit</artifactId> | |
| 65 | + <scope>test</scope> | |
| 66 | + </dependency> | |
| 67 | + | |
| 68 | + <dependency> | |
| 69 | + <groupId>org.jboss.arquillian.core</groupId> | |
| 70 | + <artifactId>arquillian-core-api</artifactId> | |
| 71 | + <scope>test</scope> | |
| 72 | + </dependency> | |
| 74 | 73 | </dependencies> |
| 75 | 74 | |
| 75 | + <profiles> | |
| 76 | + <profile> | |
| 77 | + <id>arquillian-embedded</id> | |
| 78 | + <activation> | |
| 79 | + <activeByDefault>true</activeByDefault> | |
| 80 | + </activation> | |
| 81 | + | |
| 82 | + <dependencies> | |
| 83 | + <dependency> | |
| 84 | + <groupId>org.jboss.arquillian.junit</groupId> | |
| 85 | + <artifactId>arquillian-junit-container</artifactId> | |
| 86 | + <scope>test</scope> | |
| 87 | + </dependency> | |
| 88 | + <dependency> | |
| 89 | + <groupId>org.jboss.arquillian.container</groupId> | |
| 90 | + <artifactId>arquillian-glassfish-embedded-3.1</artifactId> | |
| 91 | + <scope>test</scope> | |
| 92 | + </dependency> | |
| 93 | + <dependency> | |
| 94 | + <groupId>org.glassfish.main.extras</groupId> | |
| 95 | + <artifactId>glassfish-embedded-all</artifactId> | |
| 96 | + <scope>test</scope> | |
| 97 | + </dependency> | |
| 98 | + <dependency> | |
| 99 | + <groupId>org.slf4j</groupId> | |
| 100 | + <artifactId>slf4j-log4j12</artifactId> | |
| 101 | + <scope>test</scope> | |
| 102 | + </dependency> | |
| 103 | + <dependency> | |
| 104 | + <groupId>org.eclipse.persistence</groupId> | |
| 105 | + <artifactId>eclipselink</artifactId> | |
| 106 | + <scope>test</scope> | |
| 107 | + </dependency> | |
| 108 | + <dependency> | |
| 109 | + <groupId>org.jboss.shrinkwrap.resolver</groupId> | |
| 110 | + <artifactId>shrinkwrap-resolver-impl-maven</artifactId> | |
| 111 | + <scope>test</scope> | |
| 112 | + </dependency> | |
| 113 | + </dependencies> | |
| 114 | + </profile> | |
| 115 | + | |
| 116 | + <profile> | |
| 117 | + <id>arquillian-test</id> | |
| 118 | + <dependencies> | |
| 119 | + <dependency> | |
| 120 | + <groupId>br.gov.frameworkdemoiselle</groupId> | |
| 121 | + <artifactId>demoiselle-core</artifactId> | |
| 122 | + <exclusions> | |
| 123 | + <exclusion> | |
| 124 | + <groupId>javax.enterprise</groupId> | |
| 125 | + <artifactId>cdi-api</artifactId> | |
| 126 | + </exclusion> | |
| 127 | + <exclusion> | |
| 128 | + <artifactId>validation-api</artifactId> | |
| 129 | + <groupId>javax.validation</groupId> | |
| 130 | + </exclusion> | |
| 131 | + <exclusion> | |
| 132 | + <groupId>org.slf4j</groupId> | |
| 133 | + <artifactId>slf4j-api</artifactId> | |
| 134 | + </exclusion> | |
| 135 | + <exclusion> | |
| 136 | + <groupId>org.javassist</groupId> | |
| 137 | + <artifactId>javassist</artifactId> | |
| 138 | + </exclusion> | |
| 139 | + </exclusions> | |
| 140 | + </dependency> | |
| 141 | + </dependencies> | |
| 142 | + </profile> | |
| 143 | + </profiles> | |
| 144 | + | |
| 76 | 145 | <repositories> |
| 77 | 146 | <repository> |
| 78 | 147 | <id>sonatype-nexus-snapshots</id> | ... | ... |
impl/extension/jta/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.java
| ... | ... | @@ -1,231 +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 static org.easymock.EasyMock.createMock; | |
| 41 | -import static org.easymock.EasyMock.expect; | |
| 42 | -import static org.easymock.EasyMock.expectLastCall; | |
| 43 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | |
| 44 | -import static org.powermock.api.easymock.PowerMock.replay; | |
| 45 | -import static org.powermock.api.easymock.PowerMock.replayAll; | |
| 46 | -import static org.powermock.api.easymock.PowerMock.verify; | |
| 47 | -import static org.powermock.reflect.Whitebox.setInternalState; | |
| 48 | - | |
| 49 | -import javax.transaction.HeuristicMixedException; | |
| 50 | -import javax.transaction.HeuristicRollbackException; | |
| 51 | -import javax.transaction.NotSupportedException; | |
| 52 | -import javax.transaction.RollbackException; | |
| 53 | -import javax.transaction.SystemException; | |
| 54 | -import javax.transaction.UserTransaction; | |
| 55 | - | |
| 56 | -import junit.framework.Assert; | |
| 57 | - | |
| 58 | -import org.junit.Before; | |
| 59 | -import org.junit.Test; | |
| 60 | -import org.junit.runner.RunWith; | |
| 61 | -import org.powermock.core.classloader.annotations.PrepareForTest; | |
| 62 | -import org.powermock.modules.junit4.PowerMockRunner; | |
| 63 | - | |
| 64 | -import br.gov.frameworkdemoiselle.DemoiselleException; | |
| 65 | -import br.gov.frameworkdemoiselle.util.Beans; | |
| 66 | - | |
| 67 | -@RunWith(PowerMockRunner.class) | |
| 68 | -@PrepareForTest({ Beans.class }) | |
| 69 | -public class JTATransactionTest { | |
| 70 | - | |
| 71 | - private UserTransaction userTransaction; | |
| 72 | - | |
| 73 | - private JTATransaction jtaTransaction; | |
| 74 | - | |
| 75 | - @Before | |
| 76 | - public void setUp() { | |
| 77 | - userTransaction = createMock(UserTransaction.class); | |
| 78 | - jtaTransaction = new JTATransaction(); | |
| 79 | - | |
| 80 | - setInternalState(jtaTransaction, UserTransaction.class, userTransaction); | |
| 81 | - } | |
| 82 | - | |
| 83 | - @Test | |
| 84 | - public void testGetDElegateWithUserTransactionNull() throws SystemException { | |
| 85 | - mockStatic(Beans.class); | |
| 86 | - userTransaction = null; | |
| 87 | - setInternalState(jtaTransaction, UserTransaction.class, userTransaction); | |
| 88 | - userTransaction = createMock(UserTransaction.class); | |
| 89 | - expect(Beans.getReference(UserTransaction.class)).andReturn(userTransaction); | |
| 90 | - replayAll(); | |
| 91 | - | |
| 92 | - // Assert.assertEquals(userTransaction, jtaTransaction.getDelegate()); | |
| 93 | - } | |
| 94 | - | |
| 95 | - @Test | |
| 96 | - public void testGetDElegateWithUserTransactionIsNotNull() throws SystemException { | |
| 97 | - // Assert.assertEquals(userTransaction, jtaTransaction.getDelegate()); | |
| 98 | - } | |
| 99 | - | |
| 100 | - @Test | |
| 101 | - public void testIsActiveWithStatusEqualsActive() throws SystemException { | |
| 102 | - expect(userTransaction.getStatus()).andReturn(Integer.valueOf(0)); | |
| 103 | - replay(userTransaction); | |
| 104 | - Assert.assertTrue(this.jtaTransaction.isActive()); | |
| 105 | - } | |
| 106 | - | |
| 107 | - @Test | |
| 108 | - public void testIsActiveWithStatusEqualsMarkedRollback() throws SystemException { | |
| 109 | - expect(userTransaction.getStatus()).andReturn(Integer.valueOf(1)).times(2); | |
| 110 | - replay(userTransaction); | |
| 111 | - Assert.assertTrue(this.jtaTransaction.isActive()); | |
| 112 | - } | |
| 113 | - | |
| 114 | - @Test | |
| 115 | - public void testIsMarkedRollback() throws SystemException { | |
| 116 | - expect(userTransaction.getStatus()).andReturn(Integer.valueOf(1)); | |
| 117 | - replay(userTransaction); | |
| 118 | - Assert.assertTrue(this.jtaTransaction.isMarkedRollback()); | |
| 119 | - } | |
| 120 | - | |
| 121 | - @Test | |
| 122 | - public void testBegin() throws SystemException, NotSupportedException { | |
| 123 | - userTransaction.begin(); | |
| 124 | - replay(userTransaction); | |
| 125 | - this.jtaTransaction.begin(); | |
| 126 | - verify(); | |
| 127 | - } | |
| 128 | - | |
| 129 | - @Test | |
| 130 | - public void testCommit() throws SystemException, NotSupportedException, SecurityException, IllegalStateException, | |
| 131 | - RollbackException, HeuristicMixedException, HeuristicRollbackException { | |
| 132 | - userTransaction.commit(); | |
| 133 | - replay(userTransaction); | |
| 134 | - this.jtaTransaction.commit(); | |
| 135 | - verify(); | |
| 136 | - } | |
| 137 | - | |
| 138 | - @Test | |
| 139 | - public void testRollback() throws SystemException, NotSupportedException { | |
| 140 | - userTransaction.rollback(); | |
| 141 | - replay(userTransaction); | |
| 142 | - this.jtaTransaction.rollback(); | |
| 143 | - verify(); | |
| 144 | - } | |
| 145 | - | |
| 146 | - @Test | |
| 147 | - public void testSetRollbackOnly() throws SystemException, NotSupportedException { | |
| 148 | - userTransaction.setRollbackOnly(); | |
| 149 | - replay(userTransaction); | |
| 150 | - this.jtaTransaction.setRollbackOnly(); | |
| 151 | - verify(); | |
| 152 | - } | |
| 153 | - | |
| 154 | - @Test | |
| 155 | - public void testIsActiveThrowsSystemException() throws SystemException { | |
| 156 | - expect(userTransaction.getStatus()).andThrow(new SystemException()); | |
| 157 | - replay(userTransaction); | |
| 158 | - try { | |
| 159 | - this.jtaTransaction.isActive(); | |
| 160 | - Assert.fail(); | |
| 161 | - } catch (DemoiselleException cause) { | |
| 162 | - Assert.assertTrue(true); | |
| 163 | - } | |
| 164 | - } | |
| 165 | - | |
| 166 | - @Test | |
| 167 | - public void testIsMarkedRollbackThrowsSystemException() throws SystemException { | |
| 168 | - expect(userTransaction.getStatus()).andThrow(new SystemException()); | |
| 169 | - replay(userTransaction); | |
| 170 | - try { | |
| 171 | - this.jtaTransaction.isMarkedRollback(); | |
| 172 | - Assert.fail(); | |
| 173 | - } catch (DemoiselleException cause) { | |
| 174 | - Assert.assertTrue(true); | |
| 175 | - } | |
| 176 | - } | |
| 177 | - | |
| 178 | - @Test | |
| 179 | - public void testBeginThrowsException() throws SystemException, NotSupportedException { | |
| 180 | - userTransaction.begin(); | |
| 181 | - expectLastCall().andThrow(new SystemException()); | |
| 182 | - replay(userTransaction); | |
| 183 | - try { | |
| 184 | - this.jtaTransaction.begin(); | |
| 185 | - Assert.fail(); | |
| 186 | - } catch (DemoiselleException cause) { | |
| 187 | - Assert.assertTrue(true); | |
| 188 | - } | |
| 189 | - } | |
| 190 | - | |
| 191 | - @Test | |
| 192 | - public void testCommitThrowsException() throws SystemException, SecurityException, IllegalStateException, | |
| 193 | - RollbackException, HeuristicMixedException, HeuristicRollbackException { | |
| 194 | - userTransaction.commit(); | |
| 195 | - expectLastCall().andThrow(new SystemException()); | |
| 196 | - replay(userTransaction); | |
| 197 | - try { | |
| 198 | - this.jtaTransaction.commit(); | |
| 199 | - Assert.fail(); | |
| 200 | - } catch (DemoiselleException cause) { | |
| 201 | - Assert.assertTrue(true); | |
| 202 | - } | |
| 203 | - } | |
| 204 | - | |
| 205 | - @Test | |
| 206 | - public void testRollbackThrowsSystemException() throws SystemException { | |
| 207 | - userTransaction.rollback(); | |
| 208 | - expectLastCall().andThrow(new SystemException()); | |
| 209 | - replay(userTransaction); | |
| 210 | - try { | |
| 211 | - this.jtaTransaction.rollback(); | |
| 212 | - Assert.fail(); | |
| 213 | - } catch (DemoiselleException cause) { | |
| 214 | - Assert.assertTrue(true); | |
| 215 | - } | |
| 216 | - } | |
| 217 | - | |
| 218 | - @Test | |
| 219 | - public void testSetRollbackOnlyThrowsSystemException() throws SystemException { | |
| 220 | - userTransaction.setRollbackOnly(); | |
| 221 | - expectLastCall().andThrow(new SystemException()); | |
| 222 | - replay(userTransaction); | |
| 223 | - try { | |
| 224 | - this.jtaTransaction.setRollbackOnly(); | |
| 225 | - Assert.fail(); | |
| 226 | - } catch (DemoiselleException cause) { | |
| 227 | - Assert.assertTrue(true); | |
| 228 | - } | |
| 229 | - } | |
| 230 | - | |
| 231 | -} |
impl/extension/jta/src/test/java/jtatransaction/interceptor/InterceptorJTATransactionTest.java
0 → 100644
| ... | ... | @@ -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 @@ |
| 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 @@ |
| 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 @@ |
| 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 @@ |
| 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 @@ |
| 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 @@ |
| 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 | +} | ... | ... |
| ... | ... | @@ -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 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,47 @@ |
| 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 | +<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 39 | + xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> | |
| 40 | + | |
| 41 | + <!-- | |
| 42 | + <engine> | |
| 43 | + <property name="deploymentExportPath">target/deployments</property> | |
| 44 | + </engine> | |
| 45 | + --> | |
| 46 | + | |
| 47 | +</arquillian> | |
| 0 | 48 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | +<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 2 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
| 3 | + | |
| 4 | + <interceptors> | |
| 5 | + <class>br.gov.frameworkdemoiselle.transaction.TransactionalInterceptor</class> | |
| 6 | + <class>br.gov.frameworkdemoiselle.security.RequiredPermissionInterceptor</class> | |
| 7 | + <class>br.gov.frameworkdemoiselle.security.RequiredRoleInterceptor</class> | |
| 8 | + <class>br.gov.frameworkdemoiselle.exception.ExceptionHandlerInterceptor</class> | |
| 9 | + </interceptors> | |
| 10 | + | |
| 11 | +</beans> | ... | ... |
impl/extension/jta/src/test/resources/interceptor/persistence.xml
0 → 100644
| ... | ... | @@ -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 | 73 | \ No newline at end of file | ... | ... |
impl/extension/jta/src/test/resources/log/log4j.properties
0 → 100755
| ... | ... | @@ -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 | -# 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 @@ |
| 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 | 73 | \ No newline at end of file | ... | ... |