Commit 87e8a79a9232395efe7e48d149e81141470e6412
1 parent
63ba58ab
Exists in
master
Remoção de classes que não eram mais utilizadas internamente e que
atrapalhavam o deploy no GAE
Showing
5 changed files
with
0 additions
and
749 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ContextProducer.java
| ... | ... | @@ -1,84 +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 | -/* | |
| 38 | - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the | |
| 39 | - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE | |
| 40 | - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is | |
| 41 | - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part | |
| 42 | - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the | |
| 43 | - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework | |
| 44 | - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 45 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You | |
| 46 | - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see | |
| 47 | - * <http://www.gnu.org/licenses/>. | |
| 48 | - */ | |
| 49 | -package br.gov.frameworkdemoiselle.internal.producer; | |
| 50 | - | |
| 51 | -import java.io.Serializable; | |
| 52 | - | |
| 53 | -import javax.enterprise.inject.Default; | |
| 54 | -import javax.enterprise.inject.Produces; | |
| 55 | -import javax.naming.Context; | |
| 56 | -import javax.naming.InitialContext; | |
| 57 | -import javax.naming.NamingException; | |
| 58 | - | |
| 59 | -import br.gov.frameworkdemoiselle.DemoiselleException; | |
| 60 | -import br.gov.frameworkdemoiselle.internal.proxy.ContextProxy; | |
| 61 | - | |
| 62 | -public class ContextProducer implements Serializable { | |
| 63 | - | |
| 64 | - private static final long serialVersionUID = 1L; | |
| 65 | - | |
| 66 | - // @Inject | |
| 67 | - // @Name("demoiselle-core-bundle") | |
| 68 | - // private ResourceBundle bundle; | |
| 69 | - | |
| 70 | - @Produces | |
| 71 | - @Default | |
| 72 | - public static Context create() { | |
| 73 | - Context context = null; | |
| 74 | - | |
| 75 | - try { | |
| 76 | - context = new ContextProxy(new InitialContext()); | |
| 77 | - | |
| 78 | - } catch (NamingException cause) { | |
| 79 | - throw new DemoiselleException("Erro ao criar InitialContext", cause); | |
| 80 | - } | |
| 81 | - | |
| 82 | - return context; | |
| 83 | - } | |
| 84 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/ContextProxy.java
| ... | ... | @@ -1,168 +0,0 @@ |
| 1 | -package br.gov.frameworkdemoiselle.internal.proxy; | |
| 2 | - | |
| 3 | -import java.io.Serializable; | |
| 4 | -import java.util.Hashtable; | |
| 5 | - | |
| 6 | -import javax.naming.Binding; | |
| 7 | -import javax.naming.Context; | |
| 8 | -import javax.naming.Name; | |
| 9 | -import javax.naming.NameClassPair; | |
| 10 | -import javax.naming.NameParser; | |
| 11 | -import javax.naming.NamingEnumeration; | |
| 12 | -import javax.naming.NamingException; | |
| 13 | - | |
| 14 | -public class ContextProxy implements Context, Serializable { | |
| 15 | - | |
| 16 | - private static final long serialVersionUID = 1L; | |
| 17 | - | |
| 18 | - private final Context delegate; | |
| 19 | - | |
| 20 | - public ContextProxy(Context delegate) { | |
| 21 | - this.delegate = delegate; | |
| 22 | - } | |
| 23 | - | |
| 24 | - @Override | |
| 25 | - public Object addToEnvironment(String propName, Object propVal) throws NamingException { | |
| 26 | - return delegate.addToEnvironment(propName, propVal); | |
| 27 | - } | |
| 28 | - | |
| 29 | - @Override | |
| 30 | - public void bind(Name name, Object obj) throws NamingException { | |
| 31 | - delegate.bind(name, obj); | |
| 32 | - } | |
| 33 | - | |
| 34 | - @Override | |
| 35 | - public void bind(String name, Object obj) throws NamingException { | |
| 36 | - delegate.bind(name, obj); | |
| 37 | - } | |
| 38 | - | |
| 39 | - @Override | |
| 40 | - public void close() throws NamingException { | |
| 41 | - delegate.close(); | |
| 42 | - } | |
| 43 | - | |
| 44 | - @Override | |
| 45 | - public Name composeName(Name name, Name prefix) throws NamingException { | |
| 46 | - return delegate.composeName(name, prefix); | |
| 47 | - } | |
| 48 | - | |
| 49 | - @Override | |
| 50 | - public String composeName(String name, String prefix) throws NamingException { | |
| 51 | - return delegate.composeName(name, prefix); | |
| 52 | - } | |
| 53 | - | |
| 54 | - @Override | |
| 55 | - public Context createSubcontext(Name name) throws NamingException { | |
| 56 | - return delegate.createSubcontext(name); | |
| 57 | - } | |
| 58 | - | |
| 59 | - @Override | |
| 60 | - public Context createSubcontext(String name) throws NamingException { | |
| 61 | - return delegate.createSubcontext(name); | |
| 62 | - } | |
| 63 | - | |
| 64 | - @Override | |
| 65 | - public void destroySubcontext(Name name) throws NamingException { | |
| 66 | - delegate.destroySubcontext(name); | |
| 67 | - } | |
| 68 | - | |
| 69 | - @Override | |
| 70 | - public void destroySubcontext(String name) throws NamingException { | |
| 71 | - delegate.destroySubcontext(name); | |
| 72 | - } | |
| 73 | - | |
| 74 | - @Override | |
| 75 | - public Hashtable<?, ?> getEnvironment() throws NamingException { | |
| 76 | - return delegate.getEnvironment(); | |
| 77 | - } | |
| 78 | - | |
| 79 | - @Override | |
| 80 | - public String getNameInNamespace() throws NamingException { | |
| 81 | - return delegate.getNameInNamespace(); | |
| 82 | - } | |
| 83 | - | |
| 84 | - @Override | |
| 85 | - public NameParser getNameParser(Name name) throws NamingException { | |
| 86 | - return delegate.getNameParser(name); | |
| 87 | - } | |
| 88 | - | |
| 89 | - @Override | |
| 90 | - public NameParser getNameParser(String name) throws NamingException { | |
| 91 | - return delegate.getNameParser(name); | |
| 92 | - } | |
| 93 | - | |
| 94 | - @Override | |
| 95 | - public NamingEnumeration<NameClassPair> list(Name name) throws NamingException { | |
| 96 | - return delegate.list(name); | |
| 97 | - } | |
| 98 | - | |
| 99 | - @Override | |
| 100 | - public NamingEnumeration<NameClassPair> list(String name) throws NamingException { | |
| 101 | - return delegate.list(name); | |
| 102 | - } | |
| 103 | - | |
| 104 | - @Override | |
| 105 | - public NamingEnumeration<Binding> listBindings(Name name) throws NamingException { | |
| 106 | - return delegate.listBindings(name); | |
| 107 | - } | |
| 108 | - | |
| 109 | - @Override | |
| 110 | - public NamingEnumeration<Binding> listBindings(String name) throws NamingException { | |
| 111 | - return delegate.listBindings(name); | |
| 112 | - } | |
| 113 | - | |
| 114 | - @Override | |
| 115 | - public Object lookup(Name name) throws NamingException { | |
| 116 | - return delegate.lookup(name); | |
| 117 | - } | |
| 118 | - | |
| 119 | - @Override | |
| 120 | - public Object lookup(String name) throws NamingException { | |
| 121 | - return delegate.lookup(name); | |
| 122 | - } | |
| 123 | - | |
| 124 | - @Override | |
| 125 | - public Object lookupLink(Name name) throws NamingException { | |
| 126 | - return delegate.lookupLink(name); | |
| 127 | - } | |
| 128 | - | |
| 129 | - @Override | |
| 130 | - public Object lookupLink(String name) throws NamingException { | |
| 131 | - return delegate.lookupLink(name); | |
| 132 | - } | |
| 133 | - | |
| 134 | - @Override | |
| 135 | - public void rebind(Name name, Object obj) throws NamingException { | |
| 136 | - delegate.rebind(name, obj); | |
| 137 | - } | |
| 138 | - | |
| 139 | - @Override | |
| 140 | - public void rebind(String name, Object obj) throws NamingException { | |
| 141 | - delegate.rebind(name, obj); | |
| 142 | - } | |
| 143 | - | |
| 144 | - @Override | |
| 145 | - public Object removeFromEnvironment(String propName) throws NamingException { | |
| 146 | - return delegate.removeFromEnvironment(propName); | |
| 147 | - } | |
| 148 | - | |
| 149 | - @Override | |
| 150 | - public void rename(Name oldName, Name newName) throws NamingException { | |
| 151 | - delegate.rename(oldName, newName); | |
| 152 | - } | |
| 153 | - | |
| 154 | - @Override | |
| 155 | - public void rename(String oldName, String newName) throws NamingException { | |
| 156 | - delegate.rename(oldName, newName); | |
| 157 | - } | |
| 158 | - | |
| 159 | - @Override | |
| 160 | - public void unbind(Name name) throws NamingException { | |
| 161 | - delegate.unbind(name); | |
| 162 | - } | |
| 163 | - | |
| 164 | - @Override | |
| 165 | - public void unbind(String name) throws NamingException { | |
| 166 | - delegate.unbind(name); | |
| 167 | - } | |
| 168 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ContextProducerTest.java
| ... | ... | @@ -1,66 +0,0 @@ |
| 1 | -package br.gov.frameworkdemoiselle.internal.producer; | |
| 2 | - | |
| 3 | -import static junit.framework.Assert.assertNull; | |
| 4 | -import static junit.framework.Assert.assertTrue; | |
| 5 | -import static junit.framework.Assert.fail; | |
| 6 | -import static org.easymock.EasyMock.expect; | |
| 7 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | |
| 8 | - | |
| 9 | -import javax.naming.Context; | |
| 10 | -import javax.naming.NamingException; | |
| 11 | - | |
| 12 | -import junit.framework.Assert; | |
| 13 | - | |
| 14 | -import org.junit.Test; | |
| 15 | -import org.junit.runner.RunWith; | |
| 16 | -import org.powermock.api.easymock.PowerMock; | |
| 17 | -import org.powermock.core.classloader.annotations.PrepareForTest; | |
| 18 | -import org.powermock.modules.junit4.PowerMockRunner; | |
| 19 | - | |
| 20 | -import br.gov.frameworkdemoiselle.DemoiselleException; | |
| 21 | - | |
| 22 | -import com.sun.naming.internal.ResourceManager; | |
| 23 | - | |
| 24 | -@SuppressWarnings("restriction") | |
| 25 | -@RunWith(PowerMockRunner.class) | |
| 26 | -@PrepareForTest(ResourceManager.class) | |
| 27 | -public class ContextProducerTest { | |
| 28 | - | |
| 29 | - @Test | |
| 30 | - public void testCreate() { | |
| 31 | - | |
| 32 | - Context context = ContextProducer.create(); | |
| 33 | - | |
| 34 | - Assert.assertNotNull(context); | |
| 35 | - | |
| 36 | - } | |
| 37 | - | |
| 38 | - @Test | |
| 39 | - public void testCreateThrowingException() { | |
| 40 | - | |
| 41 | - Context context = null; | |
| 42 | - | |
| 43 | - try { | |
| 44 | - | |
| 45 | - mockStatic(ResourceManager.class); | |
| 46 | - expect(ResourceManager.getInitialEnvironment(null)).andThrow(new NamingException()); | |
| 47 | - PowerMock.replay(ResourceManager.class); | |
| 48 | - | |
| 49 | - context = ContextProducer.create(); | |
| 50 | - fail(); | |
| 51 | - | |
| 52 | - } catch (Exception e) { | |
| 53 | - assertNull(context); | |
| 54 | - assertTrue(e instanceof DemoiselleException); | |
| 55 | - } | |
| 56 | - | |
| 57 | - } | |
| 58 | - | |
| 59 | - // This test exists only to get 100% on conbertura. | |
| 60 | - @Test | |
| 61 | - public void testInstantiateContextProducer() { | |
| 62 | - @SuppressWarnings("unused") | |
| 63 | - ContextProducer contextProducer = new ContextProducer(); | |
| 64 | - } | |
| 65 | - | |
| 66 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/ContextProxyTest.java
| ... | ... | @@ -1,305 +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.proxy; | |
| 38 | - | |
| 39 | -import static org.easymock.EasyMock.expect; | |
| 40 | -import static org.easymock.EasyMock.replay; | |
| 41 | -import static org.easymock.EasyMock.verify; | |
| 42 | - | |
| 43 | -import javax.naming.Context; | |
| 44 | -import javax.naming.Name; | |
| 45 | -import javax.naming.NamingException; | |
| 46 | - | |
| 47 | -import org.easymock.EasyMock; | |
| 48 | -import org.junit.Before; | |
| 49 | -import org.junit.Test; | |
| 50 | - | |
| 51 | -public class ContextProxyTest { | |
| 52 | - | |
| 53 | - private Context context; | |
| 54 | - private ContextProxy contextProxy; | |
| 55 | - | |
| 56 | - @Before | |
| 57 | - public void setUp() throws Exception { | |
| 58 | - this.context = EasyMock.createMock(Context.class); | |
| 59 | - this.contextProxy = new ContextProxy(this.context); | |
| 60 | - } | |
| 61 | - | |
| 62 | - @Test | |
| 63 | - public void testAddToEnvironment() throws NamingException { | |
| 64 | - expect(this.context.addToEnvironment("", null)).andReturn(null); | |
| 65 | - replay(this.context); | |
| 66 | - this.contextProxy.addToEnvironment("", null); | |
| 67 | - verify(this.context); | |
| 68 | - } | |
| 69 | - | |
| 70 | - @Test | |
| 71 | - public void testBindWithNameAndObject() throws NamingException { | |
| 72 | - Name name = null; | |
| 73 | - this.context.bind(name, null); | |
| 74 | - replay(this.context); | |
| 75 | - this.contextProxy.bind(name, null); | |
| 76 | - verify(this.context); | |
| 77 | - } | |
| 78 | - | |
| 79 | - @Test | |
| 80 | - public void testBindWithStringAndObject() throws NamingException { | |
| 81 | - this.context.bind("", null); | |
| 82 | - replay(this.context); | |
| 83 | - this.contextProxy.bind("", null); | |
| 84 | - verify(this.context); | |
| 85 | - } | |
| 86 | - | |
| 87 | - @Test | |
| 88 | - public void testClose() throws NamingException { | |
| 89 | - this.context.close(); | |
| 90 | - replay(this.context); | |
| 91 | - this.contextProxy.close(); | |
| 92 | - verify(this.context); | |
| 93 | - } | |
| 94 | - | |
| 95 | - @Test | |
| 96 | - public void testComposeNameWithTwoNames() throws NamingException { | |
| 97 | - Name n1=null, n2=null; | |
| 98 | - expect(this.context.composeName(n1,n2)).andReturn(null); | |
| 99 | - replay(this.context); | |
| 100 | - this.contextProxy.composeName(n1,n2); | |
| 101 | - verify(this.context); | |
| 102 | - } | |
| 103 | - | |
| 104 | - @Test | |
| 105 | - public void testComposeNameWithTwoStrings() throws NamingException { | |
| 106 | - expect(this.context.composeName("","")).andReturn(null); | |
| 107 | - replay(this.context); | |
| 108 | - this.contextProxy.composeName("",""); | |
| 109 | - verify(this.context); | |
| 110 | - } | |
| 111 | - | |
| 112 | - @Test | |
| 113 | - public void testCreateSubcontextWithName() throws NamingException { | |
| 114 | - Name n1 = null; | |
| 115 | - expect(this.context.createSubcontext(n1)).andReturn(null); | |
| 116 | - replay(this.context); | |
| 117 | - this.contextProxy.createSubcontext(n1); | |
| 118 | - verify(this.context); | |
| 119 | - } | |
| 120 | - | |
| 121 | - @Test | |
| 122 | - public void testCreateSubcontextWithString() throws NamingException { | |
| 123 | - expect(this.context.createSubcontext("")).andReturn(null); | |
| 124 | - replay(this.context); | |
| 125 | - this.contextProxy.createSubcontext(""); | |
| 126 | - verify(this.context); | |
| 127 | - } | |
| 128 | - | |
| 129 | - @Test | |
| 130 | - public void testDestroySubcontextWithName() throws NamingException { | |
| 131 | - Name n1=null; | |
| 132 | - context.destroySubcontext(n1); | |
| 133 | - replay(this.context); | |
| 134 | - this.contextProxy.destroySubcontext(n1); | |
| 135 | - verify(this.context); | |
| 136 | - } | |
| 137 | - | |
| 138 | - @Test | |
| 139 | - public void testDestroySubcontextWithString() throws NamingException { | |
| 140 | - context.destroySubcontext(""); | |
| 141 | - replay(this.context); | |
| 142 | - this.contextProxy.destroySubcontext(""); | |
| 143 | - verify(this.context); | |
| 144 | - } | |
| 145 | - | |
| 146 | - @Test | |
| 147 | - public void testGetNameInNamespace() throws NamingException { | |
| 148 | - expect(this.context.getNameInNamespace()).andReturn(null); | |
| 149 | - replay(this.context); | |
| 150 | - this.contextProxy.getNameInNamespace(); | |
| 151 | - verify(this.context); | |
| 152 | - } | |
| 153 | - | |
| 154 | - @Test | |
| 155 | - public void testGetNameParserWithName() throws NamingException { | |
| 156 | - Name n1=null; | |
| 157 | - expect(this.context.getNameParser(n1)).andReturn(null); | |
| 158 | - replay(this.context); | |
| 159 | - this.contextProxy.getNameParser(n1); | |
| 160 | - verify(this.context); | |
| 161 | - } | |
| 162 | - | |
| 163 | - @Test | |
| 164 | - public void testGetNameParserWithString() throws NamingException { | |
| 165 | - expect(this.context.getNameParser("")).andReturn(null); | |
| 166 | - replay(this.context); | |
| 167 | - this.contextProxy.getNameParser(""); | |
| 168 | - verify(this.context); | |
| 169 | - } | |
| 170 | - | |
| 171 | - @Test | |
| 172 | - public void testListWithName() throws NamingException { | |
| 173 | - Name n1=null; | |
| 174 | - expect(this.context.list(n1)).andReturn(null); | |
| 175 | - replay(this.context); | |
| 176 | - this.contextProxy.list(n1); | |
| 177 | - verify(this.context); | |
| 178 | - } | |
| 179 | - | |
| 180 | - @Test | |
| 181 | - public void testListWithString() throws NamingException { | |
| 182 | - expect(this.context.list("")).andReturn(null); | |
| 183 | - replay(this.context); | |
| 184 | - this.contextProxy.list(""); | |
| 185 | - verify(this.context); | |
| 186 | - } | |
| 187 | - | |
| 188 | - @Test | |
| 189 | - public void testListBindingsWithName() throws NamingException { | |
| 190 | - Name n1=null; | |
| 191 | - expect(this.context.listBindings(n1)).andReturn(null); | |
| 192 | - replay(this.context); | |
| 193 | - this.contextProxy.listBindings(n1); | |
| 194 | - verify(this.context); | |
| 195 | - } | |
| 196 | - | |
| 197 | - @Test | |
| 198 | - public void testListBindingsWithString() throws NamingException { | |
| 199 | - expect(this.context.listBindings("")).andReturn(null); | |
| 200 | - replay(this.context); | |
| 201 | - this.contextProxy.listBindings(""); | |
| 202 | - verify(this.context); | |
| 203 | - } | |
| 204 | - | |
| 205 | - @Test | |
| 206 | - public void testLookupBindingsWithString() throws NamingException { | |
| 207 | - Name n1 = null; | |
| 208 | - expect(this.context.lookup(n1)).andReturn(null); | |
| 209 | - replay(this.context); | |
| 210 | - this.contextProxy.lookup(n1); | |
| 211 | - verify(this.context); | |
| 212 | - } | |
| 213 | - | |
| 214 | - @Test | |
| 215 | - public void testLookupWithString() throws NamingException { | |
| 216 | - expect(this.context.lookup("")).andReturn(null); | |
| 217 | - replay(this.context); | |
| 218 | - this.contextProxy.lookup(""); | |
| 219 | - verify(this.context); | |
| 220 | - } | |
| 221 | - | |
| 222 | - @Test | |
| 223 | - public void testLookupLinkBindingsWithString() throws NamingException { | |
| 224 | - Name n1 = null; | |
| 225 | - expect(this.context.lookupLink(n1)).andReturn(null); | |
| 226 | - replay(this.context); | |
| 227 | - this.contextProxy.lookupLink(n1); | |
| 228 | - verify(this.context); | |
| 229 | - } | |
| 230 | - | |
| 231 | - @Test | |
| 232 | - public void testLookupLinkWithString() throws NamingException { | |
| 233 | - expect(this.context.lookupLink("")).andReturn(null); | |
| 234 | - replay(this.context); | |
| 235 | - this.contextProxy.lookupLink(""); | |
| 236 | - verify(this.context); | |
| 237 | - } | |
| 238 | - | |
| 239 | - @Test | |
| 240 | - public void testRebindWithNameAndObject() throws NamingException { | |
| 241 | - Name n1 = null; | |
| 242 | - this.context.rebind(n1,null); | |
| 243 | - replay(this.context); | |
| 244 | - this.contextProxy.rebind(n1,null); | |
| 245 | - verify(this.context); | |
| 246 | - } | |
| 247 | - | |
| 248 | - @Test | |
| 249 | - public void testRebindWithStringAndObject() throws NamingException { | |
| 250 | - this.context.rebind("",null); | |
| 251 | - replay(this.context); | |
| 252 | - this.contextProxy.rebind("",null); | |
| 253 | - verify(this.context); | |
| 254 | - } | |
| 255 | - | |
| 256 | - @Test | |
| 257 | - public void testRemoveFromEnvironmentWithString() throws NamingException { | |
| 258 | - expect(this.context.removeFromEnvironment("")).andReturn(null); | |
| 259 | - replay(this.context); | |
| 260 | - this.contextProxy.removeFromEnvironment(""); | |
| 261 | - verify(this.context); | |
| 262 | - } | |
| 263 | - | |
| 264 | - @Test | |
| 265 | - public void testRenameWithTwoNames() throws NamingException { | |
| 266 | - Name n1 = null, n2=null; | |
| 267 | - this.context.rename(n1,n2); | |
| 268 | - replay(this.context); | |
| 269 | - this.contextProxy.rename(n1,n2); | |
| 270 | - verify(this.context); | |
| 271 | - } | |
| 272 | - | |
| 273 | - @Test | |
| 274 | - public void testRenameWithTwoStrings() throws NamingException{ | |
| 275 | - this.context.rename("",""); | |
| 276 | - replay(this.context); | |
| 277 | - this.contextProxy.rename("",""); | |
| 278 | - verify(this.context); | |
| 279 | - } | |
| 280 | - | |
| 281 | - @Test | |
| 282 | - public void testUnbind() throws NamingException { | |
| 283 | - Name n1 = null; | |
| 284 | - this.context.unbind(n1); | |
| 285 | - replay(this.context); | |
| 286 | - this.contextProxy.unbind(n1); | |
| 287 | - verify(this.context); | |
| 288 | - } | |
| 289 | - | |
| 290 | - @Test | |
| 291 | - public void testUnbindWithString() throws NamingException { | |
| 292 | - this.context.unbind(""); | |
| 293 | - replay(this.context); | |
| 294 | - this.contextProxy.unbind(""); | |
| 295 | - verify(this.context); | |
| 296 | - } | |
| 297 | - | |
| 298 | - @Test | |
| 299 | - public void testGetEnvironment() throws NamingException { | |
| 300 | - expect(this.context.getEnvironment()).andReturn(null); | |
| 301 | - replay(this.context); | |
| 302 | - this.contextProxy.getEnvironment(); | |
| 303 | - verify(this.context); | |
| 304 | - } | |
| 305 | -} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/HttpSessionProxyTest.java
| ... | ... | @@ -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.proxy; | |
| 38 | - | |
| 39 | -import static org.easymock.EasyMock.expect; | |
| 40 | -import static org.easymock.EasyMock.replay; | |
| 41 | -import static org.easymock.EasyMock.verify; | |
| 42 | -import static org.junit.Assert.assertEquals; | |
| 43 | - | |
| 44 | -import java.util.Enumeration; | |
| 45 | - | |
| 46 | -import javax.servlet.ServletContext; | |
| 47 | -import javax.servlet.http.HttpSession; | |
| 48 | -import javax.servlet.http.HttpSessionContext; | |
| 49 | - | |
| 50 | -import org.junit.Before; | |
| 51 | -import org.junit.Test; | |
| 52 | -import org.junit.runner.RunWith; | |
| 53 | -import org.powermock.api.easymock.PowerMock; | |
| 54 | -import org.powermock.core.classloader.annotations.PrepareForTest; | |
| 55 | -import org.powermock.modules.junit4.PowerMockRunner; | |
| 56 | - | |
| 57 | -@SuppressWarnings("deprecation") | |
| 58 | -@RunWith(PowerMockRunner.class) | |
| 59 | -@PrepareForTest({ HttpSession.class, ServletContext.class, Enumeration.class, HttpSessionContext.class }) | |
| 60 | -public class HttpSessionProxyTest { | |
| 61 | - | |
| 62 | - private HttpSessionProxy proxy; | |
| 63 | - | |
| 64 | - private ServletContext servletContext; | |
| 65 | - | |
| 66 | - private Enumeration<?> enumeration; | |
| 67 | - | |
| 68 | - private HttpSession session; | |
| 69 | - | |
| 70 | - private HttpSessionContext sessionContext; | |
| 71 | - | |
| 72 | - @Before | |
| 73 | - public void before() { | |
| 74 | - session = PowerMock.createMock(HttpSession.class); | |
| 75 | - servletContext = PowerMock.createMock(ServletContext.class); | |
| 76 | - enumeration = PowerMock.createMock(Enumeration.class); | |
| 77 | - sessionContext = PowerMock.createMock(HttpSessionContext.class); | |
| 78 | - | |
| 79 | - expect(session.getValueNames()).andReturn(new String[] {"abcdef"}); | |
| 80 | - expect(session.getValue("value")).andReturn("value"); | |
| 81 | - expect(session.getSessionContext()).andReturn(sessionContext); | |
| 82 | - expect(session.getCreationTime()).andReturn(10L); | |
| 83 | - expect(session.getId()).andReturn("ID"); | |
| 84 | - expect(session.getLastAccessedTime()).andReturn(1L); | |
| 85 | - expect(session.getServletContext()).andReturn(servletContext); | |
| 86 | - expect(session.getMaxInactiveInterval()).andReturn(2); | |
| 87 | - expect(session.getAttribute("attribute")).andReturn("attribute-1"); | |
| 88 | - expect(session.getAttributeNames()).andReturn(enumeration); | |
| 89 | - expect(session.isNew()).andReturn(true); | |
| 90 | - | |
| 91 | - session.removeValue("removeValue"); | |
| 92 | - session.putValue("put", "it"); | |
| 93 | - session.invalidate(); | |
| 94 | - session.removeAttribute("remove"); | |
| 95 | - session.setAttribute("name", "object"); | |
| 96 | - session.setMaxInactiveInterval(1); | |
| 97 | - | |
| 98 | - replay(session); | |
| 99 | - | |
| 100 | - proxy = new HttpSessionProxy(session); | |
| 101 | - } | |
| 102 | - | |
| 103 | - @Test | |
| 104 | - public void testDelegation() { | |
| 105 | - assertEquals(sessionContext, proxy.getSessionContext()); | |
| 106 | - assertEquals("value", proxy.getValue("value")); | |
| 107 | - assertEquals("abcdef", proxy.getValueNames()[0]); | |
| 108 | - assertEquals(10L, proxy.getCreationTime()); | |
| 109 | - assertEquals("ID", proxy.getId()); | |
| 110 | - assertEquals(1L, proxy.getLastAccessedTime()); | |
| 111 | - assertEquals(servletContext, proxy.getServletContext()); | |
| 112 | - assertEquals(2, proxy.getMaxInactiveInterval()); | |
| 113 | - assertEquals("attribute-1", proxy.getAttribute("attribute")); | |
| 114 | - assertEquals(enumeration, proxy.getAttributeNames()); | |
| 115 | - assertEquals(true, proxy.isNew()); | |
| 116 | - | |
| 117 | - proxy.removeValue("removeValue"); | |
| 118 | - proxy.putValue("put","it"); | |
| 119 | - proxy.invalidate(); | |
| 120 | - proxy.removeAttribute("remove"); | |
| 121 | - proxy.setAttribute("name", "object"); | |
| 122 | - proxy.setMaxInactiveInterval(1); | |
| 123 | - | |
| 124 | - verify(session); | |
| 125 | - } | |
| 126 | -} |