Commit 31a0eb70abe2beb5530af59ee27af9960ec72fa0
1 parent
5c9a7ac7
Exists in
master
Adição da classe TransactionInfoTest, para testes unitários na classe
TransactionInfo.
Showing
1 changed file
with
85 additions
and
0 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfoTest.java
0 → 100644
@@ -0,0 +1,85 @@ | @@ -0,0 +1,85 @@ | ||
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 br.gov.frameworkdemoiselle.internal.implementation; | ||
38 | + | ||
39 | +import org.junit.Assert; | ||
40 | +import org.junit.Test; | ||
41 | + | ||
42 | + | ||
43 | +public class TransactionInfoTest { | ||
44 | + | ||
45 | + private TransactionInfo transactionInfo = new TransactionInfo(); | ||
46 | + | ||
47 | + @Test | ||
48 | + public void testMarkAsOwner(){ | ||
49 | + transactionInfo.markAsOwner(); | ||
50 | + Assert.assertTrue(transactionInfo.isOwner()); | ||
51 | + } | ||
52 | + | ||
53 | + @Test | ||
54 | + public void testIncrementCounter() { | ||
55 | + int count = transactionInfo.getCounter(); | ||
56 | + | ||
57 | + transactionInfo.incrementCounter(); | ||
58 | + Assert.assertEquals(count+1, transactionInfo.getCounter()); | ||
59 | + | ||
60 | + transactionInfo.incrementCounter(); | ||
61 | + Assert.assertEquals(count+2, transactionInfo.getCounter()); | ||
62 | + } | ||
63 | + | ||
64 | + @Test | ||
65 | + public void testDecrementCounter() { | ||
66 | + int count = transactionInfo.getCounter(); | ||
67 | + | ||
68 | + transactionInfo.incrementCounter(); | ||
69 | + Assert.assertEquals(count+1, transactionInfo.getCounter()); | ||
70 | + | ||
71 | + transactionInfo.decrementCounter(); | ||
72 | + Assert.assertEquals(count, transactionInfo.getCounter()); | ||
73 | + } | ||
74 | + | ||
75 | + @Test | ||
76 | + public void testClear() { | ||
77 | + transactionInfo.incrementCounter(); | ||
78 | + transactionInfo.markAsOwner(); | ||
79 | + | ||
80 | + transactionInfo.clear(); | ||
81 | + | ||
82 | + Assert.assertEquals(0, transactionInfo.getCounter()); | ||
83 | + Assert.assertFalse(transactionInfo.isOwner()); | ||
84 | + } | ||
85 | +} |