Commit a228c9203fa328d9015c9c2f0c38f89e1486ab3a
1 parent
601afaa0
Exists in
master
Adição da classe SeBootstrapTest.
Showing
1 changed file
with
102 additions
and
0 deletions
Show diff stats
impl/extension/se/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/SeBootstrapTest.java
0 → 100644
... | ... | @@ -0,0 +1,102 @@ |
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.bootstrap; | |
38 | + | |
39 | +import static org.easymock.EasyMock.expect; | |
40 | +import static org.powermock.api.easymock.PowerMock.createMock; | |
41 | +import static org.powermock.api.easymock.PowerMock.mockStatic; | |
42 | +import static org.powermock.api.easymock.PowerMock.replay; | |
43 | +import static org.powermock.api.easymock.PowerMock.verifyAll; | |
44 | + | |
45 | +import java.util.List; | |
46 | +import java.util.Locale; | |
47 | + | |
48 | +import javax.enterprise.inject.spi.AfterBeanDiscovery; | |
49 | + | |
50 | +import junit.framework.Assert; | |
51 | + | |
52 | +import org.junit.Before; | |
53 | +import org.junit.Test; | |
54 | +import org.junit.runner.RunWith; | |
55 | +import org.powermock.core.classloader.annotations.PrepareForTest; | |
56 | +import org.powermock.modules.junit4.PowerMockRunner; | |
57 | +import org.powermock.reflect.Whitebox; | |
58 | + | |
59 | +import br.gov.frameworkdemoiselle.internal.context.Contexts; | |
60 | +import br.gov.frameworkdemoiselle.internal.context.CustomContext; | |
61 | +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; | |
62 | +import br.gov.frameworkdemoiselle.util.Beans; | |
63 | + | |
64 | +@RunWith(PowerMockRunner.class) | |
65 | +@PrepareForTest({ Beans.class, Contexts.class }) | |
66 | +public class SeBootstrapTest { | |
67 | + | |
68 | + private SeBootstrap seBootstrap; | |
69 | + | |
70 | + private AfterBeanDiscovery event; | |
71 | + | |
72 | + @Before | |
73 | + public void before() { | |
74 | + event = createMock(AfterBeanDiscovery.class); | |
75 | + mockStatic(Beans.class); | |
76 | + expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes(); | |
77 | + replay(Beans.class); | |
78 | + seBootstrap = new SeBootstrap(); | |
79 | + } | |
80 | + | |
81 | + @Test | |
82 | + public void testStoreContext() { | |
83 | + seBootstrap.storeContexts(event); | |
84 | + replay(event); | |
85 | + | |
86 | + Assert.assertEquals(event, Whitebox.getInternalState(seBootstrap, "afterBeanDiscoveryEvent")); | |
87 | + List<CustomContext> context = Whitebox.getInternalState(seBootstrap, "tempContexts"); | |
88 | + Assert.assertEquals(4, context.size()); | |
89 | + verifyAll(); | |
90 | + } | |
91 | + | |
92 | + @Test | |
93 | + public void testRemoveContexts() { | |
94 | + seBootstrap.storeContexts(event); | |
95 | + | |
96 | + AfterShutdownProccess afterShutdownProccess = createMock(AfterShutdownProccess.class); | |
97 | + replay(event, afterShutdownProccess); | |
98 | + seBootstrap.removeContexts(afterShutdownProccess); | |
99 | + | |
100 | + verifyAll(); | |
101 | + } | |
102 | +} | ... | ... |