Commit 2ce9e5ae99ac72326d74cac5ac74e69bfdc19663
Exists in
master
Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0
Showing
30 changed files
with
238 additions
and
2949 deletions
Show diff stats
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/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/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-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 |