Commit 1fb0d50057362704fe87934ff0dca226720b2626

Authored by Dancovich
2 parents b48746aa 71b4c9a7
Exists in master

Merge remote-tracking branch 'origin/2.4.0' into 2.4.0

impl/core/src/test/java/transaction/createdstrategy/Strategy.java 0 → 100644
... ... @@ -0,0 +1,113 @@
  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.createdstrategy;
  38 +
  39 +import br.gov.frameworkdemoiselle.transaction.Transaction;
  40 +
  41 +public class Strategy implements Transaction {
  42 +
  43 + private static final long serialVersionUID = 1L;
  44 +
  45 + private boolean passedInIsActiveMethod = false;
  46 +
  47 + private boolean passedInIsMarkedRollbackMethod = false;
  48 +
  49 + private boolean passedInBeginMethod = false;
  50 +
  51 + private boolean passedInCommitMethod = false;
  52 +
  53 + private boolean passedInRollbackMethod = false;
  54 +
  55 + private boolean passedInSetRollbackOnlyMethod = false;
  56 +
  57 + @Override
  58 + public boolean isActive() {
  59 + passedInIsActiveMethod = true;
  60 + return false;
  61 + }
  62 +
  63 + @Override
  64 + public boolean isMarkedRollback() {
  65 + passedInIsMarkedRollbackMethod = true;
  66 + return false;
  67 + }
  68 +
  69 + @Override
  70 + public void begin() {
  71 + passedInBeginMethod = true;
  72 + }
  73 +
  74 + @Override
  75 + public void commit() {
  76 + passedInCommitMethod = true;
  77 + }
  78 +
  79 + @Override
  80 + public void rollback() {
  81 + passedInRollbackMethod = true;
  82 + }
  83 +
  84 + @Override
  85 + public void setRollbackOnly() {
  86 + passedInSetRollbackOnlyMethod = true;
  87 + }
  88 +
  89 + public boolean isPassedInIsActiveMethod() {
  90 + return passedInIsActiveMethod;
  91 + }
  92 +
  93 + public boolean isPassedInIsMarkedRollbackMethod() {
  94 + return passedInIsMarkedRollbackMethod;
  95 + }
  96 +
  97 + public boolean isPassedInBeginMethod() {
  98 + return passedInBeginMethod;
  99 + }
  100 +
  101 + public boolean isPassedInCommitMethod() {
  102 + return passedInCommitMethod;
  103 + }
  104 +
  105 + public boolean isPassedInRollbackMethod() {
  106 + return passedInRollbackMethod;
  107 + }
  108 +
  109 + public boolean isPassedInSetRollbackOnlyMethod() {
  110 + return passedInSetRollbackOnlyMethod;
  111 + }
  112 +
  113 +}
... ...
impl/core/src/test/java/transaction/createdstrategy/TransactionWithCreatedStrategyTest.java 0 → 100644
... ... @@ -0,0 +1,113 @@
  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.createdstrategy;
  38 +
  39 +import static junit.framework.Assert.assertTrue;
  40 +
  41 +import javax.inject.Inject;
  42 +
  43 +import org.jboss.arquillian.container.test.api.Deployment;
  44 +import org.jboss.arquillian.junit.Arquillian;
  45 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  46 +import org.junit.Before;
  47 +import org.junit.Test;
  48 +import org.junit.runner.RunWith;
  49 +
  50 +import br.gov.frameworkdemoiselle.transaction.Transaction;
  51 +import br.gov.frameworkdemoiselle.transaction.TransactionContext;
  52 +
  53 +import test.Tests;
  54 +
  55 +@RunWith(Arquillian.class)
  56 +public class TransactionWithCreatedStrategyTest {
  57 +
  58 + @Inject
  59 + private TransactionContext context;
  60 +
  61 + private Transaction transaction;
  62 +
  63 + private Strategy myStrategy;
  64 +
  65 + @Deployment
  66 + public static JavaArchive createDeployment() {
  67 + JavaArchive deployment = Tests.createDeployment(TransactionWithCreatedStrategyTest.class);
  68 + return deployment;
  69 + }
  70 +
  71 + @Before
  72 + public void setTransaction() {
  73 + transaction = context.getCurrentTransaction();
  74 + myStrategy = (Strategy) context.getCurrentTransaction();
  75 + }
  76 +
  77 + @Test
  78 + public void defaultTransactionBegin() {
  79 + transaction.begin();
  80 + assertTrue(myStrategy.isPassedInBeginMethod());
  81 + }
  82 +
  83 + @Test
  84 + public void defaultTransactionCommit() {
  85 + transaction.commit();
  86 + assertTrue(myStrategy.isPassedInCommitMethod());
  87 + }
  88 +
  89 + @Test
  90 + public void defaultTransactionIsActive() {
  91 + transaction.isActive();
  92 + assertTrue(myStrategy.isPassedInIsActiveMethod());
  93 + }
  94 +
  95 + @Test
  96 + public void defaultTransactionIsMarkedRollback() {
  97 + transaction.isMarkedRollback();
  98 + assertTrue(myStrategy.isPassedInIsMarkedRollbackMethod());
  99 + }
  100 +
  101 + @Test
  102 + public void defaultTransactionRollback() {
  103 + transaction.rollback();
  104 + assertTrue(myStrategy.isPassedInRollbackMethod());
  105 + }
  106 +
  107 + @Test
  108 + public void defaultTransactionSetRollbackOnly() {
  109 + transaction.setRollbackOnly();
  110 + assertTrue(myStrategy.isPassedInSetRollbackOnlyMethod());
  111 + }
  112 +
  113 +}
... ...
impl/core/src/test/java/transaction/defaultstrategy/TransactionDefaultTest.java 0 → 100644
... ... @@ -0,0 +1,103 @@
  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.defaultstrategy;
  38 +
  39 +import javax.inject.Inject;
  40 +
  41 +import org.jboss.arquillian.container.test.api.Deployment;
  42 +import org.jboss.arquillian.junit.Arquillian;
  43 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  44 +import org.junit.Before;
  45 +import org.junit.Test;
  46 +import org.junit.runner.RunWith;
  47 +
  48 +import br.gov.frameworkdemoiselle.DemoiselleException;
  49 +import br.gov.frameworkdemoiselle.transaction.Transaction;
  50 +import br.gov.frameworkdemoiselle.transaction.TransactionContext;
  51 +
  52 +import test.Tests;
  53 +
  54 +@RunWith(Arquillian.class)
  55 +public class TransactionDefaultTest {
  56 +
  57 + @Inject
  58 + private TransactionContext context;
  59 +
  60 + private Transaction transaction;
  61 +
  62 + @Deployment
  63 + public static JavaArchive createDeployment() {
  64 + JavaArchive deployment = Tests.createDeployment(TransactionDefaultTest.class);
  65 + return deployment;
  66 + }
  67 +
  68 + @Before
  69 + public void setTransaction() {
  70 + transaction = context.getCurrentTransaction();
  71 + }
  72 +
  73 + @Test(expected = DemoiselleException.class)
  74 + public void defaultTransactionBegin() {
  75 + transaction.begin();
  76 + }
  77 +
  78 + @Test(expected = DemoiselleException.class)
  79 + public void defaultTransactionCommit() {
  80 + transaction.commit();
  81 + }
  82 +
  83 + @Test(expected = DemoiselleException.class)
  84 + public void defaultTransactionIsActive() {
  85 + transaction.isActive();
  86 + }
  87 +
  88 + @Test(expected = DemoiselleException.class)
  89 + public void defaultTransactionIsMarkedRollback() {
  90 + transaction.isMarkedRollback();
  91 + }
  92 +
  93 + @Test(expected = DemoiselleException.class)
  94 + public void defaultTransactionRollback() {
  95 + transaction.rollback();
  96 + }
  97 +
  98 + @Test(expected = DemoiselleException.class)
  99 + public void defaultTransactionSetRollbackOnly() {
  100 + transaction.setRollbackOnly();
  101 + }
  102 +
  103 +}
... ...