Commit f1402b003a2b0dcf57e43610c946ae354670ffa9
Exists in
master
Merge branch 'master' of git@github.com:demoiselle/framework.git
Showing
19 changed files
with
586 additions
and
46 deletions
Show diff stats
archetype/jsf-jpa/src/main/resources/archetype-resources/pom.xml
| @@ -42,7 +42,7 @@ | @@ -42,7 +42,7 @@ | ||
| 42 | <dependency> | 42 | <dependency> |
| 43 | <groupId>br.gov.frameworkdemoiselle.component</groupId> | 43 | <groupId>br.gov.frameworkdemoiselle.component</groupId> |
| 44 | <artifactId>demoiselle-junit</artifactId> | 44 | <artifactId>demoiselle-junit</artifactId> |
| 45 | - <version>2.3.0-RC1</version> | 45 | + <version>2.3.0</version> |
| 46 | <scope>test</scope> | 46 | <scope>test</scope> |
| 47 | </dependency> | 47 | </dependency> |
| 48 | <dependency> | 48 | <dependency> |
archetype/minimal/src/main/resources/archetype-resources/pom.xml
| @@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
| 23 | <dependency> | 23 | <dependency> |
| 24 | <groupId>br.gov.frameworkdemoiselle.component</groupId> | 24 | <groupId>br.gov.frameworkdemoiselle.component</groupId> |
| 25 | <artifactId>demoiselle-junit</artifactId> | 25 | <artifactId>demoiselle-junit</artifactId> |
| 26 | - <version>2.3.0-RC1</version> | 26 | + <version>2.3.0</version> |
| 27 | <scope>test</scope> | 27 | <scope>test</scope> |
| 28 | </dependency> | 28 | </dependency> |
| 29 | <dependency> | 29 | <dependency> |
documentation/quickstart/pt-BR/criacao.xml
| @@ -296,7 +296,7 @@ | @@ -296,7 +296,7 @@ | ||
| 296 | <para> | 296 | <para> |
| 297 | No diretório <filename>/src/main/resources/META-INF/</filename> foi criado o arquivo <filename>persistence.xml</filename> | 297 | No diretório <filename>/src/main/resources/META-INF/</filename> foi criado o arquivo <filename>persistence.xml</filename> |
| 298 | utilizado para armazenar as configurações de acesso ao banco de dados via JPA (conexões controladas por um <literal>JPA Provider</literal>, ex: Hibernate) | 298 | utilizado para armazenar as configurações de acesso ao banco de dados via JPA (conexões controladas por um <literal>JPA Provider</literal>, ex: Hibernate) |
| 299 | - ou JTA (conexões controladas pelo <literal>Application Server</literal>, ex: JBossAS) e como pode ser observado o <emphasis>Demoiselle Framework 2</emphasis> | 299 | + ou JTA (conexões controladas pelo <literal>Application Server</literal>, ex: JBossAS) e, como pode ser observado, o <emphasis>Demoiselle Framework 2</emphasis> |
| 300 | já traz neste arquivo vários exemplos de configurações para os mais distintos <literal>Application Servers</literal>, como: | 300 | já traz neste arquivo vários exemplos de configurações para os mais distintos <literal>Application Servers</literal>, como: |
| 301 | JBoss AS7, JBoss AS6, GlassFish 3, Tomcat 6 e Tomcat7. | 301 | JBoss AS7, JBoss AS6, GlassFish 3, Tomcat 6 e Tomcat7. |
| 302 | </para> | 302 | </para> |
| @@ -607,4 +607,4 @@ public class BookmarkListMB extends AbstractListPageBean<Bookmark, Long> { | @@ -607,4 +607,4 @@ public class BookmarkListMB extends AbstractListPageBean<Bookmark, Long> { | ||
| 607 | </figure> | 607 | </figure> |
| 608 | </section> | 608 | </section> |
| 609 | 609 | ||
| 610 | -</chapter> | ||
| 611 | \ No newline at end of file | 610 | \ No newline at end of file |
| 611 | +</chapter> |
documentation/reference/pom.xml
| @@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
| 45 | <parent> | 45 | <parent> |
| 46 | <groupId>br.gov.frameworkdemoiselle</groupId> | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | <artifactId>demoiselle-documentation-parent</artifactId> | 47 | <artifactId>demoiselle-documentation-parent</artifactId> |
| 48 | - <version>8-SNAPSHOT</version> | 48 | + <version>8</version> |
| 49 | <relativePath>../../../internal/parent/documentation</relativePath> | 49 | <relativePath>../../../internal/parent/documentation</relativePath> |
| 50 | </parent> | 50 | </parent> |
| 51 | 51 |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrap.java
| @@ -128,7 +128,7 @@ public abstract class AbstractLifecycleBootstrap<A extends Annotation> implement | @@ -128,7 +128,7 @@ public abstract class AbstractLifecycleBootstrap<A extends Annotation> implement | ||
| 128 | 128 | ||
| 129 | @SuppressWarnings({ "unchecked", "rawtypes" }) | 129 | @SuppressWarnings({ "unchecked", "rawtypes" }) |
| 130 | protected synchronized void proccessEvent() { | 130 | protected synchronized void proccessEvent() { |
| 131 | - getLogger().debug(getBundle().getString("executing-all", annotationClass.getSimpleName())); | 131 | + getLogger().debug(getBundle().getString("executing-all", getAnnotationClass().getSimpleName())); |
| 132 | 132 | ||
| 133 | Collections.sort(processors); | 133 | Collections.sort(processors); |
| 134 | Throwable failure = null; | 134 | Throwable failure = null; |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrapTest.java
0 → 100644
| @@ -0,0 +1,165 @@ | @@ -0,0 +1,165 @@ | ||
| 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 junit.framework.Assert.assertFalse; | ||
| 40 | +import static junit.framework.Assert.assertNotNull; | ||
| 41 | +import static junit.framework.Assert.assertTrue; | ||
| 42 | +import static org.easymock.EasyMock.createMock; | ||
| 43 | +import static org.easymock.EasyMock.expect; | ||
| 44 | +import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 45 | +import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
| 46 | + | ||
| 47 | +import java.lang.reflect.Field; | ||
| 48 | +import java.util.HashSet; | ||
| 49 | +import java.util.List; | ||
| 50 | +import java.util.Set; | ||
| 51 | + | ||
| 52 | +import javax.enterprise.context.ConversationScoped; | ||
| 53 | +import javax.enterprise.context.RequestScoped; | ||
| 54 | +import javax.enterprise.context.SessionScoped; | ||
| 55 | +import javax.enterprise.inject.spi.AnnotatedMethod; | ||
| 56 | +import javax.enterprise.inject.spi.AnnotatedType; | ||
| 57 | +import javax.enterprise.inject.spi.BeanManager; | ||
| 58 | +import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
| 59 | + | ||
| 60 | +import org.easymock.EasyMock; | ||
| 61 | +import org.junit.Assert; | ||
| 62 | +import org.junit.Before; | ||
| 63 | +import org.junit.Test; | ||
| 64 | +import org.junit.runner.RunWith; | ||
| 65 | +import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 66 | +import org.powermock.modules.junit4.PowerMockRunner; | ||
| 67 | +import org.powermock.reflect.Whitebox; | ||
| 68 | + | ||
| 69 | +import br.gov.frameworkdemoiselle.annotation.ViewScoped; | ||
| 70 | +import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; | ||
| 71 | +import br.gov.frameworkdemoiselle.internal.context.Contexts; | ||
| 72 | +import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; | ||
| 73 | +import br.gov.frameworkdemoiselle.internal.implementation.AnnotatedMethodProcessor; | ||
| 74 | +import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 75 | +import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 76 | +import br.gov.frameworkdemoiselle.lifecycle.Startup; | ||
| 77 | + | ||
| 78 | +@RunWith(PowerMockRunner.class) | ||
| 79 | +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) | ||
| 80 | +public class AbstractLifecycleBootstrapTest { | ||
| 81 | + | ||
| 82 | + private ProcessAnnotatedType event; | ||
| 83 | + | ||
| 84 | + private BeanManager beanManager; | ||
| 85 | + | ||
| 86 | + private AnnotatedType annotatedType; | ||
| 87 | + | ||
| 88 | + private StartupBootstrap startupBootstrap; | ||
| 89 | + | ||
| 90 | + private ShutdownBootstrap shutdownBootstrap; | ||
| 91 | + | ||
| 92 | + private Class annotationClass; | ||
| 93 | + | ||
| 94 | + @Before | ||
| 95 | + public void before() { | ||
| 96 | + event = createMock(ProcessAnnotatedType.class); | ||
| 97 | + annotatedType = createMock(AnnotatedType.class); | ||
| 98 | + beanManager = null; | ||
| 99 | + annotationClass = null; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + private List<AnnotatedMethodProcessor> getActions(AbstractLifecycleBootstrap bootstrap) | ||
| 103 | + throws IllegalArgumentException, IllegalAccessException { | ||
| 104 | + | ||
| 105 | + Field fields = Whitebox.getField(AbstractLifecycleBootstrap.class, "processors"); | ||
| 106 | + List<AnnotatedMethodProcessor> list = (List<AnnotatedMethodProcessor>) fields.get(bootstrap); | ||
| 107 | + return list; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + @Test | ||
| 111 | + public void processAnnotatedTypeStartup() throws IllegalArgumentException, IllegalAccessException { | ||
| 112 | + startupBootstrap = new StartupBootstrap(); | ||
| 113 | + List<AnnotatedMethodProcessor> list = getActions(startupBootstrap); | ||
| 114 | + | ||
| 115 | + assertNotNull(list); | ||
| 116 | + assertTrue(list.isEmpty()); | ||
| 117 | + | ||
| 118 | + AnnotatedMethod am1 = createMock(AnnotatedMethod.class); | ||
| 119 | + AnnotatedMethod am2 = createMock(AnnotatedMethod.class); | ||
| 120 | + AnnotatedMethod am3 = createMock(AnnotatedMethod.class); | ||
| 121 | + | ||
| 122 | + Set<AnnotatedMethod> set = new HashSet<AnnotatedMethod>(); | ||
| 123 | + set.add(am1); | ||
| 124 | + set.add(am2); | ||
| 125 | + set.add(am3); | ||
| 126 | + | ||
| 127 | + expect(am1.isAnnotationPresent(Startup.class)).andReturn(true); | ||
| 128 | + expect(am2.isAnnotationPresent(Startup.class)).andReturn(true); | ||
| 129 | + expect(am3.isAnnotationPresent(Startup.class)).andReturn(false); | ||
| 130 | + expect(event.getAnnotatedType()).andReturn(annotatedType); | ||
| 131 | + expect(annotatedType.getMethods()).andReturn(set); | ||
| 132 | + | ||
| 133 | + EasyMock.replay(event, annotatedType, am1, am2, am3); | ||
| 134 | + startupBootstrap.processAnnotatedType(event); | ||
| 135 | + EasyMock.verify(event, annotatedType); | ||
| 136 | + | ||
| 137 | + list = getActions(startupBootstrap); | ||
| 138 | + assertNotNull(list); | ||
| 139 | + assertFalse(list.isEmpty()); | ||
| 140 | + assertTrue(list.size() == 2); | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + @Test | ||
| 144 | + public void testLoadTempContexts() { | ||
| 145 | + startupBootstrap = new StartupBootstrap(); | ||
| 146 | + | ||
| 147 | + List<ThreadLocalContext> tempContexts = Whitebox.getInternalState(startupBootstrap, "tempContexts"); | ||
| 148 | + | ||
| 149 | + assertNotNull(tempContexts); | ||
| 150 | + assertTrue(tempContexts.isEmpty()); | ||
| 151 | + | ||
| 152 | + replayAll(); | ||
| 153 | + startupBootstrap.loadTempContexts(null); | ||
| 154 | + verifyAll(); | ||
| 155 | + | ||
| 156 | + assertNotNull(tempContexts); | ||
| 157 | + Assert.assertEquals(4, tempContexts.size()); | ||
| 158 | + for (ThreadLocalContext tlc : tempContexts) { | ||
| 159 | + if (!tlc.getScope().equals(SessionScoped.class) && !tlc.getScope().equals(ConversationScoped.class) | ||
| 160 | + && !tlc.getScope().equals(RequestScoped.class) && !tlc.getScope().equals(ViewScoped.class)) { | ||
| 161 | + Assert.fail(); | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + } | ||
| 165 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/util/ReflectionsTest.java
| @@ -38,6 +38,8 @@ package br.gov.frameworkdemoiselle.util; | @@ -38,6 +38,8 @@ package br.gov.frameworkdemoiselle.util; | ||
| 38 | 38 | ||
| 39 | import static org.junit.Assert.assertEquals; | 39 | import static org.junit.Assert.assertEquals; |
| 40 | 40 | ||
| 41 | +import java.lang.reflect.Member; | ||
| 42 | + | ||
| 41 | import org.junit.Test; | 43 | import org.junit.Test; |
| 42 | 44 | ||
| 43 | public class ReflectionsTest { | 45 | public class ReflectionsTest { |
| @@ -48,11 +50,24 @@ public class ReflectionsTest { | @@ -48,11 +50,24 @@ public class ReflectionsTest { | ||
| 48 | assertEquals(String.class, Reflections.getGenericTypeArgument(OtherClass.class, 1)); | 50 | assertEquals(String.class, Reflections.getGenericTypeArgument(OtherClass.class, 1)); |
| 49 | } | 51 | } |
| 50 | 52 | ||
| 53 | + @Test | ||
| 54 | + public void testGetGenericTypeArgumentMember() throws SecurityException, NoSuchFieldException { | ||
| 55 | + Member[] members = OtherClass.class.getFields(); | ||
| 56 | + assertEquals(Long.class, Reflections.getGenericTypeArgument(members[0], 0)); | ||
| 57 | + assertEquals(String.class, Reflections.getGenericTypeArgument(members[1], 0)); | ||
| 58 | + } | ||
| 51 | } | 59 | } |
| 52 | 60 | ||
| 53 | class SomeClass<T, I> { | 61 | class SomeClass<T, I> { |
| 54 | 62 | ||
| 63 | + public void setNumber(T t) { | ||
| 64 | + | ||
| 65 | + } | ||
| 55 | } | 66 | } |
| 56 | 67 | ||
| 57 | class OtherClass extends SomeClass<Long, String> { | 68 | class OtherClass extends SomeClass<Long, String> { |
| 69 | + | ||
| 70 | + public Class<Long> number; | ||
| 71 | + | ||
| 72 | + public Class<String> text; | ||
| 58 | } | 73 | } |
impl/extension/jpa/pom.xml
| @@ -78,11 +78,11 @@ | @@ -78,11 +78,11 @@ | ||
| 78 | <scope>test</scope> | 78 | <scope>test</scope> |
| 79 | </dependency> | 79 | </dependency> |
| 80 | <dependency> | 80 | <dependency> |
| 81 | - <groupId>br.gov.frameworkdemoiselle.component</groupId> | ||
| 82 | - <artifactId>demoiselle-junit</artifactId> | ||
| 83 | - <version>2.3.0-RC2-SNAPSHOT</version> | 81 | + <groupId>org.hibernate</groupId> |
| 82 | + <artifactId>hibernate-validator</artifactId> | ||
| 84 | <scope>test</scope> | 83 | <scope>test</scope> |
| 85 | </dependency> | 84 | </dependency> |
| 85 | + | ||
| 86 | <dependency> | 86 | <dependency> |
| 87 | <groupId>hsqldb</groupId> | 87 | <groupId>hsqldb</groupId> |
| 88 | <artifactId>hsqldb</artifactId> | 88 | <artifactId>hsqldb</artifactId> |
| @@ -114,4 +114,4 @@ | @@ -114,4 +114,4 @@ | ||
| 114 | </releases> | 114 | </releases> |
| 115 | </repository> | 115 | </repository> |
| 116 | </repositories> | 116 | </repositories> |
| 117 | -</project> | ||
| 118 | \ No newline at end of file | 117 | \ No newline at end of file |
| 118 | +</project> |
impl/extension/jta/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.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 | + | ||
| 1 | package br.gov.frameworkdemoiselle.transaction; | 38 | package br.gov.frameworkdemoiselle.transaction; |
| 2 | 39 | ||
| 3 | import static org.easymock.EasyMock.createMock; | 40 | import static org.easymock.EasyMock.createMock; |
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/producer/HttpServletRequestProducerTest.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 | package br.gov.frameworkdemoiselle.internal.producer; | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
| 2 | 38 | ||
| 3 | import static org.easymock.EasyMock.replay; | 39 | import static org.easymock.EasyMock.replay; |
| @@ -5,20 +41,18 @@ import static org.powermock.api.easymock.PowerMock.createMock; | @@ -5,20 +41,18 @@ import static org.powermock.api.easymock.PowerMock.createMock; | ||
| 5 | import static org.powermock.api.easymock.PowerMock.verifyAll; | 41 | import static org.powermock.api.easymock.PowerMock.verifyAll; |
| 6 | 42 | ||
| 7 | import javax.servlet.http.HttpServletRequest; | 43 | import javax.servlet.http.HttpServletRequest; |
| 8 | -import javax.servlet.http.HttpServletResponse; | ||
| 9 | 44 | ||
| 10 | import junit.framework.Assert; | 45 | import junit.framework.Assert; |
| 11 | 46 | ||
| 12 | import org.junit.Test; | 47 | import org.junit.Test; |
| 13 | import org.powermock.reflect.Whitebox; | 48 | import org.powermock.reflect.Whitebox; |
| 14 | 49 | ||
| 15 | - | ||
| 16 | public class HttpServletRequestProducerTest { | 50 | public class HttpServletRequestProducerTest { |
| 17 | 51 | ||
| 18 | private HttpServletRequestProducer httpServletRequestProducer; | 52 | private HttpServletRequestProducer httpServletRequestProducer; |
| 19 | - | 53 | + |
| 20 | private HttpServletRequest request; | 54 | private HttpServletRequest request; |
| 21 | - | 55 | + |
| 22 | @Test | 56 | @Test |
| 23 | public void testCreate() { | 57 | public void testCreate() { |
| 24 | request = createMock(HttpServletRequest.class); | 58 | request = createMock(HttpServletRequest.class); |
| @@ -28,10 +62,10 @@ public class HttpServletRequestProducerTest { | @@ -28,10 +62,10 @@ public class HttpServletRequestProducerTest { | ||
| 28 | Whitebox.setInternalState(httpServletRequestProducer, "request", request); | 62 | Whitebox.setInternalState(httpServletRequestProducer, "request", request); |
| 29 | 63 | ||
| 30 | Assert.assertEquals(httpServletRequestProducer.create(), request); | 64 | Assert.assertEquals(httpServletRequestProducer.create(), request); |
| 31 | - | 65 | + |
| 32 | verifyAll(); | 66 | verifyAll(); |
| 33 | } | 67 | } |
| 34 | - | 68 | + |
| 35 | @Test | 69 | @Test |
| 36 | public void testSetDelegate() { | 70 | public void testSetDelegate() { |
| 37 | request = createMock(HttpServletRequest.class); | 71 | request = createMock(HttpServletRequest.class); |
| @@ -40,9 +74,9 @@ public class HttpServletRequestProducerTest { | @@ -40,9 +74,9 @@ public class HttpServletRequestProducerTest { | ||
| 40 | httpServletRequestProducer = new HttpServletRequestProducer(); | 74 | httpServletRequestProducer = new HttpServletRequestProducer(); |
| 41 | 75 | ||
| 42 | httpServletRequestProducer.setDelegate(request); | 76 | httpServletRequestProducer.setDelegate(request); |
| 43 | - Assert.assertEquals(Whitebox.getInternalState(httpServletRequestProducer, "request"),request); | ||
| 44 | - | 77 | + Assert.assertEquals(Whitebox.getInternalState(httpServletRequestProducer, "request"), request); |
| 78 | + | ||
| 45 | verifyAll(); | 79 | verifyAll(); |
| 46 | - } | ||
| 47 | - | 80 | + } |
| 81 | + | ||
| 48 | } | 82 | } |
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/producer/HttpServletResponseProducerTest.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 | package br.gov.frameworkdemoiselle.internal.producer; | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
| 2 | 38 | ||
| 3 | import static org.easymock.EasyMock.replay; | 39 | import static org.easymock.EasyMock.replay; |
| 4 | import static org.powermock.api.easymock.PowerMock.createMock; | 40 | import static org.powermock.api.easymock.PowerMock.createMock; |
| 5 | import static org.powermock.api.easymock.PowerMock.verifyAll; | 41 | import static org.powermock.api.easymock.PowerMock.verifyAll; |
| 6 | 42 | ||
| 7 | -import javax.servlet.http.HttpServletRequest; | ||
| 8 | import javax.servlet.http.HttpServletResponse; | 43 | import javax.servlet.http.HttpServletResponse; |
| 9 | 44 | ||
| 10 | import junit.framework.Assert; | 45 | import junit.framework.Assert; |
| @@ -12,13 +47,12 @@ import junit.framework.Assert; | @@ -12,13 +47,12 @@ import junit.framework.Assert; | ||
| 12 | import org.junit.Test; | 47 | import org.junit.Test; |
| 13 | import org.powermock.reflect.Whitebox; | 48 | import org.powermock.reflect.Whitebox; |
| 14 | 49 | ||
| 15 | - | ||
| 16 | public class HttpServletResponseProducerTest { | 50 | public class HttpServletResponseProducerTest { |
| 17 | 51 | ||
| 18 | private HttpServletResponseProducer httpServletResponseProducer; | 52 | private HttpServletResponseProducer httpServletResponseProducer; |
| 19 | - | 53 | + |
| 20 | private HttpServletResponse response; | 54 | private HttpServletResponse response; |
| 21 | - | 55 | + |
| 22 | @Test | 56 | @Test |
| 23 | public void testCreate() { | 57 | public void testCreate() { |
| 24 | response = createMock(HttpServletResponse.class); | 58 | response = createMock(HttpServletResponse.class); |
| @@ -28,10 +62,10 @@ public class HttpServletResponseProducerTest { | @@ -28,10 +62,10 @@ public class HttpServletResponseProducerTest { | ||
| 28 | Whitebox.setInternalState(httpServletResponseProducer, "response", response); | 62 | Whitebox.setInternalState(httpServletResponseProducer, "response", response); |
| 29 | 63 | ||
| 30 | Assert.assertEquals(httpServletResponseProducer.create(), response); | 64 | Assert.assertEquals(httpServletResponseProducer.create(), response); |
| 31 | - | 65 | + |
| 32 | verifyAll(); | 66 | verifyAll(); |
| 33 | } | 67 | } |
| 34 | - | 68 | + |
| 35 | @Test | 69 | @Test |
| 36 | public void testSetDelegate() { | 70 | public void testSetDelegate() { |
| 37 | response = createMock(HttpServletResponse.class); | 71 | response = createMock(HttpServletResponse.class); |
| @@ -41,8 +75,8 @@ public class HttpServletResponseProducerTest { | @@ -41,8 +75,8 @@ public class HttpServletResponseProducerTest { | ||
| 41 | 75 | ||
| 42 | httpServletResponseProducer.setDelegate(response); | 76 | httpServletResponseProducer.setDelegate(response); |
| 43 | Assert.assertEquals(Whitebox.getInternalState(httpServletResponseProducer, "response"), response); | 77 | Assert.assertEquals(Whitebox.getInternalState(httpServletResponseProducer, "response"), response); |
| 44 | - | 78 | + |
| 45 | verifyAll(); | 79 | verifyAll(); |
| 46 | - } | ||
| 47 | - | 80 | + } |
| 81 | + | ||
| 48 | } | 82 | } |
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/producer/HttpSessionProducerTest.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 | package br.gov.frameworkdemoiselle.internal.producer; | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
| 2 | 38 | ||
| 3 | import static org.easymock.EasyMock.createMock; | 39 | import static org.easymock.EasyMock.createMock; |
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ServletLocaleProducerTest.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 | package br.gov.frameworkdemoiselle.internal.producer; | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
| 2 | 38 | ||
| 3 | import static org.easymock.EasyMock.createMock; | 39 | import static org.easymock.EasyMock.createMock; |
| @@ -36,7 +72,7 @@ public class ServletLocaleProducerTest { | @@ -36,7 +72,7 @@ public class ServletLocaleProducerTest { | ||
| 36 | 72 | ||
| 37 | verifyAll(); | 73 | verifyAll(); |
| 38 | } | 74 | } |
| 39 | - | 75 | + |
| 40 | @Test | 76 | @Test |
| 41 | public void testCreate2() { | 77 | public void testCreate2() { |
| 42 | servletLocaleProducer = new ServletLocaleProducer(); | 78 | servletLocaleProducer = new ServletLocaleProducer(); |
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/HttpServletRequestProxyTest.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 | package br.gov.frameworkdemoiselle.internal.proxy; | 37 | package br.gov.frameworkdemoiselle.internal.proxy; |
| 2 | 38 | ||
| 3 | import org.junit.runner.RunWith; | 39 | import org.junit.runner.RunWith; |
| @@ -6,6 +42,4 @@ import org.powermock.modules.junit4.PowerMockRunner; | @@ -6,6 +42,4 @@ import org.powermock.modules.junit4.PowerMockRunner; | ||
| 6 | @RunWith(PowerMockRunner.class) | 42 | @RunWith(PowerMockRunner.class) |
| 7 | public class HttpServletRequestProxyTest { | 43 | public class HttpServletRequestProxyTest { |
| 8 | 44 | ||
| 9 | - | ||
| 10 | - | ||
| 11 | } | 45 | } |
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/util/ServletFilterTest.java
0 → 100644
| @@ -0,0 +1,112 @@ | @@ -0,0 +1,112 @@ | ||
| 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.util; | ||
| 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.io.IOException; | ||
| 46 | + | ||
| 47 | +import javax.servlet.FilterChain; | ||
| 48 | +import javax.servlet.FilterConfig; | ||
| 49 | +import javax.servlet.ServletException; | ||
| 50 | +import javax.servlet.http.HttpServletRequest; | ||
| 51 | +import javax.servlet.http.HttpServletResponse; | ||
| 52 | + | ||
| 53 | +import org.junit.Test; | ||
| 54 | +import org.junit.runner.RunWith; | ||
| 55 | +import org.powermock.api.easymock.PowerMock; | ||
| 56 | +import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 57 | +import org.powermock.modules.junit4.PowerMockRunner; | ||
| 58 | + | ||
| 59 | +import br.gov.frameworkdemoiselle.internal.producer.HttpServletRequestProducer; | ||
| 60 | +import br.gov.frameworkdemoiselle.internal.producer.HttpServletResponseProducer; | ||
| 61 | + | ||
| 62 | +@RunWith(PowerMockRunner.class) | ||
| 63 | +@PrepareForTest(Beans.class) | ||
| 64 | +public class ServletFilterTest { | ||
| 65 | + | ||
| 66 | + private ServletFilter filter; | ||
| 67 | + | ||
| 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 | ||
| 80 | + public void testDoFilter() throws IOException, ServletException { | ||
| 81 | + HttpServletRequest request = createMock(HttpServletRequest.class); | ||
| 82 | + HttpServletResponse response = createMock(HttpServletResponse.class); | ||
| 83 | + | ||
| 84 | + FilterChain chain = createMock(FilterChain.class); | ||
| 85 | + HttpServletRequestProducer requestProducer = createMock(HttpServletRequestProducer.class); | ||
| 86 | + HttpServletResponseProducer responseProducer = createMock(HttpServletResponseProducer.class); | ||
| 87 | + | ||
| 88 | + mockStatic(Beans.class); | ||
| 89 | + expect(Beans.getReference(HttpServletRequestProducer.class)).andReturn(requestProducer); | ||
| 90 | + expect(Beans.getReference(HttpServletResponseProducer.class)).andReturn(responseProducer); | ||
| 91 | + requestProducer.setDelegate(request); | ||
| 92 | + PowerMock.expectLastCall().times(1); | ||
| 93 | + responseProducer.setDelegate(response); | ||
| 94 | + PowerMock.expectLastCall().times(1); | ||
| 95 | + chain.doFilter(request, response); | ||
| 96 | + PowerMock.expectLastCall().times(1); | ||
| 97 | + | ||
| 98 | + replay(Beans.class, request, response, chain, requestProducer, responseProducer); | ||
| 99 | + | ||
| 100 | + filter = new ServletFilter(); | ||
| 101 | + filter.doFilter(request, response, chain); | ||
| 102 | + | ||
| 103 | + verifyAll(); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + @Test | ||
| 107 | + public void testDestroy() { | ||
| 108 | + filter = new ServletFilter(); | ||
| 109 | + filter.destroy(); | ||
| 110 | + verifyAll(); | ||
| 111 | + } | ||
| 112 | +} |
impl/extension/servlet/src/test/java/br/gov/frameworkdemoiselle/util/ServletListenerTest.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 | package br.gov.frameworkdemoiselle.util; | 37 | package br.gov.frameworkdemoiselle.util; |
| 2 | 38 | ||
| 3 | import static org.easymock.EasyMock.createMock; | 39 | import static org.easymock.EasyMock.createMock; |
| @@ -24,41 +60,41 @@ import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; | @@ -24,41 +60,41 @@ import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; | ||
| 24 | public class ServletListenerTest { | 60 | public class ServletListenerTest { |
| 25 | 61 | ||
| 26 | private ServletListener listener; | 62 | private ServletListener listener; |
| 27 | - | 63 | + |
| 28 | @Test | 64 | @Test |
| 29 | public void testContextInitialized() { | 65 | public void testContextInitialized() { |
| 30 | ServletContextEvent event = createMock(ServletContextEvent.class); | 66 | ServletContextEvent event = createMock(ServletContextEvent.class); |
| 31 | BeanManager beanManager = PowerMock.createMock(BeanManager.class); | 67 | BeanManager beanManager = PowerMock.createMock(BeanManager.class); |
| 32 | - | 68 | + |
| 33 | mockStatic(Beans.class); | 69 | mockStatic(Beans.class); |
| 34 | expect(Beans.getBeanManager()).andReturn(beanManager); | 70 | expect(Beans.getBeanManager()).andReturn(beanManager); |
| 35 | beanManager.fireEvent(EasyMock.anyObject(AfterStartupProccess.class)); | 71 | beanManager.fireEvent(EasyMock.anyObject(AfterStartupProccess.class)); |
| 36 | PowerMock.expectLastCall().times(1); | 72 | PowerMock.expectLastCall().times(1); |
| 37 | - | 73 | + |
| 38 | replayAll(); | 74 | replayAll(); |
| 39 | - | 75 | + |
| 40 | listener = new ServletListener(); | 76 | listener = new ServletListener(); |
| 41 | listener.contextInitialized(event); | 77 | listener.contextInitialized(event); |
| 42 | - | 78 | + |
| 43 | verifyAll(); | 79 | verifyAll(); |
| 44 | } | 80 | } |
| 45 | - | 81 | + |
| 46 | @Test | 82 | @Test |
| 47 | public void testContextDestroyed() { | 83 | public void testContextDestroyed() { |
| 48 | ServletContextEvent event = createMock(ServletContextEvent.class); | 84 | ServletContextEvent event = createMock(ServletContextEvent.class); |
| 49 | BeanManager beanManager = PowerMock.createMock(BeanManager.class); | 85 | BeanManager beanManager = PowerMock.createMock(BeanManager.class); |
| 50 | - | 86 | + |
| 51 | mockStatic(Beans.class); | 87 | mockStatic(Beans.class); |
| 52 | expect(Beans.getBeanManager()).andReturn(beanManager); | 88 | expect(Beans.getBeanManager()).andReturn(beanManager); |
| 53 | beanManager.fireEvent(EasyMock.anyObject(ShutdownBootstrap.class)); | 89 | beanManager.fireEvent(EasyMock.anyObject(ShutdownBootstrap.class)); |
| 54 | PowerMock.expectLastCall().times(1); | 90 | PowerMock.expectLastCall().times(1); |
| 55 | - | 91 | + |
| 56 | replayAll(); | 92 | replayAll(); |
| 57 | - | 93 | + |
| 58 | listener = new ServletListener(); | 94 | listener = new ServletListener(); |
| 59 | listener.contextDestroyed(event); | 95 | listener.contextDestroyed(event); |
| 60 | - | 96 | + |
| 61 | verifyAll(); | 97 | verifyAll(); |
| 62 | } | 98 | } |
| 63 | - | 99 | + |
| 64 | } | 100 | } |
parent/bom/pom.xml
| @@ -142,7 +142,7 @@ | @@ -142,7 +142,7 @@ | ||
| 142 | <dependency> | 142 | <dependency> |
| 143 | <groupId>org.hibernate</groupId> | 143 | <groupId>org.hibernate</groupId> |
| 144 | <artifactId>hibernate-validator</artifactId> | 144 | <artifactId>hibernate-validator</artifactId> |
| 145 | - <version>4.2.0.Final</version> | 145 | + <version>${hibernate.validator.version}</version> |
| 146 | <exclusions> | 146 | <exclusions> |
| 147 | <exclusion> | 147 | <exclusion> |
| 148 | <groupId>javax.xml.bind</groupId> | 148 | <groupId>javax.xml.bind</groupId> |
| @@ -332,6 +332,7 @@ | @@ -332,6 +332,7 @@ | ||
| 332 | <persistence.version>2.0.0</persistence.version> | 332 | <persistence.version>2.0.0</persistence.version> |
| 333 | 333 | ||
| 334 | <hibernate.version>4.1.7.Final</hibernate.version> | 334 | <hibernate.version>4.1.7.Final</hibernate.version> |
| 335 | + <hibernate.validator.version>4.2.0.Final</hibernate.validator.version> | ||
| 335 | 336 | ||
| 336 | <junit.version>4.8.1</junit.version> | 337 | <junit.version>4.8.1</junit.version> |
| 337 | <easymock.version>3.0</easymock.version> | 338 | <easymock.version>3.0</easymock.version> |
parent/framework/pom.xml
| @@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
| 45 | <parent> | 45 | <parent> |
| 46 | <groupId>br.gov.frameworkdemoiselle</groupId> | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | <artifactId>demoiselle-parent</artifactId> | 47 | <artifactId>demoiselle-parent</artifactId> |
| 48 | - <version>8-SNAPSHOT</version> | 48 | + <version>8</version> |
| 49 | <relativePath>../../../internal/parent/demoiselle</relativePath> | 49 | <relativePath>../../../internal/parent/demoiselle</relativePath> |
| 50 | </parent> | 50 | </parent> |
| 51 | 51 |
pom.xml
| @@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
| 45 | <parent> | 45 | <parent> |
| 46 | <groupId>br.gov.frameworkdemoiselle</groupId> | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | <artifactId>demoiselle-build-parent</artifactId> | 47 | <artifactId>demoiselle-build-parent</artifactId> |
| 48 | - <version>8-SNAPSHOT</version> | 48 | + <version>8</version> |
| 49 | <relativePath>../internal/parent/build/demoiselle</relativePath> | 49 | <relativePath>../internal/parent/build/demoiselle</relativePath> |
| 50 | </parent> | 50 | </parent> |
| 51 | 51 |