Commit bbdc3141317afcdb552307eda55a60acc891675e

Authored by Ednara Oliveira
1 parent 2245b692
Exists in master

Ajustes do teste unitário de ServletFilterTest

impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/util/ServletFilterTest.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 + */
1 37 package br.gov.frameworkdemoiselle.util;
2 38  
3 39 import static org.easymock.EasyMock.expect;
4 40 import static org.powermock.api.easymock.PowerMock.createMock;
5 41 import static org.powermock.api.easymock.PowerMock.mockStatic;
6   -import static org.powermock.api.easymock.PowerMock.replayAll;
  42 +import static org.powermock.api.easymock.PowerMock.replay;
7 43 import static org.powermock.api.easymock.PowerMock.verifyAll;
8 44  
9 45 import java.io.IOException;
10 46  
11 47 import javax.servlet.FilterChain;
  48 +import javax.servlet.FilterConfig;
12 49 import javax.servlet.ServletException;
13 50 import javax.servlet.http.HttpServletRequest;
14 51 import javax.servlet.http.HttpServletResponse;
... ... @@ -29,9 +66,21 @@ public class ServletFilterTest {
29 66 private ServletFilter filter;
30 67  
31 68 @Test
  69 + public void testInit() throws ServletException {
  70 + FilterConfig config = createMock(FilterConfig.class);
  71 + replay(config);
  72 +
  73 + filter = new ServletFilter();
  74 + filter.init(config);
  75 +
  76 + verifyAll();
  77 + }
  78 +
  79 + @Test
32 80 public void testDoFilter() throws IOException, ServletException {
33 81 HttpServletRequest request = createMock(HttpServletRequest.class);
34 82 HttpServletResponse response = createMock(HttpServletResponse.class);
  83 +
35 84 FilterChain chain = createMock(FilterChain.class);
36 85 HttpServletRequestProducer requestProducer = createMock(HttpServletRequestProducer.class);
37 86 HttpServletResponseProducer responseProducer = createMock(HttpServletResponseProducer.class);
... ... @@ -46,13 +95,18 @@ public class ServletFilterTest {
46 95 chain.doFilter(request, response);
47 96 PowerMock.expectLastCall().times(1);
48 97  
49   - replayAll();
  98 + replay(Beans.class, request, response, chain, requestProducer, responseProducer);
50 99  
51 100 filter = new ServletFilter();
52   -
53 101 filter.doFilter(request, response, chain);
54 102  
55 103 verifyAll();
56 104 }
57 105  
  106 + @Test
  107 + public void testDestroy() {
  108 + filter = new ServletFilter();
  109 + filter.destroy();
  110 + verifyAll();
  111 + }
58 112 }
... ...