Commit 35ce57ee49c4b004c7584392e2bc7a901d5cb145
1 parent
e140c1fc
Exists in
master
Adaptação de testes do Slf4LoggerProxyTest
Showing
1 changed file
with
95 additions
and
80 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxyTest.java
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.proxy; | |
38 | -// | |
39 | -//import static org.easymock.EasyMock.expect; | |
40 | -//import static org.easymock.EasyMock.replay; | |
41 | -//import static org.easymock.EasyMock.verify; | |
42 | -//import static org.junit.Assert.assertEquals; | |
43 | -// | |
44 | -//import org.easymock.EasyMock; | |
45 | -//import org.junit.Before; | |
46 | -//import org.junit.Test; | |
47 | -//import org.slf4j.Logger; | |
48 | -//import org.slf4j.Marker; | |
49 | -// | |
50 | -// | |
51 | -//public class Slf4jLoggerProxyTest { | |
52 | -// | |
53 | -// private Logger logger; | |
54 | -// private Slf4jLoggerProxy slf4jLoggerProxy; | |
55 | -// | |
56 | -// @Before | |
57 | -// public void setUp() throws Exception { | |
58 | -// this.logger = EasyMock.createMock(Logger.class); | |
59 | -// this.slf4jLoggerProxy = new Slf4jLoggerProxy(this.logger); | |
60 | -// } | |
61 | -// | |
62 | -// @Test | |
63 | -// public void testDebugWithMarkerAndString() { | |
64 | -// Marker marker = null; | |
65 | -// this.logger.debug(marker,""); | |
66 | -// replay(this.logger); | |
67 | -// this.slf4jLoggerProxy.debug(marker,""); | |
68 | -// verify(this.logger); | |
69 | -// } | |
70 | -// @Test | |
71 | -// public void testDebugWithMarkerStringAndOneObject() { | |
72 | -// Marker marker = null; | |
73 | -// Object obj = null; | |
74 | -// this.logger.debug(marker,"",obj); | |
75 | -// replay(this.logger); | |
76 | -// this.slf4jLoggerProxy.debug(marker,"",obj); | |
77 | -// verify(this.logger); | |
78 | -// } | |
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.proxy; | |
38 | + | |
39 | +import static org.easymock.EasyMock.expect; | |
40 | +import static org.easymock.EasyMock.replay; | |
41 | +import static org.easymock.EasyMock.verify; | |
42 | +import static org.junit.Assert.assertEquals; | |
43 | +import static org.powermock.api.easymock.PowerMock.mockStatic; | |
44 | + | |
45 | +import javax.inject.Inject; | |
46 | + | |
47 | +import org.easymock.EasyMock; | |
48 | +import org.junit.Before; | |
49 | +import org.junit.Test; | |
50 | +import org.junit.runner.RunWith; | |
51 | +import org.powermock.api.easymock.PowerMock; | |
52 | +import org.powermock.core.classloader.annotations.PrepareForTest; | |
53 | +import org.powermock.modules.junit4.PowerMockRunner; | |
54 | +import org.slf4j.Logger; | |
55 | +import org.slf4j.LoggerFactory; | |
56 | +import org.slf4j.Marker; | |
57 | + | |
58 | +@RunWith(PowerMockRunner.class) | |
59 | +@PrepareForTest(LoggerFactory.class) | |
60 | +public class Slf4jLoggerProxyTest { | |
61 | + | |
62 | + private Logger logger; | |
63 | + private Slf4jLoggerProxy slf4jLoggerProxy; | |
64 | + | |
65 | + @Before | |
66 | + public void setUp() throws Exception { | |
67 | + this.logger = EasyMock.createMock(Logger.class); | |
68 | + this.slf4jLoggerProxy = new Slf4jLoggerProxy(Logger.class); | |
69 | + | |
70 | + mockStatic(LoggerFactory.class); | |
71 | + | |
72 | + expect(LoggerFactory.getLogger(EasyMock.anyObject(Class.class))).andReturn(logger); | |
73 | + } | |
74 | + | |
75 | + @Test | |
76 | + public void testDebugWithMarkerAndString() { | |
77 | + Marker marker = null; | |
78 | + this.logger.debug(marker,""); | |
79 | + PowerMock.replay(LoggerFactory.class, this.logger); | |
80 | + this.slf4jLoggerProxy.debug(marker,""); | |
81 | + PowerMock.verify(this.logger); | |
82 | + } | |
83 | + | |
84 | + @Test | |
85 | + public void testDebugWithMarkerStringAndOneObject() { | |
86 | + Marker marker = null; | |
87 | + Object obj = null; | |
88 | + this.logger.debug(marker,"",obj); | |
89 | + PowerMock.replay(LoggerFactory.class, this.logger); | |
90 | + this.slf4jLoggerProxy.debug(marker,"",obj); | |
91 | + PowerMock.verify(this.logger); | |
92 | + } | |
93 | + | |
79 | 94 | // @Test |
80 | 95 | // public void testDebugWithMarkerStringAndTwoObjects() { |
81 | -// Marker marker = null; | |
96 | +// Marker marker = nullthis.slf4jLoggerProxy = new Slf4jLoggerProxy(Logger.class);; | |
82 | 97 | // Object obj1 = null, obj2 = null; |
83 | 98 | // this.logger.debug(marker,"",obj1,obj2); |
84 | 99 | // replay(this.logger); |
... | ... | @@ -557,4 +572,4 @@ |
557 | 572 | // this.slf4jLoggerProxy.warn("",t); |
558 | 573 | // verify(this.logger); |
559 | 574 | // } |
560 | -//} | |
575 | +} | ... | ... |