Commit 6137c06221c0c1505bd9adf3a1bb465428019791
Exists in
master
Merge remote-tracking branch 'origin/2.4.0' into 2.4.0
Showing
72 changed files
with
1314 additions
and
3438 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
@@ -161,8 +161,11 @@ public final class Beans { | @@ -161,8 +161,11 @@ public final class Beans { | ||
161 | 161 | ||
162 | @SuppressWarnings("unchecked") | 162 | @SuppressWarnings("unchecked") |
163 | private static <T> T getReference(Set<Bean<?>> beans, Class<T> beanClass, Annotation... qualifiers) { | 163 | private static <T> T getReference(Set<Bean<?>> beans, Class<T> beanClass, Annotation... qualifiers) { |
164 | - //Bean<?> bean = beans.iterator().next(); | ||
165 | - Bean<?> bean = getBeanManager().resolve( beans ); | 164 | + Bean<?> bean = beans.iterator().next(); |
165 | + | ||
166 | + // TODO Esta mudança só deve ser submetida com os testes passando. Esta mudança quebra os testes. | ||
167 | + // Bean<?> bean = getBeanManager().resolve( beans ); | ||
168 | + | ||
166 | CreationalContext<?> context = getBeanManager().createCreationalContext(bean); | 169 | CreationalContext<?> context = getBeanManager().createCreationalContext(bean); |
167 | Type beanType = beanClass == null ? bean.getBeanClass() : beanClass; | 170 | Type beanType = beanClass == null ? bean.getBeanClass() : beanClass; |
168 | InjectionPoint injectionPoint = new CustomInjectionPoint(bean, beanType, qualifiers); | 171 | InjectionPoint injectionPoint = new CustomInjectionPoint(bean, beanType, qualifiers); |
impl/extension/jsf/pom.xml
@@ -76,6 +76,12 @@ | @@ -76,6 +76,12 @@ | ||
76 | <artifactId>jsf-api</artifactId> | 76 | <artifactId>jsf-api</artifactId> |
77 | </dependency> | 77 | </dependency> |
78 | <dependency> | 78 | <dependency> |
79 | + <groupId>org.glassfish.web</groupId> | ||
80 | + <artifactId>el-impl</artifactId> | ||
81 | + <scope>provided</scope> | ||
82 | + </dependency> | ||
83 | + <!-- For Tests --> | ||
84 | + <dependency> | ||
79 | <groupId>com.sun.faces</groupId> | 85 | <groupId>com.sun.faces</groupId> |
80 | <artifactId>jsf-impl</artifactId> | 86 | <artifactId>jsf-impl</artifactId> |
81 | <scope>test</scope> | 87 | <scope>test</scope> |
@@ -87,9 +93,10 @@ | @@ -87,9 +93,10 @@ | ||
87 | <scope>test</scope> | 93 | <scope>test</scope> |
88 | </dependency> | 94 | </dependency> |
89 | <dependency> | 95 | <dependency> |
90 | - <groupId>org.glassfish.web</groupId> | ||
91 | - <artifactId>el-impl</artifactId> | ||
92 | - <scope>provided</scope> | 96 | + <groupId>com.ocpsoft</groupId> |
97 | + <artifactId>prettyfaces-jsf2</artifactId> | ||
98 | + <version>3.3.0</version> | ||
99 | + <scope>test</scope> | ||
93 | </dependency> | 100 | </dependency> |
94 | </dependencies> | 101 | </dependencies> |
95 | 102 |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/JsfBootstrapTest.java
@@ -1,126 +0,0 @@ | @@ -1,126 +0,0 @@ | ||
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.ArrayList; | ||
46 | -//import java.util.List; | ||
47 | -//import java.util.Locale; | ||
48 | -// | ||
49 | -//import javax.enterprise.inject.spi.AfterBeanDiscovery; | ||
50 | -//import javax.enterprise.inject.spi.AfterDeploymentValidation; | ||
51 | -// | ||
52 | -//import junit.framework.Assert; | ||
53 | -// | ||
54 | -//import org.junit.Before; | ||
55 | -//import org.junit.Ignore; | ||
56 | -//import org.junit.Test; | ||
57 | -//import org.junit.runner.RunWith; | ||
58 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
59 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
60 | -//import org.powermock.reflect.Whitebox; | ||
61 | -// | ||
62 | -//import br.gov.frameworkdemoiselle.internal.context.AbstractCustomContext; | ||
63 | -//import br.gov.frameworkdemoiselle.internal.context.ContextManager; | ||
64 | -//import br.gov.frameworkdemoiselle.internal.context.ViewContext; | ||
65 | -//import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; | ||
66 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
67 | -// | ||
68 | -//@RunWith(PowerMockRunner.class) | ||
69 | -//@PrepareForTest({ Beans.class, ContextManager.class }) | ||
70 | -//@Ignore | ||
71 | -//public class JsfBootstrapTest { | ||
72 | -// | ||
73 | -// private JsfBootstrap bootstrap; | ||
74 | -// | ||
75 | -// private AfterBeanDiscovery event; | ||
76 | -// | ||
77 | -// @Before | ||
78 | -// public void before() { | ||
79 | -// event = createMock(AfterBeanDiscovery.class); | ||
80 | -// mockStatic(Beans.class); | ||
81 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes(); | ||
82 | -// replay(Beans.class); | ||
83 | -// bootstrap = new JsfBootstrap(); | ||
84 | -// } | ||
85 | -// | ||
86 | -// @Test | ||
87 | -// public void testStoreContexts() { | ||
88 | -// bootstrap.storeContexts(event); | ||
89 | -// replay(event); | ||
90 | -// | ||
91 | -// Assert.assertEquals(event, Whitebox.getInternalState(bootstrap, "afterBeanDiscoveryEvent")); | ||
92 | -// List<AbstractCustomContext> context = Whitebox.getInternalState(bootstrap, "tempContexts"); | ||
93 | -// Assert.assertEquals(1, context.size()); | ||
94 | -// verifyAll(); | ||
95 | -// } | ||
96 | -// | ||
97 | -// @Test | ||
98 | -// public void testAddContexts() { | ||
99 | -// List<AbstractCustomContext> tempContexts = new ArrayList<AbstractCustomContext>(); | ||
100 | -// AbstractCustomContext tempContext = new ViewContext(); | ||
101 | -// tempContexts.add(tempContext); | ||
102 | -// Whitebox.setInternalState(bootstrap, "tempContexts", tempContexts); | ||
103 | -// Whitebox.setInternalState(bootstrap, "afterBeanDiscoveryEvent", event); | ||
104 | -// | ||
105 | -// AfterDeploymentValidation afterDeploymentValidation = createMock(AfterDeploymentValidation.class); | ||
106 | -// | ||
107 | -// event.addContext(tempContext); | ||
108 | -// | ||
109 | -// replay(event, afterDeploymentValidation); | ||
110 | -// | ||
111 | -// bootstrap.addContexts(afterDeploymentValidation); | ||
112 | -// verifyAll(); | ||
113 | -// } | ||
114 | -// | ||
115 | -// @Test | ||
116 | -// public void testRemoveContexts() { | ||
117 | -// bootstrap.storeContexts(event); | ||
118 | -// | ||
119 | -// AfterShutdownProccess afterShutdownProccess = createMock(AfterShutdownProccess.class); | ||
120 | -// replay(event, afterShutdownProccess); | ||
121 | -// bootstrap.removeContexts(afterShutdownProccess); | ||
122 | -// | ||
123 | -// verifyAll(); | ||
124 | -// } | ||
125 | -// | ||
126 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ExceptionHandlerConfigTest.java
@@ -1,27 +0,0 @@ | @@ -1,27 +0,0 @@ | ||
1 | -package br.gov.frameworkdemoiselle.internal.configuration; | ||
2 | - | ||
3 | -import static org.junit.Assert.assertEquals; | ||
4 | - | ||
5 | -import org.junit.Before; | ||
6 | -import org.junit.Test; | ||
7 | - | ||
8 | -public class ExceptionHandlerConfigTest { | ||
9 | - | ||
10 | - private ExceptionHandlerConfig config; | ||
11 | - | ||
12 | - @Before | ||
13 | - public void setUP() throws Exception { | ||
14 | - this.config = new ExceptionHandlerConfig(); | ||
15 | - } | ||
16 | - | ||
17 | - @Test | ||
18 | - public void testGetExceptionPage() { | ||
19 | - assertEquals("/application_error", config.getDefaultRedirectExceptionPage()); | ||
20 | - } | ||
21 | - | ||
22 | - @Test | ||
23 | - public void testIsHandleApplicationException() { | ||
24 | - assertEquals(true, config.isApplicationExceptionHandle()); | ||
25 | - } | ||
26 | - | ||
27 | -} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/JsfSecurityConfigTest.java
@@ -1,38 +0,0 @@ | @@ -1,38 +0,0 @@ | ||
1 | -package br.gov.frameworkdemoiselle.internal.configuration; | ||
2 | - | ||
3 | -import static org.junit.Assert.assertEquals; | ||
4 | - | ||
5 | -import org.junit.Before; | ||
6 | -import org.junit.Test; | ||
7 | - | ||
8 | - | ||
9 | -public class JsfSecurityConfigTest { | ||
10 | - | ||
11 | - private JsfSecurityConfig config; | ||
12 | - | ||
13 | - @Before | ||
14 | - public void setUp() throws Exception { | ||
15 | - this.config = new JsfSecurityConfig(); | ||
16 | - } | ||
17 | - | ||
18 | - @Test | ||
19 | - public void testGetLoginPage() { | ||
20 | - assertEquals("/login", config.getLoginPage()); | ||
21 | - } | ||
22 | - | ||
23 | - @Test | ||
24 | - public void testGetRedirectAfterLogin() { | ||
25 | - assertEquals("/index", config.getRedirectAfterLogin()); | ||
26 | - } | ||
27 | - | ||
28 | - @Test | ||
29 | - public void testGetRedirectAfterLogout() { | ||
30 | - assertEquals("/login", config.getRedirectAfterLogout()); | ||
31 | - } | ||
32 | - | ||
33 | - @Test | ||
34 | - public void testIsRedirectEnabled() { | ||
35 | - assertEquals(true, config.isRedirectEnabled()); | ||
36 | - } | ||
37 | - | ||
38 | -} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/context/ViewContextTest.java
@@ -1,154 +0,0 @@ | @@ -1,154 +0,0 @@ | ||
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.context; | ||
38 | -// | ||
39 | -//import static junit.framework.Assert.assertEquals; | ||
40 | -// | ||
41 | -//import java.util.Map; | ||
42 | -// | ||
43 | -//import javax.enterprise.context.spi.CreationalContext; | ||
44 | -//import javax.enterprise.inject.spi.Bean; | ||
45 | -// | ||
46 | -//import org.easymock.EasyMock; | ||
47 | -//import org.junit.Before; | ||
48 | -//import org.junit.Test; | ||
49 | -//import org.junit.runner.RunWith; | ||
50 | -//import org.powermock.api.easymock.PowerMock; | ||
51 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
52 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
53 | -// | ||
54 | -//import br.gov.frameworkdemoiselle.annotation.ViewScoped; | ||
55 | -//import br.gov.frameworkdemoiselle.util.Faces; | ||
56 | -// | ||
57 | -//@RunWith(PowerMockRunner.class) | ||
58 | -//@PrepareForTest({ Faces.class }) | ||
59 | -//public class ViewContextTest { | ||
60 | -// | ||
61 | -// private ViewContext context; | ||
62 | -// | ||
63 | -// @Before | ||
64 | -// public void before() { | ||
65 | -// context = new ViewContext(); | ||
66 | -// } | ||
67 | -// | ||
68 | -//// @SuppressWarnings("unchecked") | ||
69 | -//// @Test | ||
70 | -//// public void testGetViewMapContainsInstance() { | ||
71 | -//// String instance = "instance"; | ||
72 | -//// | ||
73 | -//// Bean<?> bean = PowerMock.createMock(Bean.class); | ||
74 | -//// EasyMock.expect(bean.getName()).andReturn(instance).anyTimes(); | ||
75 | -//// | ||
76 | -//// Map<String,Object> map = PowerMock.createMock(Map.class); | ||
77 | -//// EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(true); | ||
78 | -//// EasyMock.expect(map.get(EasyMock.anyObject(String.class))).andReturn(instance); | ||
79 | -//// | ||
80 | -//// PowerMock.mockStatic(Faces.class); | ||
81 | -//// EasyMock.expect(Faces.getViewMap()).andReturn(map); | ||
82 | -//// | ||
83 | -//// PowerMock.replay(Faces.class, bean, map); | ||
84 | -//// | ||
85 | -//// assertEquals(instance, context.get(bean)); | ||
86 | -//// | ||
87 | -//// PowerMock.verifyAll(); | ||
88 | -//// } | ||
89 | -//// | ||
90 | -//// @SuppressWarnings("unchecked") | ||
91 | -//// @Test | ||
92 | -//// public void testGetViewMapDoesNotContainsInstance() { | ||
93 | -//// String instance = "instance"; | ||
94 | -//// | ||
95 | -//// Bean<String> bean = PowerMock.createMock(Bean.class); | ||
96 | -//// EasyMock.expect(bean.getName()).andReturn(instance).anyTimes(); | ||
97 | -//// EasyMock.expect(bean.create(EasyMock.anyObject(CreationalContext.class))).andReturn(instance); | ||
98 | -//// | ||
99 | -//// Map<String,Object> map = PowerMock.createMock(Map.class); | ||
100 | -//// EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(false); | ||
101 | -//// EasyMock.expect(map.put(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn(null); | ||
102 | -//// | ||
103 | -//// PowerMock.mockStatic(Faces.class); | ||
104 | -//// EasyMock.expect(Faces.getViewMap()).andReturn(map); | ||
105 | -//// | ||
106 | -//// CreationalContext<String> creationalContext = PowerMock.createMock(CreationalContext.class); | ||
107 | -//// | ||
108 | -//// PowerMock.replay(Faces.class, bean, map, creationalContext); | ||
109 | -//// | ||
110 | -//// assertEquals(instance, context.get(bean, creationalContext)); | ||
111 | -//// | ||
112 | -//// PowerMock.verifyAll(); | ||
113 | -//// } | ||
114 | -//// | ||
115 | -//// @SuppressWarnings("unchecked") | ||
116 | -//// @Test | ||
117 | -//// public void testGetViewMapInstanceNull() { | ||
118 | -//// String instance = "instance"; | ||
119 | -//// | ||
120 | -//// Bean<String> bean = PowerMock.createMock(Bean.class); | ||
121 | -//// EasyMock.expect(bean.getName()).andReturn(instance).anyTimes(); | ||
122 | -//// | ||
123 | -//// Map<String,Object> map = PowerMock.createMock(Map.class); | ||
124 | -//// EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(false); | ||
125 | -//// | ||
126 | -//// PowerMock.mockStatic(Faces.class); | ||
127 | -//// EasyMock.expect(Faces.getViewMap()).andReturn(map); | ||
128 | -//// | ||
129 | -//// PowerMock.replay(Faces.class, bean, map); | ||
130 | -//// | ||
131 | -//// assertEquals(null, context.get(bean)); | ||
132 | -//// | ||
133 | -//// PowerMock.verifyAll(); | ||
134 | -//// } | ||
135 | -// | ||
136 | -// @Test | ||
137 | -// public void testScopeClass() { | ||
138 | -// assertEquals(ViewScoped.class, context.getScope()); | ||
139 | -// } | ||
140 | -// | ||
141 | -// @Test | ||
142 | -// public void testIsActive() { | ||
143 | -// assertEquals(true, context.isActive()); | ||
144 | -// } | ||
145 | -// | ||
146 | -// @Test | ||
147 | -// public void testSetActive() { | ||
148 | -// context.setActive(false); | ||
149 | -// assertEquals(false, context.isActive()); | ||
150 | -// } | ||
151 | -// | ||
152 | -//} | ||
153 | -// | ||
154 | -// |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandlerFactoryTest.java
@@ -1,75 +0,0 @@ | @@ -1,75 +0,0 @@ | ||
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 static junit.framework.Assert.assertEquals; | ||
40 | -//import static org.easymock.EasyMock.expect; | ||
41 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
43 | -// | ||
44 | -//import javax.faces.context.ExceptionHandler; | ||
45 | -//import javax.faces.context.ExceptionHandlerFactory; | ||
46 | -// | ||
47 | -//import org.junit.Test; | ||
48 | -//import org.junit.runner.RunWith; | ||
49 | -//import org.powermock.api.easymock.PowerMock; | ||
50 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
51 | -// | ||
52 | -//@RunWith(PowerMockRunner.class) | ||
53 | -//public class ApplicationExceptionHandlerFactoryTest { | ||
54 | -// | ||
55 | -// @Test | ||
56 | -// public void testGetExceptionHandler() { | ||
57 | -// | ||
58 | -// ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class); | ||
59 | -// | ||
60 | -// ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class); | ||
61 | -// | ||
62 | -// ApplicationExceptionHandlerFactory handlerFactory = new ApplicationExceptionHandlerFactory(jsfFactory); | ||
63 | -// expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler); | ||
64 | -// | ||
65 | -// replayAll(); | ||
66 | -// | ||
67 | -// ApplicationExceptionHandler handler = (ApplicationExceptionHandler) handlerFactory.getExceptionHandler(); | ||
68 | -// | ||
69 | -// assertEquals(handler.getWrapped(), jsfExceptionHandler); | ||
70 | -// | ||
71 | -// verifyAll(); | ||
72 | -// | ||
73 | -// } | ||
74 | -// | ||
75 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/ApplicationExceptionHandlerTest.java
@@ -1,206 +0,0 @@ | @@ -1,206 +0,0 @@ | ||
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 static junit.framework.Assert.assertFalse; | ||
40 | -//import static junit.framework.Assert.assertTrue; | ||
41 | -//import static org.easymock.EasyMock.expect; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.createMock; | ||
43 | -//import static org.powermock.api.easymock.PowerMock.expectLastCall; | ||
44 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
45 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
46 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
47 | -// | ||
48 | -//import java.util.ArrayList; | ||
49 | -//import java.util.Collection; | ||
50 | -// | ||
51 | -//import javax.faces.context.ExceptionHandler; | ||
52 | -//import javax.faces.context.FacesContext; | ||
53 | -//import javax.faces.event.ExceptionQueuedEvent; | ||
54 | -//import javax.faces.event.ExceptionQueuedEventContext; | ||
55 | -//import javax.faces.event.PhaseId; | ||
56 | -// | ||
57 | -//import org.junit.Before; | ||
58 | -//import org.junit.Test; | ||
59 | -//import org.junit.runner.RunWith; | ||
60 | -//import org.powermock.api.easymock.PowerMock; | ||
61 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
62 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
63 | -// | ||
64 | -//import br.gov.frameworkdemoiselle.exception.ApplicationException; | ||
65 | -//import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig; | ||
66 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
67 | -//import br.gov.frameworkdemoiselle.util.Faces; | ||
68 | -// | ||
69 | -//@RunWith(PowerMockRunner.class) | ||
70 | -//@PrepareForTest({ Beans.class, FacesContext.class, Faces.class }) | ||
71 | -//public class ApplicationExceptionHandlerTest { | ||
72 | -// | ||
73 | -// private ApplicationExceptionHandler handler; | ||
74 | -// | ||
75 | -// private ExceptionQueuedEventContext eventContext; | ||
76 | -// | ||
77 | -// private ExceptionHandlerConfig config; | ||
78 | -// | ||
79 | -// private FacesContext facesContext; | ||
80 | -// | ||
81 | -// private Collection<ExceptionQueuedEvent> events; | ||
82 | -// | ||
83 | -// @SuppressWarnings("serial") | ||
84 | -// @ApplicationException | ||
85 | -// class AnnotatedAppException extends RuntimeException { | ||
86 | -// } | ||
87 | -// | ||
88 | -// @SuppressWarnings("serial") | ||
89 | -// class SomeException extends RuntimeException { | ||
90 | -// } | ||
91 | -// | ||
92 | -// @Before | ||
93 | -// public void setUp() { | ||
94 | -// | ||
95 | -// mockStatic(Beans.class); | ||
96 | -// mockStatic(FacesContext.class); | ||
97 | -// | ||
98 | -// events = new ArrayList<ExceptionQueuedEvent>(); | ||
99 | -// ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class); | ||
100 | -// handler = new ApplicationExceptionHandler(jsfExceptionHandler); | ||
101 | -// eventContext = PowerMock.createMock(ExceptionQueuedEventContext.class); | ||
102 | -// ExceptionQueuedEvent event = PowerMock.createMock(ExceptionQueuedEvent.class); | ||
103 | -// config = PowerMock.createMock(ExceptionHandlerConfig.class); | ||
104 | -// facesContext = PowerMock.createMock(FacesContext.class); | ||
105 | -// | ||
106 | -// expect(event.getSource()).andReturn(eventContext); | ||
107 | -// expect(Beans.getReference(ExceptionHandlerConfig.class)).andReturn(config); | ||
108 | -// expect(FacesContext.getCurrentInstance()).andReturn(facesContext).anyTimes(); | ||
109 | -// expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2); | ||
110 | -// | ||
111 | -// events.add(event); | ||
112 | -// | ||
113 | -// } | ||
114 | -// | ||
115 | -// @Test | ||
116 | -// public void testHandleAnApplicationExceptionNotOnRenderResponse() { | ||
117 | -// | ||
118 | -// mockStatic(Faces.class); | ||
119 | -// | ||
120 | -// AnnotatedAppException exception = new AnnotatedAppException(); | ||
121 | -// PhaseId phaseId = PowerMock.createMock(PhaseId.class); | ||
122 | -// | ||
123 | -// expect(eventContext.getException()).andReturn(exception); | ||
124 | -// expect(facesContext.getCurrentPhaseId()).andReturn(phaseId); | ||
125 | -// expect(config.isHandleApplicationException()).andReturn(true); | ||
126 | -// | ||
127 | -// Faces.addMessage(exception); | ||
128 | -// expectLastCall(); | ||
129 | -// | ||
130 | -// replayAll(); | ||
131 | -// | ||
132 | -// handler.handle(); | ||
133 | -// | ||
134 | -// assertTrue(events.isEmpty()); | ||
135 | -// | ||
136 | -// verifyAll(); | ||
137 | -// | ||
138 | -// } | ||
139 | -// | ||
140 | -// @Test | ||
141 | -// public void testHandleAnApplicationExceptionOnRenderResponse() { | ||
142 | -// | ||
143 | -// AnnotatedAppException exception = new AnnotatedAppException(); | ||
144 | -// // PhaseId phaseId = PhaseId.RENDER_RESPONSE; | ||
145 | -// | ||
146 | -// expect(eventContext.getException()).andReturn(exception); | ||
147 | -// // expect(facesContext.getCurrentPhaseId()).andReturn(phaseId); | ||
148 | -// expect(config.isHandleApplicationException()).andReturn(false); | ||
149 | -// | ||
150 | -// handler.getWrapped().handle(); | ||
151 | -// expectLastCall(); | ||
152 | -// | ||
153 | -// replayAll(); | ||
154 | -// | ||
155 | -// handler.handle(); | ||
156 | -// | ||
157 | -// assertFalse(events.isEmpty()); | ||
158 | -// | ||
159 | -// verifyAll(); | ||
160 | -// | ||
161 | -// } | ||
162 | -// | ||
163 | -// @Test | ||
164 | -// public void testHandleAnyException() { | ||
165 | -// | ||
166 | -// SomeException exception = new SomeException(); | ||
167 | -// // PhaseId phaseId = PowerMock.createMock(PhaseId.class); | ||
168 | -// | ||
169 | -// expect(eventContext.getException()).andReturn(exception); | ||
170 | -// // expect(facesContext.getCurrentPhaseId()).andReturn(phaseId); | ||
171 | -// expect(config.isHandleApplicationException()).andReturn(true); | ||
172 | -// | ||
173 | -// handler.getWrapped().handle(); | ||
174 | -// expectLastCall(); | ||
175 | -// | ||
176 | -// replayAll(); | ||
177 | -// | ||
178 | -// handler.handle(); | ||
179 | -// | ||
180 | -// assertFalse(events.isEmpty()); | ||
181 | -// | ||
182 | -// verifyAll(); | ||
183 | -// | ||
184 | -// } | ||
185 | -// | ||
186 | -// @Test | ||
187 | -// public void testDoNotHandleApplicationExceptions() { | ||
188 | -// | ||
189 | -// AnnotatedAppException exception = new AnnotatedAppException(); | ||
190 | -// | ||
191 | -// expect(eventContext.getException()).andReturn(exception); | ||
192 | -// expect(config.isHandleApplicationException()).andReturn(false); | ||
193 | -// | ||
194 | -// handler.getWrapped().handle(); | ||
195 | -// expectLastCall(); | ||
196 | -// | ||
197 | -// replayAll(); | ||
198 | -// | ||
199 | -// handler.handle(); | ||
200 | -// | ||
201 | -// assertFalse(events.isEmpty()); | ||
202 | -// | ||
203 | -// verifyAll(); | ||
204 | -// | ||
205 | -// } | ||
206 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/AuthenticationExceptionHandlerFactoryTest.java
@@ -1,75 +0,0 @@ | @@ -1,75 +0,0 @@ | ||
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 static junit.framework.Assert.assertEquals; | ||
40 | -//import static org.easymock.EasyMock.expect; | ||
41 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
43 | -// | ||
44 | -//import javax.faces.context.ExceptionHandler; | ||
45 | -//import javax.faces.context.ExceptionHandlerFactory; | ||
46 | -// | ||
47 | -//import org.junit.Test; | ||
48 | -//import org.junit.runner.RunWith; | ||
49 | -//import org.powermock.api.easymock.PowerMock; | ||
50 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
51 | -// | ||
52 | -//@RunWith(PowerMockRunner.class) | ||
53 | -//public class AuthenticationExceptionHandlerFactoryTest { | ||
54 | -// | ||
55 | -// @Test | ||
56 | -// public void testGetExceptionHandler() { | ||
57 | -// | ||
58 | -// ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class); | ||
59 | -// | ||
60 | -// ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class); | ||
61 | -// | ||
62 | -// AuthenticationExceptionHandlerFactory handlerFactory = new AuthenticationExceptionHandlerFactory(jsfFactory); | ||
63 | -// expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler); | ||
64 | -// | ||
65 | -// replayAll(); | ||
66 | -// | ||
67 | -// AuthenticationExceptionHandler handler = (AuthenticationExceptionHandler) handlerFactory.getExceptionHandler(); | ||
68 | -// | ||
69 | -// assertEquals(handler.getWrapped(), jsfExceptionHandler); | ||
70 | -// | ||
71 | -// verifyAll(); | ||
72 | -// | ||
73 | -// } | ||
74 | -// | ||
75 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/AuthenticationExceptionHandlerTest.java
@@ -1,134 +0,0 @@ | @@ -1,134 +0,0 @@ | ||
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 static junit.framework.Assert.assertFalse; | ||
40 | -//import static junit.framework.Assert.assertTrue; | ||
41 | -//import static org.easymock.EasyMock.expect; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.createMock; | ||
43 | -//import static org.powermock.api.easymock.PowerMock.expectLastCall; | ||
44 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
45 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
46 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
47 | -// | ||
48 | -//import java.util.ArrayList; | ||
49 | -//import java.util.Collection; | ||
50 | -// | ||
51 | -//import javax.faces.context.ExceptionHandler; | ||
52 | -//import javax.faces.event.ExceptionQueuedEvent; | ||
53 | -//import javax.faces.event.ExceptionQueuedEventContext; | ||
54 | -// | ||
55 | -//import org.junit.Before; | ||
56 | -//import org.junit.Test; | ||
57 | -//import org.junit.runner.RunWith; | ||
58 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
59 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
60 | -// | ||
61 | -//import br.gov.frameworkdemoiselle.security.NotLoggedInException; | ||
62 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
63 | -// | ||
64 | -//@RunWith(PowerMockRunner.class) | ||
65 | -//@PrepareForTest({ Beans.class}) | ||
66 | -//public class AuthenticationExceptionHandlerTest { | ||
67 | -// | ||
68 | -// private AuthenticationExceptionHandler handler; | ||
69 | -// | ||
70 | -// private ExceptionQueuedEventContext eventContext; | ||
71 | -// | ||
72 | -// private Collection<ExceptionQueuedEvent> events; | ||
73 | -// | ||
74 | -// @Before | ||
75 | -// public void setUp() { | ||
76 | -// | ||
77 | -// mockStatic(Beans.class); | ||
78 | -// | ||
79 | -// events = new ArrayList<ExceptionQueuedEvent>(); | ||
80 | -// ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class); | ||
81 | -// handler = new AuthenticationExceptionHandler(jsfExceptionHandler); | ||
82 | -// eventContext = createMock(ExceptionQueuedEventContext.class); | ||
83 | -// ExceptionQueuedEvent event = createMock(ExceptionQueuedEvent.class); | ||
84 | -// | ||
85 | -// expect(event.getSource()).andReturn(eventContext); | ||
86 | -// expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2); | ||
87 | -// | ||
88 | -// events.add(event); | ||
89 | -// | ||
90 | -// } | ||
91 | -// | ||
92 | -// @Test | ||
93 | -// public void testHandleNotLoggedInException() { | ||
94 | -// | ||
95 | -// NotLoggedInException exception = new NotLoggedInException(""); | ||
96 | -// | ||
97 | -// SecurityObserver observer = createMock(SecurityObserver.class); | ||
98 | -// expect(Beans.getReference(SecurityObserver.class)).andReturn(observer); | ||
99 | -// expect(eventContext.getException()).andReturn(exception); | ||
100 | -// | ||
101 | -// observer.redirectToLoginPage(); | ||
102 | -// expectLastCall(); | ||
103 | -// | ||
104 | -// replayAll(); | ||
105 | -// | ||
106 | -// handler.handle(); | ||
107 | -// | ||
108 | -// assertTrue(events.isEmpty()); | ||
109 | -// | ||
110 | -// verifyAll(); | ||
111 | -// | ||
112 | -// } | ||
113 | -// | ||
114 | -// @Test | ||
115 | -// public void testHandleAnyException() { | ||
116 | -// | ||
117 | -// Exception exception = new Exception(); | ||
118 | -// | ||
119 | -// expect(eventContext.getException()).andReturn(exception); | ||
120 | -// | ||
121 | -// handler.getWrapped().handle(); | ||
122 | -// expectLastCall(); | ||
123 | -// | ||
124 | -// replayAll(); | ||
125 | -// | ||
126 | -// handler.handle(); | ||
127 | -// | ||
128 | -// assertFalse(events.isEmpty()); | ||
129 | -// | ||
130 | -// verifyAll(); | ||
131 | -// | ||
132 | -// } | ||
133 | -// | ||
134 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/AuthorizationExceptionHandlerFactoryTest.java
@@ -1,75 +0,0 @@ | @@ -1,75 +0,0 @@ | ||
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 static junit.framework.Assert.assertEquals; | ||
40 | -//import static org.easymock.EasyMock.expect; | ||
41 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
43 | -// | ||
44 | -//import javax.faces.context.ExceptionHandler; | ||
45 | -//import javax.faces.context.ExceptionHandlerFactory; | ||
46 | -// | ||
47 | -//import org.junit.Test; | ||
48 | -//import org.junit.runner.RunWith; | ||
49 | -//import org.powermock.api.easymock.PowerMock; | ||
50 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
51 | -// | ||
52 | -//@RunWith(PowerMockRunner.class) | ||
53 | -//public class AuthorizationExceptionHandlerFactoryTest { | ||
54 | -// | ||
55 | -// @Test | ||
56 | -// public void testGetExceptionHandler() { | ||
57 | -// | ||
58 | -// ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class); | ||
59 | -// | ||
60 | -// ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class); | ||
61 | -// | ||
62 | -// AuthorizationExceptionHandlerFactory handlerFactory = new AuthorizationExceptionHandlerFactory(jsfFactory); | ||
63 | -// expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler); | ||
64 | -// | ||
65 | -// replayAll(); | ||
66 | -// | ||
67 | -// AuthorizationExceptionHandler handler = (AuthorizationExceptionHandler) handlerFactory.getExceptionHandler(); | ||
68 | -// | ||
69 | -// assertEquals(handler.getWrapped(), jsfExceptionHandler); | ||
70 | -// | ||
71 | -// verifyAll(); | ||
72 | -// | ||
73 | -// } | ||
74 | -// | ||
75 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/AuthorizationExceptionHandlerTest.java
@@ -1,171 +0,0 @@ | @@ -1,171 +0,0 @@ | ||
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 static junit.framework.Assert.assertFalse; | ||
40 | -//import static junit.framework.Assert.assertTrue; | ||
41 | -//import static org.easymock.EasyMock.expect; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.createMock; | ||
43 | -//import static org.powermock.api.easymock.PowerMock.expectLastCall; | ||
44 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
45 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
46 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
47 | -// | ||
48 | -//import java.util.ArrayList; | ||
49 | -//import java.util.Collection; | ||
50 | -// | ||
51 | -//import javax.faces.context.ExceptionHandler; | ||
52 | -//import javax.faces.context.FacesContext; | ||
53 | -//import javax.faces.event.ExceptionQueuedEvent; | ||
54 | -//import javax.faces.event.ExceptionQueuedEventContext; | ||
55 | -//import javax.faces.event.PhaseId; | ||
56 | -// | ||
57 | -//import org.junit.Before; | ||
58 | -//import org.junit.Test; | ||
59 | -//import org.junit.runner.RunWith; | ||
60 | -//import org.powermock.api.easymock.PowerMock; | ||
61 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
62 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
63 | -// | ||
64 | -//import br.gov.frameworkdemoiselle.security.AuthorizationException; | ||
65 | -//import br.gov.frameworkdemoiselle.util.Faces; | ||
66 | -// | ||
67 | -//@RunWith(PowerMockRunner.class) | ||
68 | -//@PrepareForTest({ FacesContext.class, Faces.class }) | ||
69 | -//public class AuthorizationExceptionHandlerTest { | ||
70 | -// | ||
71 | -// private AuthorizationExceptionHandler handler; | ||
72 | -// | ||
73 | -// private ExceptionQueuedEventContext eventContext; | ||
74 | -// | ||
75 | -// private Collection<ExceptionQueuedEvent> events; | ||
76 | -// | ||
77 | -// private FacesContext facesContext; | ||
78 | -// | ||
79 | -// @Before | ||
80 | -// public void setUp() { | ||
81 | -// | ||
82 | -// mockStatic(FacesContext.class); | ||
83 | -// | ||
84 | -// events = new ArrayList<ExceptionQueuedEvent>(); | ||
85 | -// ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class); | ||
86 | -// handler = new AuthorizationExceptionHandler(jsfExceptionHandler); | ||
87 | -// eventContext = createMock(ExceptionQueuedEventContext.class); | ||
88 | -// ExceptionQueuedEvent event = createMock(ExceptionQueuedEvent.class); | ||
89 | -// facesContext = PowerMock.createMock(FacesContext.class); | ||
90 | -// | ||
91 | -// expect(event.getSource()).andReturn(eventContext); | ||
92 | -// events.add(event); | ||
93 | -// expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2); | ||
94 | -// expect(FacesContext.getCurrentInstance()).andReturn(facesContext).anyTimes(); | ||
95 | -// | ||
96 | -// | ||
97 | -// } | ||
98 | -// | ||
99 | -// @Test | ||
100 | -// public void testHandleAnAuthorizationExceptionNotOnRenderResponse() { | ||
101 | -// | ||
102 | -// mockStatic(Faces.class); | ||
103 | -// | ||
104 | -//// ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | ||
105 | -// | ||
106 | -// AuthorizationException exception = new AuthorizationException(""); | ||
107 | -// PhaseId phaseId = PowerMock.createMock(PhaseId.class); | ||
108 | -// | ||
109 | -// expect(eventContext.getException()).andReturn(exception); | ||
110 | -// expect(facesContext.getCurrentPhaseId()).andReturn(phaseId); | ||
111 | -// | ||
112 | -// Faces.addMessage(exception); | ||
113 | -// expectLastCall(); | ||
114 | -// | ||
115 | -// replayAll(); | ||
116 | -// | ||
117 | -// handler.handle(); | ||
118 | -// | ||
119 | -// assertTrue(events.isEmpty()); | ||
120 | -// | ||
121 | -// verifyAll(); | ||
122 | -// | ||
123 | -// } | ||
124 | -// | ||
125 | -// @Test | ||
126 | -// public void testHandleAnAuthorizationExceptionOnRenderResponse() { | ||
127 | -// | ||
128 | -//// ResourceBundle bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); | ||
129 | -// | ||
130 | -// AuthorizationException exception = new AuthorizationException(""); | ||
131 | -// PhaseId phaseId = PhaseId.RENDER_RESPONSE; | ||
132 | -// | ||
133 | -// expect(eventContext.getException()).andReturn(exception); | ||
134 | -// expect(facesContext.getCurrentPhaseId()).andReturn(phaseId); | ||
135 | -// | ||
136 | -// handler.getWrapped().handle(); | ||
137 | -// expectLastCall(); | ||
138 | -// | ||
139 | -// replayAll(); | ||
140 | -// | ||
141 | -// handler.handle(); | ||
142 | -// | ||
143 | -// assertFalse(events.isEmpty()); | ||
144 | -// | ||
145 | -// verifyAll(); | ||
146 | -// | ||
147 | -// } | ||
148 | -// | ||
149 | -// @Test | ||
150 | -// public void testHandleAnyException() { | ||
151 | -// | ||
152 | -// Exception exception = new Exception(); | ||
153 | -// PhaseId phaseId = PowerMock.createMock(PhaseId.class); | ||
154 | -// | ||
155 | -// expect(eventContext.getException()).andReturn(exception); | ||
156 | -// expect(facesContext.getCurrentPhaseId()).andReturn(phaseId); | ||
157 | -// | ||
158 | -// handler.getWrapped().handle(); | ||
159 | -// expectLastCall(); | ||
160 | -// | ||
161 | -// replayAll(); | ||
162 | -// | ||
163 | -// handler.handle(); | ||
164 | -// | ||
165 | -// assertFalse(events.isEmpty()); | ||
166 | -// | ||
167 | -// verifyAll(); | ||
168 | -// | ||
169 | -// } | ||
170 | -// | ||
171 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/FileRendererImplTest.java
@@ -1,328 +0,0 @@ | @@ -1,328 +0,0 @@ | ||
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 java.io.ByteArrayInputStream; | ||
40 | -//import java.io.File; | ||
41 | -//import java.io.IOException; | ||
42 | -//import java.io.InputStream; | ||
43 | -// | ||
44 | -//import javax.faces.context.FacesContext; | ||
45 | -//import javax.servlet.ServletOutputStream; | ||
46 | -//import javax.servlet.http.HttpServletResponse; | ||
47 | -// | ||
48 | -//import junit.framework.Assert; | ||
49 | -// | ||
50 | -//import org.easymock.EasyMock; | ||
51 | -//import org.junit.Before; | ||
52 | -//import org.junit.Test; | ||
53 | -//import org.junit.runner.RunWith; | ||
54 | -//import org.powermock.api.easymock.PowerMock; | ||
55 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
56 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
57 | -//import org.powermock.reflect.Whitebox; | ||
58 | -//import org.slf4j.Logger; | ||
59 | -// | ||
60 | -//import br.gov.frameworkdemoiselle.util.Faces; | ||
61 | -//import br.gov.frameworkdemoiselle.util.FileRenderer; | ||
62 | -//import br.gov.frameworkdemoiselle.util.FileRenderer.ContentType; | ||
63 | -// | ||
64 | -//@RunWith(PowerMockRunner.class) | ||
65 | -//@PrepareForTest({ Faces.class }) | ||
66 | -//public class FileRendererImplTest { | ||
67 | -// | ||
68 | -// private Logger logger; | ||
69 | -// | ||
70 | -// private FileRenderer renderer; | ||
71 | -// | ||
72 | -// private FacesContext facesContext; | ||
73 | -// | ||
74 | -// private HttpServletResponse response; | ||
75 | -// | ||
76 | -// @Before | ||
77 | -// public void before() { | ||
78 | -// renderer = new FileRendererImpl(); | ||
79 | -// | ||
80 | -// logger = PowerMock.createMock(Logger.class); | ||
81 | -// Whitebox.setInternalState(renderer, "logger", logger); | ||
82 | -// | ||
83 | -// facesContext = PowerMock.createMock(FacesContext.class); | ||
84 | -// Whitebox.setInternalState(renderer, "context", facesContext); | ||
85 | -// | ||
86 | -// response = PowerMock.createMock(HttpServletResponse.class); | ||
87 | -// Whitebox.setInternalState(renderer, "response", response); | ||
88 | -// } | ||
89 | -// | ||
90 | -// @Test | ||
91 | -// public void testRenderBytesFail() { | ||
92 | -// byte[] bytes = "Test".getBytes(); | ||
93 | -// String fileName = "fileName.pdf"; | ||
94 | -// | ||
95 | -// logger.debug(EasyMock.anyObject(String.class)); | ||
96 | -// EasyMock.expectLastCall().anyTimes(); | ||
97 | -// | ||
98 | -// IOException exception = new IOException(); | ||
99 | -// logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception); | ||
100 | -// EasyMock.expectLastCall().anyTimes(); | ||
101 | -// | ||
102 | -// response.setContentType(ContentType.PDF.getContentType()); | ||
103 | -// EasyMock.expectLastCall().times(1); | ||
104 | -// | ||
105 | -// response.setContentLength(bytes.length); | ||
106 | -// EasyMock.expectLastCall().times(1); | ||
107 | -// | ||
108 | -// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\""); | ||
109 | -// EasyMock.expectLastCall().times(1); | ||
110 | -// | ||
111 | -// facesContext.responseComplete(); | ||
112 | -// EasyMock.expectLastCall().times(1); | ||
113 | -// | ||
114 | -// try { | ||
115 | -// EasyMock.expect(response.getOutputStream()).andThrow(exception); | ||
116 | -// } catch (IOException e) { | ||
117 | -// Assert.fail(); | ||
118 | -// } | ||
119 | -// | ||
120 | -// PowerMock.mockStatic(Faces.class); | ||
121 | -// Faces.addMessage(exception); | ||
122 | -// | ||
123 | -// PowerMock.replayAll(); | ||
124 | -// renderer.render(bytes, ContentType.PDF, fileName); | ||
125 | -// PowerMock.verifyAll(); | ||
126 | -// } | ||
127 | -// | ||
128 | -// @Test | ||
129 | -// public void testRenderBytesSuccess() throws IOException { | ||
130 | -// byte[] bytes = "Test".getBytes(); | ||
131 | -// String fileName = "fileName.pdf"; | ||
132 | -// | ||
133 | -// logger.debug(EasyMock.anyObject(String.class)); | ||
134 | -// EasyMock.expectLastCall().anyTimes(); | ||
135 | -// | ||
136 | -// facesContext.responseComplete(); | ||
137 | -// EasyMock.expectLastCall().times(1); | ||
138 | -// | ||
139 | -// response.setContentType(ContentType.PDF.getContentType()); | ||
140 | -// EasyMock.expectLastCall().times(1); | ||
141 | -// | ||
142 | -// response.setContentLength(bytes.length); | ||
143 | -// EasyMock.expectLastCall().times(1); | ||
144 | -// | ||
145 | -// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\""); | ||
146 | -// EasyMock.expectLastCall().times(1); | ||
147 | -// | ||
148 | -// ServletOutputStream stream = PowerMock.createMock(ServletOutputStream.class); | ||
149 | -// stream.write(bytes, 0, bytes.length); | ||
150 | -// EasyMock.expectLastCall().times(1); | ||
151 | -// | ||
152 | -// stream.flush(); | ||
153 | -// EasyMock.expectLastCall().times(1); | ||
154 | -// | ||
155 | -// stream.close(); | ||
156 | -// EasyMock.expectLastCall().times(1); | ||
157 | -// | ||
158 | -// EasyMock.expect(response.getOutputStream()).andReturn(stream).times(3); | ||
159 | -// | ||
160 | -// PowerMock.replayAll(); | ||
161 | -// renderer.render(bytes, ContentType.PDF, fileName); | ||
162 | -// PowerMock.verifyAll(); | ||
163 | -// } | ||
164 | -// | ||
165 | -// @Test | ||
166 | -// public void testRenderStreamFail() { | ||
167 | -// byte[] bytes = "Test".getBytes(); | ||
168 | -// InputStream stream = new ByteArrayInputStream(bytes); | ||
169 | -// String fileName = "fileName.pdf"; | ||
170 | -// | ||
171 | -// logger.debug(EasyMock.anyObject(String.class)); | ||
172 | -// EasyMock.expectLastCall().anyTimes(); | ||
173 | -// | ||
174 | -// IOException exception = new IOException(); | ||
175 | -// logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception); | ||
176 | -// EasyMock.expectLastCall().anyTimes(); | ||
177 | -// | ||
178 | -// response.setContentType(ContentType.PDF.getContentType()); | ||
179 | -// EasyMock.expectLastCall().times(1); | ||
180 | -// | ||
181 | -// response.setContentLength(bytes.length); | ||
182 | -// EasyMock.expectLastCall().times(1); | ||
183 | -// | ||
184 | -// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\""); | ||
185 | -// EasyMock.expectLastCall().times(1); | ||
186 | -// | ||
187 | -// facesContext.responseComplete(); | ||
188 | -// EasyMock.expectLastCall().times(1); | ||
189 | -// | ||
190 | -// try { | ||
191 | -// EasyMock.expect(response.getOutputStream()).andThrow(exception); | ||
192 | -// } catch (IOException e) { | ||
193 | -// Assert.fail(); | ||
194 | -// } | ||
195 | -// | ||
196 | -// PowerMock.mockStatic(Faces.class); | ||
197 | -// Faces.addMessage(exception); | ||
198 | -// | ||
199 | -// PowerMock.replayAll(); | ||
200 | -// renderer.render(stream, ContentType.PDF, fileName, false); | ||
201 | -// PowerMock.verifyAll(); | ||
202 | -// } | ||
203 | -// | ||
204 | -// @Test | ||
205 | -// public void testRenderStreamSuccess() throws IOException { | ||
206 | -// byte[] bytes = "Test".getBytes(); | ||
207 | -// InputStream inputStream = new ByteArrayInputStream(bytes); | ||
208 | -// | ||
209 | -// String fileName = "fileName.pdf"; | ||
210 | -// | ||
211 | -// logger.debug(EasyMock.anyObject(String.class)); | ||
212 | -// EasyMock.expectLastCall().anyTimes(); | ||
213 | -// | ||
214 | -// facesContext.responseComplete(); | ||
215 | -// EasyMock.expectLastCall().times(1); | ||
216 | -// | ||
217 | -// response.setContentType(ContentType.PDF.getContentType()); | ||
218 | -// EasyMock.expectLastCall().times(1); | ||
219 | -// | ||
220 | -// response.setContentLength(bytes.length); | ||
221 | -// EasyMock.expectLastCall().times(1); | ||
222 | -// | ||
223 | -// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\""); | ||
224 | -// EasyMock.expectLastCall().times(1); | ||
225 | -// | ||
226 | -// ServletOutputStream stream = new ServletOutputStream() { | ||
227 | -// | ||
228 | -// @Override | ||
229 | -// public void write(int b) throws IOException { | ||
230 | -// Assert.assertTrue(true); | ||
231 | -// } | ||
232 | -// }; | ||
233 | -// | ||
234 | -// EasyMock.expect(response.getOutputStream()).andReturn(stream).times(3); | ||
235 | -// | ||
236 | -// PowerMock.replayAll(); | ||
237 | -// renderer.render(inputStream, ContentType.PDF, fileName); | ||
238 | -// PowerMock.verifyAll(); | ||
239 | -// } | ||
240 | -// | ||
241 | -// @Test | ||
242 | -// public void testRenderFileFail() throws IOException { | ||
243 | -// | ||
244 | -// File file = new File("fileName"); | ||
245 | -// file.createNewFile(); | ||
246 | -// | ||
247 | -// String fileName = "fileName.pdf"; | ||
248 | -// | ||
249 | -// logger.debug(EasyMock.anyObject(String.class)); | ||
250 | -// EasyMock.expectLastCall().anyTimes(); | ||
251 | -// | ||
252 | -// IOException exception = new IOException(); | ||
253 | -// logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception); | ||
254 | -// EasyMock.expectLastCall().anyTimes(); | ||
255 | -// | ||
256 | -// response.setContentType(ContentType.PDF.getContentType()); | ||
257 | -// EasyMock.expectLastCall().times(1); | ||
258 | -// | ||
259 | -// response.setContentLength((int) file.length()); | ||
260 | -// EasyMock.expectLastCall().times(1); | ||
261 | -// | ||
262 | -// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\""); | ||
263 | -// EasyMock.expectLastCall().times(1); | ||
264 | -// | ||
265 | -// facesContext.responseComplete(); | ||
266 | -// EasyMock.expectLastCall().times(1); | ||
267 | -// | ||
268 | -// try { | ||
269 | -// EasyMock.expect(response.getOutputStream()).andThrow(exception); | ||
270 | -// } catch (IOException e) { | ||
271 | -// Assert.fail(); | ||
272 | -// } | ||
273 | -// | ||
274 | -// PowerMock.mockStatic(Faces.class); | ||
275 | -// Faces.addMessage(exception); | ||
276 | -// | ||
277 | -// PowerMock.replayAll(); | ||
278 | -// renderer.render(file, ContentType.PDF, fileName); | ||
279 | -// PowerMock.verifyAll(); | ||
280 | -// | ||
281 | -// file.delete(); | ||
282 | -// } | ||
283 | -// | ||
284 | -// @Test | ||
285 | -// public void testRenderFileNotFoundException() throws IOException { | ||
286 | -// | ||
287 | -// File file = new File("fileName"); | ||
288 | -// file.createNewFile(); | ||
289 | -// | ||
290 | -// String fileName = "fileName.pdf"; | ||
291 | -// | ||
292 | -// logger.debug(EasyMock.anyObject(String.class)); | ||
293 | -// EasyMock.expectLastCall().anyTimes(); | ||
294 | -// | ||
295 | -// IOException exception = new IOException(); | ||
296 | -// logger.info("Erro na geração do relatório. Incluíndo a exceção de erro em um FacesMessage", exception); | ||
297 | -// EasyMock.expectLastCall().anyTimes(); | ||
298 | -// | ||
299 | -// response.setContentType(ContentType.PDF.getContentType()); | ||
300 | -// EasyMock.expectLastCall().times(1); | ||
301 | -// | ||
302 | -// response.setContentLength((int) file.length()); | ||
303 | -// EasyMock.expectLastCall().times(1); | ||
304 | -// | ||
305 | -// response.setHeader("Content-Disposition", "filename=\"" + fileName + "\""); | ||
306 | -// EasyMock.expectLastCall().times(1); | ||
307 | -// | ||
308 | -// facesContext.responseComplete(); | ||
309 | -// EasyMock.expectLastCall().times(1); | ||
310 | -// | ||
311 | -// try { | ||
312 | -// EasyMock.expect(response.getOutputStream()).andThrow(exception); | ||
313 | -// } catch (IOException e) { | ||
314 | -// Assert.fail(); | ||
315 | -// } | ||
316 | -// | ||
317 | -// | ||
318 | -// | ||
319 | -// PowerMock.mockStatic(Faces.class); | ||
320 | -// Faces.addMessage(exception); | ||
321 | -// | ||
322 | -// PowerMock.replayAll(); | ||
323 | -// renderer.render(file, ContentType.PDF, fileName); | ||
324 | -// PowerMock.verifyAll(); | ||
325 | -// | ||
326 | -// file.delete(); | ||
327 | -// } | ||
328 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/ParameterImplTest.java
@@ -1,372 +0,0 @@ | @@ -1,372 +0,0 @@ | ||
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 PURPaOSE. 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 static org.easymock.EasyMock.expect; | ||
40 | -//import static org.junit.Assert.assertEquals; | ||
41 | -//import static org.powermock.api.easymock.PowerMock.createMock; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
43 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
44 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
45 | -// | ||
46 | -//import java.lang.reflect.Member; | ||
47 | -//import java.util.HashMap; | ||
48 | -//import java.util.Map; | ||
49 | -// | ||
50 | -//import javax.enterprise.context.RequestScoped; | ||
51 | -//import javax.enterprise.context.SessionScoped; | ||
52 | -//import javax.enterprise.inject.spi.Annotated; | ||
53 | -//import javax.enterprise.inject.spi.InjectionPoint; | ||
54 | -//import javax.faces.convert.Converter; | ||
55 | -//import javax.servlet.http.HttpServletRequest; | ||
56 | -//import javax.servlet.http.HttpSession; | ||
57 | -// | ||
58 | -//import org.easymock.EasyMock; | ||
59 | -//import org.junit.Before; | ||
60 | -//import org.junit.Ignore; | ||
61 | -//import org.junit.Test; | ||
62 | -//import org.junit.runner.RunWith; | ||
63 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
64 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
65 | -//import org.powermock.reflect.Whitebox; | ||
66 | -// | ||
67 | -//import br.gov.frameworkdemoiselle.annotation.Name; | ||
68 | -//import br.gov.frameworkdemoiselle.annotation.ViewScoped; | ||
69 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
70 | -//import br.gov.frameworkdemoiselle.util.Faces; | ||
71 | -//import br.gov.frameworkdemoiselle.util.Reflections; | ||
72 | -// | ||
73 | -//@Ignore | ||
74 | -//@RunWith(PowerMockRunner.class) | ||
75 | -//@PrepareForTest({ Reflections.class, Faces.class, Beans.class }) | ||
76 | -//public class ParameterImplTest { | ||
77 | -// | ||
78 | -// private ParameterImpl<Long> param; | ||
79 | -// | ||
80 | -// private HttpServletRequest request; | ||
81 | -// | ||
82 | -// private InjectionPoint ip; | ||
83 | -// | ||
84 | -// private Converter converter; | ||
85 | -// | ||
86 | -// private Annotated annotated; | ||
87 | -// | ||
88 | -// private Name name; | ||
89 | -// | ||
90 | -// private HttpSession session; | ||
91 | -// | ||
92 | -// private Member member; | ||
93 | -// | ||
94 | -// @Before | ||
95 | -// public void before() { | ||
96 | -// ip = createMock(InjectionPoint.class); | ||
97 | -// request = createMock(HttpServletRequest.class); | ||
98 | -// session = createMock(HttpSession.class); | ||
99 | -// annotated = createMock(Annotated.class); | ||
100 | -// name = createMock(Name.class); | ||
101 | -// converter = createMock(Converter.class); | ||
102 | -// member = createMock(Member.class); | ||
103 | -// | ||
104 | -// mockStatic(Reflections.class); | ||
105 | -// mockStatic(Faces.class); | ||
106 | -// } | ||
107 | -// | ||
108 | -// private void prepareForTestWithKeyFromNameAnnotation() { | ||
109 | -// expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); | ||
110 | -// expect(ip.getMember()).andReturn(null); | ||
111 | -// expect(annotated.isAnnotationPresent(Name.class)).andReturn(true); | ||
112 | -// expect(annotated.getAnnotation(Name.class)).andReturn(name); | ||
113 | -// expect(name.value()).andReturn("name"); | ||
114 | -// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn( | ||
115 | -// Object.class); | ||
116 | -// } | ||
117 | -// | ||
118 | -// @Test | ||
119 | -// public void testConstructorCase1() { | ||
120 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
121 | -// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | ||
122 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | ||
123 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true); | ||
124 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | ||
125 | -// | ||
126 | -// replayAll(); | ||
127 | -// param = new ParameterImpl<Long>(ip); | ||
128 | -// assertEquals("name", param.getKey()); | ||
129 | -// assertEquals(Object.class, Whitebox.getInternalState(param, "type")); | ||
130 | -// assertEquals(converter, param.getConverter()); | ||
131 | -// verifyAll(); | ||
132 | -// } | ||
133 | -// | ||
134 | -// @Test | ||
135 | -// public void testConstructorCase2() { | ||
136 | -// expect(member.getName()).andReturn("memberName"); | ||
137 | -// expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); | ||
138 | -// expect(ip.getMember()).andReturn(member).anyTimes(); | ||
139 | -// expect(annotated.isAnnotationPresent(Name.class)).andReturn(false); | ||
140 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | ||
141 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true); | ||
142 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | ||
143 | -// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Member.class), EasyMock.anyInt())).andReturn( | ||
144 | -// Object.class); | ||
145 | -// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | ||
146 | -// | ||
147 | -// replayAll(); | ||
148 | -// param = new ParameterImpl<Long>(ip); | ||
149 | -// assertEquals("memberName", param.getKey()); | ||
150 | -// assertEquals(Object.class, Whitebox.getInternalState(param, "type")); | ||
151 | -// assertEquals(converter, param.getConverter()); | ||
152 | -// verifyAll(); | ||
153 | -// } | ||
154 | -// | ||
155 | -// @Test | ||
156 | -// public void testGetValueWhenSessionScopedAndParameterValueNotNull() { | ||
157 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
158 | -// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | ||
159 | -// | ||
160 | -// mockStatic(Beans.class); | ||
161 | -// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); | ||
162 | -// | ||
163 | -// expect(Faces.convert("1", converter)).andReturn("return"); | ||
164 | -// expect(request.getSession()).andReturn(session).anyTimes(); | ||
165 | -// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | ||
166 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | ||
167 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | ||
168 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | ||
169 | -// | ||
170 | -// expect(session.getAttribute("name")).andReturn("return"); | ||
171 | -// | ||
172 | -// session.setAttribute("name", "return"); | ||
173 | -// | ||
174 | -// replayAll(); | ||
175 | -// param = new ParameterImpl<Long>(ip); | ||
176 | -// assertEquals("return", param.getValue()); | ||
177 | -// verifyAll(); | ||
178 | -// } | ||
179 | -// | ||
180 | -// @Test | ||
181 | -// public void testGetValueWhenSessionScopedAndParameterValueNull() { | ||
182 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
183 | -// | ||
184 | -// mockStatic(Beans.class); | ||
185 | -// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); | ||
186 | -// | ||
187 | -// expect(request.getSession()).andReturn(session).anyTimes(); | ||
188 | -// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null); | ||
189 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | ||
190 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | ||
191 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | ||
192 | -// expect(session.getAttribute("name")).andReturn("return"); | ||
193 | -// | ||
194 | -// replayAll(); | ||
195 | -// param = new ParameterImpl<Long>(ip); | ||
196 | -// assertEquals("return", param.getValue()); | ||
197 | -// verifyAll(); | ||
198 | -// } | ||
199 | -// | ||
200 | -// @Test | ||
201 | -// public void testGetValueWhenRequestScoped() { | ||
202 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
203 | -// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | ||
204 | -// | ||
205 | -// mockStatic(Beans.class); | ||
206 | -// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); | ||
207 | -// | ||
208 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | ||
209 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true); | ||
210 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | ||
211 | -// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | ||
212 | -// expect(request.getSession()).andReturn(session).anyTimes(); | ||
213 | -// expect(Faces.convert("1", converter)).andReturn("return"); | ||
214 | -// | ||
215 | -// replayAll(); | ||
216 | -// param = new ParameterImpl<Long>(ip); | ||
217 | -// assertEquals("return", param.getValue()); | ||
218 | -// verifyAll(); | ||
219 | -// } | ||
220 | -// | ||
221 | -// @Test | ||
222 | -// public void testGetValueWhenViewScopedWithParamValueNotNull() { | ||
223 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
224 | -// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | ||
225 | -// Map<String, Object> map = new HashMap<String, Object>(); | ||
226 | -// | ||
227 | -// mockStatic(Beans.class); | ||
228 | -// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); | ||
229 | -// | ||
230 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | ||
231 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | ||
232 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | ||
233 | -// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | ||
234 | -// expect(Faces.getViewMap()).andReturn(map); | ||
235 | -// expect(Faces.convert("1", converter)).andReturn("return"); | ||
236 | -// | ||
237 | -// replayAll(); | ||
238 | -// param = new ParameterImpl<Long>(ip); | ||
239 | -// assertEquals("return", param.getValue()); | ||
240 | -// assertEquals("return", map.get("name")); | ||
241 | -// verifyAll(); | ||
242 | -// } | ||
243 | -// | ||
244 | -// @Test | ||
245 | -// public void testGetValueWhenViewScopedWithParamValueNull() { | ||
246 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
247 | -// Map<String, Object> map = new HashMap<String, Object>(); | ||
248 | -// map.put("name", "ops"); | ||
249 | -// | ||
250 | -// mockStatic(Beans.class); | ||
251 | -// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); | ||
252 | -// | ||
253 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | ||
254 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | ||
255 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | ||
256 | -// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn(null); | ||
257 | -// expect(Faces.getViewMap()).andReturn(map); | ||
258 | -// | ||
259 | -// replayAll(); | ||
260 | -// param = new ParameterImpl<Long>(ip); | ||
261 | -// assertEquals("ops", param.getValue()); | ||
262 | -// assertEquals("ops", map.get("name")); | ||
263 | -// verifyAll(); | ||
264 | -// } | ||
265 | -// | ||
266 | -// @Test | ||
267 | -// public void testGetValueElseWithValueNull() { | ||
268 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
269 | -// expect(Faces.getConverter(EasyMock.anyObject(Class.class))).andReturn(converter); | ||
270 | -// | ||
271 | -// mockStatic(Beans.class); | ||
272 | -// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); | ||
273 | -// | ||
274 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | ||
275 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | ||
276 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | ||
277 | -// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | ||
278 | -// expect(Faces.convert("1", converter)).andReturn("return"); | ||
279 | -// | ||
280 | -// replayAll(); | ||
281 | -// param = new ParameterImpl<Long>(ip); | ||
282 | -// assertEquals("return", param.getValue()); | ||
283 | -// verifyAll(); | ||
284 | -// } | ||
285 | -// | ||
286 | -// @Test | ||
287 | -// public void testGetValueElseWithValueNotNull() { | ||
288 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
289 | -// | ||
290 | -// mockStatic(Beans.class); | ||
291 | -// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); | ||
292 | -// | ||
293 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | ||
294 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | ||
295 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | ||
296 | -// expect(request.getParameter(EasyMock.anyObject(String.class))).andReturn("1"); | ||
297 | -// | ||
298 | -// replayAll(); | ||
299 | -// param = new ParameterImpl<Long>(ip); | ||
300 | -// Whitebox.setInternalState(param, "value", "myvalue"); | ||
301 | -// assertEquals("myvalue", param.getValue()); | ||
302 | -// verifyAll(); | ||
303 | -// } | ||
304 | -// | ||
305 | -// @Test | ||
306 | -// public void testSetValueIsSessionScoped() { | ||
307 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
308 | -// | ||
309 | -// mockStatic(Beans.class); | ||
310 | -// expect(Beans.getReference(HttpServletRequest.class)).andReturn(request).anyTimes(); | ||
311 | -// | ||
312 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(true); | ||
313 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | ||
314 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | ||
315 | -// expect(request.getSession()).andReturn(session); | ||
316 | -// | ||
317 | -// session.setAttribute("name", 1L); | ||
318 | -// | ||
319 | -// replayAll(); | ||
320 | -// param = new ParameterImpl<Long>(ip); | ||
321 | -// param.setValue(1L); | ||
322 | -// verifyAll(); | ||
323 | -// } | ||
324 | -// | ||
325 | -// @Test | ||
326 | -// public void testSetValueIsViewScoped() { | ||
327 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
328 | -// | ||
329 | -// Map<String, Object> map = new HashMap<String, Object>(); | ||
330 | -// | ||
331 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | ||
332 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | ||
333 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(true); | ||
334 | -// expect(Faces.getViewMap()).andReturn(map); | ||
335 | -// | ||
336 | -// replayAll(); | ||
337 | -// param = new ParameterImpl<Long>(ip); | ||
338 | -// param.setValue(1L); | ||
339 | -// assertEquals(1L, map.get("name")); | ||
340 | -// verifyAll(); | ||
341 | -// } | ||
342 | -// | ||
343 | -// @Test | ||
344 | -// public void testSetValueElse() { | ||
345 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
346 | -// | ||
347 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | ||
348 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(false); | ||
349 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | ||
350 | -// | ||
351 | -// replayAll(); | ||
352 | -// param = new ParameterImpl<Long>(ip); | ||
353 | -// param.setValue(1L); | ||
354 | -// assertEquals(1L, Whitebox.getInternalState(param, "value")); | ||
355 | -// verifyAll(); | ||
356 | -// } | ||
357 | -// | ||
358 | -// @Test | ||
359 | -// public void testOthers() { | ||
360 | -// this.prepareForTestWithKeyFromNameAnnotation(); | ||
361 | -// | ||
362 | -// expect(annotated.isAnnotationPresent(SessionScoped.class)).andReturn(false); | ||
363 | -// expect(annotated.isAnnotationPresent(RequestScoped.class)).andReturn(true); | ||
364 | -// expect(annotated.isAnnotationPresent(ViewScoped.class)).andReturn(false); | ||
365 | -// | ||
366 | -// replayAll(); | ||
367 | -// param = new ParameterImpl<Long>(ip); | ||
368 | -// param.setValue(1L); | ||
369 | -// verifyAll(); | ||
370 | -// } | ||
371 | -// | ||
372 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/RedirectExceptionHandlerFactoryTest.java
@@ -1,75 +0,0 @@ | @@ -1,75 +0,0 @@ | ||
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 static junit.framework.Assert.assertEquals; | ||
40 | -//import static org.easymock.EasyMock.expect; | ||
41 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
43 | -// | ||
44 | -//import javax.faces.context.ExceptionHandler; | ||
45 | -//import javax.faces.context.ExceptionHandlerFactory; | ||
46 | -// | ||
47 | -//import org.junit.Test; | ||
48 | -//import org.junit.runner.RunWith; | ||
49 | -//import org.powermock.api.easymock.PowerMock; | ||
50 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
51 | -// | ||
52 | -//@RunWith(PowerMockRunner.class) | ||
53 | -//public class RedirectExceptionHandlerFactoryTest { | ||
54 | -// | ||
55 | -// @Test | ||
56 | -// public void testGetExceptionHandler() { | ||
57 | -// | ||
58 | -// ExceptionHandler jsfExceptionHandler = PowerMock.createMock(ExceptionHandler.class); | ||
59 | -// | ||
60 | -// ExceptionHandlerFactory jsfFactory = PowerMock.createMock(ExceptionHandlerFactory.class); | ||
61 | -// | ||
62 | -// RedirectExceptionHandlerFactory handlerFactory = new RedirectExceptionHandlerFactory(jsfFactory); | ||
63 | -// expect(jsfFactory.getExceptionHandler()).andReturn(jsfExceptionHandler); | ||
64 | -// | ||
65 | -// replayAll(); | ||
66 | -// | ||
67 | -// RedirectExceptionHandler handler = (RedirectExceptionHandler) handlerFactory.getExceptionHandler(); | ||
68 | -// | ||
69 | -// assertEquals(handler.getWrapped(), jsfExceptionHandler); | ||
70 | -// | ||
71 | -// verifyAll(); | ||
72 | -// | ||
73 | -// } | ||
74 | -// | ||
75 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/RedirectExceptionHandlerTest.java
@@ -1,127 +0,0 @@ | @@ -1,127 +0,0 @@ | ||
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 static junit.framework.Assert.assertFalse; | ||
40 | -//import static junit.framework.Assert.assertTrue; | ||
41 | -//import static org.easymock.EasyMock.expect; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.createMock; | ||
43 | -//import static org.powermock.api.easymock.PowerMock.expectLastCall; | ||
44 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
45 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
46 | -// | ||
47 | -//import java.util.ArrayList; | ||
48 | -//import java.util.Collection; | ||
49 | -// | ||
50 | -//import javax.faces.context.ExceptionHandler; | ||
51 | -//import javax.faces.event.ExceptionQueuedEvent; | ||
52 | -//import javax.faces.event.ExceptionQueuedEventContext; | ||
53 | -// | ||
54 | -//import org.junit.Before; | ||
55 | -//import org.junit.Test; | ||
56 | -//import org.junit.runner.RunWith; | ||
57 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
58 | -// | ||
59 | -//import br.gov.frameworkdemoiselle.annotation.Redirect; | ||
60 | -// | ||
61 | -//@RunWith(PowerMockRunner.class) | ||
62 | -//public class RedirectExceptionHandlerTest { | ||
63 | -// | ||
64 | -// private RedirectExceptionHandler handler; | ||
65 | -// | ||
66 | -// private ExceptionQueuedEventContext eventContext; | ||
67 | -// | ||
68 | -// private Collection<ExceptionQueuedEvent> events; | ||
69 | -// | ||
70 | -// @SuppressWarnings("serial") | ||
71 | -// @Redirect | ||
72 | -// class AnnotatedException extends RuntimeException { | ||
73 | -// } | ||
74 | -// | ||
75 | -// @Before | ||
76 | -// public void setUp() { | ||
77 | -// | ||
78 | -// ExceptionHandler jsfExceptionHandler = createMock(ExceptionHandler.class); | ||
79 | -// ExceptionQueuedEvent event = createMock(ExceptionQueuedEvent.class); | ||
80 | -// eventContext = createMock(ExceptionQueuedEventContext.class); | ||
81 | -// handler = new RedirectExceptionHandler(jsfExceptionHandler); | ||
82 | -// events = new ArrayList<ExceptionQueuedEvent>(); | ||
83 | -// | ||
84 | -// expect(event.getSource()).andReturn(eventContext); | ||
85 | -// events.add(event); | ||
86 | -// expect(handler.getUnhandledExceptionQueuedEvents()).andReturn(events).times(2); | ||
87 | -// | ||
88 | -// } | ||
89 | -// | ||
90 | -// @Test | ||
91 | -// public void testHandleAnAnnotatedException() { | ||
92 | -// | ||
93 | -// AnnotatedException exception = new AnnotatedException(); | ||
94 | -// | ||
95 | -// expect(eventContext.getException()).andReturn(exception); | ||
96 | -// | ||
97 | -// replayAll(); | ||
98 | -// | ||
99 | -// handler.handle(); | ||
100 | -// | ||
101 | -// assertTrue(events.isEmpty()); | ||
102 | -// | ||
103 | -// verifyAll(); | ||
104 | -// | ||
105 | -// } | ||
106 | -// | ||
107 | -// @Test | ||
108 | -// public void testHandleAnyException() { | ||
109 | -// | ||
110 | -// Exception exception = new Exception(); | ||
111 | -// | ||
112 | -// expect(eventContext.getException()).andReturn(exception); | ||
113 | -// | ||
114 | -// handler.getWrapped().handle(); | ||
115 | -// expectLastCall(); | ||
116 | -// | ||
117 | -// replayAll(); | ||
118 | -// | ||
119 | -// handler.handle(); | ||
120 | -// | ||
121 | -// assertFalse(events.isEmpty()); | ||
122 | -// | ||
123 | -// verifyAll(); | ||
124 | -// | ||
125 | -// } | ||
126 | -// | ||
127 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBeanTest.java
@@ -1,327 +0,0 @@ | @@ -1,327 +0,0 @@ | ||
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.template; | ||
38 | -// | ||
39 | -//import static org.easymock.EasyMock.expect; | ||
40 | -//import static org.junit.Assert.assertEquals; | ||
41 | -//import static org.junit.Assert.assertFalse; | ||
42 | -//import static org.junit.Assert.assertNull; | ||
43 | -//import static org.junit.Assert.assertTrue; | ||
44 | -//import static org.powermock.api.easymock.PowerMock.createMock; | ||
45 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
46 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
47 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
48 | -//import static org.powermock.reflect.Whitebox.setInternalState; | ||
49 | -// | ||
50 | -//import java.util.Locale; | ||
51 | -// | ||
52 | -//import javax.faces.component.UIViewRoot; | ||
53 | -//import javax.faces.context.FacesContext; | ||
54 | -//import javax.faces.convert.Converter; | ||
55 | -// | ||
56 | -//import org.junit.Before; | ||
57 | -//import org.junit.Test; | ||
58 | -//import org.junit.runner.RunWith; | ||
59 | -//import org.powermock.api.easymock.PowerMock; | ||
60 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
61 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
62 | -//import org.powermock.reflect.Whitebox; | ||
63 | -// | ||
64 | -//import br.gov.frameworkdemoiselle.DemoiselleException; | ||
65 | -//import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
66 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
67 | -//import br.gov.frameworkdemoiselle.util.Faces; | ||
68 | -//import br.gov.frameworkdemoiselle.util.Parameter; | ||
69 | -//import br.gov.frameworkdemoiselle.util.Reflections; | ||
70 | -//import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
71 | -// | ||
72 | -//import com.sun.faces.util.Util; | ||
73 | -// | ||
74 | -//@RunWith(PowerMockRunner.class) | ||
75 | -//@PrepareForTest({ Parameter.class, Beans.class, Reflections.class, Converter.class, FacesContext.class, Util.class, | ||
76 | -// Faces.class }) | ||
77 | -//public class AbstractEditPageBeanTest { | ||
78 | -// | ||
79 | -// private AbstractEditPageBean<Contact, Object> pageBean; | ||
80 | -// | ||
81 | -// private ResourceBundle bundle; | ||
82 | -// | ||
83 | -// @Before | ||
84 | -// public void before() { | ||
85 | -// bundle = new ResourceBundleProducer().create("demoiselle-jsf-bundle", Locale.getDefault()); | ||
86 | -// | ||
87 | -// pageBean = new AbstractEditPageBean<Contact, Object>() { | ||
88 | -// | ||
89 | -// private static final long serialVersionUID = 1L; | ||
90 | -// | ||
91 | -// @Override | ||
92 | -// public String update() { | ||
93 | -// return null; | ||
94 | -// } | ||
95 | -// | ||
96 | -// @Override | ||
97 | -// public String insert() { | ||
98 | -// return null; | ||
99 | -// } | ||
100 | -// | ||
101 | -// @Override | ||
102 | -// public String delete() { | ||
103 | -// return null; | ||
104 | -// } | ||
105 | -// | ||
106 | -// @Override | ||
107 | -// protected void handleLoad() { | ||
108 | -// } | ||
109 | -// }; | ||
110 | -// } | ||
111 | -// | ||
112 | -// @Test | ||
113 | -// public void testClear() { | ||
114 | -// Parameter<?> param = PowerMock.createMock(Parameter.class); | ||
115 | -// | ||
116 | -// assertNull(Whitebox.getInternalState(pageBean, "bean")); | ||
117 | -// assertNull(Whitebox.getInternalState(pageBean, "id")); | ||
118 | -// | ||
119 | -// setInternalState(pageBean, "bean", new Contact()); | ||
120 | -// setInternalState(pageBean, "id", param); | ||
121 | -// | ||
122 | -// pageBean.clear(); | ||
123 | -// | ||
124 | -// assertNull(Whitebox.getInternalState(pageBean, "bean")); | ||
125 | -// assertNull(Whitebox.getInternalState(pageBean, "id")); | ||
126 | -// } | ||
127 | -// | ||
128 | -// @Test | ||
129 | -// public void testCreateBean() { | ||
130 | -// mockStatic(Beans.class); | ||
131 | -// Contact c = new Contact(); | ||
132 | -// expect(Beans.getReference(Contact.class)).andReturn(c); | ||
133 | -// | ||
134 | -// replayAll(); | ||
135 | -// assertEquals(c, pageBean.createBean()); | ||
136 | -// verifyAll(); | ||
137 | -// } | ||
138 | -// | ||
139 | -// @Test | ||
140 | -// public void testGetBean() { | ||
141 | -// | ||
142 | -// pageBean = new AbstractEditPageBean<Contact, Object>() { | ||
143 | -// | ||
144 | -// private static final long serialVersionUID = 1L; | ||
145 | -// | ||
146 | -// private boolean updateMode = false; | ||
147 | -// | ||
148 | -// @Override | ||
149 | -// public String update() { | ||
150 | -// return null; | ||
151 | -// } | ||
152 | -// | ||
153 | -// @Override | ||
154 | -// public String insert() { | ||
155 | -// return null; | ||
156 | -// } | ||
157 | -// | ||
158 | -// @Override | ||
159 | -// public String delete() { | ||
160 | -// return null; | ||
161 | -// } | ||
162 | -// | ||
163 | -// @Override | ||
164 | -// protected void handleLoad() { | ||
165 | -// this.setBean(new Contact(200L)); | ||
166 | -// } | ||
167 | -// | ||
168 | -// public boolean isUpdateMode() { | ||
169 | -// return updateMode; | ||
170 | -// } | ||
171 | -// | ||
172 | -// }; | ||
173 | -// | ||
174 | -// Contact c = new Contact(); | ||
175 | -// assertNull(Whitebox.getInternalState(pageBean, "bean")); | ||
176 | -// setInternalState(pageBean, "bean", c); | ||
177 | -// assertEquals(c, pageBean.getBean()); | ||
178 | -// | ||
179 | -// mockStatic(Beans.class); | ||
180 | -// expect(Beans.getReference(Contact.class)).andReturn(c); | ||
181 | -// | ||
182 | -// pageBean.clear(); | ||
183 | -// | ||
184 | -// replayAll(); | ||
185 | -// assertEquals(c, pageBean.getBean()); | ||
186 | -// verifyAll(); | ||
187 | -// | ||
188 | -// pageBean.clear(); | ||
189 | -// | ||
190 | -// setInternalState(pageBean, "updateMode", true); | ||
191 | -// assertEquals(Long.valueOf(200), pageBean.getBean().getId()); | ||
192 | -// } | ||
193 | -// | ||
194 | -// @Test | ||
195 | -// public void testGetBeanClass() { | ||
196 | -// mockStatic(Reflections.class); | ||
197 | -// expect(Reflections.getGenericTypeArgument(pageBean.getClass(), 0)).andReturn(Object.class); | ||
198 | -// | ||
199 | -// assertNull(Whitebox.getInternalState(pageBean, "beanClass")); | ||
200 | -// | ||
201 | -// replayAll(); | ||
202 | -// assertEquals(Object.class, pageBean.getBeanClass()); | ||
203 | -// verifyAll(); | ||
204 | -// | ||
205 | -// setInternalState(pageBean, "beanClass", Contact.class, AbstractEditPageBean.class); | ||
206 | -// assertEquals(Contact.class, pageBean.getBeanClass()); | ||
207 | -// } | ||
208 | -// | ||
209 | -// @Test | ||
210 | -// public void testGetIdClass() { | ||
211 | -// mockStatic(Reflections.class); | ||
212 | -// expect(Reflections.getGenericTypeArgument(pageBean.getClass(), 1)).andReturn(Object.class); | ||
213 | -// | ||
214 | -// assertNull(Whitebox.getInternalState(pageBean, "idClass")); | ||
215 | -// | ||
216 | -// replayAll(); | ||
217 | -// assertEquals(Object.class, pageBean.getIdClass()); | ||
218 | -// verifyAll(); | ||
219 | -// | ||
220 | -// Whitebox.setInternalState(pageBean, "idClass", Long.class, AbstractEditPageBean.class); | ||
221 | -// assertEquals(Long.class, pageBean.getIdClass()); | ||
222 | -// } | ||
223 | -// | ||
224 | -// @Test | ||
225 | -// @SuppressWarnings("unchecked") | ||
226 | -// public void testGetStringId() { | ||
227 | -// mockStatic(Util.class); | ||
228 | -// | ||
229 | -// FacesContext facesContext = createMock(FacesContext.class); | ||
230 | -// Parameter<String> parameter = createMock(Parameter.class); | ||
231 | -// | ||
232 | -// setInternalState(pageBean, "facesContext", facesContext); | ||
233 | -// setInternalState(pageBean, "id", parameter); | ||
234 | -// setInternalState(pageBean, "idClass", String.class, AbstractEditPageBean.class); | ||
235 | -// | ||
236 | -// String value = "1"; | ||
237 | -// expect(parameter.getValue()).andReturn(value); | ||
238 | -// | ||
239 | -// replayAll(); | ||
240 | -// assertEquals(value, pageBean.getId()); | ||
241 | -// verifyAll(); | ||
242 | -// } | ||
243 | -// | ||
244 | -// @Test | ||
245 | -// @SuppressWarnings("unchecked") | ||
246 | -// public void testGetLongId() { | ||
247 | -// mockStatic(Faces.class); | ||
248 | -// | ||
249 | -// FacesContext facesContext = createMock(FacesContext.class); | ||
250 | -// Converter converter = createMock(Converter.class); | ||
251 | -// UIViewRoot viewRoot = createMock(UIViewRoot.class); | ||
252 | -// Parameter<String> parameter = createMock(Parameter.class); | ||
253 | -// | ||
254 | -// setInternalState(pageBean, "facesContext", facesContext); | ||
255 | -// setInternalState(pageBean, "id", parameter); | ||
256 | -// setInternalState(pageBean, "idClass", Long.class, AbstractEditPageBean.class); | ||
257 | -// | ||
258 | -// String value = "1"; | ||
259 | -// | ||
260 | -// expect(parameter.getValue()).andReturn(value); | ||
261 | -// expect(facesContext.getViewRoot()).andReturn(viewRoot); | ||
262 | -// expect(Faces.getConverter(Long.class)).andReturn(converter); | ||
263 | -// expect(converter.getAsObject(facesContext, viewRoot, value)).andReturn(Long.valueOf(value)); | ||
264 | -// | ||
265 | -// replayAll(); | ||
266 | -// assertEquals(Long.valueOf(value), pageBean.getId()); | ||
267 | -// verifyAll(); | ||
268 | -// } | ||
269 | -// | ||
270 | -// @Test | ||
271 | -// public void testGetNotStringIdWithNullConverter() { | ||
272 | -// FacesContext facesContext = createMock(FacesContext.class); | ||
273 | -// | ||
274 | -// setInternalState(pageBean, "facesContext", facesContext); | ||
275 | -// setInternalState(pageBean, "idClass", Contact.class, AbstractEditPageBean.class); | ||
276 | -// setInternalState(pageBean, "bundle", bundle); | ||
277 | -// | ||
278 | -// replayAll(); | ||
279 | -// try { | ||
280 | -// pageBean.getId(); | ||
281 | -// } catch (DemoiselleException cause) { | ||
282 | -// assertEquals(bundle.getString("id-converter-not-found", Contact.class.getCanonicalName()), | ||
283 | -// cause.getMessage()); | ||
284 | -// } | ||
285 | -// | ||
286 | -// verifyAll(); | ||
287 | -// } | ||
288 | -// | ||
289 | -// @SuppressWarnings("serial") | ||
290 | -// @Test | ||
291 | -// public void testUpdateMode() { | ||
292 | -// | ||
293 | -// pageBean = new AbstractEditPageBean<Contact, Object>() { | ||
294 | -// | ||
295 | -// private Long id = null; | ||
296 | -// | ||
297 | -// @Override | ||
298 | -// public String update() { | ||
299 | -// return null; | ||
300 | -// } | ||
301 | -// | ||
302 | -// @Override | ||
303 | -// public String insert() { | ||
304 | -// return null; | ||
305 | -// } | ||
306 | -// | ||
307 | -// @Override | ||
308 | -// public String delete() { | ||
309 | -// return null; | ||
310 | -// } | ||
311 | -// | ||
312 | -// @Override | ||
313 | -// protected void handleLoad() { | ||
314 | -// this.setBean(new Contact(200L)); | ||
315 | -// } | ||
316 | -// | ||
317 | -// public Long getId() { | ||
318 | -// return id; | ||
319 | -// } | ||
320 | -// | ||
321 | -// }; | ||
322 | -// | ||
323 | -// assertFalse(pageBean.isUpdateMode()); | ||
324 | -// setInternalState(pageBean, "id", 1L); | ||
325 | -// assertTrue(pageBean.isUpdateMode()); | ||
326 | -// } | ||
327 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/AbstractListPageBeanTest.java
@@ -1,198 +0,0 @@ | @@ -1,198 +0,0 @@ | ||
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.template; | ||
38 | -// | ||
39 | -//import static org.easymock.EasyMock.expect; | ||
40 | -//import static org.junit.Assert.assertEquals; | ||
41 | -//import static org.junit.Assert.assertNull; | ||
42 | -//import static org.junit.Assert.assertTrue; | ||
43 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
44 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
45 | -// | ||
46 | -//import java.util.ArrayList; | ||
47 | -//import java.util.HashMap; | ||
48 | -//import java.util.List; | ||
49 | -//import java.util.Map; | ||
50 | -// | ||
51 | -//import javax.faces.model.ListDataModel; | ||
52 | -// | ||
53 | -//import org.junit.Before; | ||
54 | -//import org.junit.Test; | ||
55 | -//import org.junit.runner.RunWith; | ||
56 | -//import org.powermock.api.easymock.PowerMock; | ||
57 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
58 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
59 | -//import org.powermock.reflect.Whitebox; | ||
60 | -// | ||
61 | -//import br.gov.frameworkdemoiselle.internal.implementation.PaginationImpl; | ||
62 | -//import br.gov.frameworkdemoiselle.pagination.Pagination; | ||
63 | -//import br.gov.frameworkdemoiselle.pagination.PaginationContext; | ||
64 | -//import br.gov.frameworkdemoiselle.util.Reflections; | ||
65 | -// | ||
66 | -//@RunWith(PowerMockRunner.class) | ||
67 | -//@PrepareForTest({ Reflections.class, PaginationContext.class, Pagination.class }) | ||
68 | -//public class AbstractListPageBeanTest { | ||
69 | -// | ||
70 | -// private MySimplePageBean pageBean; | ||
71 | -// | ||
72 | -// @Before | ||
73 | -// public void before() { | ||
74 | -// pageBean = new MySimplePageBean(); | ||
75 | -// } | ||
76 | -// | ||
77 | -// @SuppressWarnings("rawtypes") | ||
78 | -// @Test | ||
79 | -// public void testClear() { | ||
80 | -// assertNull(Whitebox.getInternalState(pageBean, "dataModel")); | ||
81 | -// assertNull(Whitebox.getInternalState(pageBean, "resultList")); | ||
82 | -// | ||
83 | -// Whitebox.setInternalState(pageBean, "resultList", new ArrayList()); | ||
84 | -// Whitebox.setInternalState(pageBean, "dataModel", new ListDataModel()); | ||
85 | -// | ||
86 | -// pageBean.clear(); | ||
87 | -// | ||
88 | -// assertNull(Whitebox.getInternalState(pageBean, "dataModel")); | ||
89 | -// assertNull(Whitebox.getInternalState(pageBean, "resultList")); | ||
90 | -// } | ||
91 | -// | ||
92 | -// @Test | ||
93 | -// public void testGetBeanClass() { | ||
94 | -// assertNull(Whitebox.getInternalState(pageBean, "beanClass")); | ||
95 | -// | ||
96 | -// PowerMock.mockStatic(Reflections.class); | ||
97 | -// expect(Reflections.getGenericTypeArgument(pageBean.getClass(), 0)).andReturn(Object.class); | ||
98 | -// | ||
99 | -// PowerMock.replayAll(); | ||
100 | -// assertEquals(Object.class, pageBean.getBeanClass()); | ||
101 | -// PowerMock.verifyAll(); | ||
102 | -// | ||
103 | -// Whitebox.setInternalState(pageBean, "beanClass", Contact.class, AbstractListPageBean.class); | ||
104 | -// | ||
105 | -// assertEquals(Contact.class, pageBean.getBeanClass()); | ||
106 | -// } | ||
107 | -// | ||
108 | -// @Test | ||
109 | -// public void testGetDataModel() { | ||
110 | -// assertNull(Whitebox.getInternalState(pageBean, "dataModel")); | ||
111 | -// assertEquals(ListDataModel.class, pageBean.getDataModel().getClass()); | ||
112 | -// | ||
113 | -// ListDataModel<Contact> ldm = new ListDataModel<Contact>(); | ||
114 | -// Whitebox.setInternalState(pageBean, "dataModel", ldm); | ||
115 | -// | ||
116 | -// assertEquals(ldm, pageBean.getDataModel()); | ||
117 | -// } | ||
118 | -// | ||
119 | -// @Test | ||
120 | -// public void testGetResultList() { | ||
121 | -// assertNull(Whitebox.getInternalState(pageBean, "resultList")); | ||
122 | -// | ||
123 | -// List<Contact> list = pageBean.getResultList(); | ||
124 | -// assertTrue(list.size() == 2); | ||
125 | -// | ||
126 | -// list = new ArrayList<Contact>(); | ||
127 | -// Whitebox.setInternalState(pageBean, "resultList", list); | ||
128 | -// assertTrue(list.size() == 0); | ||
129 | -// assertEquals(list, pageBean.getResultList()); | ||
130 | -// } | ||
131 | -// | ||
132 | -// @Test | ||
133 | -// public void testList() { | ||
134 | -// this.testClear(); | ||
135 | -// assertEquals(pageBean.getCurrentView(), pageBean.list()); | ||
136 | -// } | ||
137 | -// | ||
138 | -// @Test | ||
139 | -// public void testSelection() { | ||
140 | -// Map<Long, Boolean> map = new HashMap<Long, Boolean>(); | ||
141 | -// map.put(1L, true); | ||
142 | -// Whitebox.setInternalState(pageBean, "selection", map); | ||
143 | -// assertEquals(map, pageBean.getSelection()); | ||
144 | -// assertEquals(true, pageBean.getSelection().get(1L)); | ||
145 | -// | ||
146 | -// pageBean.setSelection(null); | ||
147 | -// assertNull(Whitebox.getInternalState(pageBean, "selection")); | ||
148 | -// pageBean.setSelection(map); | ||
149 | -// assertEquals(map, pageBean.getSelection()); | ||
150 | -// assertEquals(true, pageBean.getSelection().get(1L)); | ||
151 | -// } | ||
152 | -// | ||
153 | -// @Test | ||
154 | -// public void testPagination() { | ||
155 | -// Pagination pagination = new PaginationImpl(); | ||
156 | -// PaginationContext pc = PowerMock.createMock(PaginationContext.class); | ||
157 | -// expect(pc.getPagination(Contact.class, true)).andReturn(pagination); | ||
158 | -// | ||
159 | -// replayAll(); | ||
160 | -// Whitebox.setInternalState(pageBean, "paginationContext", pc); | ||
161 | -// assertEquals(pageBean.getPagination(), pagination); | ||
162 | -// verifyAll(); | ||
163 | -// } | ||
164 | -// | ||
165 | -// @Test | ||
166 | -// public void testClearSelection() { | ||
167 | -// pageBean.clearSelection(); | ||
168 | -// assertEquals(true, pageBean.getSelectedList().isEmpty()); | ||
169 | -// } | ||
170 | -// | ||
171 | -// @Test | ||
172 | -// public void testGetSelectedList() { | ||
173 | -// Map<Long, Boolean> map = new HashMap<Long, Boolean>(); | ||
174 | -// map.put(1L, true); | ||
175 | -// map.put(2L, true); | ||
176 | -// pageBean.setSelection(map); | ||
177 | -// assertEquals(2, pageBean.getSelectedList().size()); | ||
178 | -// } | ||
179 | -// | ||
180 | -//} | ||
181 | -// | ||
182 | -//@SuppressWarnings("serial") | ||
183 | -//class MySimplePageBean extends AbstractListPageBean<Contact, Long> { | ||
184 | -// | ||
185 | -// @Override | ||
186 | -// protected List<Contact> handleResultList() { | ||
187 | -// List<Contact> list = new ArrayList<Contact>(); | ||
188 | -// list.add(new Contact()); | ||
189 | -// list.add(new Contact()); | ||
190 | -// return list; | ||
191 | -// } | ||
192 | -// | ||
193 | -// @Override | ||
194 | -// public String getCurrentView() { | ||
195 | -// return "currentView"; | ||
196 | -// } | ||
197 | -// | ||
198 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/AbstractPageTest.java
@@ -1,160 +0,0 @@ | @@ -1,160 +0,0 @@ | ||
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.template; | ||
38 | -// | ||
39 | -//import static org.easymock.EasyMock.expect; | ||
40 | -//import static org.junit.Assert.assertEquals; | ||
41 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
43 | -// | ||
44 | -//import javax.faces.component.UIViewRoot; | ||
45 | -//import javax.faces.context.FacesContext; | ||
46 | -// | ||
47 | -//import org.junit.Before; | ||
48 | -//import org.junit.Test; | ||
49 | -//import org.junit.runner.RunWith; | ||
50 | -//import org.powermock.api.easymock.PowerMock; | ||
51 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
52 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
53 | -//import org.powermock.reflect.Whitebox; | ||
54 | -// | ||
55 | -//import br.gov.frameworkdemoiselle.annotation.NextView; | ||
56 | -//import br.gov.frameworkdemoiselle.annotation.PreviousView; | ||
57 | -//import br.gov.frameworkdemoiselle.message.MessageContext; | ||
58 | -// | ||
59 | -//@RunWith(PowerMockRunner.class) | ||
60 | -//@PrepareForTest({ MessageContext.class }) | ||
61 | -//public class AbstractPageTest { | ||
62 | -// | ||
63 | -// private AbstractPageBean abstractPage; | ||
64 | -// | ||
65 | -// private FacesContext facesContext; | ||
66 | -// | ||
67 | -// private UIViewRoot viewRoot; | ||
68 | -// | ||
69 | -// @Before | ||
70 | -// public void before() { | ||
71 | -// facesContext = PowerMock.createMock(FacesContext.class); | ||
72 | -// viewRoot = PowerMock.createMock(UIViewRoot.class); | ||
73 | -// expect(facesContext.getViewRoot()).andReturn(viewRoot).anyTimes(); | ||
74 | -// expect(viewRoot.getViewId()).andReturn("viewId").anyTimes(); | ||
75 | -// } | ||
76 | -// | ||
77 | -// @Test | ||
78 | -// public void testGetCurrentView() { | ||
79 | -// abstractPage = new MyAbstractPage(); | ||
80 | -// Whitebox.setInternalState(abstractPage, "facesContext", facesContext); | ||
81 | -// | ||
82 | -// replayAll(); | ||
83 | -// assertEquals(abstractPage.getCurrentView(), "viewId"); | ||
84 | -// verifyAll(); | ||
85 | -// } | ||
86 | -// | ||
87 | -// @Test | ||
88 | -// public void testGetNextViewOK() { | ||
89 | -// abstractPage = new MyAbstractPage(); | ||
90 | -// | ||
91 | -// replayAll(); | ||
92 | -// assertEquals(abstractPage.getNextView(), "next_view"); | ||
93 | -// verifyAll(); | ||
94 | -// } | ||
95 | -// | ||
96 | -// @Test | ||
97 | -// public void testGetNextViewWhenNoAnnotation() { | ||
98 | -// abstractPage = new MyAbstractPageNoAnnotations(); | ||
99 | -// | ||
100 | -// replayAll(); | ||
101 | -// assertEquals(abstractPage.getNextView(), null); | ||
102 | -// verifyAll(); | ||
103 | -// } | ||
104 | -// | ||
105 | -// @Test | ||
106 | -// public void testGetNextViewAlreadySet() { | ||
107 | -// abstractPage = new MyAbstractPageNoAnnotations(); | ||
108 | -// Whitebox.setInternalState(abstractPage, "nextView", "next"); | ||
109 | -// | ||
110 | -// replayAll(); | ||
111 | -// assertEquals(abstractPage.getNextView(), "next"); | ||
112 | -// verifyAll(); | ||
113 | -// } | ||
114 | -// | ||
115 | -// @Test | ||
116 | -// public void testGetPreviousViewOK() { | ||
117 | -// abstractPage = new MyAbstractPage(); | ||
118 | -// | ||
119 | -// replayAll(); | ||
120 | -// assertEquals(abstractPage.getPreviousView(), "prevs"); | ||
121 | -// verifyAll(); | ||
122 | -// } | ||
123 | -// | ||
124 | -// @Test | ||
125 | -// public void testGetPreviousViewAlreadySet() { | ||
126 | -// abstractPage = new MyAbstractPageNoAnnotations(); | ||
127 | -// Whitebox.setInternalState(abstractPage, "previousView", "previous"); | ||
128 | -// | ||
129 | -// replayAll(); | ||
130 | -// assertEquals(abstractPage.getPreviousView(), "previous"); | ||
131 | -// verifyAll(); | ||
132 | -// } | ||
133 | -// | ||
134 | -// @Test | ||
135 | -// public void testGetPreviousViewWhenNoAnnotation() { | ||
136 | -// abstractPage = new MyAbstractPageNoAnnotations(); | ||
137 | -// | ||
138 | -// replayAll(); | ||
139 | -// assertEquals(abstractPage.getPreviousView(), null); | ||
140 | -// verifyAll(); | ||
141 | -// } | ||
142 | -// | ||
143 | -// @Test | ||
144 | -// public void testOtherTests() { | ||
145 | -// abstractPage = new MyAbstractPageNoAnnotations(); | ||
146 | -// assertEquals(null, abstractPage.getTitle()); | ||
147 | -// } | ||
148 | -//} | ||
149 | -// | ||
150 | -//@SuppressWarnings("serial") | ||
151 | -//@NextView("next_view") | ||
152 | -//@PreviousView("prevs") | ||
153 | -//class MyAbstractPage extends AbstractPageBean { | ||
154 | -// | ||
155 | -//} | ||
156 | -// | ||
157 | -//@SuppressWarnings("serial") | ||
158 | -//class MyAbstractPageNoAnnotations extends AbstractPageBean { | ||
159 | -// | ||
160 | -//} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/template/Contact.java
@@ -1,62 +0,0 @@ | @@ -1,62 +0,0 @@ | ||
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.template; | ||
38 | - | ||
39 | -import java.io.Serializable; | ||
40 | - | ||
41 | -public class Contact implements Serializable { | ||
42 | - | ||
43 | - private static final long serialVersionUID = 1L; | ||
44 | - | ||
45 | - private Long id; | ||
46 | - | ||
47 | - public Contact() { | ||
48 | - } | ||
49 | - | ||
50 | - public Contact(Long id) { | ||
51 | - this.id = id; | ||
52 | - } | ||
53 | - | ||
54 | - public void setId(Long id) { | ||
55 | - this.id = id; | ||
56 | - } | ||
57 | - | ||
58 | - public Long getId() { | ||
59 | - return id; | ||
60 | - } | ||
61 | - | ||
62 | -} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/util/FacesTest.java
@@ -1,219 +0,0 @@ | @@ -1,219 +0,0 @@ | ||
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 junit.framework.Assert.assertEquals; | ||
40 | -//import static org.easymock.EasyMock.expect; | ||
41 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
42 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
43 | -// | ||
44 | -//import java.util.ArrayList; | ||
45 | -//import java.util.HashMap; | ||
46 | -//import java.util.List; | ||
47 | -//import java.util.Map; | ||
48 | -// | ||
49 | -//import javax.faces.application.Application; | ||
50 | -//import javax.faces.application.FacesMessage; | ||
51 | -//import javax.faces.component.UIViewRoot; | ||
52 | -//import javax.faces.context.FacesContext; | ||
53 | -//import javax.faces.convert.Converter; | ||
54 | -// | ||
55 | -//import org.easymock.EasyMock; | ||
56 | -//import org.junit.Before; | ||
57 | -//import org.junit.Test; | ||
58 | -//import org.junit.runner.RunWith; | ||
59 | -//import org.powermock.api.easymock.PowerMock; | ||
60 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
61 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
62 | -// | ||
63 | -//import br.gov.frameworkdemoiselle.exception.ApplicationException; | ||
64 | -//import br.gov.frameworkdemoiselle.message.DefaultMessage; | ||
65 | -//import br.gov.frameworkdemoiselle.message.Message; | ||
66 | -//import br.gov.frameworkdemoiselle.message.SeverityType; | ||
67 | -// | ||
68 | -//import com.sun.faces.util.Util; | ||
69 | -// | ||
70 | -//@RunWith(PowerMockRunner.class) | ||
71 | -//@PrepareForTest({ Beans.class, Strings.class, Converter.class, Util.class, ResourceBundle.class }) | ||
72 | -//public class FacesTest { | ||
73 | -// | ||
74 | -// private FacesContext facesContext; | ||
75 | -// | ||
76 | -// private Faces faces; | ||
77 | -// | ||
78 | -// @Before | ||
79 | -// public void before() { | ||
80 | -// faces = new Faces(); | ||
81 | -// | ||
82 | -// PowerMock.mockStatic(Beans.class); | ||
83 | -// facesContext = PowerMock.createMock(FacesContext.class); | ||
84 | -// } | ||
85 | -// | ||
86 | -// @SuppressWarnings("static-access") | ||
87 | -// @Test | ||
88 | -// public void testAddMessage() { | ||
89 | -// expect(Beans.getReference(ResourceBundle.class)).andReturn(null).anyTimes(); | ||
90 | -// expect(Beans.getReference(FacesContext.class)).andReturn(facesContext).anyTimes(); | ||
91 | -// | ||
92 | -// facesContext.addMessage(EasyMock.anyObject(String.class), EasyMock.anyObject(FacesMessage.class)); | ||
93 | -// EasyMock.expectLastCall().times(5); | ||
94 | -// | ||
95 | -// replayAll(); | ||
96 | -// | ||
97 | -// DefaultMessage message = new DefaultMessage("text") { | ||
98 | -// | ||
99 | -// @Override | ||
100 | -// public String toString() { | ||
101 | -// return "Message"; | ||
102 | -// } | ||
103 | -// | ||
104 | -// }; | ||
105 | -// | ||
106 | -// List<Message> messages = new ArrayList<Message>(); | ||
107 | -// messages.add(message); | ||
108 | -// | ||
109 | -// faces.addMessages(null); | ||
110 | -// faces.addMessages(messages); | ||
111 | -// faces.addMessage(message); | ||
112 | -// faces.addMessage("clientId", message); | ||
113 | -// faces.addMessage("clientId", new MyException()); | ||
114 | -// faces.addMessage(new MyException()); | ||
115 | -// verifyAll(); | ||
116 | -// } | ||
117 | -// | ||
118 | -// @SuppressWarnings("static-access") | ||
119 | -// @Test | ||
120 | -// public void testParseSeverity() { | ||
121 | -// assertEquals(faces.parse(SeverityType.ERROR), FacesMessage.SEVERITY_ERROR); | ||
122 | -// assertEquals(faces.parse(SeverityType.FATAL), FacesMessage.SEVERITY_FATAL); | ||
123 | -// assertEquals(faces.parse(SeverityType.INFO), FacesMessage.SEVERITY_INFO); | ||
124 | -// assertEquals(faces.parse(SeverityType.WARN), FacesMessage.SEVERITY_WARN); | ||
125 | -// } | ||
126 | -// | ||
127 | -// @SuppressWarnings("static-access") | ||
128 | -// @Test | ||
129 | -// public void testParseThrowable() { | ||
130 | -// FacesMessage facesMessage = faces.parse(new MyException()); | ||
131 | -// assertEquals(facesMessage.getSeverity(), FacesMessage.SEVERITY_INFO); | ||
132 | -// assertEquals(facesMessage.getSummary(), "MESSAGE"); | ||
133 | -// | ||
134 | -// facesMessage = faces.parse(new Exception()); | ||
135 | -// assertEquals(facesMessage.getSeverity(), FacesMessage.SEVERITY_ERROR); | ||
136 | -// assertEquals(facesMessage.getSummary(), "java.lang.Exception"); | ||
137 | -// } | ||
138 | -// | ||
139 | -// @SuppressWarnings("static-access") | ||
140 | -// @Test | ||
141 | -// public void testConvertNull() { | ||
142 | -// PowerMock.mockStatic(Strings.class); | ||
143 | -// | ||
144 | -// Converter converter = PowerMock.createMock(Converter.class); | ||
145 | -// expect(Strings.isEmpty(EasyMock.anyObject(String.class))).andReturn(true); | ||
146 | -// | ||
147 | -// replayAll(); | ||
148 | -// String object = (String) faces.convert("value", converter); | ||
149 | -// assertEquals(null, object); | ||
150 | -// verifyAll(); | ||
151 | -// } | ||
152 | -// | ||
153 | -// @SuppressWarnings("static-access") | ||
154 | -// @Test | ||
155 | -// public void testConvert() { | ||
156 | -// PowerMock.mockStatic(Strings.class); | ||
157 | -// | ||
158 | -// expect(Beans.getReference(FacesContext.class)).andReturn(facesContext).times(2); | ||
159 | -// | ||
160 | -// Converter converter = PowerMock.createMock(Converter.class); | ||
161 | -// expect(Strings.isEmpty(EasyMock.anyObject(String.class))).andReturn(false).times(2); | ||
162 | -// expect( | ||
163 | -// converter.getAsObject(EasyMock.anyObject(FacesContext.class), EasyMock.anyObject(UIViewRoot.class), | ||
164 | -// EasyMock.anyObject(String.class))).andReturn("THAT"); | ||
165 | -// expect(facesContext.getViewRoot()).andReturn(null); | ||
166 | -// | ||
167 | -// replayAll(); | ||
168 | -// String object = (String) faces.convert("value", converter); | ||
169 | -// assertEquals("THAT", object); | ||
170 | -// | ||
171 | -// object = (String) faces.convert("value", null); | ||
172 | -// assertEquals("value", object); | ||
173 | -// | ||
174 | -// verifyAll(); | ||
175 | -// } | ||
176 | -// | ||
177 | -// @SuppressWarnings("static-access") | ||
178 | -// @Test | ||
179 | -// public void testGetConverter() { | ||
180 | -// Application application = PowerMock.createMock(Application.class); | ||
181 | -// Converter converter = PowerMock.createMock(Converter.class); | ||
182 | -// PowerMock.mockStatic(Util.class); | ||
183 | -// | ||
184 | -// expect(Beans.getReference(FacesContext.class)).andReturn(facesContext); | ||
185 | -// expect(facesContext.getApplication()).andReturn(application); | ||
186 | -// expect(application.createConverter(getClass())).andReturn(converter); | ||
187 | -// | ||
188 | -// replayAll(); | ||
189 | -// assertEquals(converter, faces.getConverter(getClass())); | ||
190 | -// verifyAll(); | ||
191 | -// } | ||
192 | -// | ||
193 | -// @SuppressWarnings("static-access") | ||
194 | -// @Test | ||
195 | -// public void testGetViewMap() { | ||
196 | -// UIViewRoot uiViewRoot = PowerMock.createMock(UIViewRoot.class); | ||
197 | -// expect(Beans.getReference(FacesContext.class)).andReturn(facesContext); | ||
198 | -// expect(facesContext.getViewRoot()).andReturn(uiViewRoot); | ||
199 | -// | ||
200 | -// Map<String, Object> map = new HashMap<String, Object>(); | ||
201 | -// expect(uiViewRoot.getViewMap(true)).andReturn(map); | ||
202 | -// | ||
203 | -// replayAll(); | ||
204 | -// assertEquals(map, faces.getViewMap()); | ||
205 | -// verifyAll(); | ||
206 | -// } | ||
207 | -// | ||
208 | -// @SuppressWarnings("serial") | ||
209 | -// @ApplicationException(severity = SeverityType.INFO) | ||
210 | -// class MyException extends Exception { | ||
211 | -// | ||
212 | -// @Override | ||
213 | -// public String getMessage() { | ||
214 | -// return "MESSAGE"; | ||
215 | -// } | ||
216 | -// | ||
217 | -// } | ||
218 | -// | ||
219 | -//} |
impl/extension/jsf/src/test/java/exception/handler/authentication/AuthenticationExceptionTest.java
@@ -59,12 +59,11 @@ public class AuthenticationExceptionTest { | @@ -59,12 +59,11 @@ public class AuthenticationExceptionTest { | ||
59 | @ArquillianResource | 59 | @ArquillianResource |
60 | private URL deploymentUrl; | 60 | private URL deploymentUrl; |
61 | 61 | ||
62 | - private static final String PATH = "src/test/resources/security-authentication"; | 62 | + private static final String PATH = "src/test/resources/exception-handler-authentication"; |
63 | 63 | ||
64 | @Deployment(testable = false) | 64 | @Deployment(testable = false) |
65 | public static WebArchive createDeployment() { | 65 | public static WebArchive createDeployment() { |
66 | - return Tests.createDeployment().addClass(AuthenticationExceptionTest.class) | ||
67 | - .addClass(AuthenticationBean.class) | 66 | + return Tests.createDeployment().addClass(AuthenticationExceptionTest.class).addClass(AuthenticationBean.class) |
68 | .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml") | 67 | .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml") |
69 | .addAsWebResource(Tests.createFileAsset(PATH + "/login.xhtml"), "login.xhtml") | 68 | .addAsWebResource(Tests.createFileAsset(PATH + "/login.xhtml"), "login.xhtml") |
70 | .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); | 69 | .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); |
impl/extension/jsf/src/test/java/exception/handler/authorization/AuthorizationBean.java
0 → 100644
@@ -0,0 +1,61 @@ | @@ -0,0 +1,61 @@ | ||
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 exception.handler.authorization; | ||
38 | + | ||
39 | +import br.gov.frameworkdemoiselle.security.AuthorizationException; | ||
40 | +import br.gov.frameworkdemoiselle.stereotype.ViewController; | ||
41 | + | ||
42 | +@ViewController | ||
43 | +public class AuthorizationBean { | ||
44 | + | ||
45 | + private String correctMessage = "Authorization Message."; | ||
46 | + | ||
47 | + private String exceptionMessage = "Authorization Exception!"; | ||
48 | + | ||
49 | + public String getCorrectMessage() { | ||
50 | + return correctMessage; | ||
51 | + } | ||
52 | + | ||
53 | + public String getExceptionMessage() { | ||
54 | + throw new AuthorizationException(exceptionMessage); | ||
55 | + } | ||
56 | + | ||
57 | + public void loadExceptionMessage() { | ||
58 | + throw new AuthorizationException(exceptionMessage); | ||
59 | + } | ||
60 | + | ||
61 | +} |
impl/extension/jsf/src/test/java/exception/handler/authorization/AuthorizationHandledExceptionTest.java
0 → 100644
@@ -0,0 +1,94 @@ | @@ -0,0 +1,94 @@ | ||
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 exception.handler.authorization; | ||
38 | + | ||
39 | +import static org.junit.Assert.assertNotSame; | ||
40 | +import static org.junit.Assert.assertTrue; | ||
41 | + | ||
42 | +import java.io.IOException; | ||
43 | +import java.net.URL; | ||
44 | + | ||
45 | +import org.apache.commons.httpclient.HttpClient; | ||
46 | +import org.apache.commons.httpclient.HttpException; | ||
47 | +import org.apache.commons.httpclient.HttpStatus; | ||
48 | +import org.apache.commons.httpclient.methods.GetMethod; | ||
49 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
50 | +import org.jboss.arquillian.junit.Arquillian; | ||
51 | +import org.jboss.arquillian.test.api.ArquillianResource; | ||
52 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
53 | +import org.junit.Test; | ||
54 | +import org.junit.runner.RunWith; | ||
55 | + | ||
56 | +import test.Tests; | ||
57 | + | ||
58 | +@RunWith(Arquillian.class) | ||
59 | +public class AuthorizationHandledExceptionTest { | ||
60 | + | ||
61 | + @ArquillianResource | ||
62 | + private URL deploymentUrl; | ||
63 | + | ||
64 | + private static final String PATH = "src/test/resources/exception-handler-authorization"; | ||
65 | + | ||
66 | + @Deployment(testable = false) | ||
67 | + public static WebArchive createDeployment() { | ||
68 | + return Tests.createDeployment().addClass(AuthorizationHandledExceptionTest.class).addClass(AuthorizationBean.class) | ||
69 | + .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml") | ||
70 | + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml") | ||
71 | + .addAsWebInfResource(Tests.createFileAsset(PATH + "/pretty-config.xml"), "pretty-config.xml"); | ||
72 | + | ||
73 | + } | ||
74 | + | ||
75 | + @Test | ||
76 | + public void authorizationHandledException() { | ||
77 | + HttpClient client = new HttpClient(); | ||
78 | + GetMethod method = new GetMethod(deploymentUrl + "/index"); | ||
79 | + | ||
80 | + try { | ||
81 | + int status = client.executeMethod(method); | ||
82 | + String message = method.getResponseBodyAsString(); | ||
83 | + | ||
84 | + assertNotSame(HttpStatus.SC_INTERNAL_SERVER_ERROR, status); | ||
85 | + assertTrue(message.contains("Authorization Message.")); | ||
86 | + assertTrue(message.contains("Authorization Exception!")); | ||
87 | + | ||
88 | + } catch (HttpException e) { | ||
89 | + e.printStackTrace(); | ||
90 | + } catch (IOException e) { | ||
91 | + e.printStackTrace(); | ||
92 | + } | ||
93 | + } | ||
94 | +} |
impl/extension/jsf/src/test/java/exception/handler/authorization/AuthorizationNotHandledExceptionTest.java
0 → 100644
@@ -0,0 +1,93 @@ | @@ -0,0 +1,93 @@ | ||
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 exception.handler.authorization; | ||
38 | + | ||
39 | +import static org.junit.Assert.assertEquals; | ||
40 | +import static org.junit.Assert.assertFalse; | ||
41 | +import static org.junit.Assert.assertTrue; | ||
42 | + | ||
43 | +import java.io.IOException; | ||
44 | +import java.net.URL; | ||
45 | + | ||
46 | +import org.apache.commons.httpclient.HttpClient; | ||
47 | +import org.apache.commons.httpclient.HttpException; | ||
48 | +import org.apache.commons.httpclient.HttpStatus; | ||
49 | +import org.apache.commons.httpclient.methods.GetMethod; | ||
50 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
51 | +import org.jboss.arquillian.junit.Arquillian; | ||
52 | +import org.jboss.arquillian.test.api.ArquillianResource; | ||
53 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
54 | +import org.junit.Test; | ||
55 | +import org.junit.runner.RunWith; | ||
56 | + | ||
57 | +import test.Tests; | ||
58 | + | ||
59 | +@RunWith(Arquillian.class) | ||
60 | +public class AuthorizationNotHandledExceptionTest { | ||
61 | + | ||
62 | + @ArquillianResource | ||
63 | + private URL deploymentUrl; | ||
64 | + | ||
65 | + private static final String PATH = "src/test/resources/exception-handler-authorization"; | ||
66 | + | ||
67 | + @Deployment(testable = false) | ||
68 | + public static WebArchive createDeployment() { | ||
69 | + return Tests.createDeployment().addClass(AuthorizationNotHandledExceptionTest.class).addClass(AuthorizationBean.class) | ||
70 | + .addAsWebResource(Tests.createFileAsset(PATH + "/page.xhtml"), "page.xhtml") | ||
71 | + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); | ||
72 | + } | ||
73 | + | ||
74 | + @Test | ||
75 | + public void authorizationNotHandledException() { | ||
76 | + HttpClient client = new HttpClient(); | ||
77 | + GetMethod method = new GetMethod(deploymentUrl + "/page.jsf"); | ||
78 | + | ||
79 | + try { | ||
80 | + int status = client.executeMethod(method); | ||
81 | + String message = method.getResponseBodyAsString(); | ||
82 | + | ||
83 | + assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, status); | ||
84 | + assertTrue(message.contains("Authorization Exception!")); | ||
85 | + assertFalse(message.contains("Authorization Message.")); | ||
86 | + | ||
87 | + } catch (HttpException e) { | ||
88 | + e.printStackTrace(); | ||
89 | + } catch (IOException e) { | ||
90 | + e.printStackTrace(); | ||
91 | + } | ||
92 | + } | ||
93 | +} |
impl/extension/jsf/src/test/java/exception/handler/common/DummyException.java
@@ -36,8 +36,11 @@ | @@ -36,8 +36,11 @@ | ||
36 | */ | 36 | */ |
37 | package exception.handler.common; | 37 | package exception.handler.common; |
38 | 38 | ||
39 | +import org.junit.Ignore; | ||
40 | + | ||
39 | import br.gov.frameworkdemoiselle.exception.ApplicationException; | 41 | import br.gov.frameworkdemoiselle.exception.ApplicationException; |
40 | 42 | ||
43 | +@Ignore | ||
41 | @ApplicationException | 44 | @ApplicationException |
42 | public class DummyException extends RuntimeException{ | 45 | public class DummyException extends RuntimeException{ |
43 | 46 |
impl/extension/jsf/src/test/java/exception/handler/common/ExceptionHandlerConfigBean.java
@@ -36,8 +36,11 @@ | @@ -36,8 +36,11 @@ | ||
36 | */ | 36 | */ |
37 | package exception.handler.common; | 37 | package exception.handler.common; |
38 | 38 | ||
39 | +import org.junit.Ignore; | ||
40 | + | ||
39 | import br.gov.frameworkdemoiselle.stereotype.ViewController; | 41 | import br.gov.frameworkdemoiselle.stereotype.ViewController; |
40 | 42 | ||
43 | +@Ignore | ||
41 | @ViewController | 44 | @ViewController |
42 | public class ExceptionHandlerConfigBean{ | 45 | public class ExceptionHandlerConfigBean{ |
43 | 46 |
impl/extension/jsf/src/test/java/exception/handler/configuration/ExceptionHandlerConfigFilter.java
@@ -1,99 +0,0 @@ | @@ -1,99 +0,0 @@ | ||
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 exception.handler.configuration; | ||
38 | - | ||
39 | -import java.io.IOException; | ||
40 | -import java.util.Iterator; | ||
41 | -import java.util.List; | ||
42 | - | ||
43 | -import javax.faces.application.FacesMessage; | ||
44 | -import javax.faces.context.FacesContext; | ||
45 | -import javax.servlet.Filter; | ||
46 | -import javax.servlet.FilterChain; | ||
47 | -import javax.servlet.FilterConfig; | ||
48 | -import javax.servlet.ServletException; | ||
49 | -import javax.servlet.ServletRequest; | ||
50 | -import javax.servlet.ServletResponse; | ||
51 | -import javax.servlet.http.HttpServlet; | ||
52 | -import javax.servlet.http.HttpServletResponse; | ||
53 | - | ||
54 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
55 | - | ||
56 | -public class ExceptionHandlerConfigFilter implements Filter { | ||
57 | - | ||
58 | - private static final long serialVersionUID = 1L; | ||
59 | - | ||
60 | - private List<FacesMessage> facesMessage; | ||
61 | - | ||
62 | - @Override | ||
63 | - public void init(FilterConfig filterConfig) throws ServletException { | ||
64 | - } | ||
65 | - | ||
66 | - @Override | ||
67 | - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, | ||
68 | - ServletException { | ||
69 | - | ||
70 | -// try { | ||
71 | - | ||
72 | - chain.doFilter(request, response); | ||
73 | - | ||
74 | -// String message = response.getContentType(); | ||
75 | -// System.out.println("MESSAGE FILTER: " + message); | ||
76 | - | ||
77 | -// facesMessage = FacesContext.getCurrentInstance().getMessageList(); | ||
78 | - | ||
79 | -// for(FacesMessage fm : FacesContext.getCurrentInstance().getMessageList()) { | ||
80 | -// System.out.println("Sumary: " + fm.getSummary()); | ||
81 | -// System.out.println("Detail: " + fm.getDetail()); | ||
82 | -// | ||
83 | -// if(fm.getSummary().equals("DummyException!")) { | ||
84 | -// ((HttpServletResponse)response).setStatus(200); | ||
85 | -// }else { | ||
86 | -// ((HttpServletResponse)response).setStatus(200); | ||
87 | -// } | ||
88 | -// } | ||
89 | - | ||
90 | -// }catch(Exception e) { | ||
91 | -// ((HttpServletResponse)response).setStatus(200); | ||
92 | -// } | ||
93 | - } | ||
94 | - | ||
95 | - @Override | ||
96 | - public void destroy() { | ||
97 | - } | ||
98 | - | ||
99 | -} |
impl/extension/jsf/src/test/java/exception/handler/redirect/ExceptionWithCorrectRedirect.java
0 → 100644
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +package exception.handler.redirect; | ||
2 | + | ||
3 | +import br.gov.frameworkdemoiselle.annotation.Redirect; | ||
4 | +import br.gov.frameworkdemoiselle.exception.ApplicationException; | ||
5 | + | ||
6 | +@Redirect(viewId="/redirect.jsf") | ||
7 | +@ApplicationException | ||
8 | +public class ExceptionWithCorrectRedirect extends RuntimeException{ | ||
9 | + | ||
10 | + private static final long serialVersionUID = 1L; | ||
11 | + | ||
12 | + public ExceptionWithCorrectRedirect(String msg) { | ||
13 | + super(msg); | ||
14 | + } | ||
15 | +} |
impl/extension/jsf/src/test/java/exception/handler/redirect/ExceptionWithWrongRedirect.java
0 → 100644
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +package exception.handler.redirect; | ||
2 | + | ||
3 | +import br.gov.frameworkdemoiselle.annotation.Redirect; | ||
4 | +import br.gov.frameworkdemoiselle.exception.ApplicationException; | ||
5 | + | ||
6 | +@Redirect(viewId="/inexist.jsf") | ||
7 | +@ApplicationException | ||
8 | +public class ExceptionWithWrongRedirect extends RuntimeException{ | ||
9 | + | ||
10 | + private static final long serialVersionUID = 1L; | ||
11 | + | ||
12 | + public ExceptionWithWrongRedirect(String msg) { | ||
13 | + super(msg); | ||
14 | + } | ||
15 | +} |
impl/extension/jsf/src/test/java/exception/handler/redirect/RedirectBean.java
0 → 100644
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +package exception.handler.redirect; | ||
2 | + | ||
3 | +import br.gov.frameworkdemoiselle.stereotype.ViewController; | ||
4 | + | ||
5 | +@ViewController | ||
6 | +public class RedirectBean { | ||
7 | + | ||
8 | + private String redirectCorrectPage = "Correct Redirect Exception!"; | ||
9 | + | ||
10 | + private String redirectWrongPage = "Wrong Redirect Exception!"; | ||
11 | + | ||
12 | + public String getRedirectCorrectPage() { | ||
13 | + throw new ExceptionWithCorrectRedirect(redirectCorrectPage); | ||
14 | + } | ||
15 | + | ||
16 | + public String getRedirectWrongPage() { | ||
17 | + throw new ExceptionWithWrongRedirect(redirectWrongPage); | ||
18 | + } | ||
19 | + | ||
20 | +} |
impl/extension/jsf/src/test/java/exception/handler/redirect/RedirectExceptionTest.java
0 → 100644
@@ -0,0 +1,78 @@ | @@ -0,0 +1,78 @@ | ||
1 | +package exception.handler.redirect; | ||
2 | + | ||
3 | +import static org.junit.Assert.assertEquals; | ||
4 | +import static org.junit.Assert.assertFalse; | ||
5 | +import static org.junit.Assert.assertTrue; | ||
6 | + | ||
7 | +import java.io.IOException; | ||
8 | +import java.net.URL; | ||
9 | + | ||
10 | +import org.apache.commons.httpclient.HttpClient; | ||
11 | +import org.apache.commons.httpclient.HttpException; | ||
12 | +import org.apache.commons.httpclient.HttpStatus; | ||
13 | +import org.apache.commons.httpclient.methods.GetMethod; | ||
14 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
15 | +import org.jboss.arquillian.junit.Arquillian; | ||
16 | +import org.jboss.arquillian.test.api.ArquillianResource; | ||
17 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
18 | +import org.junit.Test; | ||
19 | +import org.junit.runner.RunWith; | ||
20 | + | ||
21 | +import test.Tests; | ||
22 | + | ||
23 | +@RunWith(Arquillian.class) | ||
24 | +public class RedirectExceptionTest { | ||
25 | + | ||
26 | + @ArquillianResource | ||
27 | + private URL deploymentUrl; | ||
28 | + | ||
29 | + private static final String PATH = "src/test/resources/exception-handler-redirect"; | ||
30 | + | ||
31 | + @Deployment(testable = false) | ||
32 | + public static WebArchive createDeployment() { | ||
33 | + return Tests.createDeployment().addClass(RedirectExceptionTest.class) | ||
34 | + .addClass(RedirectBean.class) | ||
35 | + .addClass(ExceptionWithCorrectRedirect.class) | ||
36 | + .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml") | ||
37 | + .addAsWebResource(Tests.createFileAsset(PATH + "/page.xhtml"), "page.xhtml") | ||
38 | + .addAsWebResource(Tests.createFileAsset(PATH + "/redirect.xhtml"), "redirect.xhtml") | ||
39 | + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); | ||
40 | + } | ||
41 | + | ||
42 | + @Test | ||
43 | + public void handleExceptionWithCorrectRedirect() { | ||
44 | + HttpClient client = new HttpClient(); | ||
45 | + GetMethod method = new GetMethod(deploymentUrl + "/index.jsf"); | ||
46 | + | ||
47 | + try { | ||
48 | + int status = client.executeMethod(method); | ||
49 | + String message = method.getResponseBodyAsString(); | ||
50 | + | ||
51 | + assertEquals(HttpStatus.SC_OK, status); | ||
52 | + assertFalse(message.contains("Correct Redirect Exception!")); | ||
53 | + assertTrue(message.contains("Page redirected!")); | ||
54 | + | ||
55 | + } catch (HttpException e) { | ||
56 | + e.printStackTrace(); | ||
57 | + } catch (IOException e) { | ||
58 | + e.printStackTrace(); | ||
59 | + } | ||
60 | + } | ||
61 | + | ||
62 | + @Test | ||
63 | + public void handleExceptionWithWrongRedirect() { | ||
64 | + HttpClient client = new HttpClient(); | ||
65 | + GetMethod method = new GetMethod(deploymentUrl + "/page.jsf"); | ||
66 | + | ||
67 | + try { | ||
68 | + int status = client.executeMethod(method); | ||
69 | + assertEquals(HttpStatus.SC_NOT_FOUND, status); | ||
70 | + | ||
71 | + } catch (HttpException e) { | ||
72 | + e.printStackTrace(); | ||
73 | + } catch (IOException e) { | ||
74 | + e.printStackTrace(); | ||
75 | + } | ||
76 | + } | ||
77 | +} | ||
78 | + |
impl/extension/jsf/src/test/java/xxxx/XTest.java
1 | package xxxx; | 1 | package xxxx; |
2 | 2 | ||
3 | +import org.junit.Ignore; | ||
4 | + | ||
3 | //import java.net.URL; | 5 | //import java.net.URL; |
4 | 6 | ||
5 | //import org.jboss.arquillian.container.test.api.Deployment; | 7 | //import org.jboss.arquillian.container.test.api.Deployment; |
@@ -15,6 +17,7 @@ package xxxx; | @@ -15,6 +17,7 @@ package xxxx; | ||
15 | //import com.thoughtworks.selenium.DefaultSelenium; | 17 | //import com.thoughtworks.selenium.DefaultSelenium; |
16 | 18 | ||
17 | //@RunWith(Arquillian.class) | 19 | //@RunWith(Arquillian.class) |
20 | +@Ignore | ||
18 | public class XTest { | 21 | public class XTest { |
19 | 22 | ||
20 | // private static final String PATH = "src/test/resources/xxx"; | 23 | // private static final String PATH = "src/test/resources/xxx"; |
impl/extension/jsf/src/test/resources/exception-handler-authentication/index.xhtml
0 → 100644
impl/extension/jsf/src/test/resources/exception-handler-authentication/login.xhtml
0 → 100644
impl/extension/jsf/src/test/resources/exception-handler-authentication/web.xml
0 → 100644
@@ -0,0 +1,61 @@ | @@ -0,0 +1,61 @@ | ||
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 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | ||
39 | + | ||
40 | + <listener> | ||
41 | + <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class> | ||
42 | + </listener> | ||
43 | + <filter> | ||
44 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
45 | + <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class> | ||
46 | + </filter> | ||
47 | + <filter-mapping> | ||
48 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
49 | + <url-pattern>/*</url-pattern> | ||
50 | + </filter-mapping> | ||
51 | + | ||
52 | + <servlet> | ||
53 | + <servlet-name>Faces Servlet</servlet-name> | ||
54 | + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | ||
55 | + <load-on-startup>1</load-on-startup> | ||
56 | + </servlet> | ||
57 | + <servlet-mapping> | ||
58 | + <servlet-name>Faces Servlet</servlet-name> | ||
59 | + <url-pattern>*.jsf</url-pattern> | ||
60 | + </servlet-mapping> | ||
61 | +</web-app> | ||
0 | \ No newline at end of file | 62 | \ No newline at end of file |
impl/extension/jsf/src/test/resources/exception-handler-authorization/index.xhtml
0 → 100644
impl/extension/jsf/src/test/resources/exception-handler-authorization/page.xhtml
0 → 100644
@@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
1 | +<html xmlns:h="http://java.sun.com/jsf/html" | ||
2 | + xmlns:ui="http://java.sun.com/jsf/facelets"> | ||
3 | + | ||
4 | + <h:body> | ||
5 | + #{authorizationBean.correctMessage} | ||
6 | + #{authorizationBean.exceptionMessage} | ||
7 | + <h:messages /> | ||
8 | + </h:body> | ||
9 | + | ||
10 | +</html> | ||
0 | \ No newline at end of file | 11 | \ No newline at end of file |
impl/extension/jsf/src/test/resources/exception-handler-authorization/pretty-config.xml
0 → 100644
@@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
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 | +<pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
38 | + xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.0 | ||
39 | + http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.0.xsd"> | ||
40 | + | ||
41 | + <rewrite match="^/*(.*)$" substitute="/$1" redirect="301" /> | ||
42 | + | ||
43 | + <url-mapping id="index"> | ||
44 | + <pattern value="/index" /> | ||
45 | + <view-id value="/index.jsf" /> | ||
46 | + <action>#{authorizationBean.loadExceptionMessage}</action> | ||
47 | + </url-mapping> | ||
48 | + | ||
49 | +</pretty-config> | ||
0 | \ No newline at end of file | 50 | \ No newline at end of file |
impl/extension/jsf/src/test/resources/exception-handler-authorization/web.xml
0 → 100644
@@ -0,0 +1,74 @@ | @@ -0,0 +1,74 @@ | ||
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 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | ||
39 | + | ||
40 | + <listener> | ||
41 | + <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class> | ||
42 | + </listener> | ||
43 | + <filter> | ||
44 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
45 | + <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class> | ||
46 | + </filter> | ||
47 | + <filter-mapping> | ||
48 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
49 | + <url-pattern>/*</url-pattern> | ||
50 | + </filter-mapping> | ||
51 | + | ||
52 | + <filter> | ||
53 | + <filter-name>Pretty Filter</filter-name> | ||
54 | + <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class> | ||
55 | + </filter> | ||
56 | + | ||
57 | + <filter-mapping> | ||
58 | + <filter-name>Pretty Filter</filter-name> | ||
59 | + <url-pattern>/*</url-pattern> | ||
60 | + <dispatcher>FORWARD</dispatcher> | ||
61 | + <dispatcher>REQUEST</dispatcher> | ||
62 | + <dispatcher>ERROR</dispatcher> | ||
63 | + </filter-mapping> | ||
64 | + | ||
65 | + <servlet> | ||
66 | + <servlet-name>Faces Servlet</servlet-name> | ||
67 | + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | ||
68 | + <load-on-startup>1</load-on-startup> | ||
69 | + </servlet> | ||
70 | + <servlet-mapping> | ||
71 | + <servlet-name>Faces Servlet</servlet-name> | ||
72 | + <url-pattern>*.jsf</url-pattern> | ||
73 | + </servlet-mapping> | ||
74 | +</web-app> | ||
0 | \ No newline at end of file | 75 | \ No newline at end of file |
impl/extension/jsf/src/test/resources/exception-handler-redirect/index.xhtml
0 → 100644
impl/extension/jsf/src/test/resources/exception-handler-redirect/page.xhtml
0 → 100644
impl/extension/jsf/src/test/resources/exception-handler-redirect/redirect.xhtml
0 → 100644
impl/extension/jsf/src/test/resources/exception-handler-redirect/web.xml
0 → 100644
@@ -0,0 +1,74 @@ | @@ -0,0 +1,74 @@ | ||
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 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | ||
39 | + | ||
40 | + <listener> | ||
41 | + <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class> | ||
42 | + </listener> | ||
43 | + <filter> | ||
44 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
45 | + <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class> | ||
46 | + </filter> | ||
47 | + <filter-mapping> | ||
48 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
49 | + <url-pattern>/*</url-pattern> | ||
50 | + </filter-mapping> | ||
51 | + | ||
52 | + <filter> | ||
53 | + <filter-name>Pretty Filter</filter-name> | ||
54 | + <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class> | ||
55 | + </filter> | ||
56 | + | ||
57 | + <filter-mapping> | ||
58 | + <filter-name>Pretty Filter</filter-name> | ||
59 | + <url-pattern>/*</url-pattern> | ||
60 | + <dispatcher>FORWARD</dispatcher> | ||
61 | + <dispatcher>REQUEST</dispatcher> | ||
62 | + <dispatcher>ERROR</dispatcher> | ||
63 | + </filter-mapping> | ||
64 | + | ||
65 | + <servlet> | ||
66 | + <servlet-name>Faces Servlet</servlet-name> | ||
67 | + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | ||
68 | + <load-on-startup>1</load-on-startup> | ||
69 | + </servlet> | ||
70 | + <servlet-mapping> | ||
71 | + <servlet-name>Faces Servlet</servlet-name> | ||
72 | + <url-pattern>*.jsf</url-pattern> | ||
73 | + </servlet-mapping> | ||
74 | +</web-app> | ||
0 | \ No newline at end of file | 75 | \ No newline at end of file |
impl/extension/jsf/src/test/resources/security-authentication/index.xhtml
impl/extension/jsf/src/test/resources/security-authentication/login.xhtml
impl/extension/jsf/src/test/resources/security-authentication/web.xml
@@ -1,61 +0,0 @@ | @@ -1,61 +0,0 @@ | ||
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 | -<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
38 | - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | ||
39 | - | ||
40 | - <listener> | ||
41 | - <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class> | ||
42 | - </listener> | ||
43 | - <filter> | ||
44 | - <filter-name>Demoiselle Servlet Filter</filter-name> | ||
45 | - <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class> | ||
46 | - </filter> | ||
47 | - <filter-mapping> | ||
48 | - <filter-name>Demoiselle Servlet Filter</filter-name> | ||
49 | - <url-pattern>/*</url-pattern> | ||
50 | - </filter-mapping> | ||
51 | - | ||
52 | - <servlet> | ||
53 | - <servlet-name>Faces Servlet</servlet-name> | ||
54 | - <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | ||
55 | - <load-on-startup>1</load-on-startup> | ||
56 | - </servlet> | ||
57 | - <servlet-mapping> | ||
58 | - <servlet-name>Faces Servlet</servlet-name> | ||
59 | - <url-pattern>*.jsf</url-pattern> | ||
60 | - </servlet-mapping> | ||
61 | -</web-app> | ||
62 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/extension/servlet/pom.xml
@@ -88,7 +88,7 @@ | @@ -88,7 +88,7 @@ | ||
88 | <dependency> | 88 | <dependency> |
89 | <groupId>org.apache.httpcomponents</groupId> | 89 | <groupId>org.apache.httpcomponents</groupId> |
90 | <artifactId>httpclient</artifactId> | 90 | <artifactId>httpclient</artifactId> |
91 | - <version>4.2.6</version> | 91 | + <version>4.3</version> |
92 | <scope>test</scope> | 92 | <scope>test</scope> |
93 | </dependency> | 93 | </dependency> |
94 | 94 |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/InternalProcessorFilterImpl.java
@@ -24,9 +24,9 @@ public class InternalProcessorFilterImpl implements InternalProcessorFilter { | @@ -24,9 +24,9 @@ public class InternalProcessorFilterImpl implements InternalProcessorFilter { | ||
24 | 24 | ||
25 | filters.add(new HttpServletRequestProducerFilter()); | 25 | filters.add(new HttpServletRequestProducerFilter()); |
26 | filters.add(new HttpServletResponseProducerFilter()); | 26 | filters.add(new HttpServletResponseProducerFilter()); |
27 | - | 27 | + |
28 | // TODO Analizar o uso do BasicAuthenticationFilter | 28 | // TODO Analizar o uso do BasicAuthenticationFilter |
29 | - // filters.add(new BasicAuthenticationFilter()); | 29 | + filters.add(new BasicAuthenticationFilter()); |
30 | } | 30 | } |
31 | 31 | ||
32 | @Override | 32 | @Override |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/security/ServletAuthenticator.java
@@ -65,11 +65,14 @@ public class ServletAuthenticator implements Authenticator { | @@ -65,11 +65,14 @@ public class ServletAuthenticator implements Authenticator { | ||
65 | @Override | 65 | @Override |
66 | public void authenticate() throws AuthenticationException { | 66 | public void authenticate() throws AuthenticationException { |
67 | try { | 67 | try { |
68 | - if (getRequest().getUserPrincipal() == null) { | ||
69 | - getRequest().login(getCredentials().getUsername(), getCredentials().getPassword()); | ||
70 | - } | 68 | + getRequest().login(getCredentials().getUsername(), getCredentials().getPassword()); |
69 | + | ||
71 | } catch (ServletException cause) { | 70 | } catch (ServletException cause) { |
72 | - throw new AuthenticationException(getBundle().getString("authentication-failed"), cause); | 71 | + if (cause.getMessage().contains("invalid")) { |
72 | + throw new InvalidCredentialsException(getBundle().getString("invalid-credentials")); | ||
73 | + } else { | ||
74 | + throw new AuthenticationException(getBundle().getString("authentication-failed"), cause); | ||
75 | + } | ||
73 | } | 76 | } |
74 | } | 77 | } |
75 | 78 |
impl/extension/servlet/src/main/resources/demoiselle-servlet-bundle.properties
@@ -34,4 +34,5 @@ | @@ -34,4 +34,5 @@ | ||
34 | # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | 34 | # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
35 | 35 | ||
36 | has-permission-not-supported=N\u00E3o \u00E9 poss\u00EDvel utilizar @{0}, pois esta funcionalidade n\u00E3o \u00E9 suportada pelo JAAS. | 36 | has-permission-not-supported=N\u00E3o \u00E9 poss\u00EDvel utilizar @{0}, pois esta funcionalidade n\u00E3o \u00E9 suportada pelo JAAS. |
37 | +invalid-credentials=Usu\u00E1rio ou senha inv\u00E1lidos. | ||
37 | authentication-failed=Falha no processo de autentica\u00E7\u00E3o. | 38 | authentication-failed=Falha no processo de autentica\u00E7\u00E3o. |
impl/extension/servlet/src/test/java/producer/request/HelperServlet.java
0 → 100644
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +package producer.request; | ||
2 | + | ||
3 | +import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR; | ||
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
5 | + | ||
6 | +import java.io.IOException; | ||
7 | + | ||
8 | +import javax.servlet.ServletException; | ||
9 | +import javax.servlet.http.HttpServlet; | ||
10 | +import javax.servlet.http.HttpServletRequest; | ||
11 | +import javax.servlet.http.HttpServletResponse; | ||
12 | + | ||
13 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
14 | + | ||
15 | +public class HelperServlet extends HttpServlet { | ||
16 | + | ||
17 | + private static final long serialVersionUID = 1L; | ||
18 | + | ||
19 | + @Override | ||
20 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
21 | + | ||
22 | + HttpServletRequest httpRequest = Beans.getReference(HttpServletRequest.class); | ||
23 | + | ||
24 | + if (httpRequest != null) { | ||
25 | + response.setStatus(SC_OK); | ||
26 | + } else { | ||
27 | + response.setStatus(SC_INTERNAL_SERVER_ERROR); | ||
28 | + } | ||
29 | + } | ||
30 | +} |
impl/extension/servlet/src/test/java/producer/request/HttpServletRequestProducerTest.java
1 | package producer.request; | 1 | package producer.request; |
2 | 2 | ||
3 | import static junit.framework.Assert.assertEquals; | 3 | import static junit.framework.Assert.assertEquals; |
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
4 | 5 | ||
5 | import java.io.IOException; | 6 | import java.io.IOException; |
6 | import java.net.URL; | 7 | import java.net.URL; |
7 | 8 | ||
8 | import org.apache.http.HttpResponse; | 9 | import org.apache.http.HttpResponse; |
9 | -import org.apache.http.HttpStatus; | ||
10 | import org.apache.http.client.ClientProtocolException; | 10 | import org.apache.http.client.ClientProtocolException; |
11 | import org.apache.http.client.methods.HttpGet; | 11 | import org.apache.http.client.methods.HttpGet; |
12 | -import org.apache.http.impl.client.DefaultHttpClient; | 12 | +import org.apache.http.impl.client.HttpClientBuilder; |
13 | import org.jboss.arquillian.container.test.api.Deployment; | 13 | import org.jboss.arquillian.container.test.api.Deployment; |
14 | import org.jboss.arquillian.junit.Arquillian; | 14 | import org.jboss.arquillian.junit.Arquillian; |
15 | import org.jboss.arquillian.test.api.ArquillianResource; | 15 | import org.jboss.arquillian.test.api.ArquillianResource; |
@@ -29,16 +29,16 @@ public class HttpServletRequestProducerTest { | @@ -29,16 +29,16 @@ public class HttpServletRequestProducerTest { | ||
29 | 29 | ||
30 | @Deployment(testable = false) | 30 | @Deployment(testable = false) |
31 | public static WebArchive createDeployment() { | 31 | public static WebArchive createDeployment() { |
32 | - return Tests.createDeployment().addClass(RequestServlet.class) | 32 | + return Tests.createDeployment().addClass(HelperServlet.class) |
33 | .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); | 33 | .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); |
34 | } | 34 | } |
35 | 35 | ||
36 | @Test | 36 | @Test |
37 | - public void createR() throws ClientProtocolException, IOException { | ||
38 | - HttpGet httpGet = new HttpGet(deploymentUrl + "/servlet"); | ||
39 | - HttpResponse httpResponse = new DefaultHttpClient().execute(httpGet); | 37 | + public void producedSuccessfully() throws ClientProtocolException, IOException { |
38 | + HttpGet httpGet = new HttpGet(deploymentUrl + "/helper"); | ||
39 | + HttpResponse httpResponse = HttpClientBuilder.create().build().execute(httpGet); | ||
40 | 40 | ||
41 | int status = httpResponse.getStatusLine().getStatusCode(); | 41 | int status = httpResponse.getStatusLine().getStatusCode(); |
42 | - assertEquals(HttpStatus.SC_OK, status); | 42 | + assertEquals(SC_OK, status); |
43 | } | 43 | } |
44 | } | 44 | } |
impl/extension/servlet/src/test/java/producer/request/RequestServlet.java
@@ -1,30 +0,0 @@ | @@ -1,30 +0,0 @@ | ||
1 | -package producer.request; | ||
2 | - | ||
3 | -import java.io.IOException; | ||
4 | - | ||
5 | -import javax.servlet.ServletException; | ||
6 | -import javax.servlet.http.HttpServlet; | ||
7 | -import javax.servlet.http.HttpServletRequest; | ||
8 | -import javax.servlet.http.HttpServletResponse; | ||
9 | - | ||
10 | -import org.apache.http.HttpStatus; | ||
11 | - | ||
12 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
13 | - | ||
14 | -public class RequestServlet extends HttpServlet { | ||
15 | - | ||
16 | - private static final long serialVersionUID = 1L; | ||
17 | - | ||
18 | - @Override | ||
19 | - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
20 | - | ||
21 | - HttpServletRequest httpRequest = Beans.getReference(HttpServletRequest.class); | ||
22 | - | ||
23 | - if (httpRequest != null) { | ||
24 | - response.setStatus(HttpStatus.SC_OK); | ||
25 | - } else { | ||
26 | - response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); | ||
27 | - } | ||
28 | - } | ||
29 | - | ||
30 | -} |
impl/extension/servlet/src/test/java/producer/response/HelperServlet.java
0 → 100644
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +package producer.response; | ||
2 | + | ||
3 | +import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR; | ||
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
5 | + | ||
6 | +import java.io.IOException; | ||
7 | + | ||
8 | +import javax.servlet.ServletException; | ||
9 | +import javax.servlet.http.HttpServlet; | ||
10 | +import javax.servlet.http.HttpServletRequest; | ||
11 | +import javax.servlet.http.HttpServletResponse; | ||
12 | + | ||
13 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
14 | + | ||
15 | +public class HelperServlet extends HttpServlet { | ||
16 | + | ||
17 | + private static final long serialVersionUID = 1L; | ||
18 | + | ||
19 | + @Override | ||
20 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
21 | + | ||
22 | + HttpServletResponse httpResponse = Beans.getReference(HttpServletResponse.class); | ||
23 | + | ||
24 | + if (httpResponse != null) { | ||
25 | + response.setStatus(SC_OK); | ||
26 | + } else { | ||
27 | + response.setStatus(SC_INTERNAL_SERVER_ERROR); | ||
28 | + } | ||
29 | + } | ||
30 | +} |
impl/extension/servlet/src/test/java/producer/response/HttpServletResponseProducerTest.java
1 | package producer.response; | 1 | package producer.response; |
2 | 2 | ||
3 | import static junit.framework.Assert.assertEquals; | 3 | import static junit.framework.Assert.assertEquals; |
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
4 | 5 | ||
5 | import java.io.IOException; | 6 | import java.io.IOException; |
6 | import java.net.URL; | 7 | import java.net.URL; |
7 | 8 | ||
8 | import org.apache.http.HttpResponse; | 9 | import org.apache.http.HttpResponse; |
9 | -import org.apache.http.HttpStatus; | ||
10 | import org.apache.http.client.ClientProtocolException; | 10 | import org.apache.http.client.ClientProtocolException; |
11 | import org.apache.http.client.methods.HttpGet; | 11 | import org.apache.http.client.methods.HttpGet; |
12 | -import org.apache.http.impl.client.DefaultHttpClient; | 12 | +import org.apache.http.impl.client.HttpClientBuilder; |
13 | import org.jboss.arquillian.container.test.api.Deployment; | 13 | import org.jboss.arquillian.container.test.api.Deployment; |
14 | import org.jboss.arquillian.junit.Arquillian; | 14 | import org.jboss.arquillian.junit.Arquillian; |
15 | import org.jboss.arquillian.test.api.ArquillianResource; | 15 | import org.jboss.arquillian.test.api.ArquillianResource; |
@@ -17,7 +17,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; | @@ -17,7 +17,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
17 | import org.junit.Test; | 17 | import org.junit.Test; |
18 | import org.junit.runner.RunWith; | 18 | import org.junit.runner.RunWith; |
19 | 19 | ||
20 | -import producer.request.RequestServlet; | 20 | +import producer.request.HelperServlet; |
21 | import test.Tests; | 21 | import test.Tests; |
22 | 22 | ||
23 | @RunWith(Arquillian.class) | 23 | @RunWith(Arquillian.class) |
@@ -30,17 +30,16 @@ public class HttpServletResponseProducerTest { | @@ -30,17 +30,16 @@ public class HttpServletResponseProducerTest { | ||
30 | 30 | ||
31 | @Deployment(testable = false) | 31 | @Deployment(testable = false) |
32 | public static WebArchive createDeployment() { | 32 | public static WebArchive createDeployment() { |
33 | - return Tests.createDeployment().addClass(RequestServlet.class) | 33 | + return Tests.createDeployment().addClass(HelperServlet.class) |
34 | .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); | 34 | .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); |
35 | } | 35 | } |
36 | 36 | ||
37 | @Test | 37 | @Test |
38 | - public void createResponse() throws ClientProtocolException, IOException { | ||
39 | - HttpGet httpGet = new HttpGet(deploymentUrl + "/servlet"); | ||
40 | - HttpResponse httpResponse = new DefaultHttpClient().execute(httpGet); | 38 | + public void producedSuccessfully() throws ClientProtocolException, IOException { |
39 | + HttpGet httpGet = new HttpGet(deploymentUrl + "/helper"); | ||
40 | + HttpResponse httpResponse = HttpClientBuilder.create().build().execute(httpGet); | ||
41 | 41 | ||
42 | int status = httpResponse.getStatusLine().getStatusCode(); | 42 | int status = httpResponse.getStatusLine().getStatusCode(); |
43 | - assertEquals(HttpStatus.SC_OK, status); | 43 | + assertEquals(SC_OK, status); |
44 | } | 44 | } |
45 | - | ||
46 | } | 45 | } |
impl/extension/servlet/src/test/java/producer/response/ResponseServlet.java
@@ -1,30 +0,0 @@ | @@ -1,30 +0,0 @@ | ||
1 | -package producer.response; | ||
2 | - | ||
3 | -import java.io.IOException; | ||
4 | - | ||
5 | -import javax.servlet.ServletException; | ||
6 | -import javax.servlet.http.HttpServlet; | ||
7 | -import javax.servlet.http.HttpServletRequest; | ||
8 | -import javax.servlet.http.HttpServletResponse; | ||
9 | - | ||
10 | -import org.apache.http.HttpStatus; | ||
11 | - | ||
12 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
13 | - | ||
14 | -public class ResponseServlet extends HttpServlet { | ||
15 | - | ||
16 | - private static final long serialVersionUID = 1L; | ||
17 | - | ||
18 | - @Override | ||
19 | - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
20 | - | ||
21 | - HttpServletResponse httpResponse = Beans.getReference(HttpServletResponse.class); | ||
22 | - | ||
23 | - if (httpResponse != null) { | ||
24 | - response.setStatus(HttpStatus.SC_OK); | ||
25 | - } else { | ||
26 | - response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); | ||
27 | - } | ||
28 | - } | ||
29 | - | ||
30 | -} |
impl/extension/servlet/src/test/java/security/SecurityServlet.java
@@ -1,42 +0,0 @@ | @@ -1,42 +0,0 @@ | ||
1 | -package security; | ||
2 | - | ||
3 | -import java.io.IOException; | ||
4 | - | ||
5 | -import javax.servlet.ServletException; | ||
6 | -import javax.servlet.annotation.WebServlet; | ||
7 | -import javax.servlet.http.HttpServlet; | ||
8 | -import javax.servlet.http.HttpServletRequest; | ||
9 | -import javax.servlet.http.HttpServletResponse; | ||
10 | - | ||
11 | -import org.apache.http.HttpStatus; | ||
12 | - | ||
13 | -import br.gov.frameworkdemoiselle.security.AuthenticationException; | ||
14 | -import br.gov.frameworkdemoiselle.security.Credentials; | ||
15 | -import br.gov.frameworkdemoiselle.security.SecurityContext; | ||
16 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
17 | - | ||
18 | -@WebServlet("/login") | ||
19 | -public class SecurityServlet extends HttpServlet { | ||
20 | - | ||
21 | - private static final long serialVersionUID = 1L; | ||
22 | - | ||
23 | - @Override | ||
24 | - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
25 | - String result = request.getHeader("Authorization"); | ||
26 | - result = (result == null ? request.getHeader("authorization") : result); | ||
27 | - | ||
28 | - Credentials credentials = Beans.getReference(Credentials.class); | ||
29 | - credentials.setUsername(request.getParameter("username")); | ||
30 | - credentials.setPassword(request.getParameter("password")); | ||
31 | - | ||
32 | - try { | ||
33 | - Beans.getReference(SecurityContext.class).login(); | ||
34 | - response.setStatus(HttpStatus.SC_OK); | ||
35 | - } catch (AuthenticationException e) { | ||
36 | - response.setStatus(HttpStatus.SC_UNAUTHORIZED); | ||
37 | - } | ||
38 | - | ||
39 | - | ||
40 | - | ||
41 | - } | ||
42 | -} |
impl/extension/servlet/src/test/java/security/SecurityTest.java
@@ -1,62 +0,0 @@ | @@ -1,62 +0,0 @@ | ||
1 | -package security; | ||
2 | - | ||
3 | -import static org.junit.Assert.assertEquals; | ||
4 | - | ||
5 | -import java.io.IOException; | ||
6 | -import java.net.URISyntaxException; | ||
7 | -import java.net.URL; | ||
8 | - | ||
9 | -import org.apache.http.HttpResponse; | ||
10 | -import org.apache.http.HttpStatus; | ||
11 | -import org.apache.http.client.ClientProtocolException; | ||
12 | -import org.apache.http.client.methods.HttpGet; | ||
13 | -import org.apache.http.client.utils.URIBuilder; | ||
14 | -import org.apache.http.impl.client.DefaultHttpClient; | ||
15 | -import org.jboss.arquillian.container.test.api.Deployment; | ||
16 | -import org.jboss.arquillian.junit.Arquillian; | ||
17 | -import org.jboss.arquillian.test.api.ArquillianResource; | ||
18 | -import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
19 | -import org.junit.Test; | ||
20 | -import org.junit.runner.RunWith; | ||
21 | - | ||
22 | -import test.Tests; | ||
23 | - | ||
24 | -import com.sun.enterprise.security.auth.login.FileLoginModule; | ||
25 | - | ||
26 | -@RunWith(Arquillian.class) | ||
27 | -public class SecurityTest { | ||
28 | - | ||
29 | - private static final String PATH = "src/test/resources/security"; | ||
30 | - | ||
31 | - @ArquillianResource | ||
32 | - private URL deploymentUrl; | ||
33 | - | ||
34 | - @Deployment(testable = false) | ||
35 | - public static WebArchive createDeployment() { | ||
36 | - return Tests.createDeployment().addClasses(SecurityServlet.class, FileLoginModule.class) | ||
37 | - .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); | ||
38 | - } | ||
39 | - | ||
40 | - @Test | ||
41 | - public void loginSucessfull() throws ClientProtocolException, IOException, URISyntaxException { | ||
42 | - URIBuilder uriBuilder = new URIBuilder(deploymentUrl + "/login"); | ||
43 | - uriBuilder.setParameter("username", "demoiselle"); | ||
44 | - uriBuilder.setParameter("password", "changeit"); | ||
45 | - | ||
46 | - HttpGet httpGet = new HttpGet(uriBuilder.build()); | ||
47 | - HttpResponse httpResponse = new DefaultHttpClient().execute(httpGet); | ||
48 | - | ||
49 | - int status = httpResponse.getStatusLine().getStatusCode(); | ||
50 | - assertEquals(HttpStatus.SC_OK, status); | ||
51 | - } | ||
52 | - | ||
53 | - @Test | ||
54 | - public void loginFailed() throws ClientProtocolException, IOException { | ||
55 | - DefaultHttpClient client = new DefaultHttpClient(); | ||
56 | - HttpGet get = new HttpGet(deploymentUrl + "/login?username=demoiselle&password=wrongpass"); | ||
57 | - HttpResponse response = client.execute(get); | ||
58 | - | ||
59 | - int status = response.getStatusLine().getStatusCode(); | ||
60 | - assertEquals(HttpStatus.SC_UNAUTHORIZED, status); | ||
61 | - } | ||
62 | -} |
impl/extension/servlet/src/test/java/security/authentication/basic/BasicAuthenticationFilterTest.java
1 | package security.authentication.basic; | 1 | package security.authentication.basic; |
2 | 2 | ||
3 | +import static org.apache.http.HttpStatus.SC_FORBIDDEN; | ||
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
5 | +import static org.junit.Assert.assertEquals; | ||
6 | + | ||
7 | +import java.io.IOException; | ||
3 | import java.net.URL; | 8 | import java.net.URL; |
4 | 9 | ||
10 | +import org.apache.commons.codec.binary.Base64; | ||
11 | +import org.apache.http.HttpResponse; | ||
12 | +import org.apache.http.client.ClientProtocolException; | ||
13 | +import org.apache.http.client.methods.HttpGet; | ||
14 | +import org.apache.http.impl.client.HttpClientBuilder; | ||
5 | import org.jboss.arquillian.container.test.api.Deployment; | 15 | import org.jboss.arquillian.container.test.api.Deployment; |
6 | import org.jboss.arquillian.junit.Arquillian; | 16 | import org.jboss.arquillian.junit.Arquillian; |
7 | import org.jboss.arquillian.test.api.ArquillianResource; | 17 | import org.jboss.arquillian.test.api.ArquillianResource; |
@@ -26,10 +36,32 @@ public class BasicAuthenticationFilterTest { | @@ -26,10 +36,32 @@ public class BasicAuthenticationFilterTest { | ||
26 | } | 36 | } |
27 | 37 | ||
28 | @Test | 38 | @Test |
29 | - public void loginSucessfull() { | 39 | + public void loginSucessfull() throws ClientProtocolException, IOException { |
40 | + String username = "demoiselle"; | ||
41 | + String password = "changeit"; | ||
42 | + | ||
43 | + HttpGet httpGet = new HttpGet(deploymentUrl + "/helper"); | ||
44 | + byte[] encoded = Base64.encodeBase64((username + ":" + password).getBytes()); | ||
45 | + httpGet.setHeader("Authorization", "Basic " + new String(encoded)); | ||
46 | + | ||
47 | + HttpResponse httpResponse = HttpClientBuilder.create().build().execute(httpGet); | ||
48 | + | ||
49 | + int status = httpResponse.getStatusLine().getStatusCode(); | ||
50 | + assertEquals(SC_OK, status); | ||
30 | } | 51 | } |
31 | 52 | ||
32 | @Test | 53 | @Test |
33 | - public void loginfailed() { | 54 | + public void loginFailed() throws ClientProtocolException, IOException { |
55 | + String username = "invalid"; | ||
56 | + String password = "invalid"; | ||
57 | + | ||
58 | + HttpGet httpGet = new HttpGet(deploymentUrl + "/helper"); | ||
59 | + byte[] encoded = Base64.encodeBase64((username + ":" + password).getBytes()); | ||
60 | + httpGet.setHeader("Authorization", "Basic " + new String(encoded)); | ||
61 | + | ||
62 | + HttpResponse httpResponse = HttpClientBuilder.create().build().execute(httpGet); | ||
63 | + | ||
64 | + int status = httpResponse.getStatusLine().getStatusCode(); | ||
65 | + assertEquals(SC_FORBIDDEN, status); | ||
34 | } | 66 | } |
35 | } | 67 | } |
impl/extension/servlet/src/test/java/security/authentication/basic/HelperServlet.java
0 → 100644
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +package security.authentication.basic; | ||
2 | + | ||
3 | +import static org.apache.http.HttpStatus.SC_FORBIDDEN; | ||
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
5 | + | ||
6 | +import java.io.IOException; | ||
7 | + | ||
8 | +import javax.servlet.ServletException; | ||
9 | +import javax.servlet.http.HttpServlet; | ||
10 | +import javax.servlet.http.HttpServletRequest; | ||
11 | +import javax.servlet.http.HttpServletResponse; | ||
12 | + | ||
13 | +import br.gov.frameworkdemoiselle.security.SecurityContext; | ||
14 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
15 | + | ||
16 | +public class HelperServlet extends HttpServlet { | ||
17 | + | ||
18 | + private static final long serialVersionUID = 1L; | ||
19 | + | ||
20 | + @Override | ||
21 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
22 | + boolean loggedIn = Beans.getReference(SecurityContext.class).isLoggedIn(); | ||
23 | + | ||
24 | + if (loggedIn) { | ||
25 | + response.setStatus(SC_OK); | ||
26 | + } else { | ||
27 | + response.setStatus(SC_FORBIDDEN); | ||
28 | + } | ||
29 | + } | ||
30 | +} |
impl/extension/servlet/src/test/java/security/authentication/form/HelperServlet.java
0 → 100644
@@ -0,0 +1,69 @@ | @@ -0,0 +1,69 @@ | ||
1 | +package security.authentication.form; | ||
2 | + | ||
3 | +import static org.apache.http.HttpStatus.SC_EXPECTATION_FAILED; | ||
4 | +import static org.apache.http.HttpStatus.SC_FORBIDDEN; | ||
5 | +import static org.apache.http.HttpStatus.SC_OK; | ||
6 | + | ||
7 | +import java.io.IOException; | ||
8 | + | ||
9 | +import javax.servlet.ServletException; | ||
10 | +import javax.servlet.http.HttpServlet; | ||
11 | +import javax.servlet.http.HttpServletRequest; | ||
12 | +import javax.servlet.http.HttpServletResponse; | ||
13 | + | ||
14 | +import br.gov.frameworkdemoiselle.security.Credentials; | ||
15 | +import br.gov.frameworkdemoiselle.security.InvalidCredentialsException; | ||
16 | +import br.gov.frameworkdemoiselle.security.SecurityContext; | ||
17 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
18 | + | ||
19 | +public class HelperServlet extends HttpServlet { | ||
20 | + | ||
21 | + private static final long serialVersionUID = 1L; | ||
22 | + | ||
23 | + @Override | ||
24 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
25 | + if (request.getRequestURI().endsWith("/login")) { | ||
26 | + login(request, response); | ||
27 | + } else { | ||
28 | + logout(request, response); | ||
29 | + } | ||
30 | + } | ||
31 | + | ||
32 | + private void login(HttpServletRequest request, HttpServletResponse response) { | ||
33 | + loadCredentials(request); | ||
34 | + SecurityContext securityContext = Beans.getReference(SecurityContext.class); | ||
35 | + | ||
36 | + try { | ||
37 | + securityContext.login(); | ||
38 | + | ||
39 | + if (securityContext.isLoggedIn()) { | ||
40 | + response.setStatus(SC_OK); | ||
41 | + } else { | ||
42 | + response.setStatus(SC_FORBIDDEN); | ||
43 | + } | ||
44 | + | ||
45 | + } catch (InvalidCredentialsException e) { | ||
46 | + response.setStatus(SC_FORBIDDEN); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + private void logout(HttpServletRequest request, HttpServletResponse response) { | ||
51 | + loadCredentials(request); | ||
52 | + SecurityContext securityContext = Beans.getReference(SecurityContext.class); | ||
53 | + | ||
54 | + securityContext.login(); | ||
55 | + securityContext.logout(); | ||
56 | + | ||
57 | + if (!securityContext.isLoggedIn()) { | ||
58 | + response.setStatus(SC_OK); | ||
59 | + } else { | ||
60 | + response.setStatus(SC_EXPECTATION_FAILED); | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
64 | + private void loadCredentials(HttpServletRequest request) { | ||
65 | + Credentials credentials = Beans.getReference(Credentials.class); | ||
66 | + credentials.setUsername(request.getParameter("username")); | ||
67 | + credentials.setPassword(request.getParameter("password")); | ||
68 | + } | ||
69 | +} |
impl/extension/servlet/src/test/java/security/authentication/form/ServletAuthenticatorTest.java
0 → 100644
@@ -0,0 +1,84 @@ | @@ -0,0 +1,84 @@ | ||
1 | +package security.authentication.form; | ||
2 | + | ||
3 | +import static org.apache.http.HttpStatus.SC_FORBIDDEN; | ||
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
5 | +import static org.junit.Assert.assertEquals; | ||
6 | + | ||
7 | +import java.io.IOException; | ||
8 | +import java.net.URISyntaxException; | ||
9 | +import java.net.URL; | ||
10 | + | ||
11 | +import org.apache.http.HttpResponse; | ||
12 | +import org.apache.http.client.ClientProtocolException; | ||
13 | +import org.apache.http.client.methods.HttpGet; | ||
14 | +import org.apache.http.client.utils.URIBuilder; | ||
15 | +import org.apache.http.impl.client.HttpClientBuilder; | ||
16 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
17 | +import org.jboss.arquillian.junit.Arquillian; | ||
18 | +import org.jboss.arquillian.test.api.ArquillianResource; | ||
19 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
20 | +import org.junit.Test; | ||
21 | +import org.junit.runner.RunWith; | ||
22 | + | ||
23 | +import test.Tests; | ||
24 | + | ||
25 | +import com.sun.enterprise.security.auth.login.FileLoginModule; | ||
26 | + | ||
27 | +@RunWith(Arquillian.class) | ||
28 | +public class ServletAuthenticatorTest { | ||
29 | + | ||
30 | + private static final String PATH = "src/test/resources/security/authentication/form"; | ||
31 | + | ||
32 | + @ArquillianResource | ||
33 | + private URL deploymentUrl; | ||
34 | + | ||
35 | + @Deployment(testable = false) | ||
36 | + public static WebArchive createDeployment() { | ||
37 | + return Tests.createDeployment().addClasses(HelperServlet.class, FileLoginModule.class) | ||
38 | + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); | ||
39 | + } | ||
40 | + | ||
41 | + @Test | ||
42 | + public void loginSucessfull() throws ClientProtocolException, IOException, URISyntaxException { | ||
43 | + URIBuilder uriBuilder = new URIBuilder(deploymentUrl + "/helper/login"); | ||
44 | + uriBuilder.setParameter("username", "demoiselle"); | ||
45 | + uriBuilder.setParameter("password", "changeit"); | ||
46 | + | ||
47 | + HttpGet httpGet = new HttpGet(uriBuilder.build()); | ||
48 | + HttpResponse httpResponse = HttpClientBuilder.create().build().execute(httpGet); | ||
49 | + | ||
50 | + int status = httpResponse.getStatusLine().getStatusCode(); | ||
51 | + assertEquals(SC_OK, status); | ||
52 | + } | ||
53 | + | ||
54 | + @Test | ||
55 | + public void loginFailed() throws ClientProtocolException, IOException, URISyntaxException { | ||
56 | + URIBuilder uriBuilder = new URIBuilder(deploymentUrl + "/helper/login"); | ||
57 | + uriBuilder.setParameter("username", "invalid"); | ||
58 | + uriBuilder.setParameter("password", "invalid"); | ||
59 | + | ||
60 | + HttpGet get = new HttpGet(uriBuilder.build()); | ||
61 | + HttpResponse response = HttpClientBuilder.create().build().execute(get); | ||
62 | + | ||
63 | + int status = response.getStatusLine().getStatusCode(); | ||
64 | + assertEquals(SC_FORBIDDEN, status); | ||
65 | + } | ||
66 | + | ||
67 | + @Test | ||
68 | + public void logoutSucessfull() throws ClientProtocolException, IOException, URISyntaxException { | ||
69 | + URIBuilder uriBuilder = new URIBuilder(deploymentUrl + "/helper/logout"); | ||
70 | + uriBuilder.setParameter("username", "demoiselle"); | ||
71 | + uriBuilder.setParameter("password", "changeit"); | ||
72 | + | ||
73 | + HttpGet httpGet = new HttpGet(uriBuilder.build()); | ||
74 | + HttpResponse httpResponse = HttpClientBuilder.create().build().execute(httpGet); | ||
75 | + | ||
76 | + int status = httpResponse.getStatusLine().getStatusCode(); | ||
77 | + assertEquals(SC_OK, status); | ||
78 | + } | ||
79 | + | ||
80 | + @Test | ||
81 | + public void logoutFailed() throws ClientProtocolException, IOException, URISyntaxException { | ||
82 | + URIBuilder uriBuilder = new URIBuilder(deploymentUrl + "/helper/logout"); | ||
83 | + } | ||
84 | +} |
impl/extension/servlet/src/test/java/security/unauthentication/form/HelperServletUnauthenticationFail.java
0 → 100644
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +package security.unauthentication.form; | ||
2 | + | ||
3 | +import static org.apache.http.HttpStatus.SC_FORBIDDEN; | ||
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
5 | + | ||
6 | +import java.io.IOException; | ||
7 | + | ||
8 | +import javax.servlet.ServletException; | ||
9 | +import javax.servlet.http.HttpServlet; | ||
10 | +import javax.servlet.http.HttpServletRequest; | ||
11 | +import javax.servlet.http.HttpServletResponse; | ||
12 | + | ||
13 | +import br.gov.frameworkdemoiselle.security.AuthenticationException; | ||
14 | +import br.gov.frameworkdemoiselle.security.Credentials; | ||
15 | +import br.gov.frameworkdemoiselle.security.SecurityContext; | ||
16 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
17 | + | ||
18 | +public class HelperServletUnauthenticationFail extends HttpServlet { | ||
19 | + | ||
20 | + private static final long serialVersionUID = 1L; | ||
21 | + | ||
22 | + @Override | ||
23 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
24 | + String result = request.getHeader("Authorization"); | ||
25 | + result = (result == null ? request.getHeader("authorization") : result); | ||
26 | + | ||
27 | + Credentials credentials = Beans.getReference(Credentials.class); | ||
28 | + credentials.setUsername(request.getParameter("username")); | ||
29 | + credentials.setPassword(request.getParameter("password")); | ||
30 | + try { | ||
31 | + Beans.getReference(SecurityContext.class).logout(); | ||
32 | + response.setStatus(SC_OK); | ||
33 | + } catch (AuthenticationException e) { | ||
34 | + response.setStatus(SC_FORBIDDEN); | ||
35 | + } | ||
36 | + } | ||
37 | +} |
impl/extension/servlet/src/test/java/security/unauthentication/form/HelperServletUnauthenticationSuccess.java
0 → 100644
@@ -0,0 +1,38 @@ | @@ -0,0 +1,38 @@ | ||
1 | +package security.unauthentication.form; | ||
2 | + | ||
3 | +import static org.apache.http.HttpStatus.SC_FORBIDDEN; | ||
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
5 | + | ||
6 | +import java.io.IOException; | ||
7 | + | ||
8 | +import javax.servlet.ServletException; | ||
9 | +import javax.servlet.http.HttpServlet; | ||
10 | +import javax.servlet.http.HttpServletRequest; | ||
11 | +import javax.servlet.http.HttpServletResponse; | ||
12 | + | ||
13 | +import br.gov.frameworkdemoiselle.security.AuthenticationException; | ||
14 | +import br.gov.frameworkdemoiselle.security.Credentials; | ||
15 | +import br.gov.frameworkdemoiselle.security.SecurityContext; | ||
16 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
17 | + | ||
18 | +public class HelperServletUnauthenticationSuccess extends HttpServlet { | ||
19 | + | ||
20 | + private static final long serialVersionUID = 1L; | ||
21 | + | ||
22 | + @Override | ||
23 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
24 | + String result = request.getHeader("Authorization"); | ||
25 | + result = (result == null ? request.getHeader("authorization") : result); | ||
26 | + | ||
27 | + Credentials credentials = Beans.getReference(Credentials.class); | ||
28 | + credentials.setUsername(request.getParameter("username")); | ||
29 | + credentials.setPassword(request.getParameter("password")); | ||
30 | + try { | ||
31 | + Beans.getReference(SecurityContext.class).login(); | ||
32 | + Beans.getReference(SecurityContext.class).logout(); | ||
33 | + response.setStatus(SC_OK); | ||
34 | + } catch (AuthenticationException e) { | ||
35 | + response.setStatus(SC_FORBIDDEN); | ||
36 | + } | ||
37 | + } | ||
38 | +} |
impl/extension/servlet/src/test/java/security/unauthentication/form/ServletAuthenticatorTest.java
0 → 100644
@@ -0,0 +1,68 @@ | @@ -0,0 +1,68 @@ | ||
1 | +package security.unauthentication.form; | ||
2 | + | ||
3 | +import static org.apache.http.HttpStatus.SC_FORBIDDEN; | ||
4 | +import static org.apache.http.HttpStatus.SC_OK; | ||
5 | +import static org.junit.Assert.assertEquals; | ||
6 | + | ||
7 | +import java.io.IOException; | ||
8 | +import java.net.URISyntaxException; | ||
9 | +import java.net.URL; | ||
10 | + | ||
11 | +import org.apache.http.HttpResponse; | ||
12 | +import org.apache.http.client.ClientProtocolException; | ||
13 | +import org.apache.http.client.methods.HttpGet; | ||
14 | +import org.apache.http.client.utils.URIBuilder; | ||
15 | +import org.apache.http.impl.client.HttpClientBuilder; | ||
16 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
17 | +import org.jboss.arquillian.junit.Arquillian; | ||
18 | +import org.jboss.arquillian.test.api.ArquillianResource; | ||
19 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
20 | +import org.junit.Test; | ||
21 | +import org.junit.runner.RunWith; | ||
22 | + | ||
23 | +import test.Tests; | ||
24 | + | ||
25 | +import com.sun.enterprise.security.auth.login.FileLoginModule; | ||
26 | + | ||
27 | +@RunWith(Arquillian.class) | ||
28 | +public class ServletAuthenticatorTest { | ||
29 | + | ||
30 | + private static final String PATH = "src/test/resources/security/unauthentication/form"; | ||
31 | + | ||
32 | + @ArquillianResource | ||
33 | + private URL deploymentUrl; | ||
34 | + | ||
35 | + @Deployment(testable = false) | ||
36 | + public static WebArchive createDeployment() { | ||
37 | + return Tests.createDeployment().addClasses(HelperServletUnauthenticationSuccess.class, FileLoginModule.class) | ||
38 | + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); | ||
39 | + } | ||
40 | + | ||
41 | + @Test | ||
42 | + public void logoutSucessfull() throws ClientProtocolException, IOException, URISyntaxException { | ||
43 | + URIBuilder uriBuilder = new URIBuilder(deploymentUrl + "/helperauthsuccess"); | ||
44 | + uriBuilder.setParameter("username", "demoiselle"); | ||
45 | + uriBuilder.setParameter("password", "changeit"); | ||
46 | + | ||
47 | + HttpGet httpGet = new HttpGet(uriBuilder.build()); | ||
48 | + HttpResponse httpResponse = HttpClientBuilder.create().build().execute(httpGet); | ||
49 | + | ||
50 | + int status = httpResponse.getStatusLine().getStatusCode(); | ||
51 | + assertEquals(SC_OK, status); | ||
52 | + } | ||
53 | + | ||
54 | + @Test | ||
55 | + public void logoutFailed() throws ClientProtocolException, IOException, URISyntaxException { | ||
56 | + URIBuilder uriBuilder = new URIBuilder(deploymentUrl + "/helperauthfail"); | ||
57 | + uriBuilder.setParameter("username", "demoiselle"); | ||
58 | + uriBuilder.setParameter("password", "changeit"); | ||
59 | + | ||
60 | + HttpGet get = new HttpGet(uriBuilder.build()); | ||
61 | + HttpResponse response = HttpClientBuilder.create().build().execute(get); | ||
62 | + | ||
63 | + int status = response.getStatusLine().getStatusCode(); | ||
64 | + assertEquals(SC_FORBIDDEN, status); | ||
65 | + } | ||
66 | + | ||
67 | + | ||
68 | +} |
impl/extension/servlet/src/test/resources/producer/request/web.xml
@@ -51,12 +51,12 @@ | @@ -51,12 +51,12 @@ | ||
51 | </filter-mapping> | 51 | </filter-mapping> |
52 | 52 | ||
53 | <servlet> | 53 | <servlet> |
54 | - <servlet-name>Request Class</servlet-name> | ||
55 | - <servlet-class>producer.request.RequestServlet</servlet-class> | 54 | + <servlet-name>Helper Servlet</servlet-name> |
55 | + <servlet-class>producer.request.HelperServlet</servlet-class> | ||
56 | </servlet> | 56 | </servlet> |
57 | 57 | ||
58 | <servlet-mapping> | 58 | <servlet-mapping> |
59 | - <servlet-name>Request Class</servlet-name> | ||
60 | - <url-pattern>/servlet</url-pattern> | 59 | + <servlet-name>Helper Servlet</servlet-name> |
60 | + <url-pattern>/helper</url-pattern> | ||
61 | </servlet-mapping> | 61 | </servlet-mapping> |
62 | </web-app> | 62 | </web-app> |
63 | \ No newline at end of file | 63 | \ No newline at end of file |
impl/extension/servlet/src/test/resources/producer/response/web.xml
@@ -51,12 +51,12 @@ | @@ -51,12 +51,12 @@ | ||
51 | </filter-mapping> | 51 | </filter-mapping> |
52 | 52 | ||
53 | <servlet> | 53 | <servlet> |
54 | - <servlet-name>Response Servlet</servlet-name> | ||
55 | - <servlet-class>producer.response.ResponseServlet</servlet-class> | 54 | + <servlet-name>Helper Servlet</servlet-name> |
55 | + <servlet-class>producer.response.HelperServlet</servlet-class> | ||
56 | </servlet> | 56 | </servlet> |
57 | 57 | ||
58 | <servlet-mapping> | 58 | <servlet-mapping> |
59 | - <servlet-name>Response Servlet</servlet-name> | ||
60 | - <url-pattern>/servlet</url-pattern> | 59 | + <servlet-name>Helper Servlet</servlet-name> |
60 | + <url-pattern>/helper</url-pattern> | ||
61 | </servlet-mapping> | 61 | </servlet-mapping> |
62 | </web-app> | 62 | </web-app> |
63 | \ No newline at end of file | 63 | \ No newline at end of file |
impl/extension/servlet/src/test/resources/security/authentication/basic/web.xml
@@ -51,32 +51,11 @@ | @@ -51,32 +51,11 @@ | ||
51 | </filter-mapping> | 51 | </filter-mapping> |
52 | 52 | ||
53 | <servlet> | 53 | <servlet> |
54 | - <servlet-name>Security Class</servlet-name> | ||
55 | - <servlet-class>security.SecurityServlet</servlet-class> | 54 | + <servlet-name>Helper Servlet</servlet-name> |
55 | + <servlet-class>security.authentication.basic.HelperServlet</servlet-class> | ||
56 | </servlet> | 56 | </servlet> |
57 | <servlet-mapping> | 57 | <servlet-mapping> |
58 | - <servlet-name>Security Class</servlet-name> | ||
59 | - <url-pattern>/login</url-pattern> | 58 | + <servlet-name>Helper Servlet</servlet-name> |
59 | + <url-pattern>/helper</url-pattern> | ||
60 | </servlet-mapping> | 60 | </servlet-mapping> |
61 | - | ||
62 | - <!-- | ||
63 | - <security-constraint> | ||
64 | - <web-resource-collection> | ||
65 | - <web-resource-name>Private URL</web-resource-name> | ||
66 | - <url-pattern>/login</url-pattern> | ||
67 | - </web-resource-collection> | ||
68 | - <auth-constraint> | ||
69 | - <role-name>*</role-name> | ||
70 | - </auth-constraint> | ||
71 | - </security-constraint> | ||
72 | - | ||
73 | - <login-config> | ||
74 | - <auth-method>BASIC</auth-method> | ||
75 | - <realm-name>fileRealm</realm-name> | ||
76 | - </login-config> | ||
77 | - | ||
78 | - <security-role> | ||
79 | - <role-name>*</role-name> | ||
80 | - </security-role> | ||
81 | - --> | ||
82 | </web-app> | 61 | </web-app> |
83 | \ No newline at end of file | 62 | \ No newline at end of file |
impl/extension/servlet/src/test/resources/security/authentication/form/web.xml
0 → 100644
@@ -0,0 +1,62 @@ | @@ -0,0 +1,62 @@ | ||
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 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | ||
39 | + | ||
40 | + <listener> | ||
41 | + <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class> | ||
42 | + </listener> | ||
43 | + | ||
44 | + <filter> | ||
45 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
46 | + <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class> | ||
47 | + </filter> | ||
48 | + <filter-mapping> | ||
49 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
50 | + <url-pattern>/*</url-pattern> | ||
51 | + </filter-mapping> | ||
52 | + | ||
53 | + <servlet> | ||
54 | + <servlet-name>Helper Servlet</servlet-name> | ||
55 | + <servlet-class>security.authentication.form.HelperServlet</servlet-class> | ||
56 | + </servlet> | ||
57 | + <servlet-mapping> | ||
58 | + <servlet-name>Helper Servlet</servlet-name> | ||
59 | + <url-pattern>/helper/login</url-pattern> | ||
60 | + <url-pattern>/helper/logout</url-pattern> | ||
61 | + </servlet-mapping> | ||
62 | +</web-app> | ||
0 | \ No newline at end of file | 63 | \ No newline at end of file |
impl/extension/servlet/src/test/resources/security/unauthentication/form/web.xml
0 → 100644
@@ -0,0 +1,71 @@ | @@ -0,0 +1,71 @@ | ||
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 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | ||
39 | + | ||
40 | + <listener> | ||
41 | + <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class> | ||
42 | + </listener> | ||
43 | + | ||
44 | + <filter> | ||
45 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
46 | + <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class> | ||
47 | + </filter> | ||
48 | + <filter-mapping> | ||
49 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
50 | + <url-pattern>/*</url-pattern> | ||
51 | + </filter-mapping> | ||
52 | + | ||
53 | + <servlet> | ||
54 | + <servlet-name>Helper Servlet Unauth Success</servlet-name> | ||
55 | + <servlet-class>security.unauthentication.form.HelperServletUnauthenticationSuccess</servlet-class> | ||
56 | + </servlet> | ||
57 | + <servlet-mapping> | ||
58 | + <servlet-name>Helper Servlet Unauth Success</servlet-name> | ||
59 | + <url-pattern>/helperauthsuccess</url-pattern> | ||
60 | + </servlet-mapping> | ||
61 | + | ||
62 | + <servlet> | ||
63 | + <servlet-name>Helper Servlet Unauth Fail</servlet-name> | ||
64 | + <servlet-class>security.unauthentication.form.HelperServletUnauthenticationFail</servlet-class> | ||
65 | + </servlet> | ||
66 | + <servlet-mapping> | ||
67 | + <servlet-name>Helper Servlet Unauth Fail</servlet-name> | ||
68 | + <url-pattern>/helperauthfail</url-pattern> | ||
69 | + </servlet-mapping> | ||
70 | + | ||
71 | +</web-app> | ||
0 | \ No newline at end of file | 72 | \ No newline at end of file |
impl/extension/servlet/src/test/resources/security/web.xml
@@ -1,82 +0,0 @@ | @@ -1,82 +0,0 @@ | ||
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 | -<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
38 | - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | ||
39 | - | ||
40 | - <listener> | ||
41 | - <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class> | ||
42 | - </listener> | ||
43 | - | ||
44 | - <filter> | ||
45 | - <filter-name>Demoiselle Servlet Filter</filter-name> | ||
46 | - <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class> | ||
47 | - </filter> | ||
48 | - <filter-mapping> | ||
49 | - <filter-name>Demoiselle Servlet Filter</filter-name> | ||
50 | - <url-pattern>/*</url-pattern> | ||
51 | - </filter-mapping> | ||
52 | - | ||
53 | - <servlet> | ||
54 | - <servlet-name>Security Class</servlet-name> | ||
55 | - <servlet-class>security.SecurityServlet</servlet-class> | ||
56 | - </servlet> | ||
57 | - <servlet-mapping> | ||
58 | - <servlet-name>Security Class</servlet-name> | ||
59 | - <url-pattern>/login</url-pattern> | ||
60 | - </servlet-mapping> | ||
61 | - | ||
62 | - <!-- | ||
63 | - <security-constraint> | ||
64 | - <web-resource-collection> | ||
65 | - <web-resource-name>Private URL</web-resource-name> | ||
66 | - <url-pattern>/login</url-pattern> | ||
67 | - </web-resource-collection> | ||
68 | - <auth-constraint> | ||
69 | - <role-name>*</role-name> | ||
70 | - </auth-constraint> | ||
71 | - </security-constraint> | ||
72 | - | ||
73 | - <login-config> | ||
74 | - <auth-method>BASIC</auth-method> | ||
75 | - <realm-name>fileRealm</realm-name> | ||
76 | - </login-config> | ||
77 | - | ||
78 | - <security-role> | ||
79 | - <role-name>*</role-name> | ||
80 | - </security-role> | ||
81 | - --> | ||
82 | -</web-app> | ||
83 | \ No newline at end of file | 0 | \ No newline at end of file |