diff --git a/impl/core/src/test/java/transaction/createdstrategy/Strategy.java b/impl/core/src/test/java/transaction/createdstrategy/Strategy.java new file mode 100644 index 0000000..15a0599 --- /dev/null +++ b/impl/core/src/test/java/transaction/createdstrategy/Strategy.java @@ -0,0 +1,113 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package transaction.createdstrategy; + +import br.gov.frameworkdemoiselle.transaction.Transaction; + +public class Strategy implements Transaction { + + private static final long serialVersionUID = 1L; + + private boolean passedInIsActiveMethod = false; + + private boolean passedInIsMarkedRollbackMethod = false; + + private boolean passedInBeginMethod = false; + + private boolean passedInCommitMethod = false; + + private boolean passedInRollbackMethod = false; + + private boolean passedInSetRollbackOnlyMethod = false; + + @Override + public boolean isActive() { + passedInIsActiveMethod = true; + return false; + } + + @Override + public boolean isMarkedRollback() { + passedInIsMarkedRollbackMethod = true; + return false; + } + + @Override + public void begin() { + passedInBeginMethod = true; + } + + @Override + public void commit() { + passedInCommitMethod = true; + } + + @Override + public void rollback() { + passedInRollbackMethod = true; + } + + @Override + public void setRollbackOnly() { + passedInSetRollbackOnlyMethod = true; + } + + public boolean isPassedInIsActiveMethod() { + return passedInIsActiveMethod; + } + + public boolean isPassedInIsMarkedRollbackMethod() { + return passedInIsMarkedRollbackMethod; + } + + public boolean isPassedInBeginMethod() { + return passedInBeginMethod; + } + + public boolean isPassedInCommitMethod() { + return passedInCommitMethod; + } + + public boolean isPassedInRollbackMethod() { + return passedInRollbackMethod; + } + + public boolean isPassedInSetRollbackOnlyMethod() { + return passedInSetRollbackOnlyMethod; + } + +} diff --git a/impl/core/src/test/java/transaction/createdstrategy/TransactionWithCreatedStrategyTest.java b/impl/core/src/test/java/transaction/createdstrategy/TransactionWithCreatedStrategyTest.java new file mode 100644 index 0000000..a5fc764 --- /dev/null +++ b/impl/core/src/test/java/transaction/createdstrategy/TransactionWithCreatedStrategyTest.java @@ -0,0 +1,113 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package transaction.createdstrategy; + +import static junit.framework.Assert.assertTrue; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import br.gov.frameworkdemoiselle.transaction.Transaction; +import br.gov.frameworkdemoiselle.transaction.TransactionContext; + +import test.Tests; + +@RunWith(Arquillian.class) +public class TransactionWithCreatedStrategyTest { + + @Inject + private TransactionContext context; + + private Transaction transaction; + + private Strategy myStrategy; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(TransactionWithCreatedStrategyTest.class); + return deployment; + } + + @Before + public void setTransaction() { + transaction = context.getCurrentTransaction(); + myStrategy = (Strategy) context.getCurrentTransaction(); + } + + @Test + public void defaultTransactionBegin() { + transaction.begin(); + assertTrue(myStrategy.isPassedInBeginMethod()); + } + + @Test + public void defaultTransactionCommit() { + transaction.commit(); + assertTrue(myStrategy.isPassedInCommitMethod()); + } + + @Test + public void defaultTransactionIsActive() { + transaction.isActive(); + assertTrue(myStrategy.isPassedInIsActiveMethod()); + } + + @Test + public void defaultTransactionIsMarkedRollback() { + transaction.isMarkedRollback(); + assertTrue(myStrategy.isPassedInIsMarkedRollbackMethod()); + } + + @Test + public void defaultTransactionRollback() { + transaction.rollback(); + assertTrue(myStrategy.isPassedInRollbackMethod()); + } + + @Test + public void defaultTransactionSetRollbackOnly() { + transaction.setRollbackOnly(); + assertTrue(myStrategy.isPassedInSetRollbackOnlyMethod()); + } + +} -- libgit2 0.21.2