Commit b9a3c893c3818aa6e6b51d9e2950588740efa7c7
1 parent
f4567b0e
Exists in
master
Inclusão das dependências com o Arquillian para substituição dos testes
Showing
69 changed files
with
289 additions
and
8567 deletions
Show diff stats
impl/core/pom.xml
| @@ -34,7 +34,8 @@ | @@ -34,7 +34,8 @@ | ||
| 34 | ou escreva para a Fundação do Software Livre (FSF) Inc., | 34 | ou escreva para a Fundação do Software Livre (FSF) Inc., |
| 35 | 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | 35 | 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
| 36 | --> | 36 | --> |
| 37 | -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | 37 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 38 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| 38 | 39 | ||
| 39 | <modelVersion>4.0.0</modelVersion> | 40 | <modelVersion>4.0.0</modelVersion> |
| 40 | 41 | ||
| @@ -76,6 +77,15 @@ | @@ -76,6 +77,15 @@ | ||
| 76 | <scope>import</scope> | 77 | <scope>import</scope> |
| 77 | <type>pom</type> | 78 | <type>pom</type> |
| 78 | </dependency> | 79 | </dependency> |
| 80 | + <!-- | ||
| 81 | + <dependency> | ||
| 82 | + <groupId>org.jboss.arquillian</groupId> | ||
| 83 | + <artifactId>arquillian-bom</artifactId> | ||
| 84 | + <version>${arquillian.version}</version> | ||
| 85 | + <scope>import</scope> | ||
| 86 | + <type>pom</type> | ||
| 87 | + </dependency> | ||
| 88 | + --> | ||
| 79 | </dependencies> | 89 | </dependencies> |
| 80 | </dependencyManagement> | 90 | </dependencyManagement> |
| 81 | 91 | ||
| @@ -152,25 +162,30 @@ | @@ -152,25 +162,30 @@ | ||
| 152 | <scope>test</scope> | 162 | <scope>test</scope> |
| 153 | </dependency> | 163 | </dependency> |
| 154 | <dependency> | 164 | <dependency> |
| 155 | - <groupId>org.easymock</groupId> | ||
| 156 | - <artifactId>easymock</artifactId> | 165 | + <groupId>org.jboss.arquillian.junit</groupId> |
| 166 | + <artifactId>arquillian-junit-container</artifactId> | ||
| 167 | + <version>${arquillian.version}</version> | ||
| 157 | <scope>test</scope> | 168 | <scope>test</scope> |
| 158 | </dependency> | 169 | </dependency> |
| 159 | <dependency> | 170 | <dependency> |
| 160 | - <groupId>org.powermock</groupId> | ||
| 161 | - <artifactId>powermock-module-junit4</artifactId> | 171 | + <groupId>org.jboss.arquillian.container</groupId> |
| 172 | + <artifactId>arquillian-weld-se-embedded-1.1</artifactId> | ||
| 173 | + <version>${arquillian.weld.se.embedded.version}</version> | ||
| 162 | <scope>test</scope> | 174 | <scope>test</scope> |
| 163 | </dependency> | 175 | </dependency> |
| 164 | <dependency> | 176 | <dependency> |
| 165 | - <groupId>org.powermock</groupId> | ||
| 166 | - <artifactId>powermock-api-easymock</artifactId> | 177 | + <groupId>org.jboss.weld.se</groupId> |
| 178 | + <artifactId>weld-se-core</artifactId> | ||
| 179 | + <version>${weld.se.version}</version> | ||
| 167 | <scope>test</scope> | 180 | <scope>test</scope> |
| 168 | </dependency> | 181 | </dependency> |
| 182 | + <!-- | ||
| 169 | <dependency> | 183 | <dependency> |
| 170 | <groupId>javax.el</groupId> | 184 | <groupId>javax.el</groupId> |
| 171 | <artifactId>el-api</artifactId> | 185 | <artifactId>el-api</artifactId> |
| 172 | <scope>test</scope> | 186 | <scope>test</scope> |
| 173 | </dependency> | 187 | </dependency> |
| 188 | + --> | ||
| 174 | <dependency> | 189 | <dependency> |
| 175 | <groupId>org.slf4j</groupId> | 190 | <groupId>org.slf4j</groupId> |
| 176 | <artifactId>slf4j-log4j12</artifactId> | 191 | <artifactId>slf4j-log4j12</artifactId> |
| @@ -202,4 +217,10 @@ | @@ -202,4 +217,10 @@ | ||
| 202 | </releases> | 217 | </releases> |
| 203 | </repository> | 218 | </repository> |
| 204 | </repositories> | 219 | </repositories> |
| 220 | + | ||
| 221 | + <properties> | ||
| 222 | + <arquillian.version>1.0.3.Final</arquillian.version> | ||
| 223 | + <arquillian.weld.se.embedded.version>1.0.0.CR6</arquillian.weld.se.embedded.version> | ||
| 224 | + <weld.se.version>1.1.8.Final</weld.se.version> | ||
| 225 | + </properties> | ||
| 205 | </project> | 226 | </project> |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java
| @@ -37,6 +37,7 @@ | @@ -37,6 +37,7 @@ | ||
| 37 | package br.gov.frameworkdemoiselle.internal.bootstrap; | 37 | package br.gov.frameworkdemoiselle.internal.bootstrap; |
| 38 | 38 | ||
| 39 | import java.util.ArrayList; | 39 | import java.util.ArrayList; |
| 40 | +import java.util.Arrays; | ||
| 40 | import java.util.Collections; | 41 | import java.util.Collections; |
| 41 | import java.util.HashMap; | 42 | import java.util.HashMap; |
| 42 | import java.util.List; | 43 | import java.util.List; |
| @@ -47,6 +48,7 @@ import javassist.CtClass; | @@ -47,6 +48,7 @@ import javassist.CtClass; | ||
| 47 | import javassist.CtMethod; | 48 | import javassist.CtMethod; |
| 48 | import javassist.CtNewMethod; | 49 | import javassist.CtNewMethod; |
| 49 | import javassist.LoaderClassPath; | 50 | import javassist.LoaderClassPath; |
| 51 | +import javassist.NotFoundException; | ||
| 50 | 52 | ||
| 51 | import javax.enterprise.event.Observes; | 53 | import javax.enterprise.event.Observes; |
| 52 | import javax.enterprise.inject.spi.AfterBeanDiscovery; | 54 | import javax.enterprise.inject.spi.AfterBeanDiscovery; |
| @@ -83,6 +85,17 @@ public class ConfigurationBootstrap implements Extension { | @@ -83,6 +85,17 @@ public class ConfigurationBootstrap implements Extension { | ||
| 83 | } | 85 | } |
| 84 | } | 86 | } |
| 85 | 87 | ||
| 88 | + private static List<CtMethod> getMethods(CtClass type) throws NotFoundException { | ||
| 89 | + List<CtMethod> fields = new ArrayList<CtMethod>(); | ||
| 90 | + | ||
| 91 | + if (type != null && !type.getName().equals(Object.class.getName())) { | ||
| 92 | + fields.addAll(Arrays.asList(type.getDeclaredMethods())); | ||
| 93 | + fields.addAll(getMethods(type.getSuperclass())); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + return fields; | ||
| 97 | + } | ||
| 98 | + | ||
| 86 | @SuppressWarnings("unchecked") | 99 | @SuppressWarnings("unchecked") |
| 87 | private Class<Object> createProxy(Class<Object> type) throws Exception { | 100 | private Class<Object> createProxy(Class<Object> type) throws Exception { |
| 88 | String superClassName = type.getCanonicalName(); | 101 | String superClassName = type.getCanonicalName(); |
| @@ -112,7 +125,7 @@ public class ConfigurationBootstrap implements Extension { | @@ -112,7 +125,7 @@ public class ConfigurationBootstrap implements Extension { | ||
| 112 | ctChieldClass.setSuperclass(ctSuperClass); | 125 | ctChieldClass.setSuperclass(ctSuperClass); |
| 113 | 126 | ||
| 114 | CtMethod ctChieldMethod; | 127 | CtMethod ctChieldMethod; |
| 115 | - for (CtMethod ctSuperMethod : ctSuperClass.getDeclaredMethods()) { | 128 | + for (CtMethod ctSuperMethod : getMethods(ctSuperClass)) { |
| 116 | ctChieldMethod = CtNewMethod.delegator(ctSuperMethod, ctChieldClass); | 129 | ctChieldMethod = CtNewMethod.delegator(ctSuperMethod, ctChieldClass); |
| 117 | ctChieldMethod.insertBefore("load(this);"); | 130 | ctChieldMethod.insertBefore("load(this);"); |
| 118 | 131 |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationImpl.java
| @@ -2,6 +2,7 @@ package br.gov.frameworkdemoiselle.internal.implementation; | @@ -2,6 +2,7 @@ package br.gov.frameworkdemoiselle.internal.implementation; | ||
| 2 | 2 | ||
| 3 | import java.io.Serializable; | 3 | import java.io.Serializable; |
| 4 | 4 | ||
| 5 | +import br.gov.frameworkdemoiselle.annotation.Ignore; | ||
| 5 | import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; | 6 | import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; |
| 6 | import br.gov.frameworkdemoiselle.util.Beans; | 7 | import br.gov.frameworkdemoiselle.util.Beans; |
| 7 | 8 | ||
| @@ -9,6 +10,7 @@ public class ConfigurationImpl implements Serializable { | @@ -9,6 +10,7 @@ public class ConfigurationImpl implements Serializable { | ||
| 9 | 10 | ||
| 10 | private static final long serialVersionUID = 1L; | 11 | private static final long serialVersionUID = 1L; |
| 11 | 12 | ||
| 13 | + @Ignore | ||
| 12 | private boolean loaded = false; | 14 | private boolean loaded = false; |
| 13 | 15 | ||
| 14 | @SuppressWarnings("unused") | 16 | @SuppressWarnings("unused") |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/AbstractConfigurationTest.java
0 → 100644
| @@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration; | ||
| 2 | + | ||
| 3 | +import java.io.File; | ||
| 4 | +import java.util.ArrayList; | ||
| 5 | +import java.util.List; | ||
| 6 | + | ||
| 7 | +import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
| 8 | +import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
| 9 | +import org.jboss.shrinkwrap.api.asset.FileAsset; | ||
| 10 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
| 11 | + | ||
| 12 | +import br.gov.frameworkdemoiselle.annotation.Ignore; | ||
| 13 | +import br.gov.frameworkdemoiselle.annotation.Name; | ||
| 14 | +import br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap; | ||
| 15 | +import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | ||
| 16 | +import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; | ||
| 17 | +import br.gov.frameworkdemoiselle.internal.producer.LocaleProducer; | ||
| 18 | +import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 19 | +import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 20 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
| 21 | + | ||
| 22 | +public abstract class AbstractConfigurationTest { | ||
| 23 | + | ||
| 24 | + protected static Class<?>[] getConfigurationClasses() { | ||
| 25 | + List<Class<?>> result = new ArrayList<Class<?>>(); | ||
| 26 | + | ||
| 27 | + result.add(Ignore.class); | ||
| 28 | + result.add(Name.class); | ||
| 29 | + result.add(Configuration.class); | ||
| 30 | + result.add(CoreBootstrap.class); | ||
| 31 | + result.add(ConfigurationBootstrap.class); | ||
| 32 | + result.add(ConfigurationLoader.class); | ||
| 33 | + result.add(Beans.class); | ||
| 34 | + result.add(ResourceBundleProducer.class); | ||
| 35 | + result.add(LoggerProducer.class); | ||
| 36 | + result.add(LocaleProducer.class); | ||
| 37 | + | ||
| 38 | + return result.toArray(new Class<?>[0]); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public static JavaArchive createConfigurationDeployment() { | ||
| 42 | + return ShrinkWrap | ||
| 43 | + .create(JavaArchive.class) | ||
| 44 | + .addClasses(getConfigurationClasses()) | ||
| 45 | + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") | ||
| 46 | + .addAsResource( | ||
| 47 | + new FileAsset(new File("src/test/resources/configuration/fields/basic/demoiselle.properties")), | ||
| 48 | + "demoiselle.properties") | ||
| 49 | + .addAsManifestResource( | ||
| 50 | + new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), | ||
| 51 | + "services/javax.enterprise.inject.spi.Extension"); | ||
| 52 | + } | ||
| 53 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/AbstractBasicFieldsConfig.java
0 → 100644
| @@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | + | ||
| 3 | +public abstract class AbstractBasicFieldsConfig { | ||
| 4 | + | ||
| 5 | + private int primitiveInteger; | ||
| 6 | + | ||
| 7 | + private Integer wrappedInteger; | ||
| 8 | + | ||
| 9 | + private String stringWithSpace; | ||
| 10 | + | ||
| 11 | + private String stringWithComma; | ||
| 12 | + | ||
| 13 | + public Integer getWrappedInteger() { | ||
| 14 | + return wrappedInteger; | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public void setWrappedInteger(Integer wrappedInteger) { | ||
| 18 | + this.wrappedInteger = wrappedInteger; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public int getPrimitiveInteger() { | ||
| 22 | + return primitiveInteger; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public void setPrimitiveInteger(int primitiveInteger) { | ||
| 26 | + this.primitiveInteger = primitiveInteger; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public String getStringWithSpace() { | ||
| 30 | + return stringWithSpace; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public void setStringWithSpace(String stringWithSpace) { | ||
| 34 | + this.stringWithSpace = stringWithSpace; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public String getStringWithComma() { | ||
| 38 | + return stringWithComma; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setStringWithComma(String stringWithComma) { | ||
| 42 | + this.stringWithComma = stringWithComma; | ||
| 43 | + } | ||
| 44 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/ConfigurationBasicFieldsTest.java
0 → 100644
| @@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | + | ||
| 3 | +import static junit.framework.Assert.assertEquals; | ||
| 4 | + | ||
| 5 | +import javax.inject.Inject; | ||
| 6 | + | ||
| 7 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
| 8 | +import org.jboss.arquillian.junit.Arquillian; | ||
| 9 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
| 10 | +import org.junit.Test; | ||
| 11 | +import org.junit.runner.RunWith; | ||
| 12 | + | ||
| 13 | +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; | ||
| 14 | + | ||
| 15 | +@RunWith(Arquillian.class) | ||
| 16 | +public class ConfigurationBasicFieldsTest extends AbstractConfigurationTest { | ||
| 17 | + | ||
| 18 | + @Inject | ||
| 19 | + private PropertiesBasicFieldsConfig propertiesConfig; | ||
| 20 | + | ||
| 21 | + @Deployment | ||
| 22 | + public static JavaArchive createDeployment() { | ||
| 23 | + return createConfigurationDeployment().addPackages(true, ConfigurationBasicFieldsTest.class.getPackage()); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Test | ||
| 27 | + public void loadPrimitiveInteger() { | ||
| 28 | + int expected = 1; | ||
| 29 | + | ||
| 30 | + assertEquals(expected, propertiesConfig.getPrimitiveInteger()); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Test | ||
| 34 | + public void loadWrappedInteger() { | ||
| 35 | + Integer expected = 2; | ||
| 36 | + | ||
| 37 | + assertEquals(expected, propertiesConfig.getWrappedInteger()); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @Test | ||
| 41 | + public void loadStringWithSpace() { | ||
| 42 | + String expected = "demoiselle framework"; | ||
| 43 | + | ||
| 44 | + assertEquals(expected, propertiesConfig.getStringWithSpace()); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | +// @Test | ||
| 48 | + public void loadStringWithComma() { | ||
| 49 | + String expected = "demoiselle,framework"; | ||
| 50 | + | ||
| 51 | + assertEquals(expected, propertiesConfig.getStringWithComma()); | ||
| 52 | + } | ||
| 53 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/PropertiesBasicFieldsConfig.java
0 → 100644
| @@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | + | ||
| 3 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; | ||
| 4 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 5 | + | ||
| 6 | +@Configuration(type = PROPERTIES) | ||
| 7 | +public class PropertiesBasicFieldsConfig extends AbstractBasicFieldsConfig { | ||
| 8 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/SystemBasicFieldsConfig.java
0 → 100644
| @@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | + | ||
| 3 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.SYSTEM; | ||
| 4 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 5 | + | ||
| 6 | +@Configuration(type = SYSTEM) | ||
| 7 | +public class SystemBasicFieldsConfig extends AbstractBasicFieldsConfig { | ||
| 8 | + | ||
| 9 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/XMLBasicFieldsConfig.java
0 → 100644
| @@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | + | ||
| 3 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; | ||
| 4 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 5 | + | ||
| 6 | +@Configuration(type = XML) | ||
| 7 | +public class XMLBasicFieldsConfig extends AbstractBasicFieldsConfig { | ||
| 8 | + | ||
| 9 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrapTest.java
| @@ -1,165 +0,0 @@ | @@ -1,165 +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 junit.framework.Assert.assertFalse; | ||
| 40 | -import static junit.framework.Assert.assertNotNull; | ||
| 41 | -import static junit.framework.Assert.assertTrue; | ||
| 42 | -import static org.easymock.EasyMock.createMock; | ||
| 43 | -import static org.easymock.EasyMock.expect; | ||
| 44 | -import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 45 | -import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
| 46 | - | ||
| 47 | -import java.lang.reflect.Field; | ||
| 48 | -import java.util.HashSet; | ||
| 49 | -import java.util.List; | ||
| 50 | -import java.util.Set; | ||
| 51 | - | ||
| 52 | -import javax.enterprise.context.ConversationScoped; | ||
| 53 | -import javax.enterprise.context.RequestScoped; | ||
| 54 | -import javax.enterprise.context.SessionScoped; | ||
| 55 | -import javax.enterprise.inject.spi.AnnotatedMethod; | ||
| 56 | -import javax.enterprise.inject.spi.AnnotatedType; | ||
| 57 | -import javax.enterprise.inject.spi.BeanManager; | ||
| 58 | -import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
| 59 | - | ||
| 60 | -import org.easymock.EasyMock; | ||
| 61 | -import org.junit.Assert; | ||
| 62 | -import org.junit.Before; | ||
| 63 | -import org.junit.Test; | ||
| 64 | -import org.junit.runner.RunWith; | ||
| 65 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 66 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 67 | -import org.powermock.reflect.Whitebox; | ||
| 68 | - | ||
| 69 | -import br.gov.frameworkdemoiselle.annotation.ViewScoped; | ||
| 70 | -import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; | ||
| 71 | -import br.gov.frameworkdemoiselle.internal.context.Contexts; | ||
| 72 | -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; | ||
| 73 | -import br.gov.frameworkdemoiselle.internal.implementation.AnnotatedMethodProcessor; | ||
| 74 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 75 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 76 | -import br.gov.frameworkdemoiselle.lifecycle.Startup; | ||
| 77 | - | ||
| 78 | -@RunWith(PowerMockRunner.class) | ||
| 79 | -@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) | ||
| 80 | -public class AbstractLifecycleBootstrapTest { | ||
| 81 | - | ||
| 82 | - private ProcessAnnotatedType event; | ||
| 83 | - | ||
| 84 | - private BeanManager beanManager; | ||
| 85 | - | ||
| 86 | - private AnnotatedType annotatedType; | ||
| 87 | - | ||
| 88 | - private StartupBootstrap startupBootstrap; | ||
| 89 | - | ||
| 90 | - private ShutdownBootstrap shutdownBootstrap; | ||
| 91 | - | ||
| 92 | - private Class annotationClass; | ||
| 93 | - | ||
| 94 | - @Before | ||
| 95 | - public void before() { | ||
| 96 | - event = createMock(ProcessAnnotatedType.class); | ||
| 97 | - annotatedType = createMock(AnnotatedType.class); | ||
| 98 | - beanManager = null; | ||
| 99 | - annotationClass = null; | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - private List<AnnotatedMethodProcessor> getActions(AbstractLifecycleBootstrap bootstrap) | ||
| 103 | - throws IllegalArgumentException, IllegalAccessException { | ||
| 104 | - | ||
| 105 | - Field fields = Whitebox.getField(AbstractLifecycleBootstrap.class, "processors"); | ||
| 106 | - List<AnnotatedMethodProcessor> list = (List<AnnotatedMethodProcessor>) fields.get(bootstrap); | ||
| 107 | - return list; | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - @Test | ||
| 111 | - public void processAnnotatedTypeStartup() throws IllegalArgumentException, IllegalAccessException { | ||
| 112 | - startupBootstrap = new StartupBootstrap(); | ||
| 113 | - List<AnnotatedMethodProcessor> list = getActions(startupBootstrap); | ||
| 114 | - | ||
| 115 | - assertNotNull(list); | ||
| 116 | - assertTrue(list.isEmpty()); | ||
| 117 | - | ||
| 118 | - AnnotatedMethod am1 = createMock(AnnotatedMethod.class); | ||
| 119 | - AnnotatedMethod am2 = createMock(AnnotatedMethod.class); | ||
| 120 | - AnnotatedMethod am3 = createMock(AnnotatedMethod.class); | ||
| 121 | - | ||
| 122 | - Set<AnnotatedMethod> set = new HashSet<AnnotatedMethod>(); | ||
| 123 | - set.add(am1); | ||
| 124 | - set.add(am2); | ||
| 125 | - set.add(am3); | ||
| 126 | - | ||
| 127 | - expect(am1.isAnnotationPresent(Startup.class)).andReturn(true); | ||
| 128 | - expect(am2.isAnnotationPresent(Startup.class)).andReturn(true); | ||
| 129 | - expect(am3.isAnnotationPresent(Startup.class)).andReturn(false); | ||
| 130 | - expect(event.getAnnotatedType()).andReturn(annotatedType); | ||
| 131 | - expect(annotatedType.getMethods()).andReturn(set); | ||
| 132 | - | ||
| 133 | - EasyMock.replay(event, annotatedType, am1, am2, am3); | ||
| 134 | - startupBootstrap.processAnnotatedType(event); | ||
| 135 | - EasyMock.verify(event, annotatedType); | ||
| 136 | - | ||
| 137 | - list = getActions(startupBootstrap); | ||
| 138 | - assertNotNull(list); | ||
| 139 | - assertFalse(list.isEmpty()); | ||
| 140 | - assertTrue(list.size() == 2); | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - @Test | ||
| 144 | - public void testLoadTempContexts() { | ||
| 145 | - startupBootstrap = new StartupBootstrap(); | ||
| 146 | - | ||
| 147 | - List<ThreadLocalContext> tempContexts = Whitebox.getInternalState(startupBootstrap, "tempContexts"); | ||
| 148 | - | ||
| 149 | - assertNotNull(tempContexts); | ||
| 150 | - assertTrue(tempContexts.isEmpty()); | ||
| 151 | - | ||
| 152 | - replayAll(); | ||
| 153 | - startupBootstrap.loadTempContexts(null); | ||
| 154 | - verifyAll(); | ||
| 155 | - | ||
| 156 | - assertNotNull(tempContexts); | ||
| 157 | - Assert.assertEquals(4, tempContexts.size()); | ||
| 158 | - for (ThreadLocalContext tlc : tempContexts) { | ||
| 159 | - if (!tlc.getScope().equals(SessionScoped.class) && !tlc.getScope().equals(ConversationScoped.class) | ||
| 160 | - && !tlc.getScope().equals(RequestScoped.class) && !tlc.getScope().equals(ViewScoped.class)) { | ||
| 161 | - Assert.fail(); | ||
| 162 | - } | ||
| 163 | - } | ||
| 164 | - } | ||
| 165 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrapTest.java
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/MyStartupAnnotatedClass.java
| @@ -1,70 +0,0 @@ | @@ -1,70 +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 java.util.Stack; | ||
| 40 | - | ||
| 41 | -import br.gov.frameworkdemoiselle.annotation.Priority; | ||
| 42 | -import br.gov.frameworkdemoiselle.lifecycle.Startup; | ||
| 43 | - | ||
| 44 | -public class MyStartupAnnotatedClass { | ||
| 45 | - | ||
| 46 | - public static Stack<String> stackOfMethods = new Stack<String>(); | ||
| 47 | - | ||
| 48 | - @Startup | ||
| 49 | - @Priority(1) | ||
| 50 | - public void startMethod1(){ | ||
| 51 | - addMethodExecuted("startMethod1"); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - @Startup | ||
| 55 | - @Priority(1) | ||
| 56 | - public void startMethod2(){ | ||
| 57 | - addMethodExecuted("startMethod2"); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - @Startup | ||
| 61 | - @Priority(0) | ||
| 62 | - public void startMethod3(){ | ||
| 63 | - addMethodExecuted("startMethod3"); | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - private void addMethodExecuted(String name) { | ||
| 67 | - stackOfMethods.push(name); | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrapTest.java
| @@ -1,200 +0,0 @@ | @@ -1,200 +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.easymock.EasyMock.replay; | ||
| 41 | -//import static org.easymock.EasyMock.verify; | ||
| 42 | -//import static org.junit.Assert.assertFalse; | ||
| 43 | -//import static org.junit.Assert.assertNotNull; | ||
| 44 | -//import static org.junit.Assert.assertTrue; | ||
| 45 | -// | ||
| 46 | -//import java.lang.reflect.Field; | ||
| 47 | -//import java.util.ArrayList; | ||
| 48 | -//import java.util.HashSet; | ||
| 49 | -//import java.util.List; | ||
| 50 | -//import java.util.Locale; | ||
| 51 | -//import java.util.Set; | ||
| 52 | -// | ||
| 53 | -//import javax.enterprise.inject.spi.AfterBeanDiscovery; | ||
| 54 | -//import javax.enterprise.inject.spi.AnnotatedMethod; | ||
| 55 | -//import javax.enterprise.inject.spi.AnnotatedType; | ||
| 56 | -//import javax.enterprise.inject.spi.BeanManager; | ||
| 57 | -//import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
| 58 | -// | ||
| 59 | -//import org.easymock.EasyMock; | ||
| 60 | -//import org.junit.Before; | ||
| 61 | -//import org.junit.Ignore; | ||
| 62 | -//import org.junit.Test; | ||
| 63 | -//import org.junit.runner.RunWith; | ||
| 64 | -//import org.powermock.api.easymock.PowerMock; | ||
| 65 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 66 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
| 67 | -//import org.powermock.reflect.Whitebox; | ||
| 68 | -//import org.slf4j.Logger; | ||
| 69 | -// | ||
| 70 | -//import br.gov.frameworkdemoiselle.annotation.Shutdown; | ||
| 71 | -//import br.gov.frameworkdemoiselle.internal.context.Contexts; | ||
| 72 | -//import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; | ||
| 73 | -//import br.gov.frameworkdemoiselle.internal.processor.ShutdownProcessor; | ||
| 74 | -//import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 75 | -//import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 76 | -//import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 77 | -// | ||
| 78 | -//@Ignore | ||
| 79 | -//@RunWith(PowerMockRunner.class) | ||
| 80 | -//@PrepareForTest({ Contexts.class, LoggerProducer.class, ResourceBundle.class, ResourceBundleProducer.class }) | ||
| 81 | -//@SuppressWarnings("rawtypes") | ||
| 82 | -//public class ShutdownBootstrapTest { | ||
| 83 | -// | ||
| 84 | -// private ProcessAnnotatedType event; | ||
| 85 | -// | ||
| 86 | -// private BeanManager beanManager; | ||
| 87 | -// | ||
| 88 | -// private AnnotatedType annotatedType; | ||
| 89 | -// | ||
| 90 | -// @Before | ||
| 91 | -// public void before() { | ||
| 92 | -// event = EasyMock.createMock(ProcessAnnotatedType.class); | ||
| 93 | -// annotatedType = EasyMock.createMock(AnnotatedType.class); | ||
| 94 | -// beanManager = null; | ||
| 95 | -// } | ||
| 96 | -// | ||
| 97 | -// @SuppressWarnings("unchecked") | ||
| 98 | -// private List<ShutdownProcessor> getProcessors(ShutdownBootstrap bootstrap) throws IllegalArgumentException, | ||
| 99 | -// IllegalAccessException { | ||
| 100 | -// Set<Field> fields = Whitebox.getAllStaticFields(ShutdownBootstrap.class); | ||
| 101 | -// List<ShutdownProcessor> list = new ArrayList<ShutdownProcessor>(); | ||
| 102 | -// for (Field field : fields) { | ||
| 103 | -// if (field.getName().equals("processors")) { | ||
| 104 | -// list = (List<ShutdownProcessor>) field.get(bootstrap); | ||
| 105 | -// } | ||
| 106 | -// } | ||
| 107 | -// return list; | ||
| 108 | -// } | ||
| 109 | -// | ||
| 110 | -// @SuppressWarnings({ "unchecked" }) | ||
| 111 | -// @Test | ||
| 112 | -// public void processAnnotatedType() throws IllegalArgumentException, IllegalAccessException { | ||
| 113 | -// ShutdownBootstrap bootstrap = new ShutdownBootstrap(); | ||
| 114 | -// List<ShutdownProcessor> list = getProcessors(bootstrap); | ||
| 115 | -// | ||
| 116 | -// assertTrue(list.isEmpty()); | ||
| 117 | -// | ||
| 118 | -// AnnotatedMethod am1 = PowerMock.createMock(AnnotatedMethod.class); | ||
| 119 | -// AnnotatedMethod am2 = PowerMock.createMock(AnnotatedMethod.class); | ||
| 120 | -// AnnotatedMethod am3 = PowerMock.createMock(AnnotatedMethod.class); | ||
| 121 | -// | ||
| 122 | -// Set<AnnotatedMethod> set = new HashSet<AnnotatedMethod>(); | ||
| 123 | -// set.add(am1); | ||
| 124 | -// set.add(am2); | ||
| 125 | -// set.add(am3); | ||
| 126 | -// | ||
| 127 | -// expect(am1.isAnnotationPresent(Shutdown.class)).andReturn(true); | ||
| 128 | -// expect(am2.isAnnotationPresent(Shutdown.class)).andReturn(true); | ||
| 129 | -// expect(am3.isAnnotationPresent(Shutdown.class)).andReturn(false); | ||
| 130 | -// expect(event.getAnnotatedType()).andReturn(annotatedType); | ||
| 131 | -// expect(annotatedType.getMethods()).andReturn(set); | ||
| 132 | -// | ||
| 133 | -// replay(event, annotatedType, am1, am2, am3); | ||
| 134 | -// bootstrap.processAnnotatedType(event, beanManager); | ||
| 135 | -// verify(event, annotatedType); | ||
| 136 | -// | ||
| 137 | -// list = getProcessors(bootstrap); | ||
| 138 | -// assertNotNull(list); | ||
| 139 | -// assertFalse(list.isEmpty()); | ||
| 140 | -// assertTrue(list.size() == 2); | ||
| 141 | -// } | ||
| 142 | -// | ||
| 143 | -// @SuppressWarnings({ "unchecked", "static-access" }) | ||
| 144 | -// @Test | ||
| 145 | -// public void testShuttingDown() throws Throwable { | ||
| 146 | -// ShutdownBootstrap bootstrap = new ShutdownBootstrap(); | ||
| 147 | -// | ||
| 148 | -// PowerMock.mockStatic(Contexts.class); | ||
| 149 | -// PowerMock.mockStatic(LoggerProducer.class); | ||
| 150 | -// | ||
| 151 | -// Logger logger = PowerMock.createMock(Logger.class); | ||
| 152 | -// ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class); | ||
| 153 | -// ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class); | ||
| 154 | -// | ||
| 155 | -// expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger).anyTimes(); | ||
| 156 | -// expect(bundleFactory.create(EasyMock.anyObject(String.class), EasyMock.anyObject(Locale.class))).andReturn( | ||
| 157 | -// bundle).anyTimes(); | ||
| 158 | -// expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn("") | ||
| 159 | -// .anyTimes(); | ||
| 160 | -// | ||
| 161 | -// logger.debug(EasyMock.anyObject(String.class)); | ||
| 162 | -// logger.trace(EasyMock.anyObject(String.class)); | ||
| 163 | -// EasyMock.expectLastCall().anyTimes(); | ||
| 164 | -// | ||
| 165 | -// Whitebox.setInternalState(AbstractBootstrap.class, ResourceBundleProducer.class, bundleFactory); | ||
| 166 | -// | ||
| 167 | -// List<ShutdownProcessor> list = getProcessors(bootstrap); | ||
| 168 | -// list.clear(); | ||
| 169 | -// | ||
| 170 | -// MyShuttingDownProcessor<?> processor = PowerMock.createMock(MyShuttingDownProcessor.class); | ||
| 171 | -// list.add(processor); | ||
| 172 | -// expect(processor.process()).andReturn(true).times(1); | ||
| 173 | -// | ||
| 174 | -// Contexts.add(EasyMock.anyObject(ThreadLocalContext.class), EasyMock.anyObject(AfterBeanDiscovery.class)); | ||
| 175 | -// EasyMock.expectLastCall().anyTimes(); | ||
| 176 | -// | ||
| 177 | -// Contexts.remove(EasyMock.anyObject(ThreadLocalContext.class)); | ||
| 178 | -// EasyMock.expectLastCall().anyTimes(); | ||
| 179 | -// | ||
| 180 | -// PowerMock.replayAll(); | ||
| 181 | -// ShutdownBootstrap.shutdown(); | ||
| 182 | -// | ||
| 183 | -// assertTrue(list.isEmpty()); | ||
| 184 | -// PowerMock.verifyAll(); | ||
| 185 | -// } | ||
| 186 | -//} | ||
| 187 | -// | ||
| 188 | -//@SuppressWarnings("rawtypes") | ||
| 189 | -//class MyShuttingDownProcessor<T> extends ShutdownProcessor<T> { | ||
| 190 | -// | ||
| 191 | -// @SuppressWarnings("unchecked") | ||
| 192 | -// public MyShuttingDownProcessor(AnnotatedMethod annotatedMethod, BeanManager beanManager) { | ||
| 193 | -// super(annotatedMethod, beanManager); | ||
| 194 | -// } | ||
| 195 | -// | ||
| 196 | -// @Override | ||
| 197 | -// public int compareTo(final ShutdownProcessor<T> other) { | ||
| 198 | -// return 1; | ||
| 199 | -// } | ||
| 200 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrapTest.java
| @@ -1,262 +0,0 @@ | @@ -1,262 +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 junit.framework.Assert.assertEquals; | ||
| 40 | -//import static org.easymock.EasyMock.expect; | ||
| 41 | -//import static org.easymock.EasyMock.replay; | ||
| 42 | -//import static org.easymock.EasyMock.verify; | ||
| 43 | -//import static org.junit.Assert.assertFalse; | ||
| 44 | -//import static org.junit.Assert.assertNotNull; | ||
| 45 | -//import static org.junit.Assert.assertTrue; | ||
| 46 | -//import static org.junit.Assert.fail; | ||
| 47 | -// | ||
| 48 | -//import java.lang.reflect.Field; | ||
| 49 | -//import java.util.HashSet; | ||
| 50 | -//import java.util.List; | ||
| 51 | -//import java.util.Locale; | ||
| 52 | -//import java.util.Set; | ||
| 53 | -// | ||
| 54 | -//import javax.enterprise.context.ConversationScoped; | ||
| 55 | -//import javax.enterprise.context.RequestScoped; | ||
| 56 | -//import javax.enterprise.context.SessionScoped; | ||
| 57 | -//import javax.enterprise.inject.spi.AfterBeanDiscovery; | ||
| 58 | -//import javax.enterprise.inject.spi.AnnotatedMethod; | ||
| 59 | -//import javax.enterprise.inject.spi.AnnotatedType; | ||
| 60 | -//import javax.enterprise.inject.spi.BeanManager; | ||
| 61 | -//import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
| 62 | -// | ||
| 63 | -//import junit.framework.Assert; | ||
| 64 | -// | ||
| 65 | -//import org.easymock.EasyMock; | ||
| 66 | -//import org.junit.Before; | ||
| 67 | -//import org.junit.Ignore; | ||
| 68 | -//import org.junit.Test; | ||
| 69 | -//import org.junit.runner.RunWith; | ||
| 70 | -//import org.powermock.api.easymock.PowerMock; | ||
| 71 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 72 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
| 73 | -//import org.powermock.reflect.Whitebox; | ||
| 74 | -//import org.slf4j.Logger; | ||
| 75 | -// | ||
| 76 | -//import br.gov.frameworkdemoiselle.annotation.Startup; | ||
| 77 | -//import br.gov.frameworkdemoiselle.annotation.ViewScoped; | ||
| 78 | -//import br.gov.frameworkdemoiselle.internal.context.Contexts; | ||
| 79 | -//import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; | ||
| 80 | -//import br.gov.frameworkdemoiselle.internal.processor.StartupProcessor; | ||
| 81 | -//import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
| 82 | -//import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 83 | -//import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 84 | -// | ||
| 85 | -//@Ignore | ||
| 86 | -//@RunWith(PowerMockRunner.class) | ||
| 87 | -//@PrepareForTest({ Contexts.class, LoggerProducer.class, ResourceBundle.class, ResourceBundleProducer.class }) | ||
| 88 | -//@SuppressWarnings({ "rawtypes", "unchecked" }) | ||
| 89 | -//public class StartupBootstrapTest { | ||
| 90 | -// | ||
| 91 | -// private ProcessAnnotatedType event; | ||
| 92 | -// | ||
| 93 | -// private BeanManager beanManager; | ||
| 94 | -// | ||
| 95 | -// private AnnotatedType annotatedType; | ||
| 96 | -// | ||
| 97 | -// @Before | ||
| 98 | -// public void before() { | ||
| 99 | -// event = EasyMock.createMock(ProcessAnnotatedType.class); | ||
| 100 | -// annotatedType = EasyMock.createMock(AnnotatedType.class); | ||
| 101 | -// beanManager = null; | ||
| 102 | -// } | ||
| 103 | -// | ||
| 104 | -// private List<StartupProcessor> getActions(StartupBootstrap bootstrap) throws IllegalArgumentException, | ||
| 105 | -// IllegalAccessException { | ||
| 106 | -// Set<Field> fields = Whitebox.getAllStaticFields(StartupBootstrap.class); | ||
| 107 | -// List<StartupProcessor> list = null; | ||
| 108 | -// for (Field field : fields) { | ||
| 109 | -// if (field.getName().equals("processors")) { | ||
| 110 | -// list = (List<StartupProcessor>) field.get(bootstrap); | ||
| 111 | -// } | ||
| 112 | -// } | ||
| 113 | -// return list; | ||
| 114 | -// } | ||
| 115 | -// | ||
| 116 | -// @Test | ||
| 117 | -// public void processAnnotatedType() throws IllegalArgumentException, IllegalAccessException { | ||
| 118 | -// StartupBootstrap bootstrap = new StartupBootstrap(); | ||
| 119 | -// List<StartupProcessor> list = getActions(bootstrap); | ||
| 120 | -// | ||
| 121 | -// assertNotNull(list); | ||
| 122 | -// assertTrue(list.isEmpty()); | ||
| 123 | -// | ||
| 124 | -// AnnotatedMethod am1 = PowerMock.createMock(AnnotatedMethod.class); | ||
| 125 | -// AnnotatedMethod am2 = PowerMock.createMock(AnnotatedMethod.class); | ||
| 126 | -// AnnotatedMethod am3 = PowerMock.createMock(AnnotatedMethod.class); | ||
| 127 | -// | ||
| 128 | -// Set<AnnotatedMethod> set = new HashSet<AnnotatedMethod>(); | ||
| 129 | -// set.add(am1); | ||
| 130 | -// set.add(am2); | ||
| 131 | -// set.add(am3); | ||
| 132 | -// | ||
| 133 | -// expect(am1.isAnnotationPresent(Startup.class)).andReturn(true); | ||
| 134 | -// expect(am2.isAnnotationPresent(Startup.class)).andReturn(true); | ||
| 135 | -// expect(am3.isAnnotationPresent(Startup.class)).andReturn(false); | ||
| 136 | -// expect(event.getAnnotatedType()).andReturn(annotatedType); | ||
| 137 | -// expect(annotatedType.getMethods()).andReturn(set); | ||
| 138 | -// | ||
| 139 | -// replay(event, annotatedType, am1, am2, am3); | ||
| 140 | -// bootstrap.processAnnotatedType(event, beanManager); | ||
| 141 | -// verify(event, annotatedType); | ||
| 142 | -// | ||
| 143 | -// list = getActions(bootstrap); | ||
| 144 | -// assertNotNull(list); | ||
| 145 | -// assertFalse(list.isEmpty()); | ||
| 146 | -// assertTrue(list.size() == 2); | ||
| 147 | -// } | ||
| 148 | -// | ||
| 149 | -// @SuppressWarnings("static-access") | ||
| 150 | -// @Test | ||
| 151 | -// public void testLoadTempContexts() { | ||
| 152 | -// StartupBootstrap bootstrap = new StartupBootstrap(); | ||
| 153 | -// | ||
| 154 | -// Logger logger = PowerMock.createMock(Logger.class); | ||
| 155 | -// ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class); | ||
| 156 | -// ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class); | ||
| 157 | -// | ||
| 158 | -// PowerMock.mockStatic(Contexts.class); | ||
| 159 | -// PowerMock.mockStatic(LoggerProducer.class); | ||
| 160 | -// | ||
| 161 | -// List<ThreadLocalContext> tempContexts = Whitebox.getInternalState(bootstrap, "tempContexts"); | ||
| 162 | -// | ||
| 163 | -// assertNotNull(tempContexts); | ||
| 164 | -// assertTrue(tempContexts.isEmpty()); | ||
| 165 | -// | ||
| 166 | -// expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger).anyTimes(); | ||
| 167 | -// expect(bundleFactory.create(EasyMock.anyObject(String.class), EasyMock.anyObject(Locale.class))).andReturn( | ||
| 168 | -// bundle).anyTimes(); | ||
| 169 | -// expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn("") | ||
| 170 | -// .anyTimes(); | ||
| 171 | -// | ||
| 172 | -// logger.trace(EasyMock.anyObject(String.class)); | ||
| 173 | -// EasyMock.expectLastCall().anyTimes(); | ||
| 174 | -// | ||
| 175 | -// Contexts.add(EasyMock.anyObject(ThreadLocalContext.class), EasyMock.anyObject(AfterBeanDiscovery.class)); | ||
| 176 | -// EasyMock.expectLastCall().anyTimes(); | ||
| 177 | -// | ||
| 178 | -// Whitebox.setInternalState(AbstractBootstrap.class, ResourceBundleProducer.class, bundleFactory); | ||
| 179 | -// | ||
| 180 | -// PowerMock.replayAll(); | ||
| 181 | -// bootstrap.loadTempContexts(null); | ||
| 182 | -// PowerMock.verifyAll(); | ||
| 183 | -// | ||
| 184 | -// assertNotNull(tempContexts); | ||
| 185 | -// assertEquals(4, tempContexts.size()); | ||
| 186 | -// | ||
| 187 | -// for (ThreadLocalContext tlc : tempContexts) { | ||
| 188 | -// if (!tlc.getScope().equals(SessionScoped.class) && !tlc.getScope().equals(ConversationScoped.class) | ||
| 189 | -// && !tlc.getScope().equals(RequestScoped.class) && !tlc.getScope().equals(ViewScoped.class)) { | ||
| 190 | -// fail(); | ||
| 191 | -// } | ||
| 192 | -// } | ||
| 193 | -// } | ||
| 194 | -// | ||
| 195 | -// @SuppressWarnings("static-access") | ||
| 196 | -// @Test | ||
| 197 | -// public void testStartup() throws Throwable { | ||
| 198 | -// StartupBootstrap bootstrap = new StartupBootstrap(); | ||
| 199 | -// | ||
| 200 | -// PowerMock.mockStatic(Contexts.class); | ||
| 201 | -// PowerMock.mockStatic(LoggerProducer.class); | ||
| 202 | -// | ||
| 203 | -// Logger logger = PowerMock.createMock(Logger.class); | ||
| 204 | -// ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class); | ||
| 205 | -// ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class); | ||
| 206 | -// | ||
| 207 | -// expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger).anyTimes(); | ||
| 208 | -// expect(bundleFactory.create(EasyMock.anyObject(String.class), EasyMock.anyObject(Locale.class))).andReturn( | ||
| 209 | -// bundle).anyTimes(); | ||
| 210 | -// expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn("") | ||
| 211 | -// .anyTimes(); | ||
| 212 | -// | ||
| 213 | -// logger.debug(EasyMock.anyObject(String.class)); | ||
| 214 | -// EasyMock.expectLastCall().anyTimes(); | ||
| 215 | -// | ||
| 216 | -// Whitebox.setInternalState(AbstractBootstrap.class, ResourceBundleProducer.class, bundleFactory); | ||
| 217 | -// | ||
| 218 | -// List<StartupProcessor> list = getActions(bootstrap); | ||
| 219 | -// list.clear(); | ||
| 220 | -// | ||
| 221 | -// MyProcessor<?> processor = PowerMock.createMock(MyProcessor.class); | ||
| 222 | -// list.add(processor); | ||
| 223 | -// expect(processor.process()).andReturn(true).times(1); | ||
| 224 | -// | ||
| 225 | -// PowerMock.replayAll(); | ||
| 226 | -// bootstrap.startup(); | ||
| 227 | -// | ||
| 228 | -// assertTrue(list.isEmpty()); | ||
| 229 | -// PowerMock.verifyAll(); | ||
| 230 | -// } | ||
| 231 | -// | ||
| 232 | -// @SuppressWarnings("static-access") | ||
| 233 | -// @Test | ||
| 234 | -// public void testLoadTempContextsAndStartup() { | ||
| 235 | -// | ||
| 236 | -// StartupBootstrap bootstrap = new StartupBootstrap(); | ||
| 237 | -// | ||
| 238 | -// bootstrap.loadTempContexts(null); | ||
| 239 | -// Assert.assertFalse(Contexts.getActiveContexts().isEmpty()); | ||
| 240 | -// | ||
| 241 | -// try { | ||
| 242 | -// bootstrap.startup(); | ||
| 243 | -// Assert.assertTrue(Contexts.getActiveContexts().isEmpty()); | ||
| 244 | -// } catch (Throwable e) { | ||
| 245 | -// fail(); | ||
| 246 | -// } | ||
| 247 | -// } | ||
| 248 | -//} | ||
| 249 | -// | ||
| 250 | -//@SuppressWarnings("rawtypes") | ||
| 251 | -//class MyProcessor<T> extends StartupProcessor<T> { | ||
| 252 | -// | ||
| 253 | -// @SuppressWarnings("unchecked") | ||
| 254 | -// public MyProcessor(AnnotatedMethod annotatedMethod, BeanManager beanManager) { | ||
| 255 | -// super(annotatedMethod, beanManager); | ||
| 256 | -// } | ||
| 257 | -// | ||
| 258 | -// @Override | ||
| 259 | -// public int compareTo(final StartupProcessor<T> other) { | ||
| 260 | -// return 1; | ||
| 261 | -// } | ||
| 262 | -// } |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassExtendsFromClassThanImplementsTransactionInterface.java
| @@ -1,44 +0,0 @@ | @@ -1,44 +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.configuration; | ||
| 38 | - | ||
| 39 | - | ||
| 40 | -public class ClassExtendsFromClassThanImplementsTransactionInterface extends ClassImplementsTransactionInterface{ | ||
| 41 | - | ||
| 42 | - private static final long serialVersionUID = 1L; | ||
| 43 | - | ||
| 44 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassImplementsTransactionInterface.java
| @@ -1,80 +0,0 @@ | @@ -1,80 +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.configuration; | ||
| 38 | - | ||
| 39 | -import br.gov.frameworkdemoiselle.transaction.Transaction; | ||
| 40 | - | ||
| 41 | -public class ClassImplementsTransactionInterface implements Transaction { | ||
| 42 | - | ||
| 43 | - private static final long serialVersionUID = 1L; | ||
| 44 | - | ||
| 45 | - @Override | ||
| 46 | - public void begin() { | ||
| 47 | - // TODO Auto-generated method stub | ||
| 48 | - | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - @Override | ||
| 52 | - public void commit() { | ||
| 53 | - // TODO Auto-generated method stub | ||
| 54 | - | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - @Override | ||
| 58 | - public void rollback() { | ||
| 59 | - // TODO Auto-generated method stub | ||
| 60 | - | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - @Override | ||
| 64 | - public void setRollbackOnly() { | ||
| 65 | - // TODO Auto-generated method stub | ||
| 66 | - | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - @Override | ||
| 70 | - public boolean isActive() { | ||
| 71 | - // TODO Auto-generated method stub | ||
| 72 | - return false; | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - @Override | ||
| 76 | - public boolean isMarkedRollback() { | ||
| 77 | - // TODO Auto-generated method stub | ||
| 78 | - return false; | ||
| 79 | - } | ||
| 80 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassThanImplementsInterfaceThanExtendsFromTransactionInterface.java
| @@ -1,79 +0,0 @@ | @@ -1,79 +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.configuration; | ||
| 38 | - | ||
| 39 | -public class ClassThanImplementsInterfaceThanExtendsFromTransactionInterface implements | ||
| 40 | - InterfaceExtendsFromTransactionInterface { | ||
| 41 | - | ||
| 42 | - private static final long serialVersionUID = 1L; | ||
| 43 | - | ||
| 44 | - @Override | ||
| 45 | - public boolean isActive() { | ||
| 46 | - // TODO Auto-generated method stub | ||
| 47 | - return false; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - @Override | ||
| 51 | - public boolean isMarkedRollback() { | ||
| 52 | - // TODO Auto-generated method stub | ||
| 53 | - return false; | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - @Override | ||
| 57 | - public void begin() { | ||
| 58 | - // TODO Auto-generated method stub | ||
| 59 | - | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - @Override | ||
| 63 | - public void commit() { | ||
| 64 | - // TODO Auto-generated method stub | ||
| 65 | - | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - @Override | ||
| 69 | - public void rollback() { | ||
| 70 | - // TODO Auto-generated method stub | ||
| 71 | - | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - @Override | ||
| 75 | - public void setRollbackOnly() { | ||
| 76 | - // TODO Auto-generated method stub | ||
| 77 | - | ||
| 78 | - } | ||
| 79 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java
| @@ -1,523 +0,0 @@ | @@ -1,523 +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.configuration; | ||
| 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.junit.Assert.fail; | ||
| 44 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 45 | -// | ||
| 46 | -//import java.util.Locale; | ||
| 47 | -//import java.util.Properties; | ||
| 48 | -// | ||
| 49 | -//import javax.validation.constraints.NotNull; | ||
| 50 | -// | ||
| 51 | -//import org.junit.After; | ||
| 52 | -//import org.junit.Before; | ||
| 53 | -//import org.junit.Test; | ||
| 54 | -//import org.junit.runner.RunWith; | ||
| 55 | -//import org.powermock.api.easymock.PowerMock; | ||
| 56 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 57 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
| 58 | -// | ||
| 59 | -//import br.gov.frameworkdemoiselle.annotation.Ignore; | ||
| 60 | -//import br.gov.frameworkdemoiselle.annotation.Name; | ||
| 61 | -//import br.gov.frameworkdemoiselle.configuration.ConfigType; | ||
| 62 | -//import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 63 | -//import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | ||
| 64 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
| 65 | -// | ||
| 66 | -//@RunWith(PowerMockRunner.class) | ||
| 67 | -//@PrepareForTest(Beans.class) | ||
| 68 | -//public class ConfigurationLoaderTest { | ||
| 69 | -// | ||
| 70 | -// private ConfigurationLoader configurationLoader; | ||
| 71 | -// | ||
| 72 | -// private CoreBootstrap coreBootstrap; | ||
| 73 | -// | ||
| 74 | -// @Configuration | ||
| 75 | -// public class ConfigurationSuccessfulPropertiesWithClassField { | ||
| 76 | -// | ||
| 77 | -// protected Class<?> classe; | ||
| 78 | -// | ||
| 79 | -// } | ||
| 80 | -// | ||
| 81 | -// @Configuration | ||
| 82 | -// public class ConfigurationSuccessfulPropertiesWithPropertiesField { | ||
| 83 | -// | ||
| 84 | -// protected Properties properties; | ||
| 85 | -// | ||
| 86 | -// } | ||
| 87 | -// | ||
| 88 | -// @Configuration | ||
| 89 | -// public class ConfigurationSuccessfulProperties { | ||
| 90 | -// | ||
| 91 | -// @Name("frameworkdemoiselle.configurationtest.nameConfiguration") | ||
| 92 | -// protected String nameConfiguration; | ||
| 93 | -// | ||
| 94 | -// } | ||
| 95 | -// | ||
| 96 | -// @Configuration | ||
| 97 | -// public class ConfigurationSuccessfulProperties2 { | ||
| 98 | -// | ||
| 99 | -// @Name("frameworkdemoiselle.configurationtest.name") | ||
| 100 | -// protected String name; | ||
| 101 | -// | ||
| 102 | -// } | ||
| 103 | -// | ||
| 104 | -// @Configuration(resource = "absentFile") | ||
| 105 | -// public class ConfigurationPropertiesWithAbsentFile { | ||
| 106 | -// | ||
| 107 | -// @Name("frameworkdemoiselle.configurationtest.nameConfiguration") | ||
| 108 | -// protected String nameConfiguration; | ||
| 109 | -// | ||
| 110 | -// } | ||
| 111 | -// | ||
| 112 | -// @Configuration | ||
| 113 | -// public class ConfigurationWithEmptyName { | ||
| 114 | -// | ||
| 115 | -// @Name("") | ||
| 116 | -// protected String nameConfiguration; | ||
| 117 | -// | ||
| 118 | -// } | ||
| 119 | -// | ||
| 120 | -// @Configuration | ||
| 121 | -// public class ConfigurationWithoutNameAnnotation { | ||
| 122 | -// | ||
| 123 | -// protected String nameConfiguration; | ||
| 124 | -// | ||
| 125 | -// } | ||
| 126 | -// | ||
| 127 | -// @Configuration | ||
| 128 | -// public class ConfigurationWithIgnoreAnnotation { | ||
| 129 | -// | ||
| 130 | -// @Ignore | ||
| 131 | -// protected String nameConfiguration; | ||
| 132 | -// | ||
| 133 | -// } | ||
| 134 | -// | ||
| 135 | -// @Configuration(prefix = "frameworkdemoiselle.configurationtest.") | ||
| 136 | -// public class ConfigurationWithPrefix { | ||
| 137 | -// | ||
| 138 | -// @Name("nameConfiguration") | ||
| 139 | -// protected String nameConfiguration; | ||
| 140 | -// | ||
| 141 | -// } | ||
| 142 | -// | ||
| 143 | -// @Configuration | ||
| 144 | -// public class ConfigurationWithKeyNotFoundInProperties { | ||
| 145 | -// | ||
| 146 | -// protected Integer notExistKey; | ||
| 147 | -// } | ||
| 148 | -// | ||
| 149 | -// @Configuration | ||
| 150 | -// public class ConfigurationWithNotNullFieldButValueIsNull { | ||
| 151 | -// | ||
| 152 | -// @Name("notexistKey") | ||
| 153 | -// @NotNull | ||
| 154 | -// protected int nameConfiguration; | ||
| 155 | -// | ||
| 156 | -// } | ||
| 157 | -// | ||
| 158 | -// @Configuration | ||
| 159 | -// public class ConfigurationWithNotNullFieldAndValueIsNotNull { | ||
| 160 | -// | ||
| 161 | -// @Name("nameConfiguration") | ||
| 162 | -// @NotNull | ||
| 163 | -// protected String nameConfiguration; | ||
| 164 | -// | ||
| 165 | -// } | ||
| 166 | -// | ||
| 167 | -// @Configuration | ||
| 168 | -// public class ConfigurationWithNonPrimitiveFieldValueNull { | ||
| 169 | -// | ||
| 170 | -// @Name("notexistKey") | ||
| 171 | -// protected String nameConfiguration; | ||
| 172 | -// | ||
| 173 | -// } | ||
| 174 | -// | ||
| 175 | -// @Configuration | ||
| 176 | -// public class ConfigurationWithPrimitiveFieldValueNull { | ||
| 177 | -// | ||
| 178 | -// @Name("notexistKey") | ||
| 179 | -// protected int nameConfiguration = 1; | ||
| 180 | -// | ||
| 181 | -// } | ||
| 182 | -// | ||
| 183 | -// @Configuration(type = ConfigType.SYSTEM) | ||
| 184 | -// public class ConfigurationWithKeyFromSystem { | ||
| 185 | -// | ||
| 186 | -// @Name("os.name") | ||
| 187 | -// protected String nameConfiguration; | ||
| 188 | -// | ||
| 189 | -// } | ||
| 190 | -// | ||
| 191 | -// @Configuration(type = ConfigType.XML) | ||
| 192 | -// public class ConfigurationWithKeyFromXML { | ||
| 193 | -// | ||
| 194 | -// @Name("nameConfiguration") | ||
| 195 | -// protected String nameConfiguration; | ||
| 196 | -// | ||
| 197 | -// } | ||
| 198 | -// | ||
| 199 | -// @Configuration(type = ConfigType.XML, prefix = "br.gov.frameworkdemoiselle") | ||
| 200 | -// public class ConfigurationFromXMLWithPrefix { | ||
| 201 | -// | ||
| 202 | -// @Name("nameConfiguration") | ||
| 203 | -// protected String nameConfiguration; | ||
| 204 | -// | ||
| 205 | -// } | ||
| 206 | -// | ||
| 207 | -// @Configuration | ||
| 208 | -// public class ConfigurationWithConventionAllUpperCase { | ||
| 209 | -// | ||
| 210 | -// protected String conventionAllUpperCase; | ||
| 211 | -// | ||
| 212 | -// } | ||
| 213 | -// | ||
| 214 | -// @Configuration(type = ConfigType.XML) | ||
| 215 | -// public class ConfigurationXMLWithConventionAllUpperCase { | ||
| 216 | -// | ||
| 217 | -// protected String conventionAllUpperCase; | ||
| 218 | -// | ||
| 219 | -// } | ||
| 220 | -// | ||
| 221 | -// @Configuration | ||
| 222 | -// public class ConfigurationWithConventionAllLowerCase { | ||
| 223 | -// | ||
| 224 | -// protected String conventionAllLowerCase; | ||
| 225 | -// | ||
| 226 | -// } | ||
| 227 | -// | ||
| 228 | -// @Configuration(type = ConfigType.XML) | ||
| 229 | -// public class ConfigurationXMLWithConventionAllLowerCase { | ||
| 230 | -// | ||
| 231 | -// protected String conventionAllLowerCase; | ||
| 232 | -// | ||
| 233 | -// } | ||
| 234 | -// | ||
| 235 | -// @Configuration(prefix = "br.gov.frameworkdemoiselle.") | ||
| 236 | -// public class ConfigurationPropertiesSuccessWithPrefixNonAmbiguous { | ||
| 237 | -// | ||
| 238 | -// protected String success; | ||
| 239 | -// | ||
| 240 | -// } | ||
| 241 | -// | ||
| 242 | -// @Configuration | ||
| 243 | -// public class ConfigurationPropertiesErrorWithComplexObject { | ||
| 244 | -// | ||
| 245 | -// protected ConfigurationWithConventionAllLowerCase complexObject; | ||
| 246 | -// } | ||
| 247 | -// | ||
| 248 | -// @Before | ||
| 249 | -// public void setUp() throws Exception { | ||
| 250 | -// this.configurationLoader = new ConfigurationLoader(); | ||
| 251 | -// mockStatic(Beans.class); | ||
| 252 | -// this.coreBootstrap = PowerMock.createMock(CoreBootstrap.class); | ||
| 253 | -// | ||
| 254 | -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); | ||
| 255 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 256 | -// } | ||
| 257 | -// | ||
| 258 | -// @After | ||
| 259 | -// public void tearDown() throws Exception { | ||
| 260 | -// } | ||
| 261 | -// | ||
| 262 | -// @Test | ||
| 263 | -// public void testConfigurationSuccessfulPropertiesWithClassField() { | ||
| 264 | -// ConfigurationSuccessfulPropertiesWithClassField config = new ConfigurationSuccessfulPropertiesWithClassField(); | ||
| 265 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 266 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 267 | -// configurationLoader.load(config); | ||
| 268 | -// assertEquals(ConfigurationLoaderTest.class, config.classe); | ||
| 269 | -// } | ||
| 270 | -// | ||
| 271 | -// @Test | ||
| 272 | -// public void testConfigurationSuccessfulPropertiesWithPropertiesField() { | ||
| 273 | -// ConfigurationSuccessfulPropertiesWithPropertiesField config = new ConfigurationSuccessfulPropertiesWithPropertiesField(); | ||
| 274 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 275 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 276 | -// configurationLoader.load(config); | ||
| 277 | -// assertEquals("teste1", config.properties.getProperty("1")); | ||
| 278 | -// assertEquals("teste2", config.properties.getProperty("2")); | ||
| 279 | -// assertTrue(config.properties.containsKey("1")); | ||
| 280 | -// assertTrue(config.properties.containsKey("2")); | ||
| 281 | -// } | ||
| 282 | -// | ||
| 283 | -// @Test | ||
| 284 | -// public void testConfigurationSuccessfulPropertiesPossibleConventions() { | ||
| 285 | -// ConfigurationSuccessfulProperties config = new ConfigurationSuccessfulProperties(); | ||
| 286 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 287 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 288 | -// configurationLoader.load(config); | ||
| 289 | -// assertEquals("ConfigurationTest", config.nameConfiguration); | ||
| 290 | -// | ||
| 291 | -// } | ||
| 292 | -// | ||
| 293 | -// @Test | ||
| 294 | -// public void testConfigurationSuccessfulPropertiesNoConventions() { | ||
| 295 | -// ConfigurationSuccessfulProperties2 config = new ConfigurationSuccessfulProperties2(); | ||
| 296 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 297 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 298 | -// configurationLoader.load(config); | ||
| 299 | -// assertEquals("ConfigurationTest2", config.name); | ||
| 300 | -// } | ||
| 301 | -// | ||
| 302 | -// // @Test | ||
| 303 | -// // public void ConfigurationPropertiesWithAbsentFile() { | ||
| 304 | -// // ConfigurationPropertiesWithAbsentFile config = new ConfigurationPropertiesWithAbsentFile(); | ||
| 305 | -// // | ||
| 306 | -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 307 | -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 308 | -// // | ||
| 309 | -// // try { | ||
| 310 | -// // configurationLoader.load(config); | ||
| 311 | -// // fail(); | ||
| 312 | -// // } catch (Exception e) { | ||
| 313 | -// // } | ||
| 314 | -// // } | ||
| 315 | -// | ||
| 316 | -// @Test | ||
| 317 | -// public void testConfigurationProcessorWithNameEmpty() { | ||
| 318 | -// ConfigurationWithEmptyName config = new ConfigurationWithEmptyName(); | ||
| 319 | -// | ||
| 320 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 321 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 322 | -// | ||
| 323 | -// try { | ||
| 324 | -// configurationLoader.load(config); | ||
| 325 | -// fail(); | ||
| 326 | -// } catch (Exception e) { | ||
| 327 | -// } | ||
| 328 | -// } | ||
| 329 | -// | ||
| 330 | -// @Test | ||
| 331 | -// public void testConfigurationWithoutNameAnnotation() { | ||
| 332 | -// ConfigurationWithoutNameAnnotation config = new ConfigurationWithoutNameAnnotation(); | ||
| 333 | -// | ||
| 334 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 335 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 336 | -// | ||
| 337 | -// configurationLoader.load(config); | ||
| 338 | -// assertEquals("ConfigurationTest", config.nameConfiguration); | ||
| 339 | -// } | ||
| 340 | -// | ||
| 341 | -// @Test | ||
| 342 | -// public void testConfigurationWithIgnoreAnnotation() { | ||
| 343 | -// ConfigurationWithIgnoreAnnotation config = new ConfigurationWithIgnoreAnnotation(); | ||
| 344 | -// | ||
| 345 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 346 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 347 | -// | ||
| 348 | -// configurationLoader.load(config); | ||
| 349 | -// assertNull(config.nameConfiguration); | ||
| 350 | -// } | ||
| 351 | -// | ||
| 352 | -// @Test | ||
| 353 | -// public void testConfigurationWithPrefix() { | ||
| 354 | -// ConfigurationWithPrefix config = new ConfigurationWithPrefix(); | ||
| 355 | -// | ||
| 356 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 357 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 358 | -// | ||
| 359 | -// configurationLoader.load(config); | ||
| 360 | -// assertEquals("ConfigurationTest", config.nameConfiguration); | ||
| 361 | -// } | ||
| 362 | -// | ||
| 363 | -// @Test | ||
| 364 | -// public void testConfigurationWithKeyNotFoundInProperties() { | ||
| 365 | -// ConfigurationWithKeyNotFoundInProperties config = new ConfigurationWithKeyNotFoundInProperties(); | ||
| 366 | -// | ||
| 367 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 368 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 369 | -// | ||
| 370 | -// configurationLoader.load(config); | ||
| 371 | -// assertNull(config.notExistKey); | ||
| 372 | -// } | ||
| 373 | -// | ||
| 374 | -// @Test | ||
| 375 | -// public void testConfigurationWithNotNullFieldButValueIsNull() { | ||
| 376 | -// ConfigurationWithNotNullFieldButValueIsNull config = new ConfigurationWithNotNullFieldButValueIsNull(); | ||
| 377 | -// | ||
| 378 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 379 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 380 | -// | ||
| 381 | -// try { | ||
| 382 | -// configurationLoader.load(config); | ||
| 383 | -// fail(); | ||
| 384 | -// } catch (Exception e) { | ||
| 385 | -// assertTrue(true); | ||
| 386 | -// } | ||
| 387 | -// } | ||
| 388 | -// | ||
| 389 | -// @Test | ||
| 390 | -// public void testConfigurationWithNotNullFieldAndValueIsNotNull() { | ||
| 391 | -// ConfigurationWithNotNullFieldAndValueIsNotNull config = new ConfigurationWithNotNullFieldAndValueIsNotNull(); | ||
| 392 | -// | ||
| 393 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 394 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 395 | -// | ||
| 396 | -// configurationLoader.load(config); | ||
| 397 | -// assertEquals("ConfigurationTest", config.nameConfiguration); | ||
| 398 | -// } | ||
| 399 | -// | ||
| 400 | -// @Test | ||
| 401 | -// public void testConfigurationWithNonPrimitiveFieldValueNull() { | ||
| 402 | -// ConfigurationWithNonPrimitiveFieldValueNull config = new ConfigurationWithNonPrimitiveFieldValueNull(); | ||
| 403 | -// | ||
| 404 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 405 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 406 | -// | ||
| 407 | -// configurationLoader.load(config); | ||
| 408 | -// assertNull(config.nameConfiguration); | ||
| 409 | -// } | ||
| 410 | -// | ||
| 411 | -// @Test | ||
| 412 | -// public void testConfigurationWithPrimitiveFieldValueNull() { | ||
| 413 | -// ConfigurationWithPrimitiveFieldValueNull config = new ConfigurationWithPrimitiveFieldValueNull(); | ||
| 414 | -// | ||
| 415 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 416 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 417 | -// | ||
| 418 | -// configurationLoader.load(config); | ||
| 419 | -// assertEquals(1, config.nameConfiguration); | ||
| 420 | -// } | ||
| 421 | -// | ||
| 422 | -// @Test | ||
| 423 | -// public void testConfigurationWithKeyFromSystem() { | ||
| 424 | -// ConfigurationWithKeyFromSystem config = new ConfigurationWithKeyFromSystem(); | ||
| 425 | -// | ||
| 426 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 427 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 428 | -// | ||
| 429 | -// configurationLoader.load(config); | ||
| 430 | -// assertEquals(System.getProperty("os.name"), config.nameConfiguration); | ||
| 431 | -// } | ||
| 432 | -// | ||
| 433 | -// @Test | ||
| 434 | -// public void testConfigurationWithKeyFromXML() { | ||
| 435 | -// ConfigurationWithKeyFromXML config = new ConfigurationWithKeyFromXML(); | ||
| 436 | -// | ||
| 437 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 438 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 439 | -// | ||
| 440 | -// configurationLoader.load(config); | ||
| 441 | -// assertEquals("ConfigurationTest", config.nameConfiguration); | ||
| 442 | -// } | ||
| 443 | -// | ||
| 444 | -// @Test | ||
| 445 | -// public void testConfigurationWithPrefixNotAmbiguous() { | ||
| 446 | -// ConfigurationPropertiesSuccessWithPrefixNonAmbiguous config = new ConfigurationPropertiesSuccessWithPrefixNonAmbiguous(); | ||
| 447 | -// | ||
| 448 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 449 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 450 | -// | ||
| 451 | -// configurationLoader.load(config); | ||
| 452 | -// assertEquals("Success", config.success); | ||
| 453 | -// } | ||
| 454 | -// | ||
| 455 | -// // @Test | ||
| 456 | -// // public void testConfigurationWithConventionAllLowerCase() { | ||
| 457 | -// // ConfigurationWithConventionAllLowerCase config = new ConfigurationWithConventionAllLowerCase(); | ||
| 458 | -// // | ||
| 459 | -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 460 | -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 461 | -// // | ||
| 462 | -// // configurationLoader.load(config); | ||
| 463 | -// // assertEquals("All LowerCase", config.conventionAllLowerCase); | ||
| 464 | -// // } | ||
| 465 | -// | ||
| 466 | -// // @Test | ||
| 467 | -// // public void testConfigurationWithConventionAllUpperCase() { | ||
| 468 | -// // ConfigurationWithConventionAllUpperCase config = new ConfigurationWithConventionAllUpperCase(); | ||
| 469 | -// // | ||
| 470 | -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 471 | -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 472 | -// // | ||
| 473 | -// // configurationLoader.load(config); | ||
| 474 | -// // assertEquals("ALL UPPERCASE", config.conventionAllUpperCase); | ||
| 475 | -// // } | ||
| 476 | -// | ||
| 477 | -// @Test | ||
| 478 | -// public void testConfigurationPropertiesErrorWithComplexObject() { | ||
| 479 | -// ConfigurationPropertiesErrorWithComplexObject config = new ConfigurationPropertiesErrorWithComplexObject(); | ||
| 480 | -// | ||
| 481 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 482 | -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 483 | -// | ||
| 484 | -// try { | ||
| 485 | -// configurationLoader.load(config); | ||
| 486 | -// fail(); | ||
| 487 | -// } catch (Throwable throwable) { | ||
| 488 | -// } | ||
| 489 | -// } | ||
| 490 | -// | ||
| 491 | -// // @Test | ||
| 492 | -// // public void testConfigurationFromXMLWithPrefix() { | ||
| 493 | -// // ConfigurationFromXMLWithPrefix config = new ConfigurationFromXMLWithPrefix(); | ||
| 494 | -// // | ||
| 495 | -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 496 | -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 497 | -// // | ||
| 498 | -// // configurationLoader.load(config); | ||
| 499 | -// // assertEquals("ConfigurationTest", config.nameConfiguration); | ||
| 500 | -// // } | ||
| 501 | -// | ||
| 502 | -// // @Test | ||
| 503 | -// // public void testConfigurationXMLWithConventionAllUpperCase() { | ||
| 504 | -// // ConfigurationXMLWithConventionAllUpperCase config = new ConfigurationXMLWithConventionAllUpperCase(); | ||
| 505 | -// // | ||
| 506 | -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 507 | -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 508 | -// // | ||
| 509 | -// // configurationLoader.load(config); | ||
| 510 | -// // assertEquals("ALL UPPERCASE", config.conventionAllUpperCase); | ||
| 511 | -// // } | ||
| 512 | -// | ||
| 513 | -// // @Test | ||
| 514 | -// // public void testConfigurationXMLWithConventionAllLowerCase() { | ||
| 515 | -// // ConfigurationXMLWithConventionAllLowerCase config = new ConfigurationXMLWithConventionAllLowerCase(); | ||
| 516 | -// // | ||
| 517 | -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 518 | -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); | ||
| 519 | -// // | ||
| 520 | -// // configurationLoader.load(config); | ||
| 521 | -// // assertEquals("All LowerCase", config.conventionAllLowerCase); | ||
| 522 | -// // } | ||
| 523 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java
| @@ -1,545 +0,0 @@ | @@ -1,545 +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.configuration; | ||
| 38 | -// | ||
| 39 | -//import static org.easymock.EasyMock.expect; | ||
| 40 | -//import static org.junit.Assert.assertEquals; | ||
| 41 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 42 | -// | ||
| 43 | -//import java.awt.Color; | ||
| 44 | -//import java.math.BigDecimal; | ||
| 45 | -//import java.math.BigInteger; | ||
| 46 | -//import java.net.URL; | ||
| 47 | -//import java.util.Calendar; | ||
| 48 | -//import java.util.Date; | ||
| 49 | -//import java.util.GregorianCalendar; | ||
| 50 | -//import java.util.Locale; | ||
| 51 | -// | ||
| 52 | -//import org.junit.After; | ||
| 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 | -// | ||
| 60 | -//import br.gov.frameworkdemoiselle.configuration.ConfigType; | ||
| 61 | -//import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 62 | -//import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | ||
| 63 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
| 64 | -// | ||
| 65 | -//@RunWith(PowerMockRunner.class) | ||
| 66 | -//@PrepareForTest(Beans.class) | ||
| 67 | -//public class ConfigurationLoaderWithArrayTest { | ||
| 68 | -// | ||
| 69 | -// private ConfigurationLoader configurationLoader; | ||
| 70 | -// | ||
| 71 | -// @Configuration(type = ConfigType.PROPERTIES, resource = "configuration-with-array") | ||
| 72 | -// public class ConfigurationPropertiesWithArray { | ||
| 73 | -// | ||
| 74 | -// /* | ||
| 75 | -// * All methods supported by org.apache.commons.configuration.DataConfiguration class for array | ||
| 76 | -// */ | ||
| 77 | -// | ||
| 78 | -// protected BigDecimal[] bigDecimalArray; | ||
| 79 | -// | ||
| 80 | -// protected BigInteger[] bigIntegerArray; | ||
| 81 | -// | ||
| 82 | -// protected boolean[] booleanArray; | ||
| 83 | -// | ||
| 84 | -// protected byte[] byteArray; | ||
| 85 | -// | ||
| 86 | -// protected Calendar[] calendarArray; | ||
| 87 | -// | ||
| 88 | -// protected Color[] colorArray; | ||
| 89 | -// | ||
| 90 | -// protected Date[] dateArray; | ||
| 91 | -// | ||
| 92 | -// protected double[] doubleArray; | ||
| 93 | -// | ||
| 94 | -// protected float[] floatArray; | ||
| 95 | -// | ||
| 96 | -// protected int[] integerArray; | ||
| 97 | -// | ||
| 98 | -// protected Locale[] localeArray; | ||
| 99 | -// | ||
| 100 | -// protected long[] longArray; | ||
| 101 | -// | ||
| 102 | -// protected short[] shortArray; | ||
| 103 | -// | ||
| 104 | -// protected URL[] urlArray; | ||
| 105 | -// | ||
| 106 | -// protected String[] stringArray; | ||
| 107 | -// | ||
| 108 | -// } | ||
| 109 | -// | ||
| 110 | -// @Configuration(type = ConfigType.XML, resource = "configuration-with-array") | ||
| 111 | -// public class ConfigurationXMLWithArray { | ||
| 112 | -// | ||
| 113 | -// /* | ||
| 114 | -// * All methods supported by org.apache.commons.configuration.DataConfiguration class for array | ||
| 115 | -// */ | ||
| 116 | -// | ||
| 117 | -// protected BigDecimal[] bigDecimalArray; | ||
| 118 | -// | ||
| 119 | -// protected BigInteger[] bigIntegerArray; | ||
| 120 | -// | ||
| 121 | -// protected boolean[] booleanArray; | ||
| 122 | -// | ||
| 123 | -// protected byte[] byteArray; | ||
| 124 | -// | ||
| 125 | -// protected Calendar[] calendarArray; | ||
| 126 | -// | ||
| 127 | -// protected Color[] colorArray; | ||
| 128 | -// | ||
| 129 | -// protected Date[] dateArray; | ||
| 130 | -// | ||
| 131 | -// protected double[] doubleArray; | ||
| 132 | -// | ||
| 133 | -// protected float[] floatArray; | ||
| 134 | -// | ||
| 135 | -// protected int[] integerArray; | ||
| 136 | -// | ||
| 137 | -// protected Locale[] localeArray; | ||
| 138 | -// | ||
| 139 | -// protected long[] longArray; | ||
| 140 | -// | ||
| 141 | -// protected short[] shortArray; | ||
| 142 | -// | ||
| 143 | -// protected URL[] urlArray; | ||
| 144 | -// | ||
| 145 | -// protected String[] stringArray; | ||
| 146 | -// | ||
| 147 | -// } | ||
| 148 | -// | ||
| 149 | -// @Before | ||
| 150 | -// public void setUp() throws Exception { | ||
| 151 | -// configurationLoader = new ConfigurationLoader(); | ||
| 152 | -// } | ||
| 153 | -// | ||
| 154 | -// @After | ||
| 155 | -// public void tearDown() throws Exception { | ||
| 156 | -// } | ||
| 157 | -// | ||
| 158 | -// @Test | ||
| 159 | -// public void testConfigurationPropertiesWithIntegerArray() { | ||
| 160 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 161 | -// | ||
| 162 | -// Integer integerValue = config.integerArray[0]; | ||
| 163 | -// | ||
| 164 | -// assertEquals(Integer.class, integerValue.getClass()); | ||
| 165 | -// assertEquals(Integer.MAX_VALUE, integerValue.intValue()); | ||
| 166 | -// assertEquals(4, config.integerArray.length); | ||
| 167 | -// } | ||
| 168 | -// | ||
| 169 | -// @Test | ||
| 170 | -// public void testConfigurationPropertiesWithShortArray() { | ||
| 171 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 172 | -// | ||
| 173 | -// Short shortValue = config.shortArray[0]; | ||
| 174 | -// | ||
| 175 | -// assertEquals(Short.class, shortValue.getClass()); | ||
| 176 | -// assertEquals(Short.MAX_VALUE, shortValue.shortValue()); | ||
| 177 | -// assertEquals(4, config.shortArray.length); | ||
| 178 | -// } | ||
| 179 | -// | ||
| 180 | -// @Test | ||
| 181 | -// public void testConfigurationPropertiesWithByteArray() { | ||
| 182 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 183 | -// | ||
| 184 | -// Byte byteValue = config.byteArray[0]; | ||
| 185 | -// | ||
| 186 | -// assertEquals(Byte.class, byteValue.getClass()); | ||
| 187 | -// assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); | ||
| 188 | -// assertEquals(8, config.byteArray.length); | ||
| 189 | -// } | ||
| 190 | -// | ||
| 191 | -// @Test | ||
| 192 | -// public void testConfigurationPropertiesWithBooleanArray() { | ||
| 193 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 194 | -// | ||
| 195 | -// Boolean booleanValue = config.booleanArray[0]; | ||
| 196 | -// | ||
| 197 | -// assertEquals(Boolean.class, booleanValue.getClass()); | ||
| 198 | -// assertEquals(2, config.booleanArray.length); | ||
| 199 | -// } | ||
| 200 | -// | ||
| 201 | -// @Test | ||
| 202 | -// public void testConfigurationPropertiesWithLongArray() { | ||
| 203 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 204 | -// | ||
| 205 | -// Long longValue = config.longArray[0]; | ||
| 206 | -// | ||
| 207 | -// assertEquals(Long.class, longValue.getClass()); | ||
| 208 | -// assertEquals(Long.MAX_VALUE, longValue.longValue()); | ||
| 209 | -// assertEquals(5, config.longArray.length); | ||
| 210 | -// } | ||
| 211 | -// | ||
| 212 | -// @Test | ||
| 213 | -// public void testConfigurationPropertiesWithFloatArray() { | ||
| 214 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 215 | -// | ||
| 216 | -// Float floatValue = config.floatArray[0]; | ||
| 217 | -// | ||
| 218 | -// assertEquals(Float.class, floatValue.getClass()); | ||
| 219 | -// assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); | ||
| 220 | -// assertEquals(5, config.floatArray.length); | ||
| 221 | -// } | ||
| 222 | -// | ||
| 223 | -// @Test | ||
| 224 | -// public void testConfigurationPropertiesWithDoubleArray() { | ||
| 225 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 226 | -// | ||
| 227 | -// Double doubleValue = config.doubleArray[0]; | ||
| 228 | -// | ||
| 229 | -// assertEquals(Double.class, doubleValue.getClass()); | ||
| 230 | -// assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1); | ||
| 231 | -// assertEquals(3, config.doubleArray.length); | ||
| 232 | -// } | ||
| 233 | -// | ||
| 234 | -// @Test | ||
| 235 | -// public void testConfigurationPropertiesWithBigDecimalArray() { | ||
| 236 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 237 | -// | ||
| 238 | -// BigDecimal bigDecimalValue = config.bigDecimalArray[0]; | ||
| 239 | -// | ||
| 240 | -// assertEquals(BigDecimal.class, bigDecimalValue.getClass()); | ||
| 241 | -// assertEquals(3, config.bigDecimalArray.length); | ||
| 242 | -// } | ||
| 243 | -// | ||
| 244 | -// @Test | ||
| 245 | -// public void testConfigurationPropertiesWithBigIntegerArray() { | ||
| 246 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 247 | -// | ||
| 248 | -// BigInteger bigIntegerValue = config.bigIntegerArray[0]; | ||
| 249 | -// | ||
| 250 | -// assertEquals(BigInteger.class, bigIntegerValue.getClass()); | ||
| 251 | -// assertEquals(3, config.bigIntegerArray.length); | ||
| 252 | -// } | ||
| 253 | -// | ||
| 254 | -// @Test | ||
| 255 | -// public void testConfigurationPropertiesWithCalendarArray() { | ||
| 256 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 257 | -// | ||
| 258 | -// Calendar calendarValue = config.calendarArray[0]; | ||
| 259 | -// | ||
| 260 | -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); | ||
| 261 | -// | ||
| 262 | -// assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); | ||
| 263 | -// assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); | ||
| 264 | -// assertEquals(3, config.calendarArray.length); | ||
| 265 | -// } | ||
| 266 | -// | ||
| 267 | -// @Test | ||
| 268 | -// public void testConfigurationPropertiesWithDateArray() { | ||
| 269 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 270 | -// | ||
| 271 | -// Date dateValue = config.dateArray[0]; | ||
| 272 | -// | ||
| 273 | -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); | ||
| 274 | -// | ||
| 275 | -// Date date = new Date(calendar.getTimeInMillis()); | ||
| 276 | -// | ||
| 277 | -// assertEquals(Date.class, dateValue.getClass()); | ||
| 278 | -// assertEquals(date.getTime(), dateValue.getTime()); | ||
| 279 | -// assertEquals(3, config.dateArray.length); | ||
| 280 | -// } | ||
| 281 | -// | ||
| 282 | -// @Test | ||
| 283 | -// public void testConfigurationPropertiesWithColorArray() { | ||
| 284 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 285 | -// | ||
| 286 | -// Color colorValue = config.colorArray[0]; | ||
| 287 | -// | ||
| 288 | -// assertEquals(Color.class, colorValue.getClass()); | ||
| 289 | -// assertEquals(Color.gray, colorValue); | ||
| 290 | -// assertEquals(3, config.colorArray.length); | ||
| 291 | -// } | ||
| 292 | -// | ||
| 293 | -// @Test | ||
| 294 | -// public void testConfigurationPropertiesWithLocaleArray() { | ||
| 295 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 296 | -// | ||
| 297 | -// Locale localeValue = config.localeArray[0]; | ||
| 298 | -// Locale localeValue2 = config.localeArray[1]; | ||
| 299 | -// | ||
| 300 | -// assertEquals(Locale.class, localeValue.getClass()); | ||
| 301 | -// assertEquals(Locale.ENGLISH, localeValue); | ||
| 302 | -// assertEquals("BR", localeValue2.getCountry()); | ||
| 303 | -// assertEquals(3, config.localeArray.length); | ||
| 304 | -// } | ||
| 305 | -// | ||
| 306 | -// @Test | ||
| 307 | -// public void testConfigurationPropertiesWithURLArray() { | ||
| 308 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 309 | -// | ||
| 310 | -// URL urlValue = config.urlArray[0]; | ||
| 311 | -// | ||
| 312 | -// URL otherURL = null; | ||
| 313 | -// | ||
| 314 | -// try { | ||
| 315 | -// otherURL = new URL("http://www.test.com"); | ||
| 316 | -// } catch (Exception e) { | ||
| 317 | -// | ||
| 318 | -// } | ||
| 319 | -// | ||
| 320 | -// assertEquals(URL.class, urlValue.getClass()); | ||
| 321 | -// assertEquals(otherURL, urlValue); | ||
| 322 | -// assertEquals(3, config.urlArray.length); | ||
| 323 | -// } | ||
| 324 | -// | ||
| 325 | -// @Test | ||
| 326 | -// public void testConfigurationPropertiesWithStringArray() { | ||
| 327 | -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); | ||
| 328 | -// | ||
| 329 | -// String stringValue = config.stringArray[0]; | ||
| 330 | -// | ||
| 331 | -// assertEquals(String.class, stringValue.getClass()); | ||
| 332 | -// assertEquals("Test", stringValue); | ||
| 333 | -// assertEquals(3, config.stringArray.length); | ||
| 334 | -// } | ||
| 335 | -// | ||
| 336 | -// private ConfigurationPropertiesWithArray prepareConfigurationPropertiesWithArray() { | ||
| 337 | -// mockStatic(Beans.class); | ||
| 338 | -// ConfigurationPropertiesWithArray config = new ConfigurationPropertiesWithArray(); | ||
| 339 | -// CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); | ||
| 340 | -// | ||
| 341 | -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); | ||
| 342 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 343 | -// | ||
| 344 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 345 | -// | ||
| 346 | -// PowerMock.replayAll(CoreBootstrap.class,Beans.class); | ||
| 347 | -// | ||
| 348 | -// configurationLoader.load(config); | ||
| 349 | -// return config; | ||
| 350 | -// } | ||
| 351 | -// | ||
| 352 | -// @Test | ||
| 353 | -// public void testConfigurationXMLWithIntegerArray() { | ||
| 354 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 355 | -// | ||
| 356 | -// Integer integerValue = config.integerArray[0]; | ||
| 357 | -// | ||
| 358 | -// assertEquals(Integer.class, integerValue.getClass()); | ||
| 359 | -// assertEquals(Integer.MAX_VALUE, integerValue.intValue()); | ||
| 360 | -// assertEquals(4, config.integerArray.length); | ||
| 361 | -// } | ||
| 362 | -// | ||
| 363 | -// @Test | ||
| 364 | -// public void testConfigurationXMLWithShortArray() { | ||
| 365 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 366 | -// | ||
| 367 | -// Short shortValue = config.shortArray[0]; | ||
| 368 | -// | ||
| 369 | -// assertEquals(Short.class, shortValue.getClass()); | ||
| 370 | -// assertEquals(Short.MAX_VALUE, shortValue.shortValue()); | ||
| 371 | -// assertEquals(4, config.shortArray.length); | ||
| 372 | -// } | ||
| 373 | -// | ||
| 374 | -// @Test | ||
| 375 | -// public void testConfigurationXMLWithByteArray() { | ||
| 376 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 377 | -// | ||
| 378 | -// Byte byteValue = config.byteArray[0]; | ||
| 379 | -// | ||
| 380 | -// assertEquals(Byte.class, byteValue.getClass()); | ||
| 381 | -// assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); | ||
| 382 | -// assertEquals(8, config.byteArray.length); | ||
| 383 | -// } | ||
| 384 | -// | ||
| 385 | -// @Test | ||
| 386 | -// public void testConfigurationXMLWithBooleanArray() { | ||
| 387 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 388 | -// | ||
| 389 | -// Boolean booleanValue = config.booleanArray[0]; | ||
| 390 | -// | ||
| 391 | -// assertEquals(Boolean.class, booleanValue.getClass()); | ||
| 392 | -// assertEquals(2, config.booleanArray.length); | ||
| 393 | -// } | ||
| 394 | -// | ||
| 395 | -// @Test | ||
| 396 | -// public void testConfigurationXMLWithLongArray() { | ||
| 397 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 398 | -// | ||
| 399 | -// Long longValue = config.longArray[0]; | ||
| 400 | -// | ||
| 401 | -// assertEquals(Long.class, longValue.getClass()); | ||
| 402 | -// assertEquals(Long.MAX_VALUE, longValue.longValue()); | ||
| 403 | -// assertEquals(5, config.longArray.length); | ||
| 404 | -// } | ||
| 405 | -// | ||
| 406 | -// @Test | ||
| 407 | -// public void testConfigurationXMLWithFloatArray() { | ||
| 408 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 409 | -// | ||
| 410 | -// Float floatValue = config.floatArray[0]; | ||
| 411 | -// | ||
| 412 | -// assertEquals(Float.class, floatValue.getClass()); | ||
| 413 | -// assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); | ||
| 414 | -// assertEquals(5, config.floatArray.length); | ||
| 415 | -// } | ||
| 416 | -// | ||
| 417 | -// @Test | ||
| 418 | -// public void testConfigurationXMLWithDoubleArray() { | ||
| 419 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 420 | -// | ||
| 421 | -// Double doubleValue = config.doubleArray[0]; | ||
| 422 | -// | ||
| 423 | -// assertEquals(Double.class, doubleValue.getClass()); | ||
| 424 | -// assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1); | ||
| 425 | -// assertEquals(3, config.doubleArray.length); | ||
| 426 | -// } | ||
| 427 | -// | ||
| 428 | -// @Test | ||
| 429 | -// public void testConfigurationXMLWithBigDecimalArray() { | ||
| 430 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 431 | -// | ||
| 432 | -// BigDecimal bigDecimalValue = config.bigDecimalArray[0]; | ||
| 433 | -// | ||
| 434 | -// assertEquals(BigDecimal.class, bigDecimalValue.getClass()); | ||
| 435 | -// assertEquals(3, config.bigDecimalArray.length); | ||
| 436 | -// } | ||
| 437 | -// | ||
| 438 | -// @Test | ||
| 439 | -// public void testConfigurationXMLWithBigIntegerArray() { | ||
| 440 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 441 | -// | ||
| 442 | -// BigInteger bigIntegerValue = config.bigIntegerArray[0]; | ||
| 443 | -// | ||
| 444 | -// assertEquals(BigInteger.class, bigIntegerValue.getClass()); | ||
| 445 | -// assertEquals(3, config.bigIntegerArray.length); | ||
| 446 | -// } | ||
| 447 | -// | ||
| 448 | -// @Test | ||
| 449 | -// public void testConfigurationXMLWithCalendarArray() { | ||
| 450 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 451 | -// | ||
| 452 | -// Calendar calendarValue = config.calendarArray[0]; | ||
| 453 | -// | ||
| 454 | -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); | ||
| 455 | -// | ||
| 456 | -// assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); | ||
| 457 | -// assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); | ||
| 458 | -// assertEquals(3, config.calendarArray.length); | ||
| 459 | -// } | ||
| 460 | -// | ||
| 461 | -// @Test | ||
| 462 | -// public void testConfigurationXMLWithDateArray() { | ||
| 463 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 464 | -// | ||
| 465 | -// Date dateValue = config.dateArray[0]; | ||
| 466 | -// | ||
| 467 | -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); | ||
| 468 | -// | ||
| 469 | -// Date date = new Date(calendar.getTimeInMillis()); | ||
| 470 | -// | ||
| 471 | -// assertEquals(Date.class, dateValue.getClass()); | ||
| 472 | -// assertEquals(date.getTime(), dateValue.getTime()); | ||
| 473 | -// assertEquals(3, config.dateArray.length); | ||
| 474 | -// } | ||
| 475 | -// | ||
| 476 | -// @Test | ||
| 477 | -// public void testConfigurationXMLWithColorArray() { | ||
| 478 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 479 | -// | ||
| 480 | -// Color colorValue = config.colorArray[0]; | ||
| 481 | -// | ||
| 482 | -// assertEquals(Color.class, colorValue.getClass()); | ||
| 483 | -// assertEquals(Color.gray, colorValue); | ||
| 484 | -// assertEquals(3, config.colorArray.length); | ||
| 485 | -// } | ||
| 486 | -// | ||
| 487 | -// @Test | ||
| 488 | -// public void testConfigurationXMLWithLocaleArray() { | ||
| 489 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 490 | -// | ||
| 491 | -// Locale localeValue = config.localeArray[0]; | ||
| 492 | -// Locale localeValue2 = config.localeArray[1]; | ||
| 493 | -// | ||
| 494 | -// assertEquals(Locale.class, localeValue.getClass()); | ||
| 495 | -// assertEquals(Locale.ENGLISH, localeValue); | ||
| 496 | -// assertEquals("BR", localeValue2.getCountry()); | ||
| 497 | -// assertEquals(3, config.localeArray.length); | ||
| 498 | -// } | ||
| 499 | -// | ||
| 500 | -// @Test | ||
| 501 | -// public void testConfigurationXMLWithURLArray() { | ||
| 502 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 503 | -// | ||
| 504 | -// URL urlValue = config.urlArray[0]; | ||
| 505 | -// | ||
| 506 | -// URL otherURL = null; | ||
| 507 | -// | ||
| 508 | -// try { | ||
| 509 | -// otherURL = new URL("http://www.test.com"); | ||
| 510 | -// } catch (Exception e) { | ||
| 511 | -// | ||
| 512 | -// } | ||
| 513 | -// | ||
| 514 | -// assertEquals(URL.class, urlValue.getClass()); | ||
| 515 | -// assertEquals(otherURL, urlValue); | ||
| 516 | -// assertEquals(3, config.urlArray.length); | ||
| 517 | -// } | ||
| 518 | -// | ||
| 519 | -// @Test | ||
| 520 | -// public void testConfigurationXMLWithStringArray() { | ||
| 521 | -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); | ||
| 522 | -// | ||
| 523 | -// String stringValue = config.stringArray[0]; | ||
| 524 | -// | ||
| 525 | -// assertEquals(String.class, stringValue.getClass()); | ||
| 526 | -// assertEquals("Test", stringValue); | ||
| 527 | -// assertEquals(3, config.stringArray.length); | ||
| 528 | -// } | ||
| 529 | -// | ||
| 530 | -// private ConfigurationXMLWithArray prepareConfigurationXMLWithArray() { | ||
| 531 | -// mockStatic(Beans.class); | ||
| 532 | -// ConfigurationXMLWithArray config = new ConfigurationXMLWithArray(); | ||
| 533 | -// CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); | ||
| 534 | -// | ||
| 535 | -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); | ||
| 536 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 537 | -// | ||
| 538 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 539 | -// | ||
| 540 | -// PowerMock.replayAll(CoreBootstrap.class,Beans.class); | ||
| 541 | -// | ||
| 542 | -// configurationLoader.load(config); | ||
| 543 | -// return config; | ||
| 544 | -// } | ||
| 545 | -// } |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java
| @@ -1,546 +0,0 @@ | @@ -1,546 +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.configuration; | ||
| 38 | -// | ||
| 39 | -//import static org.easymock.EasyMock.expect; | ||
| 40 | -//import static org.junit.Assert.assertEquals; | ||
| 41 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 42 | -// | ||
| 43 | -//import java.awt.Color; | ||
| 44 | -//import java.math.BigDecimal; | ||
| 45 | -//import java.math.BigInteger; | ||
| 46 | -//import java.net.URL; | ||
| 47 | -//import java.util.Calendar; | ||
| 48 | -//import java.util.Date; | ||
| 49 | -//import java.util.GregorianCalendar; | ||
| 50 | -//import java.util.List; | ||
| 51 | -//import java.util.Locale; | ||
| 52 | -// | ||
| 53 | -//import org.junit.After; | ||
| 54 | -//import org.junit.Before; | ||
| 55 | -//import org.junit.Test; | ||
| 56 | -//import org.junit.runner.RunWith; | ||
| 57 | -//import org.powermock.api.easymock.PowerMock; | ||
| 58 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 59 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
| 60 | -// | ||
| 61 | -//import br.gov.frameworkdemoiselle.configuration.ConfigType; | ||
| 62 | -//import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 63 | -//import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | ||
| 64 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
| 65 | -// | ||
| 66 | -//@RunWith(PowerMockRunner.class) | ||
| 67 | -//@PrepareForTest(Beans.class) | ||
| 68 | -//public class ConfigurationLoaderWithListTest { | ||
| 69 | -// | ||
| 70 | -// private ConfigurationLoader configurationLoader; | ||
| 71 | -// | ||
| 72 | -// @Configuration(type = ConfigType.PROPERTIES, resource = "configuration-with-list") | ||
| 73 | -// public class ConfigurationPropertiesWithList { | ||
| 74 | -// | ||
| 75 | -// /* | ||
| 76 | -// * All methods supported by org.apache.commons.configuration.DataConfiguration class for List type | ||
| 77 | -// */ | ||
| 78 | -// | ||
| 79 | -// protected List<BigDecimal> bigDecimalList; | ||
| 80 | -// | ||
| 81 | -// protected List<BigInteger> bigIntegerList; | ||
| 82 | -// | ||
| 83 | -// protected List<Boolean> booleanList; | ||
| 84 | -// | ||
| 85 | -// protected List<Byte> byteList; | ||
| 86 | -// | ||
| 87 | -// protected List<Calendar> calendarList; | ||
| 88 | -// | ||
| 89 | -// protected List<Color> colorList; | ||
| 90 | -// | ||
| 91 | -// protected List<Date> dateList; | ||
| 92 | -// | ||
| 93 | -// protected List<Double> doubleList; | ||
| 94 | -// | ||
| 95 | -// protected List<Float> floatList; | ||
| 96 | -// | ||
| 97 | -// protected List<Integer> integerList; | ||
| 98 | -// | ||
| 99 | -// protected List<Locale> localeList; | ||
| 100 | -// | ||
| 101 | -// protected List<Long> longList; | ||
| 102 | -// | ||
| 103 | -// protected List<Short> shortList; | ||
| 104 | -// | ||
| 105 | -// protected List<URL> urlList; | ||
| 106 | -// | ||
| 107 | -// protected List<String> stringList; | ||
| 108 | -// } | ||
| 109 | -// | ||
| 110 | -// @Configuration(type = ConfigType.XML, resource = "configuration-with-list") | ||
| 111 | -// public class ConfigurationXMLWithList { | ||
| 112 | -// | ||
| 113 | -// /* | ||
| 114 | -// * All methods supported by org.apache.commons.configuration.DataConfiguration class for List type | ||
| 115 | -// */ | ||
| 116 | -// | ||
| 117 | -// protected List<BigDecimal> bigDecimalList; | ||
| 118 | -// | ||
| 119 | -// protected List<BigInteger> bigIntegerList; | ||
| 120 | -// | ||
| 121 | -// protected List<Boolean> booleanList; | ||
| 122 | -// | ||
| 123 | -// protected List<Byte> byteList; | ||
| 124 | -// | ||
| 125 | -// protected List<Calendar> calendarList; | ||
| 126 | -// | ||
| 127 | -// protected List<Color> colorList; | ||
| 128 | -// | ||
| 129 | -// protected List<Date> dateList; | ||
| 130 | -// | ||
| 131 | -// protected List<Double> doubleList; | ||
| 132 | -// | ||
| 133 | -// protected List<Float> floatList; | ||
| 134 | -// | ||
| 135 | -// protected List<Integer> integerList; | ||
| 136 | -// | ||
| 137 | -// protected List<Locale> localeList; | ||
| 138 | -// | ||
| 139 | -// protected List<Long> longList; | ||
| 140 | -// | ||
| 141 | -// protected List<Short> shortList; | ||
| 142 | -// | ||
| 143 | -// protected List<URL> urlList; | ||
| 144 | -// | ||
| 145 | -// protected List<String> stringList; | ||
| 146 | -// } | ||
| 147 | -// | ||
| 148 | -// @Before | ||
| 149 | -// public void setUp() throws Exception { | ||
| 150 | -// configurationLoader = new ConfigurationLoader(); | ||
| 151 | -// } | ||
| 152 | -// | ||
| 153 | -// @After | ||
| 154 | -// public void tearDown() throws Exception { | ||
| 155 | -// } | ||
| 156 | -// | ||
| 157 | -// @Test | ||
| 158 | -// public void testConfigurationPropertiesWithIntegerList() { | ||
| 159 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 160 | -// | ||
| 161 | -// Integer integerValue = config.integerList.get(0); | ||
| 162 | -// | ||
| 163 | -// assertEquals(Integer.class, integerValue.getClass()); | ||
| 164 | -// assertEquals(Integer.MAX_VALUE, integerValue.intValue()); | ||
| 165 | -// assertEquals(4, config.integerList.size()); | ||
| 166 | -// } | ||
| 167 | -// | ||
| 168 | -// @Test | ||
| 169 | -// public void testConfigurationPropertiesWithShortList() { | ||
| 170 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 171 | -// | ||
| 172 | -// Short shortValue = config.shortList.get(0); | ||
| 173 | -// | ||
| 174 | -// assertEquals(Short.class, shortValue.getClass()); | ||
| 175 | -// assertEquals(Short.MAX_VALUE, shortValue.shortValue()); | ||
| 176 | -// assertEquals(4, config.shortList.size()); | ||
| 177 | -// } | ||
| 178 | -// | ||
| 179 | -// @Test | ||
| 180 | -// public void testConfigurationPropertiesWithByteList() { | ||
| 181 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 182 | -// | ||
| 183 | -// Byte byteValue = config.byteList.get(0); | ||
| 184 | -// | ||
| 185 | -// assertEquals(Byte.class, byteValue.getClass()); | ||
| 186 | -// assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); | ||
| 187 | -// assertEquals(8, config.byteList.size()); | ||
| 188 | -// } | ||
| 189 | -// | ||
| 190 | -// @Test | ||
| 191 | -// public void testConfigurationPropertiesWithBooleanList() { | ||
| 192 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 193 | -// | ||
| 194 | -// Boolean booleanValue = config.booleanList.get(0); | ||
| 195 | -// | ||
| 196 | -// assertEquals(Boolean.class, booleanValue.getClass()); | ||
| 197 | -// assertEquals(2, config.booleanList.size()); | ||
| 198 | -// } | ||
| 199 | -// | ||
| 200 | -// @Test | ||
| 201 | -// public void testConfigurationPropertiesWithLongList() { | ||
| 202 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 203 | -// | ||
| 204 | -// Long longValue = config.longList.get(0); | ||
| 205 | -// | ||
| 206 | -// assertEquals(Long.class, longValue.getClass()); | ||
| 207 | -// assertEquals(Long.MAX_VALUE, longValue.longValue()); | ||
| 208 | -// assertEquals(5, config.longList.size()); | ||
| 209 | -// } | ||
| 210 | -// | ||
| 211 | -// @Test | ||
| 212 | -// public void testConfigurationPropertiesWithFloatList() { | ||
| 213 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 214 | -// | ||
| 215 | -// Float floatValue = config.floatList.get(0); | ||
| 216 | -// | ||
| 217 | -// assertEquals(Float.class, floatValue.getClass()); | ||
| 218 | -// assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); | ||
| 219 | -// assertEquals(5, config.floatList.size()); | ||
| 220 | -// } | ||
| 221 | -// | ||
| 222 | -// @Test | ||
| 223 | -// public void testConfigurationPropertiesWithDoubleList() { | ||
| 224 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 225 | -// | ||
| 226 | -// Double doubleValue = config.doubleList.get(0); | ||
| 227 | -// | ||
| 228 | -// assertEquals(Double.class, doubleValue.getClass()); | ||
| 229 | -// assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1); | ||
| 230 | -// assertEquals(3, config.doubleList.size()); | ||
| 231 | -// } | ||
| 232 | -// | ||
| 233 | -// @Test | ||
| 234 | -// public void testConfigurationPropertiesWithBigDecimalList() { | ||
| 235 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 236 | -// | ||
| 237 | -// BigDecimal bigDecimalValue = config.bigDecimalList.get(0); | ||
| 238 | -// | ||
| 239 | -// assertEquals(BigDecimal.class, bigDecimalValue.getClass()); | ||
| 240 | -// assertEquals(3, config.bigDecimalList.size()); | ||
| 241 | -// } | ||
| 242 | -// | ||
| 243 | -// @Test | ||
| 244 | -// public void testConfigurationPropertiesWithBigIntegerList() { | ||
| 245 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 246 | -// | ||
| 247 | -// BigInteger bigIntegerValue = config.bigIntegerList.get(0); | ||
| 248 | -// | ||
| 249 | -// assertEquals(BigInteger.class, bigIntegerValue.getClass()); | ||
| 250 | -// assertEquals(3, config.bigIntegerList.size()); | ||
| 251 | -// } | ||
| 252 | -// | ||
| 253 | -// @Test | ||
| 254 | -// public void testConfigurationPropertiesWithCalendarList() { | ||
| 255 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 256 | -// | ||
| 257 | -// Calendar calendarValue = config.calendarList.get(0); | ||
| 258 | -// | ||
| 259 | -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); | ||
| 260 | -// | ||
| 261 | -// assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); | ||
| 262 | -// assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); | ||
| 263 | -// assertEquals(3, config.calendarList.size()); | ||
| 264 | -// } | ||
| 265 | -// | ||
| 266 | -// @Test | ||
| 267 | -// public void testConfigurationPropertiesWithDateList() { | ||
| 268 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 269 | -// | ||
| 270 | -// Date dateValue = config.dateList.get(0); | ||
| 271 | -// | ||
| 272 | -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); | ||
| 273 | -// | ||
| 274 | -// Date date = new Date(calendar.getTimeInMillis()); | ||
| 275 | -// | ||
| 276 | -// assertEquals(Date.class, dateValue.getClass()); | ||
| 277 | -// assertEquals(date.getTime(), dateValue.getTime()); | ||
| 278 | -// assertEquals(3, config.dateList.size()); | ||
| 279 | -// } | ||
| 280 | -// | ||
| 281 | -// @Test | ||
| 282 | -// public void testConfigurationPropertiesWithColorList() { | ||
| 283 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 284 | -// | ||
| 285 | -// Color colorValue = config.colorList.get(0); | ||
| 286 | -// | ||
| 287 | -// assertEquals(Color.class, colorValue.getClass()); | ||
| 288 | -// assertEquals(Color.gray, colorValue); | ||
| 289 | -// assertEquals(3, config.colorList.size()); | ||
| 290 | -// } | ||
| 291 | -// | ||
| 292 | -// @Test | ||
| 293 | -// public void testConfigurationPropertiesWithLocaleList() { | ||
| 294 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 295 | -// | ||
| 296 | -// Locale localeValue = config.localeList.get(0); | ||
| 297 | -// Locale localeValue2 = config.localeList.get(1); | ||
| 298 | -// | ||
| 299 | -// assertEquals(Locale.class, localeValue.getClass()); | ||
| 300 | -// assertEquals(Locale.ENGLISH, localeValue); | ||
| 301 | -// assertEquals("BR", localeValue2.getCountry()); | ||
| 302 | -// assertEquals(3, config.localeList.size()); | ||
| 303 | -// } | ||
| 304 | -// | ||
| 305 | -// @Test | ||
| 306 | -// public void testConfigurationPropertiesWithURLList() { | ||
| 307 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 308 | -// | ||
| 309 | -// URL urlValue = config.urlList.get(0); | ||
| 310 | -// | ||
| 311 | -// URL otherURL = null; | ||
| 312 | -// | ||
| 313 | -// try { | ||
| 314 | -// otherURL = new URL("http://www.test.com"); | ||
| 315 | -// } catch (Exception e) { | ||
| 316 | -// | ||
| 317 | -// } | ||
| 318 | -// | ||
| 319 | -// assertEquals(URL.class, urlValue.getClass()); | ||
| 320 | -// assertEquals(otherURL, urlValue); | ||
| 321 | -// assertEquals(3, config.urlList.size()); | ||
| 322 | -// } | ||
| 323 | -// | ||
| 324 | -// @Test | ||
| 325 | -// public void testConfigurationPropertiesWithStringList() { | ||
| 326 | -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); | ||
| 327 | -// | ||
| 328 | -// String stringValue = config.stringList.get(0); | ||
| 329 | -// | ||
| 330 | -// assertEquals(String.class, stringValue.getClass()); | ||
| 331 | -// assertEquals("Test", stringValue); | ||
| 332 | -// assertEquals(3, config.stringList.size()); | ||
| 333 | -// } | ||
| 334 | -// | ||
| 335 | -// private ConfigurationPropertiesWithList prepareConfigurationPropertiesWithList() { | ||
| 336 | -// mockStatic(Beans.class); | ||
| 337 | -// CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); | ||
| 338 | -// | ||
| 339 | -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); | ||
| 340 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 341 | -// | ||
| 342 | -// ConfigurationPropertiesWithList config = new ConfigurationPropertiesWithList(); | ||
| 343 | -// | ||
| 344 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 345 | -// | ||
| 346 | -// PowerMock.replayAll(CoreBootstrap.class,Beans.class); | ||
| 347 | -// | ||
| 348 | -// configurationLoader.load(config); | ||
| 349 | -// return config; | ||
| 350 | -// } | ||
| 351 | -// | ||
| 352 | -// @Test | ||
| 353 | -// public void testConfigurationXMLWithIntegerList() { | ||
| 354 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 355 | -// | ||
| 356 | -// Integer integerValue = config.integerList.get(0); | ||
| 357 | -// | ||
| 358 | -// assertEquals(Integer.class, integerValue.getClass()); | ||
| 359 | -// assertEquals(Integer.MAX_VALUE, integerValue.intValue()); | ||
| 360 | -// assertEquals(4, config.integerList.size()); | ||
| 361 | -// } | ||
| 362 | -// | ||
| 363 | -// @Test | ||
| 364 | -// public void testConfigurationXMLWithShortList() { | ||
| 365 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 366 | -// | ||
| 367 | -// Short shortValue = config.shortList.get(0); | ||
| 368 | -// | ||
| 369 | -// assertEquals(Short.class, shortValue.getClass()); | ||
| 370 | -// assertEquals(Short.MAX_VALUE, shortValue.shortValue()); | ||
| 371 | -// assertEquals(4, config.shortList.size()); | ||
| 372 | -// } | ||
| 373 | -// | ||
| 374 | -// @Test | ||
| 375 | -// public void testConfigurationXMLWithByteList() { | ||
| 376 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 377 | -// | ||
| 378 | -// Byte byteValue = config.byteList.get(0); | ||
| 379 | -// | ||
| 380 | -// assertEquals(Byte.class, byteValue.getClass()); | ||
| 381 | -// assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); | ||
| 382 | -// assertEquals(8, config.byteList.size()); | ||
| 383 | -// } | ||
| 384 | -// | ||
| 385 | -// @Test | ||
| 386 | -// public void testConfigurationXMLWithBooleanList() { | ||
| 387 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 388 | -// | ||
| 389 | -// Boolean booleanValue = config.booleanList.get(0); | ||
| 390 | -// | ||
| 391 | -// assertEquals(Boolean.class, booleanValue.getClass()); | ||
| 392 | -// assertEquals(2, config.booleanList.size()); | ||
| 393 | -// } | ||
| 394 | -// | ||
| 395 | -// @Test | ||
| 396 | -// public void testConfigurationXMLWithLongList() { | ||
| 397 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 398 | -// | ||
| 399 | -// Long longValue = config.longList.get(0); | ||
| 400 | -// | ||
| 401 | -// assertEquals(Long.class, longValue.getClass()); | ||
| 402 | -// assertEquals(Long.MAX_VALUE, longValue.longValue()); | ||
| 403 | -// assertEquals(5, config.longList.size()); | ||
| 404 | -// } | ||
| 405 | -// | ||
| 406 | -// @Test | ||
| 407 | -// public void testConfigurationXMLWithFloatList() { | ||
| 408 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 409 | -// | ||
| 410 | -// Float floatValue = config.floatList.get(0); | ||
| 411 | -// | ||
| 412 | -// assertEquals(Float.class, floatValue.getClass()); | ||
| 413 | -// assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); | ||
| 414 | -// assertEquals(5, config.floatList.size()); | ||
| 415 | -// } | ||
| 416 | -// | ||
| 417 | -// @Test | ||
| 418 | -// public void testConfigurationXMLWithDoubleList() { | ||
| 419 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 420 | -// | ||
| 421 | -// Double doubleValue = config.doubleList.get(0); | ||
| 422 | -// | ||
| 423 | -// assertEquals(Double.class, doubleValue.getClass()); | ||
| 424 | -// assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1); | ||
| 425 | -// assertEquals(3, config.doubleList.size()); | ||
| 426 | -// } | ||
| 427 | -// | ||
| 428 | -// @Test | ||
| 429 | -// public void testConfigurationXMLWithBigDecimalList() { | ||
| 430 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 431 | -// | ||
| 432 | -// BigDecimal bigDecimalValue = config.bigDecimalList.get(0); | ||
| 433 | -// | ||
| 434 | -// assertEquals(BigDecimal.class, bigDecimalValue.getClass()); | ||
| 435 | -// assertEquals(3, config.bigDecimalList.size()); | ||
| 436 | -// } | ||
| 437 | -// | ||
| 438 | -// @Test | ||
| 439 | -// public void testConfigurationXMLWithBigIntegerList() { | ||
| 440 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 441 | -// | ||
| 442 | -// BigInteger bigIntegerValue = config.bigIntegerList.get(0); | ||
| 443 | -// | ||
| 444 | -// assertEquals(BigInteger.class, bigIntegerValue.getClass()); | ||
| 445 | -// assertEquals(3, config.bigIntegerList.size()); | ||
| 446 | -// } | ||
| 447 | -// | ||
| 448 | -// @Test | ||
| 449 | -// public void testConfigurationXMLWithCalendarList() { | ||
| 450 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 451 | -// | ||
| 452 | -// Calendar calendarValue = config.calendarList.get(0); | ||
| 453 | -// | ||
| 454 | -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); | ||
| 455 | -// | ||
| 456 | -// assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); | ||
| 457 | -// assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); | ||
| 458 | -// assertEquals(3, config.calendarList.size()); | ||
| 459 | -// } | ||
| 460 | -// | ||
| 461 | -// @Test | ||
| 462 | -// public void testConfigurationXMLWithDateList() { | ||
| 463 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 464 | -// | ||
| 465 | -// Date dateValue = config.dateList.get(0); | ||
| 466 | -// | ||
| 467 | -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); | ||
| 468 | -// | ||
| 469 | -// Date date = new Date(calendar.getTimeInMillis()); | ||
| 470 | -// | ||
| 471 | -// assertEquals(Date.class, dateValue.getClass()); | ||
| 472 | -// assertEquals(date.getTime(), dateValue.getTime()); | ||
| 473 | -// assertEquals(3, config.dateList.size()); | ||
| 474 | -// } | ||
| 475 | -// | ||
| 476 | -// @Test | ||
| 477 | -// public void testConfigurationXMLWithColorList() { | ||
| 478 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 479 | -// | ||
| 480 | -// Color colorValue = config.colorList.get(0); | ||
| 481 | -// | ||
| 482 | -// assertEquals(Color.class, colorValue.getClass()); | ||
| 483 | -// assertEquals(Color.gray, colorValue); | ||
| 484 | -// assertEquals(3, config.colorList.size()); | ||
| 485 | -// } | ||
| 486 | -// | ||
| 487 | -// @Test | ||
| 488 | -// public void testConfigurationXMLWithLocaleList() { | ||
| 489 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 490 | -// | ||
| 491 | -// Locale localeValue = config.localeList.get(0); | ||
| 492 | -// Locale localeValue2 = config.localeList.get(1); | ||
| 493 | -// | ||
| 494 | -// assertEquals(Locale.class, localeValue.getClass()); | ||
| 495 | -// assertEquals(Locale.ENGLISH, localeValue); | ||
| 496 | -// assertEquals("BR", localeValue2.getCountry()); | ||
| 497 | -// assertEquals(3, config.localeList.size()); | ||
| 498 | -// } | ||
| 499 | -// | ||
| 500 | -// @Test | ||
| 501 | -// public void testConfigurationXMLWithURLList() { | ||
| 502 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 503 | -// | ||
| 504 | -// URL urlValue = config.urlList.get(0); | ||
| 505 | -// | ||
| 506 | -// URL otherURL = null; | ||
| 507 | -// | ||
| 508 | -// try { | ||
| 509 | -// otherURL = new URL("http://www.test.com"); | ||
| 510 | -// } catch (Exception e) { | ||
| 511 | -// | ||
| 512 | -// } | ||
| 513 | -// | ||
| 514 | -// assertEquals(URL.class, urlValue.getClass()); | ||
| 515 | -// assertEquals(otherURL, urlValue); | ||
| 516 | -// assertEquals(3, config.urlList.size()); | ||
| 517 | -// } | ||
| 518 | -// | ||
| 519 | -// @Test | ||
| 520 | -// public void testConfigurationXMLWithStringList() { | ||
| 521 | -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); | ||
| 522 | -// | ||
| 523 | -// String stringValue = config.stringList.get(0); | ||
| 524 | -// | ||
| 525 | -// assertEquals(String.class, stringValue.getClass()); | ||
| 526 | -// assertEquals("Test", stringValue); | ||
| 527 | -// assertEquals(3, config.stringList.size()); | ||
| 528 | -// } | ||
| 529 | -// | ||
| 530 | -// private ConfigurationXMLWithList prepareConfigurationXMLWithList() { | ||
| 531 | -// mockStatic(Beans.class); | ||
| 532 | -// CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); | ||
| 533 | -// | ||
| 534 | -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); | ||
| 535 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 536 | -// | ||
| 537 | -// ConfigurationXMLWithList config = new ConfigurationXMLWithList(); | ||
| 538 | -// | ||
| 539 | -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); | ||
| 540 | -// | ||
| 541 | -// PowerMock.replayAll(CoreBootstrap.class,Beans.class); | ||
| 542 | -// | ||
| 543 | -// configurationLoader.load(config); | ||
| 544 | -// return config; | ||
| 545 | -// } | ||
| 546 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/InterfaceExtendsFromTransactionInterface.java
| @@ -1,44 +0,0 @@ | @@ -1,44 +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.configuration; | ||
| 38 | - | ||
| 39 | -import br.gov.frameworkdemoiselle.transaction.Transaction; | ||
| 40 | - | ||
| 41 | - | ||
| 42 | -public interface InterfaceExtendsFromTransactionInterface extends Transaction{ | ||
| 43 | - | ||
| 44 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfigTest.java
| @@ -1,63 +0,0 @@ | @@ -1,63 +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.configuration; | ||
| 38 | - | ||
| 39 | -import static org.junit.Assert.assertEquals; | ||
| 40 | - | ||
| 41 | -import org.junit.Before; | ||
| 42 | -import org.junit.Test; | ||
| 43 | - | ||
| 44 | -public class PaginationConfigTest { | ||
| 45 | - | ||
| 46 | - private PaginationConfig config; | ||
| 47 | - | ||
| 48 | - @Before | ||
| 49 | - public void setUp() throws Exception { | ||
| 50 | - this.config = new PaginationConfig(); | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - @Test | ||
| 54 | - public void testGetMaxPageLinks() { | ||
| 55 | - assertEquals(5, config.getMaxPageLinks()); | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - @Test | ||
| 59 | - public void testGetPageSize() { | ||
| 60 | - assertEquals(10, config.getPageSize()); | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java
| @@ -1,49 +0,0 @@ | @@ -1,49 +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 | -import br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthenticator; | ||
| 9 | -import br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthorizer; | ||
| 10 | -import br.gov.frameworkdemoiselle.security.Authenticator; | ||
| 11 | -import br.gov.frameworkdemoiselle.security.Authorizer; | ||
| 12 | - | ||
| 13 | -public class SecurityConfigTest { | ||
| 14 | - | ||
| 15 | - private SecurityConfig config; | ||
| 16 | - | ||
| 17 | - @Before | ||
| 18 | - public void setUp() throws Exception { | ||
| 19 | - this.config = new SecurityConfig(); | ||
| 20 | - } | ||
| 21 | - | ||
| 22 | - @Test | ||
| 23 | - public void testIsEnabled() { | ||
| 24 | - assertEquals(true, config.isEnabled()); | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - @Test | ||
| 28 | - public void testSetEnabled() { | ||
| 29 | - config.setEnabled(false); | ||
| 30 | - assertEquals(false, config.isEnabled()); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - @Test | ||
| 34 | - public void testSetAuthenticatorClass() { | ||
| 35 | - Authenticator authenticator = new DefaultAuthenticator(); | ||
| 36 | - config.setAuthenticatorClass(authenticator.getClass()); | ||
| 37 | - assertEquals("br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthenticator", config | ||
| 38 | - .getAuthenticatorClass().getName()); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - @Test | ||
| 42 | - public void testSetAuthorizerClass() { | ||
| 43 | - Authorizer authorizer = new DefaultAuthorizer(); | ||
| 44 | - config.setAuthorizerClass(authorizer.getClass()); | ||
| 45 | - assertEquals("br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthorizer", config | ||
| 46 | - .getAuthorizerClass().getName()); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/TransactionConfigTest.java
| @@ -1,23 +0,0 @@ | @@ -1,23 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.internal.configuration; | ||
| 2 | - | ||
| 3 | -import junit.framework.Assert; | ||
| 4 | - | ||
| 5 | -import org.junit.Before; | ||
| 6 | -import org.junit.Test; | ||
| 7 | - | ||
| 8 | - | ||
| 9 | -public class TransactionConfigTest { | ||
| 10 | - | ||
| 11 | - TransactionConfig transactionConfig; | ||
| 12 | - | ||
| 13 | - @Before | ||
| 14 | - public void setUp() { | ||
| 15 | - transactionConfig = new TransactionConfig(); | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | - @Test | ||
| 19 | - public void testGetTransactionClass() { | ||
| 20 | - Assert.assertNull(transactionConfig.getTransactionClass()); | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextStoreTest.java
| @@ -1,89 +0,0 @@ | @@ -1,89 +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 java.util.Map; | ||
| 40 | -import java.util.TreeMap; | ||
| 41 | - | ||
| 42 | -import org.easymock.EasyMock; | ||
| 43 | -import org.junit.Assert; | ||
| 44 | -import org.junit.Before; | ||
| 45 | -import org.junit.Test; | ||
| 46 | -import org.powermock.api.easymock.PowerMock; | ||
| 47 | -import org.powermock.reflect.Whitebox; | ||
| 48 | - | ||
| 49 | -public class ContextStoreTest { | ||
| 50 | - | ||
| 51 | - private ContextStore store; | ||
| 52 | - | ||
| 53 | - private Map<String, Object> map; | ||
| 54 | - | ||
| 55 | - @SuppressWarnings("unchecked") | ||
| 56 | - @Before | ||
| 57 | - public void setUp() { | ||
| 58 | - store = new ContextStore(); | ||
| 59 | - map = PowerMock.createMock(Map.class); | ||
| 60 | - Whitebox.setInternalState(store, "map", map); | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - @Test | ||
| 64 | - public void testContains() { | ||
| 65 | - EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(true); | ||
| 66 | - EasyMock.replay(map); | ||
| 67 | - | ||
| 68 | - Assert.assertTrue(store.contains("")); | ||
| 69 | - EasyMock.verify(map); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - @Test | ||
| 73 | - public void testGet() { | ||
| 74 | - EasyMock.expect(map.get(EasyMock.anyObject(String.class))).andReturn("testing"); | ||
| 75 | - EasyMock.replay(map); | ||
| 76 | - | ||
| 77 | - Assert.assertEquals("testing", store.get("")); | ||
| 78 | - EasyMock.verify(map); | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - @Test | ||
| 82 | - public void testPut() { | ||
| 83 | - Map<String, Object> map = new TreeMap<String, Object>(); | ||
| 84 | - Whitebox.setInternalState(store, "map", map); | ||
| 85 | - store.put("testing", map); | ||
| 86 | - Assert.assertTrue(map.containsKey("testing")); | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextsTest.java
| @@ -1,221 +0,0 @@ | @@ -1,221 +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 org.easymock.EasyMock.createMock; | ||
| 40 | -import static org.easymock.EasyMock.expect; | ||
| 41 | -import static org.easymock.EasyMock.expectLastCall; | ||
| 42 | -import static org.junit.Assert.assertEquals; | ||
| 43 | -import static org.junit.Assert.assertFalse; | ||
| 44 | -import static org.junit.Assert.assertTrue; | ||
| 45 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 46 | -import static org.powermock.api.easymock.PowerMock.replay; | ||
| 47 | - | ||
| 48 | -import java.util.ArrayList; | ||
| 49 | -import java.util.List; | ||
| 50 | -import java.util.Locale; | ||
| 51 | - | ||
| 52 | -import javax.enterprise.context.ApplicationScoped; | ||
| 53 | -import javax.enterprise.context.RequestScoped; | ||
| 54 | -import javax.enterprise.context.SessionScoped; | ||
| 55 | -import javax.enterprise.inject.spi.AfterBeanDiscovery; | ||
| 56 | - | ||
| 57 | -import org.junit.Before; | ||
| 58 | -import org.junit.Test; | ||
| 59 | -import org.junit.runner.RunWith; | ||
| 60 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 61 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 62 | - | ||
| 63 | -import br.gov.frameworkdemoiselle.annotation.ViewScoped; | ||
| 64 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 65 | - | ||
| 66 | -@RunWith(PowerMockRunner.class) | ||
| 67 | -@PrepareForTest(Beans.class) | ||
| 68 | -public class ContextsTest { | ||
| 69 | - | ||
| 70 | - private AfterBeanDiscovery event; | ||
| 71 | - | ||
| 72 | - @Before | ||
| 73 | - public void setUp() throws Exception { | ||
| 74 | - Contexts.clear(); | ||
| 75 | - mockStatic(Beans.class); | ||
| 76 | - | ||
| 77 | - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 78 | - | ||
| 79 | - replay(Beans.class); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - @Test | ||
| 83 | - public void testRemovingInexistentContext() { | ||
| 84 | - Contexts.remove(new ThreadLocalContext(SessionScoped.class)); | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - @Test | ||
| 88 | - public void testRemovingLastInactiveContext() { | ||
| 89 | - ThreadLocalContext context1 = new ThreadLocalContext(RequestScoped.class); | ||
| 90 | - ThreadLocalContext context2 = new ThreadLocalContext(RequestScoped.class); | ||
| 91 | - ThreadLocalContext context3 = new ThreadLocalContext(RequestScoped.class); | ||
| 92 | - | ||
| 93 | - Contexts.add(context1, event); | ||
| 94 | - Contexts.add(context2, event); | ||
| 95 | - Contexts.add(context3, event); | ||
| 96 | - Contexts.remove(context3); | ||
| 97 | - assertFalse(Contexts.getInactiveContexts().contains(context3)); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - @Test | ||
| 101 | - public void testRemovingActiveContextAndActivatingInactiveContext() { | ||
| 102 | - ThreadLocalContext context1 = new ThreadLocalContext(SessionScoped.class); | ||
| 103 | - ThreadLocalContext context2 = new ThreadLocalContext(SessionScoped.class); | ||
| 104 | - ThreadLocalContext context3 = new ThreadLocalContext(SessionScoped.class); | ||
| 105 | - | ||
| 106 | - Contexts.add(context1, event); | ||
| 107 | - Contexts.add(context2, event); | ||
| 108 | - Contexts.add(context3, event); | ||
| 109 | - assertTrue(context1.isActive()); | ||
| 110 | - assertFalse(context2.isActive()); | ||
| 111 | - assertFalse(context3.isActive()); | ||
| 112 | - | ||
| 113 | - Contexts.remove(context1); | ||
| 114 | - assertTrue(context2.isActive()); | ||
| 115 | - assertFalse(context3.isActive()); | ||
| 116 | - | ||
| 117 | - Contexts.remove(context2); | ||
| 118 | - assertTrue(context3.isActive()); | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - @Test | ||
| 122 | - public void testRemovingActiveContext() { | ||
| 123 | - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class); | ||
| 124 | - | ||
| 125 | - Contexts.add(context, event); | ||
| 126 | - Contexts.remove(context); | ||
| 127 | - assertEquals(0, Contexts.getActiveContexts().size()); | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - @Test | ||
| 131 | - public void testRemovingInactiveContext() { | ||
| 132 | - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class); | ||
| 133 | - | ||
| 134 | - Contexts.add(new ThreadLocalContext(SessionScoped.class), event); | ||
| 135 | - Contexts.add(context, event); | ||
| 136 | - Contexts.remove(context); | ||
| 137 | - assertEquals(0, Contexts.getInactiveContexts().size()); | ||
| 138 | - } | ||
| 139 | - | ||
| 140 | - @Test | ||
| 141 | - public void testClear() { | ||
| 142 | - List<ThreadLocalContext> list = new ArrayList<ThreadLocalContext>(); | ||
| 143 | - | ||
| 144 | - list.add(new ThreadLocalContext(SessionScoped.class)); | ||
| 145 | - list.add(new ThreadLocalContext(SessionScoped.class)); | ||
| 146 | - list.add(new ThreadLocalContext(ApplicationScoped.class)); | ||
| 147 | - | ||
| 148 | - for (ThreadLocalContext context : list) { | ||
| 149 | - Contexts.add(context, event); | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - Contexts.clear(); | ||
| 153 | - assertEquals(0, Contexts.getActiveContexts().size()); | ||
| 154 | - assertEquals(0, Contexts.getInactiveContexts().size()); | ||
| 155 | - | ||
| 156 | - for (ThreadLocalContext context : list) { | ||
| 157 | - assertFalse(context.isActive()); | ||
| 158 | - } | ||
| 159 | - } | ||
| 160 | - | ||
| 161 | - @Test | ||
| 162 | - public void testAdd() { | ||
| 163 | - Contexts.add(new ThreadLocalContext(SessionScoped.class), event); | ||
| 164 | - assertEquals(1, Contexts.getActiveContexts().size()); | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - @Test | ||
| 168 | - public void testAddingRepeatedScopeType() { | ||
| 169 | - Contexts.add(new ThreadLocalContext(SessionScoped.class), event); | ||
| 170 | - assertEquals(1, Contexts.getActiveContexts().size()); | ||
| 171 | - assertEquals(0, Contexts.getInactiveContexts().size()); | ||
| 172 | - | ||
| 173 | - Contexts.add(new ThreadLocalContext(SessionScoped.class), event); | ||
| 174 | - assertEquals(1, Contexts.getActiveContexts().size()); | ||
| 175 | - assertEquals(1, Contexts.getInactiveContexts().size()); | ||
| 176 | - } | ||
| 177 | - | ||
| 178 | - @Test | ||
| 179 | - public void testAddingRepeatedScopeInstance() { | ||
| 180 | - ThreadLocalContext context1 = new ThreadLocalContext(SessionScoped.class); | ||
| 181 | - ThreadLocalContext context2 = new ThreadLocalContext(SessionScoped.class); | ||
| 182 | - | ||
| 183 | - Contexts.add(context1, event); | ||
| 184 | - Contexts.add(context2, event); | ||
| 185 | - | ||
| 186 | - assertTrue(context1.isActive()); | ||
| 187 | - assertFalse(context2.isActive()); | ||
| 188 | - | ||
| 189 | - assertEquals(1, Contexts.getActiveContexts().size()); | ||
| 190 | - assertEquals(1, Contexts.getInactiveContexts().size()); | ||
| 191 | - } | ||
| 192 | - | ||
| 193 | - @Test | ||
| 194 | - public void testIsActive() { | ||
| 195 | - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class); | ||
| 196 | - | ||
| 197 | - Contexts.add(context, event); | ||
| 198 | - assertTrue(context.isActive()); | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | - @Test | ||
| 202 | - public void testIsInactive() { | ||
| 203 | - ThreadLocalContext context = new ThreadLocalContext(ViewScoped.class); | ||
| 204 | - | ||
| 205 | - Contexts.add(new ThreadLocalContext(ViewScoped.class), event); | ||
| 206 | - Contexts.add(context, event); | ||
| 207 | - assertFalse(context.isActive()); | ||
| 208 | - } | ||
| 209 | - | ||
| 210 | - @Test | ||
| 211 | - public void testAddWithEventNotNull() { | ||
| 212 | - event = createMock(AfterBeanDiscovery.class); | ||
| 213 | - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class); | ||
| 214 | - event.addContext(context); | ||
| 215 | - expectLastCall(); | ||
| 216 | - replay(event); | ||
| 217 | - | ||
| 218 | - Contexts.add(context, event); | ||
| 219 | - assertEquals(1, Contexts.getActiveContexts().size()); | ||
| 220 | - } | ||
| 221 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalContextTest.java
| @@ -1,231 +0,0 @@ | @@ -1,231 +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 org.easymock.EasyMock.expect; | ||
| 40 | -import static org.junit.Assert.fail; | ||
| 41 | - | ||
| 42 | -import java.lang.annotation.Annotation; | ||
| 43 | -import java.lang.reflect.Type; | ||
| 44 | -import java.util.Set; | ||
| 45 | - | ||
| 46 | -import javax.enterprise.context.ContextNotActiveException; | ||
| 47 | -import javax.enterprise.context.spi.CreationalContext; | ||
| 48 | -import javax.enterprise.inject.spi.Bean; | ||
| 49 | -import javax.enterprise.inject.spi.InjectionPoint; | ||
| 50 | -import javax.inject.Scope; | ||
| 51 | - | ||
| 52 | -import org.easymock.EasyMock; | ||
| 53 | -import org.junit.Assert; | ||
| 54 | -import org.junit.Before; | ||
| 55 | -import org.junit.Test; | ||
| 56 | -import org.junit.runner.RunWith; | ||
| 57 | -import org.powermock.api.easymock.PowerMock; | ||
| 58 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 59 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 60 | -import org.powermock.reflect.Whitebox; | ||
| 61 | - | ||
| 62 | -@RunWith(PowerMockRunner.class) | ||
| 63 | -@PrepareForTest({ Bean.class }) | ||
| 64 | -public class ThreadLocalContextTest { | ||
| 65 | - | ||
| 66 | - private ThreadLocalContext context; | ||
| 67 | - | ||
| 68 | - @Before | ||
| 69 | - public void before() { | ||
| 70 | - context = new ThreadLocalContext(Scope.class); | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - @Test | ||
| 74 | - public void testContextNotActive() { | ||
| 75 | - try { | ||
| 76 | - context.setActive(false); | ||
| 77 | - context.get(null); | ||
| 78 | - fail(); | ||
| 79 | - } catch (ContextNotActiveException exception) { | ||
| 80 | - } | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - @SuppressWarnings({ "unchecked" }) | ||
| 84 | - @Test | ||
| 85 | - public void testStoreContainsInstance() { | ||
| 86 | - String instance = "instance"; | ||
| 87 | - | ||
| 88 | - ContextStore store = PowerMock.createMock(ContextStore.class); | ||
| 89 | - expect(store.get(EasyMock.anyObject(String.class))).andReturn(instance); | ||
| 90 | - expect(store.contains(EasyMock.anyObject(String.class))).andReturn(true); | ||
| 91 | - | ||
| 92 | - ThreadLocal<ContextStore> threadLocal = PowerMock.createMock(ThreadLocal.class); | ||
| 93 | - expect(threadLocal.get()).andReturn(store).times(4); | ||
| 94 | - | ||
| 95 | - Whitebox.setInternalState(context, "threadLocal", threadLocal); | ||
| 96 | - | ||
| 97 | - Bean<String> contextual = new MyBean(); | ||
| 98 | - PowerMock.replayAll(threadLocal, store); | ||
| 99 | - | ||
| 100 | - context.setActive(true); | ||
| 101 | - Assert.assertEquals(instance, context.get(contextual)); | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - @SuppressWarnings("unchecked") | ||
| 105 | - @Test | ||
| 106 | - public void testStoreDoesNotContainsInstance() { | ||
| 107 | - String instance = "instance"; | ||
| 108 | - | ||
| 109 | - ContextStore store = PowerMock.createMock(ContextStore.class); | ||
| 110 | - expect(store.get(EasyMock.anyObject(String.class))).andReturn(instance); | ||
| 111 | - expect(store.contains(EasyMock.anyObject(String.class))).andReturn(false).times(1); | ||
| 112 | - | ||
| 113 | - ThreadLocal<ContextStore> threadLocal = PowerMock.createMock(ThreadLocal.class); | ||
| 114 | - expect(threadLocal.get()).andReturn(store).times(8); | ||
| 115 | - | ||
| 116 | - Whitebox.setInternalState(context, "threadLocal", threadLocal); | ||
| 117 | - | ||
| 118 | - Bean<String> contextual = new MyBean(); | ||
| 119 | - | ||
| 120 | - CreationalContext<String> creationalContext = PowerMock.createMock(CreationalContext.class); | ||
| 121 | - store.put("java.lang.String", instance); | ||
| 122 | - | ||
| 123 | - PowerMock.replayAll(threadLocal, store); | ||
| 124 | - | ||
| 125 | - context.setActive(true); | ||
| 126 | - Assert.assertEquals(instance, context.get(contextual, creationalContext)); | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - @Test | ||
| 130 | - public void testStoreDoesNotContainsInstanceAndCreationalContextIsNull() { | ||
| 131 | - String instance = "instance"; | ||
| 132 | - | ||
| 133 | - ContextStore store = PowerMock.createMock(ContextStore.class); | ||
| 134 | - expect(store.get(EasyMock.anyObject(String.class))).andReturn(instance); | ||
| 135 | - expect(store.contains(EasyMock.anyObject(String.class))).andReturn(false); | ||
| 136 | - | ||
| 137 | - @SuppressWarnings("unchecked") | ||
| 138 | - ThreadLocal<ContextStore> threadLocal = PowerMock.createMock(ThreadLocal.class); | ||
| 139 | - expect(threadLocal.get()).andReturn(store).times(4); | ||
| 140 | - | ||
| 141 | - Whitebox.setInternalState(context, "threadLocal", threadLocal); | ||
| 142 | - | ||
| 143 | - Bean<String> contextual = new MyBean(); | ||
| 144 | - PowerMock.replayAll(threadLocal, store); | ||
| 145 | - | ||
| 146 | - context.setActive(true); | ||
| 147 | - Assert.assertNull(context.get(contextual)); | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - @Test | ||
| 151 | - public void testContextStoreIsNull() { | ||
| 152 | - String instance = "instance"; | ||
| 153 | - | ||
| 154 | - @SuppressWarnings("unchecked") | ||
| 155 | - ThreadLocal<ContextStore> threadLocal = PowerMock.createMock(ThreadLocal.class); | ||
| 156 | - expect(threadLocal.get()).andReturn(null); | ||
| 157 | - threadLocal.set(EasyMock.anyObject(ContextStore.class)); | ||
| 158 | - PowerMock.expectLastCall(); | ||
| 159 | - | ||
| 160 | - ContextStore store = PowerMock.createMock(ContextStore.class); | ||
| 161 | - expect(store.get(EasyMock.anyObject(String.class))).andReturn(instance); | ||
| 162 | - expect(threadLocal.get()).andReturn(store).times(4); | ||
| 163 | - expect(store.contains(EasyMock.anyObject(String.class))).andReturn(true); | ||
| 164 | - | ||
| 165 | - Whitebox.setInternalState(context, "threadLocal", threadLocal); | ||
| 166 | - | ||
| 167 | - Bean<String> contextual = new MyBean(); | ||
| 168 | - PowerMock.replayAll(threadLocal, store); | ||
| 169 | - | ||
| 170 | - context.setActive(true); | ||
| 171 | - Assert.assertEquals(instance, context.get(contextual)); | ||
| 172 | - } | ||
| 173 | - | ||
| 174 | - class MyBean implements Bean<String> { | ||
| 175 | - | ||
| 176 | - @Override | ||
| 177 | - public String create(CreationalContext<String> creationalContext) { | ||
| 178 | - return "instance"; | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - @Override | ||
| 182 | - public void destroy(String instance, CreationalContext<String> creationalContext) { | ||
| 183 | - } | ||
| 184 | - | ||
| 185 | - @Override | ||
| 186 | - public Set<Type> getTypes() { | ||
| 187 | - return null; | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - @Override | ||
| 191 | - public Set<Annotation> getQualifiers() { | ||
| 192 | - return null; | ||
| 193 | - } | ||
| 194 | - | ||
| 195 | - @Override | ||
| 196 | - public Class<? extends Annotation> getScope() { | ||
| 197 | - return null; | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - @Override | ||
| 201 | - public String getName() { | ||
| 202 | - return null; | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - @Override | ||
| 206 | - public Set<Class<? extends Annotation>> getStereotypes() { | ||
| 207 | - return null; | ||
| 208 | - } | ||
| 209 | - | ||
| 210 | - @Override | ||
| 211 | - public Class<?> getBeanClass() { | ||
| 212 | - return String.class; | ||
| 213 | - } | ||
| 214 | - | ||
| 215 | - @Override | ||
| 216 | - public boolean isAlternative() { | ||
| 217 | - return false; | ||
| 218 | - } | ||
| 219 | - | ||
| 220 | - @Override | ||
| 221 | - public boolean isNullable() { | ||
| 222 | - return false; | ||
| 223 | - } | ||
| 224 | - | ||
| 225 | - @Override | ||
| 226 | - public Set<InjectionPoint> getInjectionPoints() { | ||
| 227 | - return null; | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - } | ||
| 231 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java
| @@ -1,65 +0,0 @@ | @@ -1,65 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.internal.implementation; | ||
| 2 | - | ||
| 3 | -import static org.easymock.EasyMock.expect; | ||
| 4 | -import static org.junit.Assert.assertTrue; | ||
| 5 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 6 | -import static org.powermock.api.easymock.PowerMock.replay; | ||
| 7 | - | ||
| 8 | -import java.util.Locale; | ||
| 9 | - | ||
| 10 | -import org.junit.After; | ||
| 11 | -import org.junit.Before; | ||
| 12 | -import org.junit.Test; | ||
| 13 | -import org.junit.runner.RunWith; | ||
| 14 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 15 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 16 | - | ||
| 17 | -import br.gov.frameworkdemoiselle.DemoiselleException; | ||
| 18 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 19 | - | ||
| 20 | -/** | ||
| 21 | - * @author SERPRO | ||
| 22 | - * @see DefaultAuthenticator | ||
| 23 | - */ | ||
| 24 | -@RunWith(PowerMockRunner.class) | ||
| 25 | -@PrepareForTest(Beans.class) | ||
| 26 | -public class DefaultAuthenticatorTest { | ||
| 27 | - | ||
| 28 | - private DefaultAuthenticator authenticator; | ||
| 29 | - | ||
| 30 | - @Before | ||
| 31 | - public void setUp() throws Exception { | ||
| 32 | - authenticator = new DefaultAuthenticator(); | ||
| 33 | - | ||
| 34 | - mockStatic(Beans.class); | ||
| 35 | - | ||
| 36 | - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 37 | - | ||
| 38 | - replay(Beans.class); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - @After | ||
| 42 | - public void tearDown() { | ||
| 43 | - authenticator = null; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - @Test | ||
| 47 | - public void testAuthenticate() { | ||
| 48 | - try { | ||
| 49 | - authenticator.authenticate(); | ||
| 50 | - } catch (Exception e) { | ||
| 51 | - assertTrue(e instanceof DemoiselleException); | ||
| 52 | - } | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - @Test(expected = DemoiselleException.class) | ||
| 56 | - public void testUnAuthenticate() { | ||
| 57 | - authenticator.unAuthenticate(); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - @Test(expected = DemoiselleException.class) | ||
| 61 | - public void testGetUser() { | ||
| 62 | - authenticator.getUser(); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java
| @@ -1,55 +0,0 @@ | @@ -1,55 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.internal.implementation; | ||
| 2 | - | ||
| 3 | -import static org.easymock.EasyMock.expect; | ||
| 4 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 5 | -import static org.powermock.api.easymock.PowerMock.replay; | ||
| 6 | - | ||
| 7 | -import java.util.Locale; | ||
| 8 | - | ||
| 9 | -import org.junit.After; | ||
| 10 | -import org.junit.Before; | ||
| 11 | -import org.junit.Test; | ||
| 12 | -import org.junit.runner.RunWith; | ||
| 13 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 14 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 15 | - | ||
| 16 | -import br.gov.frameworkdemoiselle.DemoiselleException; | ||
| 17 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 18 | - | ||
| 19 | -/** | ||
| 20 | - * @author SERPRO | ||
| 21 | - * @see DefaultAuthorizer | ||
| 22 | - */ | ||
| 23 | -@RunWith(PowerMockRunner.class) | ||
| 24 | -@PrepareForTest(Beans.class) | ||
| 25 | -public class DefaultAuthorizerTest { | ||
| 26 | - | ||
| 27 | - private DefaultAuthorizer authorizer; | ||
| 28 | - | ||
| 29 | - @Before | ||
| 30 | - public void setUp() throws Exception { | ||
| 31 | - authorizer = new DefaultAuthorizer(); | ||
| 32 | - | ||
| 33 | - mockStatic(Beans.class); | ||
| 34 | - | ||
| 35 | - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 36 | - | ||
| 37 | - replay(Beans.class); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - @After | ||
| 41 | - public void tearDown() { | ||
| 42 | - authorizer = null; | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - @Test(expected = DemoiselleException.class) | ||
| 46 | - public void testHasRole() { | ||
| 47 | - authorizer.hasRole(null); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - @Test(expected = DemoiselleException.class) | ||
| 51 | - public void testHasPermission() { | ||
| 52 | - authorizer.hasPermission(null, null); | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java
| @@ -1,110 +0,0 @@ | @@ -1,110 +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 org.easymock.EasyMock.expect; | ||
| 40 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 41 | -import static org.powermock.api.easymock.PowerMock.replay; | ||
| 42 | - | ||
| 43 | -import java.util.Locale; | ||
| 44 | - | ||
| 45 | -import org.junit.After; | ||
| 46 | -import org.junit.Before; | ||
| 47 | -import org.junit.Test; | ||
| 48 | -import org.junit.runner.RunWith; | ||
| 49 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 50 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 51 | - | ||
| 52 | -import br.gov.frameworkdemoiselle.DemoiselleException; | ||
| 53 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 54 | - | ||
| 55 | -/** | ||
| 56 | - * @author SERPRO | ||
| 57 | - * @see DefaultTransaction | ||
| 58 | - */ | ||
| 59 | -@RunWith(PowerMockRunner.class) | ||
| 60 | -@PrepareForTest(Beans.class) | ||
| 61 | -public class DefaultTransactionTest { | ||
| 62 | - | ||
| 63 | - private DefaultTransaction tx; | ||
| 64 | - | ||
| 65 | - @Before | ||
| 66 | - public void setUp() throws Exception { | ||
| 67 | - tx = new DefaultTransaction(); | ||
| 68 | - | ||
| 69 | - mockStatic(Beans.class); | ||
| 70 | - | ||
| 71 | - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 72 | - | ||
| 73 | - replay(Beans.class); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - @After | ||
| 77 | - public void tearDown() { | ||
| 78 | - tx = null; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - @Test(expected=DemoiselleException.class) | ||
| 82 | - public void testBegin() { | ||
| 83 | - tx.begin(); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - @Test(expected=DemoiselleException.class) | ||
| 87 | - public void testCommit() { | ||
| 88 | - tx.commit(); | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - @Test(expected=DemoiselleException.class) | ||
| 92 | - public void testIsActive() { | ||
| 93 | - tx.isActive(); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - @Test(expected=DemoiselleException.class) | ||
| 97 | - public void testIsMarkedRollback() { | ||
| 98 | - tx.isMarkedRollback(); | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - @Test(expected=DemoiselleException.class) | ||
| 102 | - public void testRollback() { | ||
| 103 | - tx.rollback(); | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - @Test(expected=DemoiselleException.class) | ||
| 107 | - public void testSetRollbackOnly() { | ||
| 108 | - tx.setRollbackOnly(); | ||
| 109 | - } | ||
| 110 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImplTest.java
| @@ -1,254 +0,0 @@ | @@ -1,254 +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 org.easymock.EasyMock.expect; | ||
| 40 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 41 | -import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 42 | - | ||
| 43 | -import java.util.Locale; | ||
| 44 | - | ||
| 45 | -import junit.framework.Assert; | ||
| 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.slf4j.Logger; | ||
| 54 | - | ||
| 55 | -import br.gov.frameworkdemoiselle.message.Message; | ||
| 56 | -import br.gov.frameworkdemoiselle.message.MessageContext; | ||
| 57 | -import br.gov.frameworkdemoiselle.message.SeverityType; | ||
| 58 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 59 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 60 | - | ||
| 61 | -@RunWith(PowerMockRunner.class) | ||
| 62 | -@PrepareForTest({ Beans.class, ResourceBundle.class }) | ||
| 63 | -public class MessageContextImplTest { | ||
| 64 | - | ||
| 65 | - MessageContext messageContext; | ||
| 66 | - | ||
| 67 | - Message m1; | ||
| 68 | - | ||
| 69 | - private ResourceBundle bundle; | ||
| 70 | - | ||
| 71 | - @SuppressWarnings("unused") | ||
| 72 | - @Before | ||
| 73 | - public void before() { | ||
| 74 | - messageContext = new MessageContextImpl(); | ||
| 75 | - | ||
| 76 | - Locale locale = Locale.getDefault(); | ||
| 77 | - | ||
| 78 | - mockStatic(Beans.class); | ||
| 79 | - expect(Beans.getReference(Locale.class)).andReturn(locale).anyTimes(); | ||
| 80 | - | ||
| 81 | - expect(Beans.getReference(ResourceBundle.class)).andReturn(bundle).anyTimes(); | ||
| 82 | - replayAll(Beans.class); | ||
| 83 | - | ||
| 84 | - Logger logger = PowerMock.createMock(Logger.class); | ||
| 85 | - | ||
| 86 | - m1 = new Message() { | ||
| 87 | - | ||
| 88 | - private String key = "m1.message"; | ||
| 89 | - | ||
| 90 | - private String resourceName = "messages"; | ||
| 91 | - | ||
| 92 | - private Locale locale = Locale.getDefault(); | ||
| 93 | - | ||
| 94 | - private SeverityType severityType = SeverityType.INFO; | ||
| 95 | - | ||
| 96 | - private Object[] parameters = {}; | ||
| 97 | - | ||
| 98 | - public String getText() { | ||
| 99 | - return key; | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - public void setKey(String key) { | ||
| 103 | - this.key = key; | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - public String getResourceName() { | ||
| 107 | - return resourceName; | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - public void setResourceName(String resourceName) { | ||
| 111 | - this.resourceName = resourceName; | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - public Locale getLocale() { | ||
| 115 | - return locale; | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - public void setLocale(Locale locale) { | ||
| 119 | - this.locale = locale; | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - public SeverityType getSeverity() { | ||
| 123 | - return severityType; | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - public void setSeverityType(SeverityType severityType) { | ||
| 127 | - this.severityType = severityType; | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - public Object[] getParameters() { | ||
| 131 | - return parameters; | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - public Message setParameters(Object[] parameters) { | ||
| 135 | - this.parameters = parameters; | ||
| 136 | - return this; | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - public String getStringMessage() { | ||
| 140 | - return "stringMessage"; | ||
| 141 | - } | ||
| 142 | - }; | ||
| 143 | - } | ||
| 144 | - | ||
| 145 | - @Test | ||
| 146 | - public void testAddMessage() { | ||
| 147 | - messageContext.add(m1); | ||
| 148 | - Assert.assertTrue(messageContext.getMessages().size() == 1); | ||
| 149 | - Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(m1.getText())); | ||
| 150 | - Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(m1.getSeverity())); | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - @Test | ||
| 154 | - public void testClearMessages() { | ||
| 155 | - Assert.assertTrue(messageContext.getMessages().isEmpty()); | ||
| 156 | - | ||
| 157 | - messageContext.add(m1); | ||
| 158 | - messageContext.add(m1, (Object[]) null); | ||
| 159 | - | ||
| 160 | - Assert.assertTrue(messageContext.getMessages().size() == 2); | ||
| 161 | - | ||
| 162 | - messageContext.clear(); | ||
| 163 | - | ||
| 164 | - Assert.assertTrue(messageContext.getMessages().isEmpty()); | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - @Test | ||
| 168 | - public void testGetMessages() { | ||
| 169 | - Assert.assertNotNull(messageContext.getMessages()); | ||
| 170 | - Assert.assertTrue(messageContext.getMessages().isEmpty()); | ||
| 171 | - | ||
| 172 | - messageContext.add("key1"); | ||
| 173 | - Assert.assertTrue(messageContext.getMessages().size() == 1); | ||
| 174 | - | ||
| 175 | - messageContext.add("key2"); | ||
| 176 | - Assert.assertTrue(messageContext.getMessages().size() == 2); | ||
| 177 | - | ||
| 178 | - Assert.assertTrue(messageContext.getMessages().get(0).getText().equals("key1")); | ||
| 179 | - Assert.assertTrue(messageContext.getMessages().get(1).getText().equals("key2")); | ||
| 180 | - } | ||
| 181 | - | ||
| 182 | - // @Test | ||
| 183 | - // public void testAddMessageObjectArray() { | ||
| 184 | - // Object[] param = { "1", "2" }; | ||
| 185 | - // messageContext.add(m1, param); | ||
| 186 | - | ||
| 187 | - // Assert.assertTrue(messageContext.getMessages().size() == 1); | ||
| 188 | - // Assert.assertTrue(messageContext.getMessages().contains(m1)); | ||
| 189 | - // Assert.assertNotNull(messageContext.getMessages().get(0).getParameters()); | ||
| 190 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | ||
| 191 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | ||
| 192 | - // } | ||
| 193 | - | ||
| 194 | - // @Test | ||
| 195 | - // public void testAddStringObjectArray() { | ||
| 196 | - // String key = "my.key"; | ||
| 197 | - // Object[] param = { "1", "2" }; | ||
| 198 | - // messageContext.add(key, param); | ||
| 199 | - // | ||
| 200 | - // Assert.assertTrue(messageContext.getMessages().size() == 1); | ||
| 201 | - // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | ||
| 202 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | ||
| 203 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | ||
| 204 | - // } | ||
| 205 | - // | ||
| 206 | - // @Test | ||
| 207 | - // public void testAddStringLocaleObjectArray() { | ||
| 208 | - // String key = "my.key"; | ||
| 209 | - // Object[] param = { "1", "2" }; | ||
| 210 | - // Locale locale = Locale.CANADA_FRENCH; | ||
| 211 | - // messageContext.add(key, locale, param); | ||
| 212 | - // | ||
| 213 | - // Assert.assertTrue(messageContext.getMessages().size() == 1); | ||
| 214 | - // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | ||
| 215 | - // Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); | ||
| 216 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | ||
| 217 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | ||
| 218 | - // } | ||
| 219 | - // | ||
| 220 | - // @Test | ||
| 221 | - // public void testAddStringLocaleSeverityTypeObjectArray() { | ||
| 222 | - // String key = "my.key"; | ||
| 223 | - // Object[] param = { "1", "2" }; | ||
| 224 | - // Locale locale = Locale.CANADA_FRENCH; | ||
| 225 | - // SeverityType severity = SeverityType.ERROR; | ||
| 226 | - // messageContext.add(key, locale, severity, param); | ||
| 227 | - // | ||
| 228 | - // Assert.assertTrue(messageContext.getMessages().size() == 1); | ||
| 229 | - // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | ||
| 230 | - // Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); | ||
| 231 | - // Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(severity)); | ||
| 232 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | ||
| 233 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | ||
| 234 | - // } | ||
| 235 | - // | ||
| 236 | - // @Test | ||
| 237 | - // public void testAddStringLocaleSeverityTypeStringObjectArray() { | ||
| 238 | - // String key = "my.key"; | ||
| 239 | - // Object[] param = { "1", "2" }; | ||
| 240 | - // Locale locale = Locale.CANADA_FRENCH; | ||
| 241 | - // SeverityType severity = SeverityType.ERROR; | ||
| 242 | - // String resource = "myresourcename"; | ||
| 243 | - // messageContext.add(key, locale, severity, resource, param); | ||
| 244 | - // | ||
| 245 | - // Assert.assertTrue(messageContext.getMessages().size() == 1); | ||
| 246 | - // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); | ||
| 247 | - // Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); | ||
| 248 | - // Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(severity)); | ||
| 249 | - // Assert.assertTrue(messageContext.getMessages().get(0).getResourceName().equals(resource)); | ||
| 250 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); | ||
| 251 | - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); | ||
| 252 | - // } | ||
| 253 | - | ||
| 254 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationContextImplTest.java
| @@ -1,131 +0,0 @@ | @@ -1,131 +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 org.easymock.EasyMock.expect; | ||
| 40 | -import static org.junit.Assert.assertEquals; | ||
| 41 | -import static org.junit.Assert.assertNotNull; | ||
| 42 | -import static org.junit.Assert.assertNull; | ||
| 43 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 44 | -import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 45 | - | ||
| 46 | -import java.util.HashMap; | ||
| 47 | -import java.util.Map; | ||
| 48 | - | ||
| 49 | -import org.easymock.EasyMock; | ||
| 50 | -import org.junit.After; | ||
| 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 | -import org.powermock.reflect.Whitebox; | ||
| 57 | - | ||
| 58 | -import br.gov.frameworkdemoiselle.internal.configuration.PaginationConfig; | ||
| 59 | -import br.gov.frameworkdemoiselle.pagination.Pagination; | ||
| 60 | -import br.gov.frameworkdemoiselle.pagination.PaginationContext; | ||
| 61 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 62 | - | ||
| 63 | -@RunWith(PowerMockRunner.class) | ||
| 64 | -@PrepareForTest(Beans.class) | ||
| 65 | -public class PaginationContextImplTest { | ||
| 66 | - | ||
| 67 | - private PaginationContext context; | ||
| 68 | - | ||
| 69 | - private PaginationConfig config = new PaginationConfig(); | ||
| 70 | - | ||
| 71 | - private Pagination pagination; | ||
| 72 | - | ||
| 73 | - public void setUp() { | ||
| 74 | - context = new PaginationContextImpl(); | ||
| 75 | - | ||
| 76 | - PaginationConfig config = PowerMock.createMock(PaginationConfig.class); | ||
| 77 | - EasyMock.expect(config.getPageSize()).andReturn(10).anyTimes(); | ||
| 78 | - EasyMock.replay(config); | ||
| 79 | - | ||
| 80 | - Whitebox.setInternalState(context, "config", config); | ||
| 81 | - Whitebox.setInternalState(context, "cache", getInitialMap()); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - @After | ||
| 85 | - public void tearDown() { | ||
| 86 | - context = null; | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - private Map<Class<?>, Pagination> getInitialMap() { | ||
| 90 | - Map<Class<?>, Pagination> map = new HashMap<Class<?>, Pagination>(); | ||
| 91 | - pagination = new PaginationImpl(); | ||
| 92 | - map.put(getClass(), pagination); | ||
| 93 | - | ||
| 94 | - return map; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - @Test | ||
| 98 | - public void testNullPaginationConfig() { | ||
| 99 | - context = new PaginationContextImpl(); | ||
| 100 | - | ||
| 101 | - mockStatic(Beans.class); | ||
| 102 | - expect(Beans.getReference(PaginationConfig.class)).andReturn(config).anyTimes(); | ||
| 103 | - replayAll(Beans.class); | ||
| 104 | - | ||
| 105 | - assertNotNull(context.getPagination(Object.class, true)); | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - @Test | ||
| 109 | - public void testGetPaginationWithoutCreateParameter() { | ||
| 110 | - setUp(); | ||
| 111 | - | ||
| 112 | - assertEquals(pagination, context.getPagination(getClass())); | ||
| 113 | - assertNull(context.getPagination(Object.class)); | ||
| 114 | - } | ||
| 115 | - | ||
| 116 | - @Test | ||
| 117 | - public void testGetPaginationWithCreateParameterTrueValued() { | ||
| 118 | - setUp(); | ||
| 119 | - | ||
| 120 | - assertEquals(pagination, context.getPagination(getClass(), true)); | ||
| 121 | - assertNotNull(context.getPagination(Object.class, true)); | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | - @Test | ||
| 125 | - public void testGetPaginationWithCreateParameterFalseValued() { | ||
| 126 | - setUp(); | ||
| 127 | - | ||
| 128 | - assertEquals(pagination, context.getPagination(getClass(), false)); | ||
| 129 | - assertNull(context.getPagination(Object.class, false)); | ||
| 130 | - } | ||
| 131 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationImplTest.java
| @@ -1,322 +0,0 @@ | @@ -1,322 +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 org.junit.Assert.assertEquals; | ||
| 40 | -import static org.junit.Assert.fail; | ||
| 41 | - | ||
| 42 | -import org.junit.After; | ||
| 43 | -import org.junit.Before; | ||
| 44 | -import org.junit.Test; | ||
| 45 | - | ||
| 46 | -import br.gov.frameworkdemoiselle.pagination.Pagination; | ||
| 47 | -import br.gov.frameworkdemoiselle.util.Strings; | ||
| 48 | - | ||
| 49 | -/** | ||
| 50 | - * @author SERPRO | ||
| 51 | - */ | ||
| 52 | - | ||
| 53 | -public class PaginationImplTest { | ||
| 54 | - | ||
| 55 | - private Pagination pagination; | ||
| 56 | - | ||
| 57 | - @Before | ||
| 58 | - public void setUp() { | ||
| 59 | - pagination = new PaginationImpl(); | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - @After | ||
| 63 | - public void tearDown() { | ||
| 64 | - pagination = null; | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - @Test | ||
| 68 | - public void testConstructor() { | ||
| 69 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 70 | - assertEquals(0, pagination.getTotalResults()); | ||
| 71 | - assertEquals(0, pagination.getTotalPages()); | ||
| 72 | - assertEquals(0, pagination.getFirstResult()); | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - @Test | ||
| 76 | - public void testCurrentPageProperty() { | ||
| 77 | - pagination.setCurrentPage(0); | ||
| 78 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 79 | - | ||
| 80 | - pagination.setCurrentPage(1); | ||
| 81 | - assertEquals(1, pagination.getCurrentPage()); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - @Test | ||
| 85 | - public void testPageSizeProperty() { | ||
| 86 | - pagination.setPageSize(0); | ||
| 87 | - assertEquals(0, pagination.getPageSize()); | ||
| 88 | - | ||
| 89 | - pagination.setPageSize(1); | ||
| 90 | - assertEquals(1, pagination.getPageSize()); | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - @Test | ||
| 94 | - public void testTotalResultsProperty() { | ||
| 95 | - pagination.setTotalResults(0); | ||
| 96 | - assertEquals(0, pagination.getTotalResults()); | ||
| 97 | - | ||
| 98 | - pagination.setTotalResults(1); | ||
| 99 | - assertEquals(1, pagination.getTotalResults()); | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - @Test | ||
| 103 | - public void testTotalPagesWhenTotalResultsChanges() { | ||
| 104 | - pagination.setPageSize(10); | ||
| 105 | - | ||
| 106 | - pagination.setTotalResults(0); | ||
| 107 | - assertEquals(0, pagination.getTotalPages()); | ||
| 108 | - | ||
| 109 | - pagination.setTotalResults(9); | ||
| 110 | - assertEquals(1, pagination.getTotalPages()); | ||
| 111 | - | ||
| 112 | - pagination.setTotalResults(10); | ||
| 113 | - assertEquals(1, pagination.getTotalPages()); | ||
| 114 | - | ||
| 115 | - pagination.setTotalResults(11); | ||
| 116 | - assertEquals(2, pagination.getTotalPages()); | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - @Test | ||
| 120 | - public void testIndexOutOfBoundsException() { | ||
| 121 | - try { | ||
| 122 | - pagination.setCurrentPage(-1); | ||
| 123 | - fail(); | ||
| 124 | - } catch (IndexOutOfBoundsException cause) { | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - try { | ||
| 128 | - pagination.setFirstResult(-1); | ||
| 129 | - fail(); | ||
| 130 | - } catch (IndexOutOfBoundsException cause) { | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - try { | ||
| 134 | - pagination.setPageSize(-1); | ||
| 135 | - fail(); | ||
| 136 | - } catch (IndexOutOfBoundsException cause) { | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - try { | ||
| 140 | - pagination.setTotalResults(-1); | ||
| 141 | - fail(); | ||
| 142 | - } catch (IndexOutOfBoundsException cause) { | ||
| 143 | - } | ||
| 144 | - | ||
| 145 | - try { | ||
| 146 | - pagination.setTotalResults(1); | ||
| 147 | - pagination.setFirstResult(1); | ||
| 148 | - fail(); | ||
| 149 | - } catch (IndexOutOfBoundsException cause) { | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - try { | ||
| 153 | - pagination.setTotalResults(1); | ||
| 154 | - pagination.setFirstResult(2); | ||
| 155 | - fail(); | ||
| 156 | - } catch (IndexOutOfBoundsException cause) { | ||
| 157 | - } | ||
| 158 | - | ||
| 159 | - try { | ||
| 160 | - pagination.setPageSize(2); | ||
| 161 | - pagination.setTotalResults(3); | ||
| 162 | - pagination.setCurrentPage(2); | ||
| 163 | - fail(); | ||
| 164 | - } catch (IndexOutOfBoundsException cause) { | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - try { | ||
| 168 | - pagination.setPageSize(2); | ||
| 169 | - pagination.setTotalResults(3); | ||
| 170 | - pagination.setCurrentPage(3); | ||
| 171 | - fail(); | ||
| 172 | - } catch (IndexOutOfBoundsException cause) { | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - try { | ||
| 176 | - pagination.setTotalResults(0); | ||
| 177 | - pagination.setFirstResult(0); | ||
| 178 | - } catch (IndexOutOfBoundsException cause) { | ||
| 179 | - fail(); | ||
| 180 | - } | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | - @Test | ||
| 184 | - public void testTotalPagesWhenPageSizeChanges() { | ||
| 185 | - pagination.setTotalResults(10); | ||
| 186 | - | ||
| 187 | - pagination.setPageSize(0); | ||
| 188 | - assertEquals(0, pagination.getTotalPages()); | ||
| 189 | - | ||
| 190 | - pagination.setPageSize(9); | ||
| 191 | - assertEquals(2, pagination.getTotalPages()); | ||
| 192 | - | ||
| 193 | - pagination.setPageSize(10); | ||
| 194 | - assertEquals(1, pagination.getTotalPages()); | ||
| 195 | - | ||
| 196 | - pagination.setPageSize(11); | ||
| 197 | - assertEquals(1, pagination.getTotalPages()); | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - @Test | ||
| 201 | - public void testCurrentPageWhenPageSizeChanges() { | ||
| 202 | - pagination.setTotalResults(10); | ||
| 203 | - | ||
| 204 | - pagination.setPageSize(5); | ||
| 205 | - pagination.setCurrentPage(1); | ||
| 206 | - pagination.setPageSize(0); | ||
| 207 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 208 | - | ||
| 209 | - pagination.setPageSize(5); | ||
| 210 | - pagination.setCurrentPage(1); | ||
| 211 | - pagination.setPageSize(9); | ||
| 212 | - assertEquals(1, pagination.getCurrentPage()); | ||
| 213 | - | ||
| 214 | - pagination.setPageSize(5); | ||
| 215 | - pagination.setCurrentPage(1); | ||
| 216 | - pagination.setPageSize(10); | ||
| 217 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 218 | - | ||
| 219 | - pagination.setPageSize(5); | ||
| 220 | - pagination.setCurrentPage(0); | ||
| 221 | - pagination.setPageSize(11); | ||
| 222 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 223 | - } | ||
| 224 | - | ||
| 225 | - @Test | ||
| 226 | - public void testCurrentPageWhenTotalResultsChanges() { | ||
| 227 | - pagination.setPageSize(10); | ||
| 228 | - | ||
| 229 | - pagination.setTotalResults(11); | ||
| 230 | - pagination.setCurrentPage(1); | ||
| 231 | - pagination.setTotalResults(0); | ||
| 232 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 233 | - | ||
| 234 | - pagination.setTotalResults(11); | ||
| 235 | - pagination.setCurrentPage(1); | ||
| 236 | - pagination.setTotalResults(9); | ||
| 237 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 238 | - | ||
| 239 | - pagination.setTotalResults(11); | ||
| 240 | - pagination.setCurrentPage(1); | ||
| 241 | - pagination.setTotalResults(10); | ||
| 242 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 243 | - | ||
| 244 | - pagination.setTotalResults(12); | ||
| 245 | - pagination.setCurrentPage(1); | ||
| 246 | - pagination.setTotalResults(11); | ||
| 247 | - assertEquals(1, pagination.getCurrentPage()); | ||
| 248 | - } | ||
| 249 | - | ||
| 250 | - @Test | ||
| 251 | - public void testCurrentPageWhenFirstResultChanges() { | ||
| 252 | - pagination.setPageSize(10); | ||
| 253 | - pagination.setTotalResults(100); | ||
| 254 | - | ||
| 255 | - pagination.setFirstResult(0); | ||
| 256 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 257 | - | ||
| 258 | - pagination.setFirstResult(1); | ||
| 259 | - assertEquals(0, pagination.getCurrentPage()); | ||
| 260 | - | ||
| 261 | - pagination.setFirstResult(98); | ||
| 262 | - assertEquals(9, pagination.getCurrentPage()); | ||
| 263 | - | ||
| 264 | - pagination.setFirstResult(99); | ||
| 265 | - assertEquals(9, pagination.getCurrentPage()); | ||
| 266 | - } | ||
| 267 | - | ||
| 268 | - @Test | ||
| 269 | - public void testFirstResultWhenPageSizeChanges() { | ||
| 270 | - pagination.setTotalResults(10); | ||
| 271 | - | ||
| 272 | - pagination.setPageSize(10); | ||
| 273 | - pagination.setFirstResult(5); | ||
| 274 | - pagination.setPageSize(0); | ||
| 275 | - assertEquals(0, pagination.getFirstResult()); | ||
| 276 | - | ||
| 277 | - pagination.setPageSize(10); | ||
| 278 | - pagination.setFirstResult(9); | ||
| 279 | - pagination.setPageSize(1); | ||
| 280 | - assertEquals(0, pagination.getFirstResult()); | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - @Test | ||
| 284 | - public void testFirstResultWhenTotalResultsChanges() { | ||
| 285 | - pagination.setPageSize(10); | ||
| 286 | - | ||
| 287 | - pagination.setTotalResults(50); | ||
| 288 | - pagination.setFirstResult(49); | ||
| 289 | - pagination.setTotalResults(0); | ||
| 290 | - assertEquals(0, pagination.getFirstResult()); | ||
| 291 | - | ||
| 292 | - pagination.setTotalResults(50); | ||
| 293 | - pagination.setFirstResult(49); | ||
| 294 | - pagination.setTotalResults(1); | ||
| 295 | - assertEquals(0, pagination.getFirstResult()); | ||
| 296 | - | ||
| 297 | - pagination.setTotalResults(50); | ||
| 298 | - pagination.setFirstResult(49); | ||
| 299 | - pagination.setTotalResults(49); | ||
| 300 | - assertEquals(40, pagination.getFirstResult()); | ||
| 301 | - } | ||
| 302 | - | ||
| 303 | - @Test | ||
| 304 | - public void testFirstResultWhenCurrentPageChanges() { | ||
| 305 | - pagination.setPageSize(10); | ||
| 306 | - pagination.setTotalResults(100); | ||
| 307 | - | ||
| 308 | - pagination.setCurrentPage(0); | ||
| 309 | - assertEquals(0, pagination.getFirstResult()); | ||
| 310 | - | ||
| 311 | - pagination.setCurrentPage(1); | ||
| 312 | - assertEquals(10, pagination.getFirstResult()); | ||
| 313 | - | ||
| 314 | - pagination.setCurrentPage(9); | ||
| 315 | - assertEquals(90, pagination.getFirstResult()); | ||
| 316 | - } | ||
| 317 | - | ||
| 318 | - @Test | ||
| 319 | - public void testToStringFormat() { | ||
| 320 | - assertEquals(Strings.toString(pagination), pagination.toString()); | ||
| 321 | - } | ||
| 322 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImplTest.java
| @@ -1,393 +0,0 @@ | @@ -1,393 +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 junit.framework.Assert.assertFalse; | ||
| 41 | -import static junit.framework.Assert.assertNotNull; | ||
| 42 | -import static junit.framework.Assert.assertNull; | ||
| 43 | -import static junit.framework.Assert.assertTrue; | ||
| 44 | -import static junit.framework.Assert.fail; | ||
| 45 | -import static org.easymock.EasyMock.createMock; | ||
| 46 | -import static org.easymock.EasyMock.expect; | ||
| 47 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 48 | -import static org.powermock.api.easymock.PowerMock.replay; | ||
| 49 | -import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 50 | -import static org.powermock.reflect.Whitebox.setInternalState; | ||
| 51 | - | ||
| 52 | -import java.security.Principal; | ||
| 53 | -import java.util.ArrayList; | ||
| 54 | -import java.util.List; | ||
| 55 | -import java.util.Locale; | ||
| 56 | - | ||
| 57 | -import javax.enterprise.inject.spi.BeanManager; | ||
| 58 | - | ||
| 59 | -import org.easymock.EasyMock; | ||
| 60 | -import org.junit.Before; | ||
| 61 | -import org.junit.Test; | ||
| 62 | -import org.junit.runner.RunWith; | ||
| 63 | -import org.powermock.api.easymock.PowerMock; | ||
| 64 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 65 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 66 | - | ||
| 67 | -import br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap; | ||
| 68 | -import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfig; | ||
| 69 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 70 | -import br.gov.frameworkdemoiselle.security.Authenticator; | ||
| 71 | -import br.gov.frameworkdemoiselle.security.Authorizer; | ||
| 72 | -import br.gov.frameworkdemoiselle.security.NotLoggedInException; | ||
| 73 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 74 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 75 | - | ||
| 76 | -@RunWith(PowerMockRunner.class) | ||
| 77 | -@PrepareForTest({ Beans.class, ResourceBundle.class }) | ||
| 78 | -public class SecurityContextImplTest { | ||
| 79 | - | ||
| 80 | - private SecurityContextImpl context; | ||
| 81 | - | ||
| 82 | - private SecurityConfig config; | ||
| 83 | - | ||
| 84 | - private ResourceBundle bundle; | ||
| 85 | - | ||
| 86 | - @Before | ||
| 87 | - public void setUpConfig() { | ||
| 88 | - context = new SecurityContextImpl(); | ||
| 89 | - config = createMock(SecurityConfig.class); | ||
| 90 | - | ||
| 91 | - mockStatic(Beans.class); | ||
| 92 | - expect(Beans.getReference(SecurityConfig.class)).andReturn(config).anyTimes(); | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - @Test | ||
| 96 | - public void testHasPermissionWithSecurityDisabled() { | ||
| 97 | - expect(config.isEnabled()).andReturn(false); | ||
| 98 | - replayAll(Beans.class, config); | ||
| 99 | - | ||
| 100 | - try { | ||
| 101 | - assertTrue(context.hasPermission(null, null)); | ||
| 102 | - } catch (NotLoggedInException e) { | ||
| 103 | - fail(); | ||
| 104 | - } | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - public void mockGetAuthenticator() { | ||
| 108 | - Class<? extends Authenticator> cache = AuthenticatorImpl.class; | ||
| 109 | - List<Class<? extends Authenticator>> cacheList = new ArrayList<Class<? extends Authenticator>>(); | ||
| 110 | - cacheList.add(cache); | ||
| 111 | - | ||
| 112 | - AuthenticatorBootstrap bootstrap = PowerMock.createMock(AuthenticatorBootstrap.class); | ||
| 113 | - | ||
| 114 | - expect(Beans.getReference(AuthenticatorBootstrap.class)).andReturn(bootstrap).anyTimes(); | ||
| 115 | - expect(config.getAuthenticatorClass()).andReturn(null).anyTimes(); | ||
| 116 | - expect(bootstrap.getCache()).andReturn(cacheList); | ||
| 117 | - expect(Beans.getReference(AuthenticatorImpl.class)).andReturn(new AuthenticatorImpl()); | ||
| 118 | - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes(); | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - @Test | ||
| 122 | - public void testHasPermissionWithSecurityEnabledAndNotLoggedIn() { | ||
| 123 | - mockGetAuthenticator(); | ||
| 124 | - | ||
| 125 | - expect(config.isEnabled()).andReturn(true).anyTimes(); | ||
| 126 | - replayAll(Beans.class, config); | ||
| 127 | - | ||
| 128 | - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); | ||
| 129 | - | ||
| 130 | - try { | ||
| 131 | - context.hasPermission(null, null); | ||
| 132 | - fail(); | ||
| 133 | - } catch (NotLoggedInException e) { | ||
| 134 | - assertTrue(e.getMessage().equals(bundle.getString("user-not-authenticated"))); | ||
| 135 | - } | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - // @Test | ||
| 139 | - // public void testHasPermissionWithSecurityEnabledAndLoggedIn() { | ||
| 140 | - // expect(config.isEnabled()).andReturn(true).anyTimes(); | ||
| 141 | - // replay(config); | ||
| 142 | - // | ||
| 143 | - // loginSuccessfully(); | ||
| 144 | - // | ||
| 145 | - // Authorizer authorizer = createMock(Authorizer.class); | ||
| 146 | - // expect(authorizer.hasPermission(null, null)).andReturn(true); | ||
| 147 | - // | ||
| 148 | - // setInternalState(context, "authorizer", authorizer); | ||
| 149 | - // | ||
| 150 | - // replay(authorizer); | ||
| 151 | - // | ||
| 152 | - // try { | ||
| 153 | - // assertTrue(context.hasPermission(null, null)); | ||
| 154 | - // } catch (NotLoggedInException e) { | ||
| 155 | - // fail(); | ||
| 156 | - // } | ||
| 157 | - // } | ||
| 158 | - | ||
| 159 | - private void loginSuccessfully() { | ||
| 160 | - Authenticator authenticator = createMock(Authenticator.class); | ||
| 161 | - // expect(authenticator.authenticate()).andReturn(true); | ||
| 162 | - | ||
| 163 | - BeanManager manager = createMock(BeanManager.class); | ||
| 164 | - expect(Beans.getBeanManager()).andReturn(manager); | ||
| 165 | - manager.fireEvent(EasyMock.anyObject(Class.class)); | ||
| 166 | - PowerMock.expectLastCall(); | ||
| 167 | - | ||
| 168 | - Principal user = createMock(Principal.class); | ||
| 169 | - expect(authenticator.getUser()).andReturn(user).anyTimes(); | ||
| 170 | - | ||
| 171 | - setInternalState(context, "authenticator", authenticator); | ||
| 172 | - | ||
| 173 | - replayAll(authenticator, user, Beans.class, manager); | ||
| 174 | - | ||
| 175 | - context.login(); | ||
| 176 | - assertTrue(context.isLoggedIn()); | ||
| 177 | - } | ||
| 178 | - | ||
| 179 | - @Test | ||
| 180 | - public void testHasRoleWithSecurityDisabled() { | ||
| 181 | - expect(config.isEnabled()).andReturn(false); | ||
| 182 | - replayAll(Beans.class, config); | ||
| 183 | - | ||
| 184 | - try { | ||
| 185 | - assertTrue(context.hasRole(null)); | ||
| 186 | - } catch (NotLoggedInException e) { | ||
| 187 | - fail(); | ||
| 188 | - } | ||
| 189 | - } | ||
| 190 | - | ||
| 191 | - @Test | ||
| 192 | - public void testHasRoleWithSecurityEnabledAndNotLoggedIn() { | ||
| 193 | - mockGetAuthenticator(); | ||
| 194 | - | ||
| 195 | - expect(config.isEnabled()).andReturn(true).anyTimes(); | ||
| 196 | - replayAll(Beans.class, config); | ||
| 197 | - | ||
| 198 | - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); | ||
| 199 | - | ||
| 200 | - try { | ||
| 201 | - context.hasRole(null); | ||
| 202 | - fail(); | ||
| 203 | - } catch (NotLoggedInException e) { | ||
| 204 | - assertTrue(e.getMessage().equals(bundle.getString("user-not-authenticated"))); | ||
| 205 | - } | ||
| 206 | - } | ||
| 207 | - | ||
| 208 | - // @Test | ||
| 209 | - // public void testHasRoleWithSecurityEnabledAndLoggedIn() { | ||
| 210 | - // expect(config.isEnabled()).andReturn(true).anyTimes(); | ||
| 211 | - // replay(config); | ||
| 212 | - // | ||
| 213 | - // loginSuccessfully(); | ||
| 214 | - // | ||
| 215 | - // Authorizer authorizer = createMock(Authorizer.class); | ||
| 216 | - // expect(authorizer.hasRole(null)).andReturn(true); | ||
| 217 | - // | ||
| 218 | - // setInternalState(context, "authorizer", authorizer); | ||
| 219 | - // | ||
| 220 | - // replay(authorizer); | ||
| 221 | - // | ||
| 222 | - // try { | ||
| 223 | - // assertTrue(context.hasRole(null)); | ||
| 224 | - // } catch (NotLoggedInException e) { | ||
| 225 | - // fail(); | ||
| 226 | - // } | ||
| 227 | - // } | ||
| 228 | - | ||
| 229 | - @Test | ||
| 230 | - public void testIsLoggedInWithSecurityEnabled() { | ||
| 231 | - Authenticator authenticator = createMock(Authenticator.class); | ||
| 232 | - expect(authenticator.getUser()).andReturn(null).anyTimes(); | ||
| 233 | - expect(config.isEnabled()).andReturn(true).anyTimes(); | ||
| 234 | - | ||
| 235 | - setInternalState(context, "authenticator", authenticator); | ||
| 236 | - | ||
| 237 | - replayAll(config, authenticator); | ||
| 238 | - | ||
| 239 | - assertFalse(context.isLoggedIn()); | ||
| 240 | - } | ||
| 241 | - | ||
| 242 | - @Test | ||
| 243 | - public void testIsLoggedInWithSecurityDisabled() { | ||
| 244 | - expect(config.isEnabled()).andReturn(false); | ||
| 245 | - replayAll(config, Beans.class); | ||
| 246 | - | ||
| 247 | - assertTrue(context.isLoggedIn()); | ||
| 248 | - } | ||
| 249 | - | ||
| 250 | - @Test | ||
| 251 | - public void testLoginWithSecurityDisabled() { | ||
| 252 | - expect(config.isEnabled()).andReturn(false).times(2); | ||
| 253 | - replayAll(config, Beans.class); | ||
| 254 | - context.login(); | ||
| 255 | - | ||
| 256 | - assertTrue(context.isLoggedIn()); | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - // @Test | ||
| 260 | - // public void testLoginWithAuthenticationFail() { | ||
| 261 | - // Authenticator authenticator = createMock(Authenticator.class); | ||
| 262 | - // | ||
| 263 | - // expect(config.isEnabled()).andReturn(true).anyTimes(); | ||
| 264 | - // expect(authenticator.getUser()).andReturn(null).anyTimes(); | ||
| 265 | - // | ||
| 266 | - // setInternalState(context, "authenticator", authenticator); | ||
| 267 | - // | ||
| 268 | - // replayAll(authenticator, config); | ||
| 269 | - // | ||
| 270 | - // context.login(); | ||
| 271 | - // assertFalse(context.isLoggedIn()); | ||
| 272 | - // } | ||
| 273 | - | ||
| 274 | - @Test | ||
| 275 | - public void testLogOutWithSecurityDisabled() { | ||
| 276 | - expect(config.isEnabled()).andReturn(false).times(2); | ||
| 277 | - | ||
| 278 | - replayAll(config, Beans.class); | ||
| 279 | - | ||
| 280 | - try { | ||
| 281 | - context.logout(); | ||
| 282 | - assertTrue(context.isLoggedIn()); | ||
| 283 | - } catch (NotLoggedInException e) { | ||
| 284 | - fail(); | ||
| 285 | - } | ||
| 286 | - } | ||
| 287 | - | ||
| 288 | - @Test | ||
| 289 | - public void testLogOutWithoutPreviousLogin() { | ||
| 290 | - Authenticator authenticator = createMock(Authenticator.class); | ||
| 291 | - | ||
| 292 | - expect(authenticator.getUser()).andReturn(null).anyTimes(); | ||
| 293 | - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes(); | ||
| 294 | - expect(config.isEnabled()).andReturn(true).anyTimes(); | ||
| 295 | - | ||
| 296 | - setInternalState(context, "authenticator", authenticator); | ||
| 297 | - | ||
| 298 | - replayAll(config, authenticator, Beans.class); | ||
| 299 | - | ||
| 300 | - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); | ||
| 301 | - | ||
| 302 | - try { | ||
| 303 | - context.logout(); | ||
| 304 | - fail(); | ||
| 305 | - } catch (NotLoggedInException e) { | ||
| 306 | - assertTrue(e.getMessage().equals(bundle.getString("user-not-authenticated"))); | ||
| 307 | - } | ||
| 308 | - } | ||
| 309 | - | ||
| 310 | - // @Test | ||
| 311 | - // public void testLogOutAfterSuccessfulLogin() { | ||
| 312 | - // expect(config.isEnabled()).andReturn(true).anyTimes(); | ||
| 313 | - // | ||
| 314 | - // Authenticator authenticator = createMock(Authenticator.class); | ||
| 315 | - // authenticator.unAuthenticate(); | ||
| 316 | - // PowerMock.expectLastCall(); | ||
| 317 | - // | ||
| 318 | - // Principal user = createMock(Principal.class); | ||
| 319 | - // expect(authenticator.getUser()).andReturn(user); | ||
| 320 | - // expect(authenticator.getUser()).andReturn(null); | ||
| 321 | - // | ||
| 322 | - // BeanManager manager = createMock(BeanManager.class); | ||
| 323 | - // expect(Beans.getBeanManager()).andReturn(manager).times(2); | ||
| 324 | - // manager.fireEvent(EasyMock.anyObject(Class.class)); | ||
| 325 | - // PowerMock.expectLastCall().times(2); | ||
| 326 | - // | ||
| 327 | - // setInternalState(context, "authenticator", authenticator); | ||
| 328 | - // | ||
| 329 | - // replayAll(Beans.class, authenticator, user, manager, config); | ||
| 330 | - // | ||
| 331 | - // context.login(); | ||
| 332 | - // context.logout(); | ||
| 333 | - // | ||
| 334 | - // assertFalse(context.isLoggedIn()); | ||
| 335 | - // } | ||
| 336 | - | ||
| 337 | - @Test | ||
| 338 | - public void testGetUserWhenSecurityIsDisabled() { | ||
| 339 | - Authenticator authenticator = createMock(Authenticator.class); | ||
| 340 | - expect(authenticator.getUser()).andReturn(null).anyTimes(); | ||
| 341 | - expect(config.isEnabled()).andReturn(false).anyTimes(); | ||
| 342 | - replay(config, authenticator, Beans.class); | ||
| 343 | - | ||
| 344 | - setInternalState(context, "authenticator", authenticator); | ||
| 345 | - | ||
| 346 | - assertNotNull(context.getCurrentUser()); | ||
| 347 | - assertNotNull(context.getCurrentUser().getName()); | ||
| 348 | - } | ||
| 349 | - | ||
| 350 | - @Test | ||
| 351 | - public void testGetUserWhenSecurityIsEnabled() { | ||
| 352 | - Authenticator authenticator = createMock(Authenticator.class); | ||
| 353 | - expect(authenticator.getUser()).andReturn(null).anyTimes(); | ||
| 354 | - expect(config.isEnabled()).andReturn(true); | ||
| 355 | - replay(config, authenticator, Beans.class); | ||
| 356 | - | ||
| 357 | - setInternalState(context, "authenticator", authenticator); | ||
| 358 | - | ||
| 359 | - assertNull(context.getCurrentUser()); | ||
| 360 | - } | ||
| 361 | - | ||
| 362 | - @Test | ||
| 363 | - public void testGetUserWhenSecurityIsEnabledAndUserIsNotNull() { | ||
| 364 | - Principal user = createMock(Principal.class); | ||
| 365 | - | ||
| 366 | - Authenticator authenticator = createMock(Authenticator.class); | ||
| 367 | - expect(authenticator.getUser()).andReturn(user).anyTimes(); | ||
| 368 | - expect(config.isEnabled()).andReturn(true).anyTimes(); | ||
| 369 | - replay(config, user, authenticator, Beans.class); | ||
| 370 | - | ||
| 371 | - setInternalState(context, "authenticator", authenticator); | ||
| 372 | - | ||
| 373 | - assertEquals(context.getCurrentUser(), user); | ||
| 374 | - } | ||
| 375 | - | ||
| 376 | - class AuthenticatorImpl implements Authenticator { | ||
| 377 | - | ||
| 378 | - private static final long serialVersionUID = 1L; | ||
| 379 | - | ||
| 380 | - @Override | ||
| 381 | - public void authenticate() { | ||
| 382 | - } | ||
| 383 | - | ||
| 384 | - @Override | ||
| 385 | - public void unAuthenticate() { | ||
| 386 | - } | ||
| 387 | - | ||
| 388 | - @Override | ||
| 389 | - public Principal getUser() { | ||
| 390 | - return null; | ||
| 391 | - } | ||
| 392 | - } | ||
| 393 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionContextImplTest.java
| @@ -1,124 +0,0 @@ | @@ -1,124 +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 org.easymock.EasyMock.expect; | ||
| 40 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 41 | -import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 42 | - | ||
| 43 | -import java.util.ArrayList; | ||
| 44 | -import java.util.List; | ||
| 45 | - | ||
| 46 | -import junit.framework.Assert; | ||
| 47 | - | ||
| 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.internal.bootstrap.TransactionBootstrap; | ||
| 55 | -import br.gov.frameworkdemoiselle.internal.configuration.TransactionConfig; | ||
| 56 | -import br.gov.frameworkdemoiselle.transaction.Transaction; | ||
| 57 | -import br.gov.frameworkdemoiselle.transaction.TransactionContext; | ||
| 58 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 59 | - | ||
| 60 | -@RunWith(PowerMockRunner.class) | ||
| 61 | -@PrepareForTest({ Beans.class, StrategySelector.class }) | ||
| 62 | -public class TransactionContextImplTest { | ||
| 63 | - | ||
| 64 | - private TransactionContext context; | ||
| 65 | - | ||
| 66 | - private Transaction transaction; | ||
| 67 | - | ||
| 68 | - // @Test | ||
| 69 | - // public void testGetTransactionNull() { | ||
| 70 | - // context = new TransactionContextImpl(); | ||
| 71 | - // | ||
| 72 | - // Class<? extends Transaction> cache = TransactionImpl.class; | ||
| 73 | - // | ||
| 74 | - // List<Class<? extends Transaction>> cacheList = new ArrayList<Class<? extends Transaction>>(); | ||
| 75 | - // cacheList.add(cache); | ||
| 76 | - // | ||
| 77 | - // TransactionBootstrap bootstrap = PowerMock.createMock(TransactionBootstrap.class); | ||
| 78 | - // TransactionConfig config = PowerMock.createMock(TransactionConfig.class); | ||
| 79 | - // | ||
| 80 | - // mockStatic(Beans.class); | ||
| 81 | - // expect(Beans.getReference(TransactionBootstrap.class)).andReturn(bootstrap).anyTimes(); | ||
| 82 | - // expect(Beans.getReference(TransactionConfig.class)).andReturn(config); | ||
| 83 | - // expect(config.getTransactionClass()).andReturn(null).anyTimes(); | ||
| 84 | - // expect(bootstrap.getCache()).andReturn(cacheList); | ||
| 85 | - // expect(Beans.getReference(TransactionImpl.class)).andReturn(new TransactionImpl()); | ||
| 86 | - // | ||
| 87 | - // replayAll(Beans.class); | ||
| 88 | - // | ||
| 89 | - // transaction = context.getCurrentTransaction(); | ||
| 90 | - // Assert.assertEquals(transaction.getClass(),TransactionImpl.class); | ||
| 91 | - // } | ||
| 92 | - | ||
| 93 | - class TransactionImpl implements Transaction { | ||
| 94 | - | ||
| 95 | - private static final long serialVersionUID = 1L; | ||
| 96 | - | ||
| 97 | - @Override | ||
| 98 | - public boolean isActive() { | ||
| 99 | - return false; | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - @Override | ||
| 103 | - public boolean isMarkedRollback() { | ||
| 104 | - return false; | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - @Override | ||
| 108 | - public void begin() { | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - @Override | ||
| 112 | - public void commit() { | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - @Override | ||
| 116 | - public void rollback() { | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - @Override | ||
| 120 | - public void setRollbackOnly() { | ||
| 121 | - } | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfoTest.java
| @@ -1,85 +0,0 @@ | @@ -1,85 +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 org.junit.Assert; | ||
| 40 | -//import org.junit.Test; | ||
| 41 | -// | ||
| 42 | -// | ||
| 43 | -//public class TransactionInfoTest { | ||
| 44 | -// | ||
| 45 | -// private TransactionInfo transactionInfo = new TransactionInfo(); | ||
| 46 | -// | ||
| 47 | -// @Test | ||
| 48 | -// public void testMarkAsOwner(){ | ||
| 49 | -// transactionInfo.markAsOwner(); | ||
| 50 | -// Assert.assertTrue(transactionInfo.isOwner()); | ||
| 51 | -// } | ||
| 52 | -// | ||
| 53 | -// @Test | ||
| 54 | -// public void testIncrementCounter() { | ||
| 55 | -// int count = transactionInfo.getCounter(); | ||
| 56 | -// | ||
| 57 | -// transactionInfo.incrementCounter(); | ||
| 58 | -// Assert.assertEquals(count+1, transactionInfo.getCounter()); | ||
| 59 | -// | ||
| 60 | -// transactionInfo.incrementCounter(); | ||
| 61 | -// Assert.assertEquals(count+2, transactionInfo.getCounter()); | ||
| 62 | -// } | ||
| 63 | -// | ||
| 64 | -// @Test | ||
| 65 | -// public void testDecrementCounter() { | ||
| 66 | -// int count = transactionInfo.getCounter(); | ||
| 67 | -// | ||
| 68 | -// transactionInfo.incrementCounter(); | ||
| 69 | -// Assert.assertEquals(count+1, transactionInfo.getCounter()); | ||
| 70 | -// | ||
| 71 | -// transactionInfo.decrementCounter(); | ||
| 72 | -// Assert.assertEquals(count, transactionInfo.getCounter()); | ||
| 73 | -// } | ||
| 74 | -// | ||
| 75 | -// @Test | ||
| 76 | -// public void testClear() { | ||
| 77 | -// transactionInfo.incrementCounter(); | ||
| 78 | -// transactionInfo.markAsOwner(); | ||
| 79 | -// | ||
| 80 | -// transactionInfo.clear(); | ||
| 81 | -// | ||
| 82 | -// Assert.assertEquals(0, transactionInfo.getCounter()); | ||
| 83 | -// Assert.assertFalse(transactionInfo.isOwner()); | ||
| 84 | -// } | ||
| 85 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptorTest.java
| @@ -1,341 +0,0 @@ | @@ -1,341 +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.interceptor; | ||
| 38 | -// | ||
| 39 | -//import static org.easymock.EasyMock.expect; | ||
| 40 | -//import static org.easymock.EasyMock.verify; | ||
| 41 | -//import static org.junit.Assert.assertEquals; | ||
| 42 | -//import static org.junit.Assert.assertNull; | ||
| 43 | -//import static org.junit.Assert.assertTrue; | ||
| 44 | -//import static org.junit.Assert.fail; | ||
| 45 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 46 | -//import static org.powermock.api.easymock.PowerMock.replay; | ||
| 47 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 48 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
| 49 | -// | ||
| 50 | -//import java.util.Locale; | ||
| 51 | -// | ||
| 52 | -//import javax.interceptor.InvocationContext; | ||
| 53 | -// | ||
| 54 | -//import org.easymock.EasyMock; | ||
| 55 | -//import org.junit.Before; | ||
| 56 | -//import org.junit.Test; | ||
| 57 | -//import org.junit.runner.RunWith; | ||
| 58 | -//import org.powermock.api.easymock.PowerMock; | ||
| 59 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 60 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
| 61 | -//import org.slf4j.Logger; | ||
| 62 | -// | ||
| 63 | -//import br.gov.frameworkdemoiselle.DemoiselleException; | ||
| 64 | -//import br.gov.frameworkdemoiselle.exception.ExceptionHandler; | ||
| 65 | -//import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | ||
| 66 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
| 67 | -// | ||
| 68 | -//@RunWith(PowerMockRunner.class) | ||
| 69 | -//@PrepareForTest(Beans.class) | ||
| 70 | -//public class ExceptionHandlerInterceptorTest { | ||
| 71 | -// | ||
| 72 | -// private ExceptionHandlerInterceptor interceptor; | ||
| 73 | -// | ||
| 74 | -// private InvocationContext context; | ||
| 75 | -// | ||
| 76 | -// private Logger logger; | ||
| 77 | -// | ||
| 78 | -// private CoreBootstrap coreBootstrap; | ||
| 79 | -// | ||
| 80 | -// class TestException extends DemoiselleException { | ||
| 81 | -// | ||
| 82 | -// private static final long serialVersionUID = 1L; | ||
| 83 | -// | ||
| 84 | -// public TestException(String message) { | ||
| 85 | -// super(message); | ||
| 86 | -// } | ||
| 87 | -// } | ||
| 88 | -// | ||
| 89 | -// class ClassWithMethodsAnnotatedWithExceptionHandler { | ||
| 90 | -// | ||
| 91 | -// int times = 0; | ||
| 92 | -// | ||
| 93 | -// @ExceptionHandler | ||
| 94 | -// public void methodWithExceptionHandlerAnotation(DemoiselleException cause) { | ||
| 95 | -// times++; | ||
| 96 | -// } | ||
| 97 | -// | ||
| 98 | -// @ExceptionHandler | ||
| 99 | -// public void methodWithExceptionHandlerAnotationAndGenericException(Exception cause) { | ||
| 100 | -// times++; | ||
| 101 | -// } | ||
| 102 | -// | ||
| 103 | -// } | ||
| 104 | -// | ||
| 105 | -// class ClassWithoutMethodsAnnotatedWithExceptionHandler { | ||
| 106 | -// | ||
| 107 | -// public void methodWithoutExceptionHandlerAnotation(DemoiselleException cause) { | ||
| 108 | -// } | ||
| 109 | -// } | ||
| 110 | -// | ||
| 111 | -// class ClassWithMethodsAnnotatedWithExceptionHandlerAndThrowException { | ||
| 112 | -// | ||
| 113 | -// int times = 0; | ||
| 114 | -// | ||
| 115 | -// @ExceptionHandler | ||
| 116 | -// public void methodWithExceptionHandlerAnotation(DemoiselleException cause) { | ||
| 117 | -// times++; | ||
| 118 | -// throw new RuntimeException(); | ||
| 119 | -// } | ||
| 120 | -// } | ||
| 121 | -// | ||
| 122 | -// class ClassWithMethodWithoutParameterAnnotatedWithExceptionHandler { | ||
| 123 | -// | ||
| 124 | -// @ExceptionHandler | ||
| 125 | -// public void methodWithExceptionHandlerAnotation() { | ||
| 126 | -// } | ||
| 127 | -// | ||
| 128 | -// } | ||
| 129 | -// | ||
| 130 | -// class ClassWithExceptionHandlerMethodThatRethrowException { | ||
| 131 | -// | ||
| 132 | -// int times = 0; | ||
| 133 | -// | ||
| 134 | -// @ExceptionHandler | ||
| 135 | -// public void methodThatRethrowException(TestException cause) { | ||
| 136 | -// times++; | ||
| 137 | -// throw cause; | ||
| 138 | -// } | ||
| 139 | -// | ||
| 140 | -// } | ||
| 141 | -// | ||
| 142 | -// @Before | ||
| 143 | -// public void setUp() throws Exception { | ||
| 144 | -// | ||
| 145 | -// this.interceptor = new ExceptionHandlerInterceptor(); | ||
| 146 | -// this.context = PowerMock.createMock(InvocationContext.class); | ||
| 147 | -// this.coreBootstrap = PowerMock.createMock(CoreBootstrap.class); | ||
| 148 | -// | ||
| 149 | -// mockStatic(Beans.class); | ||
| 150 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes(); | ||
| 151 | -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(this.coreBootstrap).anyTimes(); | ||
| 152 | -// | ||
| 153 | -// } | ||
| 154 | -// | ||
| 155 | -// @Test | ||
| 156 | -// public void manageSuccessfully() throws Throwable { | ||
| 157 | -// expect(this.context.proceed()).andReturn(null); | ||
| 158 | -// expect(this.context.getTarget()).andReturn(null); | ||
| 159 | -// replayAll(); | ||
| 160 | -// assertEquals(null, this.interceptor.manage(this.context)); | ||
| 161 | -// verify(); | ||
| 162 | -// } | ||
| 163 | -// | ||
| 164 | -// @Test | ||
| 165 | -// public void manageWithClassThatDoesNotContainHandleMethod() throws Exception { | ||
| 166 | -// ClassWithoutMethodsAnnotatedWithExceptionHandler classWithoutException = new ClassWithoutMethodsAnnotatedWithExceptionHandler(); | ||
| 167 | -// | ||
| 168 | -// expect(this.context.getTarget()).andReturn(classWithoutException); | ||
| 169 | -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); | ||
| 170 | -// expect(this.coreBootstrap.isAnnotatedType(ClassWithoutMethodsAnnotatedWithExceptionHandler.class)).andReturn( | ||
| 171 | -// true); | ||
| 172 | -// | ||
| 173 | -// replayAll(this.context, this.coreBootstrap, Beans.class); | ||
| 174 | -// | ||
| 175 | -// try { | ||
| 176 | -// this.interceptor.manage(this.context); | ||
| 177 | -// fail(); | ||
| 178 | -// } catch (DemoiselleException e) { | ||
| 179 | -// assertTrue(true); | ||
| 180 | -// } | ||
| 181 | -// | ||
| 182 | -// verifyAll(); | ||
| 183 | -// } | ||
| 184 | -// | ||
| 185 | -// @Test | ||
| 186 | -// public void manageWithClassThatContainsHandleMethod() throws Exception { | ||
| 187 | -// ClassWithMethodsAnnotatedWithExceptionHandler classWithException = new ClassWithMethodsAnnotatedWithExceptionHandler(); | ||
| 188 | -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); | ||
| 189 | -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); | ||
| 190 | -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandler.class)).andReturn(true); | ||
| 191 | -// | ||
| 192 | -// replayAll(this.context, this.coreBootstrap, Beans.class); | ||
| 193 | -// | ||
| 194 | -// assertNull(this.interceptor.manage(this.context)); | ||
| 195 | -// assertEquals(1, classWithException.times); | ||
| 196 | -// verifyAll(); | ||
| 197 | -// } | ||
| 198 | -// | ||
| 199 | -// @Test | ||
| 200 | -// public void manageWithClassThatContainsParentExceptionHandleMethod() throws Exception { | ||
| 201 | -// ClassWithMethodsAnnotatedWithExceptionHandler classWithException = new ClassWithMethodsAnnotatedWithExceptionHandler(); | ||
| 202 | -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); | ||
| 203 | -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); | ||
| 204 | -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandler.class)).andReturn(true); | ||
| 205 | -// replayAll(this.context, this.coreBootstrap, Beans.class); | ||
| 206 | -// | ||
| 207 | -// assertNull(this.interceptor.manage(this.context)); | ||
| 208 | -// assertEquals(1, classWithException.times); | ||
| 209 | -// verifyAll(); | ||
| 210 | -// } | ||
| 211 | -// | ||
| 212 | -// @Test | ||
| 213 | -// public void manageWithClassThatContainsHandleMethodWithDiferentException() throws Exception { | ||
| 214 | -// ClassWithMethodsAnnotatedWithExceptionHandler classWithException = new ClassWithMethodsAnnotatedWithExceptionHandler(); | ||
| 215 | -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); | ||
| 216 | -// expect(this.context.proceed()).andThrow(new TestException("")); | ||
| 217 | -// replay(this.context); | ||
| 218 | -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandler.class)).andReturn(true); | ||
| 219 | -// replayAll(this.context, this.coreBootstrap, Beans.class); | ||
| 220 | -// | ||
| 221 | -// try { | ||
| 222 | -// this.interceptor.manage(this.context); | ||
| 223 | -// fail(); | ||
| 224 | -// } catch (TestException e) { | ||
| 225 | -// assertEquals(0, classWithException.times); | ||
| 226 | -// } | ||
| 227 | -// | ||
| 228 | -// verify(); | ||
| 229 | -// } | ||
| 230 | -// | ||
| 231 | -// @Test | ||
| 232 | -// public void manageWithClassThatContainsHandleMethodThatThrowsAnotherException() throws Exception { | ||
| 233 | -// ClassWithMethodsAnnotatedWithExceptionHandlerAndThrowException classWithException = new ClassWithMethodsAnnotatedWithExceptionHandlerAndThrowException(); | ||
| 234 | -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); | ||
| 235 | -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); | ||
| 236 | -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandlerAndThrowException.class)) | ||
| 237 | -// .andReturn(true); | ||
| 238 | -// replayAll(this.context, this.coreBootstrap, Beans.class); | ||
| 239 | -// | ||
| 240 | -// try { | ||
| 241 | -// this.interceptor.manage(this.context); | ||
| 242 | -// fail(); | ||
| 243 | -// } catch (RuntimeException e) { | ||
| 244 | -// assertEquals(1, classWithException.times); | ||
| 245 | -// } | ||
| 246 | -// | ||
| 247 | -// verifyAll(); | ||
| 248 | -// } | ||
| 249 | -// | ||
| 250 | -// @Test | ||
| 251 | -// public void manageWithClassThatContainsHandleMethodsAndIsInvokedTwice() throws Exception { | ||
| 252 | -// ClassWithMethodsAnnotatedWithExceptionHandler classWithException = new ClassWithMethodsAnnotatedWithExceptionHandler(); | ||
| 253 | -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); | ||
| 254 | -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); | ||
| 255 | -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandler.class)).andReturn(true) | ||
| 256 | -// .anyTimes(); | ||
| 257 | -// replayAll(this.context, this.coreBootstrap, Beans.class); | ||
| 258 | -// | ||
| 259 | -// assertNull(this.interceptor.manage(this.context)); | ||
| 260 | -// assertEquals(1, classWithException.times); | ||
| 261 | -// | ||
| 262 | -// this.context = PowerMock.createMock(InvocationContext.class); | ||
| 263 | -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); | ||
| 264 | -// expect(this.context.proceed()).andThrow(new Exception("")); | ||
| 265 | -// replayAll(this.context); | ||
| 266 | -// | ||
| 267 | -// assertNull(this.interceptor.manage(this.context)); | ||
| 268 | -// assertEquals(2, classWithException.times); | ||
| 269 | -// verifyAll(); | ||
| 270 | -// | ||
| 271 | -// } | ||
| 272 | -// | ||
| 273 | -// @Test | ||
| 274 | -// public void manageWithClassThatContainsHandleMethodWithoutParameter() throws Exception { | ||
| 275 | -// ClassWithMethodWithoutParameterAnnotatedWithExceptionHandler classWithException = new ClassWithMethodWithoutParameterAnnotatedWithExceptionHandler(); | ||
| 276 | -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); | ||
| 277 | -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); | ||
| 278 | -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodWithoutParameterAnnotatedWithExceptionHandler.class)) | ||
| 279 | -// .andReturn(true); | ||
| 280 | -// replayAll(this.context, this.coreBootstrap, Beans.class); | ||
| 281 | -// | ||
| 282 | -// try { | ||
| 283 | -// this.interceptor.manage(this.context); | ||
| 284 | -// fail(); | ||
| 285 | -// } catch (DemoiselleException e) { | ||
| 286 | -// assertTrue(true); | ||
| 287 | -// } | ||
| 288 | -// | ||
| 289 | -// verifyAll(); | ||
| 290 | -// } | ||
| 291 | -// | ||
| 292 | -// @Test | ||
| 293 | -// public void manageHandlerMethodThatRethrowExpectedException() throws Exception { | ||
| 294 | -// ClassWithExceptionHandlerMethodThatRethrowException testClass = new ClassWithExceptionHandlerMethodThatRethrowException(); | ||
| 295 | -// expect(this.context.getTarget()).andReturn(testClass).anyTimes(); | ||
| 296 | -// expect(this.context.proceed()).andThrow(new TestException("")); | ||
| 297 | -// expect(this.coreBootstrap.isAnnotatedType(ClassWithExceptionHandlerMethodThatRethrowException.class)) | ||
| 298 | -// .andReturn(true); | ||
| 299 | -// replayAll(this.context, this.coreBootstrap, Beans.class); | ||
| 300 | -// | ||
| 301 | -// try { | ||
| 302 | -// this.interceptor.manage(this.context); | ||
| 303 | -// fail(); | ||
| 304 | -// } catch (TestException e) { | ||
| 305 | -// assertEquals(1, testClass.times); | ||
| 306 | -// } | ||
| 307 | -// | ||
| 308 | -// verifyAll(); | ||
| 309 | -// } | ||
| 310 | -// | ||
| 311 | -// /** | ||
| 312 | -// * Tests an exception handler when the class that contains the method is a proxy. This is the case when using | ||
| 313 | -// * injection. | ||
| 314 | -// * | ||
| 315 | -// * @throws Exception | ||
| 316 | -// */ | ||
| 317 | -// @Test | ||
| 318 | -// public void manageHandlerMethodInsideProxyClass() throws Exception { | ||
| 319 | -// // creates a proxy class | ||
| 320 | -// ClassWithExceptionHandlerMethodThatRethrowException testClass = PowerMock | ||
| 321 | -// .createNicePartialMockForAllMethodsExcept(ClassWithExceptionHandlerMethodThatRethrowException.class, | ||
| 322 | -// "methodThatRethrowException"); | ||
| 323 | -// expect(this.context.getTarget()).andReturn(testClass).anyTimes(); | ||
| 324 | -// expect(this.context.proceed()).andThrow(new TestException("")); | ||
| 325 | -// expect(this.coreBootstrap.isAnnotatedType(testClass.getClass())).andReturn(false); | ||
| 326 | -// | ||
| 327 | -// this.logger = PowerMock.createMock(Logger.class); | ||
| 328 | -// this.logger.info(EasyMock.anyObject(String.class)); | ||
| 329 | -// this.logger.debug(EasyMock.anyObject(String.class)); | ||
| 330 | -// replayAll(testClass, this.context, this.coreBootstrap, logger, Beans.class); | ||
| 331 | -// | ||
| 332 | -// this.interceptor = new ExceptionHandlerInterceptor(); | ||
| 333 | -// | ||
| 334 | -// try { | ||
| 335 | -// this.interceptor.manage(this.context); | ||
| 336 | -// fail(); | ||
| 337 | -// } catch (TestException e) { | ||
| 338 | -// assertEquals(1, testClass.times); | ||
| 339 | -// } | ||
| 340 | -// } | ||
| 341 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredPermissionInterceptorTest.java
| @@ -1,407 +0,0 @@ | @@ -1,407 +0,0 @@ | ||
| 1 | -//package br.gov.frameworkdemoiselle.internal.interceptor; | ||
| 2 | -// | ||
| 3 | -//import static org.easymock.EasyMock.createMock; | ||
| 4 | -//import static org.easymock.EasyMock.expect; | ||
| 5 | -//import static org.easymock.EasyMock.expectLastCall; | ||
| 6 | -//import static org.junit.Assert.fail; | ||
| 7 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 8 | -//import static org.powermock.api.easymock.PowerMock.replay; | ||
| 9 | -// | ||
| 10 | -//import java.util.Locale; | ||
| 11 | -// | ||
| 12 | -//import javax.enterprise.inject.Instance; | ||
| 13 | -//import javax.interceptor.InvocationContext; | ||
| 14 | -// | ||
| 15 | -//import org.junit.Before; | ||
| 16 | -//import org.junit.Test; | ||
| 17 | -//import org.junit.runner.RunWith; | ||
| 18 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 19 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
| 20 | -// | ||
| 21 | -//import br.gov.frameworkdemoiselle.annotation.Name; | ||
| 22 | -//import br.gov.frameworkdemoiselle.security.NotLoggedInException; | ||
| 23 | -//import br.gov.frameworkdemoiselle.security.RequiredPermission; | ||
| 24 | -//import br.gov.frameworkdemoiselle.security.SecurityContext; | ||
| 25 | -//import br.gov.frameworkdemoiselle.security.SecurityException; | ||
| 26 | -//import br.gov.frameworkdemoiselle.security.User; | ||
| 27 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
| 28 | -// | ||
| 29 | -//@RunWith(PowerMockRunner.class) | ||
| 30 | -//@PrepareForTest(Beans.class) | ||
| 31 | -//public class RequiredPermissionInterceptorTest { | ||
| 32 | -// | ||
| 33 | -// private RequiredPermissionInterceptor interceptor; | ||
| 34 | -// | ||
| 35 | -// private InvocationContext ic; | ||
| 36 | -// | ||
| 37 | -// private SecurityContext securityContext; | ||
| 38 | -// | ||
| 39 | -// class UnnamedClass { | ||
| 40 | -// | ||
| 41 | -// @RequiredPermission | ||
| 42 | -// public void requiredPermissionWithoutDeclaredResourceAndOperation() { | ||
| 43 | -// } | ||
| 44 | -// | ||
| 45 | -// @RequiredPermission(operation = "insert") | ||
| 46 | -// public void requiredPermissionWithDeclaredOperation() { | ||
| 47 | -// } | ||
| 48 | -// | ||
| 49 | -// @RequiredPermission(resource = "contact") | ||
| 50 | -// public void requiredPermissionWithDeclaredResource() { | ||
| 51 | -// } | ||
| 52 | -// | ||
| 53 | -// @RequiredPermission(resource = "contact", operation = "insert") | ||
| 54 | -// public void requiredPermissionWithDeclaredResourceAndOperation() { | ||
| 55 | -// } | ||
| 56 | -// } | ||
| 57 | -// | ||
| 58 | -// @Name("contact2") | ||
| 59 | -// class NamedClass { | ||
| 60 | -// | ||
| 61 | -// @RequiredPermission | ||
| 62 | -// public void requiredPermissionWithoutDeclaredResourceAndOperation() { | ||
| 63 | -// } | ||
| 64 | -// | ||
| 65 | -// @RequiredPermission(operation = "insert") | ||
| 66 | -// public void requiredPermissionWithDeclaredOperation() { | ||
| 67 | -// } | ||
| 68 | -// | ||
| 69 | -// @RequiredPermission(resource = "contact") | ||
| 70 | -// public void requiredPermissionWithDeclaredResource() { | ||
| 71 | -// } | ||
| 72 | -// | ||
| 73 | -// @RequiredPermission(resource = "contact", operation = "insert") | ||
| 74 | -// public void requiredPermissionWithDeclaredResourceAndOperation() { | ||
| 75 | -// } | ||
| 76 | -// } | ||
| 77 | -// | ||
| 78 | -// @Name("contact2") | ||
| 79 | -// class NamedClassWithNamedMethods { | ||
| 80 | -// | ||
| 81 | -// @Name("delete") | ||
| 82 | -// @RequiredPermission | ||
| 83 | -// public void requiredPermissionWithoutDeclaredResourceAndOperation() { | ||
| 84 | -// } | ||
| 85 | -// | ||
| 86 | -// @Name("delete") | ||
| 87 | -// @RequiredPermission(operation = "insert") | ||
| 88 | -// public void requiredPermissionWithDeclaredOperation() { | ||
| 89 | -// } | ||
| 90 | -// | ||
| 91 | -// @Name("delete") | ||
| 92 | -// @RequiredPermission(resource = "contact") | ||
| 93 | -// public void requiredPermissionWithDeclaredResource() { | ||
| 94 | -// } | ||
| 95 | -// | ||
| 96 | -// @Name("delete") | ||
| 97 | -// @RequiredPermission(resource = "contact", operation = "insert") | ||
| 98 | -// public void requiredPermissionWithDeclaredResourceAndOperation() { | ||
| 99 | -// } | ||
| 100 | -// } | ||
| 101 | -// | ||
| 102 | -// @RequiredPermission | ||
| 103 | -// class ClassAnnotedWithRequiredPermission { | ||
| 104 | -// | ||
| 105 | -// public void withoutRequiredPermissionAnnotation() { | ||
| 106 | -// } | ||
| 107 | -// | ||
| 108 | -// @RequiredPermission(operation = "insert") | ||
| 109 | -// public void requiredPermissionWithDeclaredOperation() { | ||
| 110 | -// } | ||
| 111 | -// } | ||
| 112 | -// | ||
| 113 | -// @Before | ||
| 114 | -// public void setUp() throws Exception { | ||
| 115 | -// @SuppressWarnings("unchecked") | ||
| 116 | -// Instance<SecurityContext> securityContextInstance = createMock(Instance.class); | ||
| 117 | -// | ||
| 118 | -// User user = createMock(User.class); | ||
| 119 | -// | ||
| 120 | -// this.securityContext = createMock(SecurityContext.class); | ||
| 121 | -// this.ic = createMock(InvocationContext.class); | ||
| 122 | -// | ||
| 123 | -// mockStatic(Beans.class); | ||
| 124 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 125 | -// expect(Beans.getReference(SecurityContext.class)).andReturn(this.securityContext); | ||
| 126 | -// | ||
| 127 | -// expect(user.getId()).andReturn("UserName").anyTimes(); | ||
| 128 | -// expect(this.securityContext.getUser()).andReturn(user).anyTimes(); | ||
| 129 | -// expect(securityContextInstance.get()).andReturn(securityContext).anyTimes(); | ||
| 130 | -// expect(this.ic.proceed()).andReturn(null); | ||
| 131 | -// replay(securityContextInstance, user, Beans.class); | ||
| 132 | -// | ||
| 133 | -// this.interceptor = new RequiredPermissionInterceptor(); | ||
| 134 | -// } | ||
| 135 | -// | ||
| 136 | -// private void prepareMock(Object target, String methodName, String expectedResource, String expectedOperation, | ||
| 137 | -// boolean hasPermission, boolean isLoggedUser) throws Exception { | ||
| 138 | -// | ||
| 139 | -// expect(this.securityContext.isLoggedIn()).andReturn(isLoggedUser).anyTimes(); | ||
| 140 | -// | ||
| 141 | -// this.securityContext.hasPermission(expectedResource, expectedOperation); | ||
| 142 | -// | ||
| 143 | -// if (isLoggedUser) { | ||
| 144 | -// expectLastCall().andReturn(hasPermission); | ||
| 145 | -// } else { | ||
| 146 | -// expectLastCall().andThrow(new NotLoggedInException("")); | ||
| 147 | -// } | ||
| 148 | -// | ||
| 149 | -// expect(this.ic.getTarget()).andReturn(target).anyTimes(); | ||
| 150 | -// expect(this.ic.getMethod()).andReturn(target.getClass().getMethod(methodName)).anyTimes(); | ||
| 151 | -// replay(this.ic, this.securityContext); | ||
| 152 | -// } | ||
| 153 | -// | ||
| 154 | -// /* Testing UnnamedClass */ | ||
| 155 | -// | ||
| 156 | -// @Test | ||
| 157 | -// public void testManageUnnamedClassAtRequiredPermissionWithoutDeclaredResourceAndOperationMethod() throws Exception { | ||
| 158 | -// try { | ||
| 159 | -// Object target = new UnnamedClass(); | ||
| 160 | -// String methodName = "requiredPermissionWithoutDeclaredResourceAndOperation"; | ||
| 161 | -// String expectedResource = target.getClass().getSimpleName(); | ||
| 162 | -// String expectedOperation = methodName; | ||
| 163 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 164 | -// | ||
| 165 | -// interceptor.manage(this.ic); | ||
| 166 | -// } catch (SecurityException cause) { | ||
| 167 | -// fail(); | ||
| 168 | -// } | ||
| 169 | -// } | ||
| 170 | -// | ||
| 171 | -// @Test | ||
| 172 | -// public void testManageUnnamedClassAtRequiredPermissionWithDeclaredOperationMethod() throws Exception { | ||
| 173 | -// try { | ||
| 174 | -// Object target = new UnnamedClass(); | ||
| 175 | -// String methodName = "requiredPermissionWithDeclaredOperation"; | ||
| 176 | -// String expectedResource = target.getClass().getSimpleName(); | ||
| 177 | -// String expectedOperation = "insert"; | ||
| 178 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 179 | -// | ||
| 180 | -// interceptor.manage(this.ic); | ||
| 181 | -// } catch (SecurityException cause) { | ||
| 182 | -// fail(); | ||
| 183 | -// } | ||
| 184 | -// } | ||
| 185 | -// | ||
| 186 | -// @Test | ||
| 187 | -// public void testManageUnnamedClassAtRequiredPermissionWithDeclaredResourceMethod() throws Exception { | ||
| 188 | -// try { | ||
| 189 | -// Object target = new UnnamedClass(); | ||
| 190 | -// String methodName = "requiredPermissionWithDeclaredResource"; | ||
| 191 | -// String expectedResource = "contact"; | ||
| 192 | -// String expectedOperation = methodName; | ||
| 193 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 194 | -// | ||
| 195 | -// interceptor.manage(this.ic); | ||
| 196 | -// } catch (SecurityException cause) { | ||
| 197 | -// fail(); | ||
| 198 | -// } | ||
| 199 | -// } | ||
| 200 | -// | ||
| 201 | -// @Test | ||
| 202 | -// public void testManageUnnamedClassAtRequiredPermissionWithDeclaredResourceAndOperation() throws Exception { | ||
| 203 | -// try { | ||
| 204 | -// Object target = new UnnamedClass(); | ||
| 205 | -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; | ||
| 206 | -// String expectedResource = "contact"; | ||
| 207 | -// String expectedOperation = "insert"; | ||
| 208 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 209 | -// | ||
| 210 | -// interceptor.manage(this.ic); | ||
| 211 | -// } catch (SecurityException cause) { | ||
| 212 | -// fail(); | ||
| 213 | -// } | ||
| 214 | -// } | ||
| 215 | -// | ||
| 216 | -// /* Testing NamedClass */ | ||
| 217 | -// | ||
| 218 | -// @Test | ||
| 219 | -// public void testManageNamedClassAtRequiredPermissionWithoutDeclaredResourceAndOperationMethod() throws Exception { | ||
| 220 | -// try { | ||
| 221 | -// Object target = new NamedClass(); | ||
| 222 | -// String methodName = "requiredPermissionWithoutDeclaredResourceAndOperation"; | ||
| 223 | -// String expectedResource = "contact2"; | ||
| 224 | -// String expectedOperation = methodName; | ||
| 225 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 226 | -// | ||
| 227 | -// interceptor.manage(this.ic); | ||
| 228 | -// } catch (SecurityException cause) { | ||
| 229 | -// fail(); | ||
| 230 | -// } | ||
| 231 | -// } | ||
| 232 | -// | ||
| 233 | -// @Test | ||
| 234 | -// public void testManageNamedClassAtRequiredPermissionWithDeclaredOperationMethod() throws Exception { | ||
| 235 | -// try { | ||
| 236 | -// Object target = new NamedClass(); | ||
| 237 | -// String methodName = "requiredPermissionWithDeclaredOperation"; | ||
| 238 | -// String expectedResource = "contact2"; | ||
| 239 | -// String expectedOperation = "insert"; | ||
| 240 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 241 | -// | ||
| 242 | -// interceptor.manage(this.ic); | ||
| 243 | -// } catch (SecurityException cause) { | ||
| 244 | -// fail(); | ||
| 245 | -// } | ||
| 246 | -// } | ||
| 247 | -// | ||
| 248 | -// @Test | ||
| 249 | -// public void testManageNamedClassAtRequiredPermissionWithDeclaredResourceMethod() throws Exception { | ||
| 250 | -// try { | ||
| 251 | -// Object target = new NamedClass(); | ||
| 252 | -// String methodName = "requiredPermissionWithDeclaredResource"; | ||
| 253 | -// String expectedResource = "contact"; | ||
| 254 | -// String expectedOperation = methodName; | ||
| 255 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 256 | -// | ||
| 257 | -// interceptor.manage(this.ic); | ||
| 258 | -// } catch (SecurityException cause) { | ||
| 259 | -// fail(); | ||
| 260 | -// } | ||
| 261 | -// } | ||
| 262 | -// | ||
| 263 | -// @Test | ||
| 264 | -// public void testManageNamedClassAtRequiredPermissionWithDeclaredResourceAndOperation() throws Exception { | ||
| 265 | -// try { | ||
| 266 | -// Object target = new NamedClass(); | ||
| 267 | -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; | ||
| 268 | -// String expectedResource = "contact"; | ||
| 269 | -// String expectedOperation = "insert"; | ||
| 270 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 271 | -// | ||
| 272 | -// interceptor.manage(this.ic); | ||
| 273 | -// } catch (SecurityException cause) { | ||
| 274 | -// fail(); | ||
| 275 | -// } | ||
| 276 | -// } | ||
| 277 | -// | ||
| 278 | -// /* Testing NamedClassWithNamedMethods */ | ||
| 279 | -// | ||
| 280 | -// @Test | ||
| 281 | -// public void testManageNamedClassWithNamedMethodsAtRequiredPermissionWithoutDeclaredResourceAndOperationMethod() | ||
| 282 | -// throws Exception { | ||
| 283 | -// try { | ||
| 284 | -// Object target = new NamedClassWithNamedMethods(); | ||
| 285 | -// String methodName = "requiredPermissionWithoutDeclaredResourceAndOperation"; | ||
| 286 | -// String expectedResource = "contact2"; | ||
| 287 | -// String expectedOperation = "delete"; | ||
| 288 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 289 | -// | ||
| 290 | -// interceptor.manage(this.ic); | ||
| 291 | -// } catch (SecurityException cause) { | ||
| 292 | -// fail(); | ||
| 293 | -// } | ||
| 294 | -// } | ||
| 295 | -// | ||
| 296 | -// @Test | ||
| 297 | -// public void testManageNamedClassWithNamedMethodsAtRequiredPermissionWithDeclaredOperationMethod() throws Exception { | ||
| 298 | -// try { | ||
| 299 | -// Object target = new NamedClassWithNamedMethods(); | ||
| 300 | -// String methodName = "requiredPermissionWithDeclaredOperation"; | ||
| 301 | -// String expectedResource = "contact2"; | ||
| 302 | -// String expectedOperation = "insert"; | ||
| 303 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 304 | -// | ||
| 305 | -// interceptor.manage(this.ic); | ||
| 306 | -// } catch (SecurityException cause) { | ||
| 307 | -// fail(); | ||
| 308 | -// } | ||
| 309 | -// } | ||
| 310 | -// | ||
| 311 | -// @Test | ||
| 312 | -// public void testManageNamedClassWithNamedMethodsAtRequiredPermissionWithDeclaredResourceMethod() throws Exception { | ||
| 313 | -// try { | ||
| 314 | -// Object target = new NamedClassWithNamedMethods(); | ||
| 315 | -// String methodName = "requiredPermissionWithDeclaredResource"; | ||
| 316 | -// String expectedResource = "contact"; | ||
| 317 | -// String expectedOperation = "delete"; | ||
| 318 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 319 | -// | ||
| 320 | -// interceptor.manage(this.ic); | ||
| 321 | -// } catch (SecurityException cause) { | ||
| 322 | -// fail(); | ||
| 323 | -// } | ||
| 324 | -// } | ||
| 325 | -// | ||
| 326 | -// @Test | ||
| 327 | -// public void testManageNamedClassWithNamedMethodsAtRequiredPermissionWithDeclaredResourceAndOperation() | ||
| 328 | -// throws Exception { | ||
| 329 | -// try { | ||
| 330 | -// Object target = new NamedClassWithNamedMethods(); | ||
| 331 | -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; | ||
| 332 | -// String expectedResource = "contact"; | ||
| 333 | -// String expectedOperation = "insert"; | ||
| 334 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 335 | -// | ||
| 336 | -// interceptor.manage(this.ic); | ||
| 337 | -// } catch (SecurityException cause) { | ||
| 338 | -// fail(); | ||
| 339 | -// } | ||
| 340 | -// } | ||
| 341 | -// | ||
| 342 | -// /* Testing ClassAnnotedWithRequiredPermission */ | ||
| 343 | -// | ||
| 344 | -// @Test | ||
| 345 | -// public void testManageClassAnnotedWithRequiredPermissionAtWithoutRequiredPermissionAnnotation() throws Exception { | ||
| 346 | -// try { | ||
| 347 | -// Object target = new ClassAnnotedWithRequiredPermission(); | ||
| 348 | -// String methodName = "withoutRequiredPermissionAnnotation"; | ||
| 349 | -// String expectedResource = target.getClass().getSimpleName(); | ||
| 350 | -// String expectedOperation = methodName; | ||
| 351 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 352 | -// | ||
| 353 | -// interceptor.manage(this.ic); | ||
| 354 | -// } catch (SecurityException cause) { | ||
| 355 | -// fail(); | ||
| 356 | -// } | ||
| 357 | -// } | ||
| 358 | -// | ||
| 359 | -// @Test | ||
| 360 | -// public void testManageClassAnnotedWithRequiredPermissionAtRequiredPermissionWithDeclaredOperation() | ||
| 361 | -// throws Exception { | ||
| 362 | -// try { | ||
| 363 | -// Object target = new ClassAnnotedWithRequiredPermission(); | ||
| 364 | -// String methodName = "requiredPermissionWithDeclaredOperation"; | ||
| 365 | -// String expectedResource = target.getClass().getSimpleName(); | ||
| 366 | -// String expectedOperation = "insert"; | ||
| 367 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); | ||
| 368 | -// | ||
| 369 | -// interceptor.manage(this.ic); | ||
| 370 | -// } catch (SecurityException cause) { | ||
| 371 | -// fail(); | ||
| 372 | -// } | ||
| 373 | -// } | ||
| 374 | -// | ||
| 375 | -// /* Other tests */ | ||
| 376 | -// | ||
| 377 | -// @Test | ||
| 378 | -// public void testManagePermissionNotAllowed() throws Exception { | ||
| 379 | -// try { | ||
| 380 | -// Object target = new UnnamedClass(); | ||
| 381 | -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; | ||
| 382 | -// String expectedResource = "contact"; | ||
| 383 | -// String expectedOperation = "insert"; | ||
| 384 | -// prepareMock(target, methodName, expectedResource, expectedOperation, false, true); | ||
| 385 | -// | ||
| 386 | -// interceptor.manage(this.ic); | ||
| 387 | -// fail(); | ||
| 388 | -// } catch (SecurityException cause) { | ||
| 389 | -// } | ||
| 390 | -// } | ||
| 391 | -// | ||
| 392 | -// @Test | ||
| 393 | -// public void testUserNotLoggedIn() throws Exception { | ||
| 394 | -// try { | ||
| 395 | -// Object target = new UnnamedClass(); | ||
| 396 | -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; | ||
| 397 | -// String expectedResource = "contact"; | ||
| 398 | -// String expectedOperation = "insert"; | ||
| 399 | -// prepareMock(target, methodName, expectedResource, expectedOperation, true, false); | ||
| 400 | -// | ||
| 401 | -// interceptor.manage(this.ic); | ||
| 402 | -// fail(); | ||
| 403 | -// } catch (SecurityException cause) { | ||
| 404 | -// } | ||
| 405 | -// } | ||
| 406 | -// | ||
| 407 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredRoleInterceptorTest.java
| @@ -1,296 +0,0 @@ | @@ -1,296 +0,0 @@ | ||
| 1 | -//package br.gov.frameworkdemoiselle.internal.interceptor; | ||
| 2 | -// | ||
| 3 | -//import static org.easymock.EasyMock.expect; | ||
| 4 | -//import static org.junit.Assert.fail; | ||
| 5 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 6 | -//import static org.powermock.api.easymock.PowerMock.replay; | ||
| 7 | -// | ||
| 8 | -//import java.util.Locale; | ||
| 9 | -// | ||
| 10 | -//import javax.enterprise.inject.Instance; | ||
| 11 | -//import javax.interceptor.InvocationContext; | ||
| 12 | -// | ||
| 13 | -//import org.easymock.EasyMock; | ||
| 14 | -//import org.junit.Before; | ||
| 15 | -//import org.junit.Test; | ||
| 16 | -//import org.junit.runner.RunWith; | ||
| 17 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 18 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
| 19 | -// | ||
| 20 | -//import br.gov.frameworkdemoiselle.security.AuthorizationException; | ||
| 21 | -//import br.gov.frameworkdemoiselle.security.NotLoggedInException; | ||
| 22 | -//import br.gov.frameworkdemoiselle.security.RequiredRole; | ||
| 23 | -//import br.gov.frameworkdemoiselle.security.SecurityContext; | ||
| 24 | -//import br.gov.frameworkdemoiselle.security.User; | ||
| 25 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
| 26 | -// | ||
| 27 | -//@RunWith(PowerMockRunner.class) | ||
| 28 | -//@PrepareForTest(Beans.class) | ||
| 29 | -//public class RequiredRoleInterceptorTest { | ||
| 30 | -// | ||
| 31 | -// private RequiredRoleInterceptor interceptor; | ||
| 32 | -// | ||
| 33 | -// private InvocationContext ic; | ||
| 34 | -// | ||
| 35 | -// private SecurityContext securityContext; | ||
| 36 | -// | ||
| 37 | -// class ClassNotAnnoted { | ||
| 38 | -// | ||
| 39 | -// @RequiredRole("simpleRoleName") | ||
| 40 | -// public void requiredRoleWithSingleRole() { | ||
| 41 | -// } | ||
| 42 | -// | ||
| 43 | -// @RequiredRole({ "firstRole", "secondRole", "thirdRole", "fourthRole", "fifthRole" }) | ||
| 44 | -// public void requiredRoleWithArrayOfRoles() { | ||
| 45 | -// } | ||
| 46 | -// | ||
| 47 | -// @RequiredRole({ "firstRole, secondRole" }) | ||
| 48 | -// public void requiredRoleWithArrayOfSingleRoleComma() { | ||
| 49 | -// } | ||
| 50 | -// | ||
| 51 | -// @RequiredRole("firstRole, secondRole") | ||
| 52 | -// public void requiredRoleWithSingleRoleComma() { | ||
| 53 | -// } | ||
| 54 | -// | ||
| 55 | -// @RequiredRole("") | ||
| 56 | -// public void requiredRoleWithEmptyValue() { | ||
| 57 | -// } | ||
| 58 | -// | ||
| 59 | -// @RequiredRole({}) | ||
| 60 | -// public void requiredRoleWithEmptyArray() { | ||
| 61 | -// } | ||
| 62 | -// | ||
| 63 | -// @RequiredRole({ "" }) | ||
| 64 | -// public void requiredRoleWithArrayOfEmptyString() { | ||
| 65 | -// } | ||
| 66 | -// | ||
| 67 | -// public void methodNotAnnoted() { | ||
| 68 | -// } | ||
| 69 | -// } | ||
| 70 | -// | ||
| 71 | -// @RequiredRole("classRole") | ||
| 72 | -// class ClassAnnotedWithRequiredRole { | ||
| 73 | -// | ||
| 74 | -// public void withoutRole() { | ||
| 75 | -// } | ||
| 76 | -// | ||
| 77 | -// @RequiredRole("simpleRoleName") | ||
| 78 | -// public void requiredRoleWithSingleRole() { | ||
| 79 | -// } | ||
| 80 | -// } | ||
| 81 | -// | ||
| 82 | -// @Before | ||
| 83 | -// public void setUp() throws Exception { | ||
| 84 | -// | ||
| 85 | -// @SuppressWarnings("unchecked") | ||
| 86 | -// Instance<SecurityContext> securityContextInstance = EasyMock.createMock(Instance.class); | ||
| 87 | -// User user = EasyMock.createMock(User.class); | ||
| 88 | -// | ||
| 89 | -// this.securityContext = EasyMock.createMock(SecurityContext.class); | ||
| 90 | -// this.ic = EasyMock.createMock(InvocationContext.class); | ||
| 91 | -// | ||
| 92 | -// mockStatic(Beans.class); | ||
| 93 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 94 | -// expect(Beans.getReference(SecurityContext.class)).andReturn(this.securityContext); | ||
| 95 | -// | ||
| 96 | -// expect(user.getId()).andReturn("UserName").anyTimes(); | ||
| 97 | -// expect(this.securityContext.getUser()).andReturn(user).anyTimes(); | ||
| 98 | -// expect(securityContextInstance.get()).andReturn(securityContext).anyTimes(); | ||
| 99 | -// expect(this.ic.proceed()).andReturn(null); | ||
| 100 | -// replay(securityContextInstance, user, Beans.class); | ||
| 101 | -// | ||
| 102 | -// this.interceptor = new RequiredRoleInterceptor(); | ||
| 103 | -// } | ||
| 104 | -// | ||
| 105 | -// private void prepareMock(Object target, String methodName, String[] expectedRoles, boolean hasHole, | ||
| 106 | -// boolean isLoggedUser) throws Exception { | ||
| 107 | -// | ||
| 108 | -// expect(this.securityContext.isLoggedIn()).andReturn(isLoggedUser).anyTimes(); | ||
| 109 | -// | ||
| 110 | -// for (String role : expectedRoles) { | ||
| 111 | -// this.securityContext.hasRole(role); | ||
| 112 | -// if (isLoggedUser) { | ||
| 113 | -// EasyMock.expectLastCall().andReturn(hasHole); | ||
| 114 | -// } else { | ||
| 115 | -// EasyMock.expectLastCall().andThrow(new NotLoggedInException("")); | ||
| 116 | -// } | ||
| 117 | -// } | ||
| 118 | -// | ||
| 119 | -// expect(this.ic.getTarget()).andReturn(target).anyTimes(); | ||
| 120 | -// expect(this.ic.getMethod()).andReturn(target.getClass().getMethod(methodName)).anyTimes(); | ||
| 121 | -// replay(this.ic, this.securityContext); | ||
| 122 | -// } | ||
| 123 | -// | ||
| 124 | -// // @Test | ||
| 125 | -// // public void testManageClassNotAnnotedAtRequiredRoleWithSingleRole() throws Exception { | ||
| 126 | -// // Object target = new ClassNotAnnoted(); | ||
| 127 | -// // String methodName = "requiredRoleWithSingleRole"; | ||
| 128 | -// // String[] expectedRoles = { "simpleRoleName" }; | ||
| 129 | -// // prepareMock(target, methodName, expectedRoles, true, true); | ||
| 130 | -// // | ||
| 131 | -// // interceptor.manage(this.ic); | ||
| 132 | -// // } | ||
| 133 | -// | ||
| 134 | -// // @Test | ||
| 135 | -// // public void testManageClassNotAnnotedAtRequiredRoleWithArrayOfRoles() throws Exception { | ||
| 136 | -// // Object target = new ClassNotAnnoted(); | ||
| 137 | -// // String methodName = "requiredRoleWithArrayOfRoles"; | ||
| 138 | -// // String[] expectedRoles = { "firstRole", "secondRole", "thirdRole", "fourthRole", "fifthRole" }; | ||
| 139 | -// // prepareMock(target, methodName, expectedRoles, true, true); | ||
| 140 | -// // | ||
| 141 | -// // interceptor.manage(this.ic); | ||
| 142 | -// // } | ||
| 143 | -// | ||
| 144 | -// // @Test | ||
| 145 | -// // public void testManageClassNotAnnotedAtRequiredRoleWithArrayOfSingleRoleComma() throws Exception { | ||
| 146 | -// // Object target = new ClassNotAnnoted(); | ||
| 147 | -// // String methodName = "requiredRoleWithArrayOfSingleRoleComma"; | ||
| 148 | -// // String[] expectedRoles = { "firstRole, secondRole" }; | ||
| 149 | -// // prepareMock(target, methodName, expectedRoles, true, true); | ||
| 150 | -// // | ||
| 151 | -// // interceptor.manage(this.ic); | ||
| 152 | -// // } | ||
| 153 | -// | ||
| 154 | -// // @Test | ||
| 155 | -// // public void testManageClassNotAnnotedAtRequiredRoleWithSingleRoleComma() throws Exception { | ||
| 156 | -// // Object target = new ClassNotAnnoted(); | ||
| 157 | -// // String methodName = "requiredRoleWithSingleRoleComma"; | ||
| 158 | -// // String[] expectedRoles = { "firstRole, secondRole" }; | ||
| 159 | -// // prepareMock(target, methodName, expectedRoles, true, true); | ||
| 160 | -// // | ||
| 161 | -// // interceptor.manage(this.ic); | ||
| 162 | -// // } | ||
| 163 | -// | ||
| 164 | -// // @Test | ||
| 165 | -// // public void testManageClassNotAnnotedAtRequiredRoleWithEmptyValue() throws Exception { | ||
| 166 | -// // try { | ||
| 167 | -// // Object target = new ClassNotAnnoted(); | ||
| 168 | -// // String methodName = "requiredRoleWithEmptyValue"; | ||
| 169 | -// // String[] expectedRoles = { "" }; | ||
| 170 | -// // prepareMock(target, methodName, expectedRoles, false, true); | ||
| 171 | -// // | ||
| 172 | -// // interceptor.manage(this.ic); | ||
| 173 | -// // fail(); | ||
| 174 | -// // } catch (AuthorizationException cause) { | ||
| 175 | -// // } | ||
| 176 | -// // } | ||
| 177 | -// | ||
| 178 | -// // @Test | ||
| 179 | -// // public void testManageClassNotAnnotedAtRequiredRoleWithEmptyArray() throws Exception { | ||
| 180 | -// // try { | ||
| 181 | -// // Object target = new ClassNotAnnoted(); | ||
| 182 | -// // String methodName = "requiredRoleWithEmptyArray"; | ||
| 183 | -// // String[] expectedRoles = { "" }; | ||
| 184 | -// // prepareMock(target, methodName, expectedRoles, false, true); | ||
| 185 | -// // | ||
| 186 | -// // interceptor.manage(this.ic); | ||
| 187 | -// // fail(); | ||
| 188 | -// // } catch (AuthorizationException cause) { | ||
| 189 | -// // } | ||
| 190 | -// // } | ||
| 191 | -// | ||
| 192 | -// // @Test | ||
| 193 | -// // public void testManageClassNotAnnotedAtRequiredRoleWithArrayOfEmptyString() throws Exception { | ||
| 194 | -// // try { | ||
| 195 | -// // Object target = new ClassNotAnnoted(); | ||
| 196 | -// // String methodName = "requiredRoleWithArrayOfEmptyString"; | ||
| 197 | -// // String[] expectedRoles = { "" }; | ||
| 198 | -// // prepareMock(target, methodName, expectedRoles, false, true); | ||
| 199 | -// // | ||
| 200 | -// // interceptor.manage(this.ic); | ||
| 201 | -// // fail(); | ||
| 202 | -// // } catch (AuthorizationException cause) { | ||
| 203 | -// // } | ||
| 204 | -// // } | ||
| 205 | -// | ||
| 206 | -// // @Test | ||
| 207 | -// // public void testManageClassNotAnnotedAtMethodNotAnnoted() throws Exception { | ||
| 208 | -// // try { | ||
| 209 | -// // Object target = new ClassNotAnnoted(); | ||
| 210 | -// // String methodName = "methodNotAnnoted"; | ||
| 211 | -// // String[] expectedRoles = { "" }; | ||
| 212 | -// // prepareMock(target, methodName, expectedRoles, false, true); | ||
| 213 | -// // | ||
| 214 | -// // interceptor.manage(this.ic); | ||
| 215 | -// // fail(); | ||
| 216 | -// // } catch (AuthorizationException cause) { | ||
| 217 | -// // } | ||
| 218 | -// // } | ||
| 219 | -// | ||
| 220 | -// // @Test | ||
| 221 | -// // public void testManageClassAnnotedWithRequiredRoleAtWithoutRole() throws Exception { | ||
| 222 | -// // Object target = new ClassAnnotedWithRequiredRole(); | ||
| 223 | -// // String methodName = "withoutRole"; | ||
| 224 | -// // String[] expectedRoles = { "classRole" }; | ||
| 225 | -// // prepareMock(target, methodName, expectedRoles, true, true); | ||
| 226 | -// // | ||
| 227 | -// // interceptor.manage(this.ic); | ||
| 228 | -// // } | ||
| 229 | -// | ||
| 230 | -// // @Test | ||
| 231 | -// // public void testManageClassAnnotedWithRequiredRoleAtRequiredRoleWithSingleRole() throws Exception { | ||
| 232 | -// // Object target = new ClassAnnotedWithRequiredRole(); | ||
| 233 | -// // String methodName = "requiredRoleWithSingleRole"; | ||
| 234 | -// // String[] expectedRoles = { "simpleRoleName" }; | ||
| 235 | -// // prepareMock(target, methodName, expectedRoles, true, true); | ||
| 236 | -// // | ||
| 237 | -// // interceptor.manage(this.ic); | ||
| 238 | -// // } | ||
| 239 | -// | ||
| 240 | -// // @Test | ||
| 241 | -// // public void testDoesNotHaveSingleRole() throws Exception { | ||
| 242 | -// // try { | ||
| 243 | -// // Object target = new ClassNotAnnoted(); | ||
| 244 | -// // String methodName = "requiredRoleWithSingleRole"; | ||
| 245 | -// // String[] expectedRoles = { "simpleRoleName" }; | ||
| 246 | -// // prepareMock(target, methodName, expectedRoles, false, true); | ||
| 247 | -// // | ||
| 248 | -// // interceptor.manage(this.ic); | ||
| 249 | -// // fail(); | ||
| 250 | -// // } catch (AuthorizationException cause) { | ||
| 251 | -// // } | ||
| 252 | -// // } | ||
| 253 | -// | ||
| 254 | -// @Test | ||
| 255 | -// public void testUserNotLoggedIn() throws Exception { | ||
| 256 | -// try { | ||
| 257 | -// Object target = new ClassNotAnnoted(); | ||
| 258 | -// String methodName = "requiredRoleWithSingleRole"; | ||
| 259 | -// String[] expectedRoles = { "simpleRoleName" }; | ||
| 260 | -// prepareMock(target, methodName, expectedRoles, true, false); | ||
| 261 | -// | ||
| 262 | -// interceptor.manage(this.ic); | ||
| 263 | -// fail(); | ||
| 264 | -// } catch (NotLoggedInException cause) { | ||
| 265 | -// } | ||
| 266 | -// } | ||
| 267 | -// | ||
| 268 | -// // @Test | ||
| 269 | -// // public void testDoesNotHaveOneOrMoreRolesOfArray() throws Exception { | ||
| 270 | -// // Object target = new ClassNotAnnoted(); | ||
| 271 | -// // String methodName = "requiredRoleWithArrayOfRoles"; | ||
| 272 | -// // String[] expectedRoles = { "thirdRole", "fourthRole", "fifthRole" }; | ||
| 273 | -// // | ||
| 274 | -// // expect(this.securityContext.hasRole("firstRole")).andReturn(false); | ||
| 275 | -// // expect(this.securityContext.hasRole("secondRole")).andReturn(false); | ||
| 276 | -// // | ||
| 277 | -// // prepareMock(target, methodName, expectedRoles, true, true); | ||
| 278 | -// // | ||
| 279 | -// // interceptor.manage(this.ic); | ||
| 280 | -// // } | ||
| 281 | -// | ||
| 282 | -// // @Test | ||
| 283 | -// // public void testHasMoreRolesThenArray() throws Exception { | ||
| 284 | -// // Object target = new ClassNotAnnoted(); | ||
| 285 | -// // String methodName = "requiredRoleWithArrayOfRoles"; | ||
| 286 | -// // String[] expectedRoles = { "thirdRole", "fourthRole", "fifthRole" }; | ||
| 287 | -// // | ||
| 288 | -// // expect(this.securityContext.hasRole("firstRole")).andReturn(false); | ||
| 289 | -// // expect(this.securityContext.hasRole("secondRole")).andReturn(false); | ||
| 290 | -// // expect(this.securityContext.hasRole("sixthRole")).andReturn(true); | ||
| 291 | -// // | ||
| 292 | -// // prepareMock(target, methodName, expectedRoles, true, true); | ||
| 293 | -// // | ||
| 294 | -// // interceptor.manage(this.ic); | ||
| 295 | -// // } | ||
| 296 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptorTest.java
| @@ -1,202 +0,0 @@ | @@ -1,202 +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.interceptor; | ||
| 38 | -// | ||
| 39 | -//import static org.easymock.EasyMock.expect; | ||
| 40 | -//import static org.easymock.EasyMock.verify; | ||
| 41 | -//import static org.junit.Assert.assertEquals; | ||
| 42 | -//import static org.junit.Assert.assertTrue; | ||
| 43 | -//import static org.junit.Assert.fail; | ||
| 44 | -//import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 45 | -//import static org.powermock.api.easymock.PowerMock.replay; | ||
| 46 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 47 | -// | ||
| 48 | -//import java.util.Locale; | ||
| 49 | -// | ||
| 50 | -//import javax.enterprise.inject.Instance; | ||
| 51 | -//import javax.interceptor.InvocationContext; | ||
| 52 | -// | ||
| 53 | -//import org.easymock.EasyMock; | ||
| 54 | -//import org.junit.Before; | ||
| 55 | -//import org.junit.Test; | ||
| 56 | -//import org.junit.runner.RunWith; | ||
| 57 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 58 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
| 59 | -// | ||
| 60 | -//import br.gov.frameworkdemoiselle.DemoiselleException; | ||
| 61 | -//import br.gov.frameworkdemoiselle.internal.implementation.TransactionInfo; | ||
| 62 | -//import br.gov.frameworkdemoiselle.transaction.Transaction; | ||
| 63 | -//import br.gov.frameworkdemoiselle.transaction.TransactionContext; | ||
| 64 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
| 65 | -// | ||
| 66 | -//@RunWith(PowerMockRunner.class) | ||
| 67 | -//@PrepareForTest(Beans.class) | ||
| 68 | -//public class TransactionalInterceptorTest { | ||
| 69 | -// | ||
| 70 | -// private TransactionalInterceptor interceptor; | ||
| 71 | -// | ||
| 72 | -// private InvocationContext ic; | ||
| 73 | -// | ||
| 74 | -// private Transaction transaction; | ||
| 75 | -// | ||
| 76 | -// private TransactionContext transactionContext; | ||
| 77 | -// | ||
| 78 | -// class ClassWithMethod { | ||
| 79 | -// | ||
| 80 | -// public void method() { | ||
| 81 | -// System.out.println("test method"); | ||
| 82 | -// } | ||
| 83 | -// } | ||
| 84 | -// | ||
| 85 | -// @Before | ||
| 86 | -// @SuppressWarnings("unchecked") | ||
| 87 | -// public void setUp() throws Exception { | ||
| 88 | -// Instance<Transaction> transactionInstance = EasyMock.createMock(Instance.class); | ||
| 89 | -// Instance<TransactionInfo> transactionInfoInstance = EasyMock.createMock(Instance.class); | ||
| 90 | -// Instance<TransactionContext> transactionContextInstance = EasyMock.createMock(Instance.class); | ||
| 91 | -// | ||
| 92 | -// TransactionInfo transactionInfo = new TransactionInfo(); | ||
| 93 | -// transaction = EasyMock.createMock(Transaction.class); | ||
| 94 | -// this.transactionContext = EasyMock.createMock(TransactionContext.class); | ||
| 95 | -// this.ic = EasyMock.createMock(InvocationContext.class); | ||
| 96 | -// | ||
| 97 | -// mockStatic(Beans.class); | ||
| 98 | -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 99 | -// expect(Beans.getReference(TransactionContext.class)).andReturn(transactionContext); | ||
| 100 | -// expect(Beans.getReference(TransactionInfo.class)).andReturn(transactionInfo); | ||
| 101 | -// | ||
| 102 | -// expect(transactionInstance.get()).andReturn(transaction).anyTimes(); | ||
| 103 | -// expect(transactionContextInstance.get()).andReturn(transactionContext).anyTimes(); | ||
| 104 | -// expect(transactionInfoInstance.get()).andReturn(transactionInfo).anyTimes(); | ||
| 105 | -// expect(transactionContext.getCurrentTransaction()).andReturn(transaction).anyTimes(); | ||
| 106 | -// expect(this.ic.proceed()).andReturn(null); | ||
| 107 | -// expect(this.ic.getMethod()).andReturn(ClassWithMethod.class.getMethod("method")); | ||
| 108 | -// replayAll(Beans.class, this.ic, transactionContextInstance, transactionInfoInstance, transactionInstance, | ||
| 109 | -// transactionContext); | ||
| 110 | -// | ||
| 111 | -// this.interceptor = new TransactionalInterceptor(); | ||
| 112 | -// | ||
| 113 | -// } | ||
| 114 | -// | ||
| 115 | -// @Test | ||
| 116 | -// public void testManageWithInativeTransactionAndTransactionInterceptorBeginAndDoNotIsMarkedRollback() | ||
| 117 | -// throws Exception { | ||
| 118 | -// expect(this.transaction.isActive()).andReturn(false).times(1); | ||
| 119 | -// expect(this.transaction.isActive()).andReturn(true).times(2); | ||
| 120 | -// expect(this.transaction.isMarkedRollback()).andReturn(false).anyTimes(); | ||
| 121 | -// this.transaction.begin(); | ||
| 122 | -// this.transaction.commit(); | ||
| 123 | -// replay(this.transaction); | ||
| 124 | -// | ||
| 125 | -// assertEquals(null, this.interceptor.manage(this.ic)); | ||
| 126 | -// verify(); | ||
| 127 | -// } | ||
| 128 | -// | ||
| 129 | -// @Test | ||
| 130 | -// public void testManageWithInativeTransactionAndTransactionInterceptorBeginAndIsMarkedRollback() throws Exception { | ||
| 131 | -// expect(this.transaction.isActive()).andReturn(false).times(1); | ||
| 132 | -// expect(this.transaction.isActive()).andReturn(true).times(2); | ||
| 133 | -// expect(this.transaction.isMarkedRollback()).andReturn(true).anyTimes(); | ||
| 134 | -// this.transaction.begin(); | ||
| 135 | -// this.transaction.rollback(); | ||
| 136 | -// replay(this.transaction); | ||
| 137 | -// | ||
| 138 | -// assertEquals(null, this.interceptor.manage(this.ic)); | ||
| 139 | -// verify(); | ||
| 140 | -// } | ||
| 141 | -// | ||
| 142 | -// @Test | ||
| 143 | -// public void testManageWithAtiveTransaction() throws Exception { | ||
| 144 | -// expect(this.transaction.isActive()).andReturn(true).anyTimes(); | ||
| 145 | -// replay(this.transaction); | ||
| 146 | -// | ||
| 147 | -// assertEquals(null, this.interceptor.manage(this.ic)); | ||
| 148 | -// verify(); | ||
| 149 | -// } | ||
| 150 | -// | ||
| 151 | -// @Test | ||
| 152 | -// public void testManageWithAtiveTransactionButTheTransactionWasInative() throws Exception { | ||
| 153 | -// expect(this.transaction.isActive()).andReturn(true).times(1); | ||
| 154 | -// expect(this.transaction.isActive()).andReturn(false).times(2); | ||
| 155 | -// replay(this.transaction); | ||
| 156 | -// | ||
| 157 | -// assertEquals(null, this.interceptor.manage(this.ic)); | ||
| 158 | -// verify(); | ||
| 159 | -// } | ||
| 160 | -// | ||
| 161 | -// @Test | ||
| 162 | -// public void testManageWithAtiveTransactionAndMethodThrowExceptionAndDoNotIsMarkedRollback() throws Exception { | ||
| 163 | -// expect(this.transaction.isActive()).andReturn(true).anyTimes(); | ||
| 164 | -// expect(this.transaction.isMarkedRollback()).andReturn(false).anyTimes(); | ||
| 165 | -// this.transaction.setRollbackOnly(); | ||
| 166 | -// replay(this.transaction); | ||
| 167 | -// | ||
| 168 | -// this.ic = EasyMock.createMock(InvocationContext.class); | ||
| 169 | -// expect(this.ic.proceed()).andThrow(new DemoiselleException("")); | ||
| 170 | -// expect(this.ic.getMethod()).andReturn(ClassWithMethod.class.getMethod("method")); | ||
| 171 | -// replay(this.ic); | ||
| 172 | -// | ||
| 173 | -// try { | ||
| 174 | -// this.interceptor.manage(this.ic); | ||
| 175 | -// fail(); | ||
| 176 | -// } catch (DemoiselleException cause) { | ||
| 177 | -// assertTrue(true); | ||
| 178 | -// } | ||
| 179 | -// verify(); | ||
| 180 | -// } | ||
| 181 | -// | ||
| 182 | -// @Test | ||
| 183 | -// public void testManageWithAtiveTransactionAndMethodThrowExceptionAndIsMarkedRollback() throws Exception { | ||
| 184 | -// expect(this.transaction.isActive()).andReturn(true).anyTimes(); | ||
| 185 | -// expect(this.transaction.isMarkedRollback()).andReturn(true).anyTimes(); | ||
| 186 | -// this.transaction.setRollbackOnly(); | ||
| 187 | -// replay(this.transaction); | ||
| 188 | -// | ||
| 189 | -// this.ic = EasyMock.createMock(InvocationContext.class); | ||
| 190 | -// expect(this.ic.proceed()).andThrow(new DemoiselleException("")); | ||
| 191 | -// expect(this.ic.getMethod()).andReturn(ClassWithMethod.class.getMethod("method")); | ||
| 192 | -// replay(this.ic); | ||
| 193 | -// | ||
| 194 | -// try { | ||
| 195 | -// this.interceptor.manage(this.ic); | ||
| 196 | -// fail(); | ||
| 197 | -// } catch (DemoiselleException cause) { | ||
| 198 | -// assertTrue(true); | ||
| 199 | -// } | ||
| 200 | -// verify(); | ||
| 201 | -// } | ||
| 202 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LocaleProducer.java
0 → 100644
| @@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.internal.producer; | ||
| 2 | + | ||
| 3 | +import java.util.Locale; | ||
| 4 | + | ||
| 5 | +import javax.enterprise.inject.Default; | ||
| 6 | +import javax.enterprise.inject.Produces; | ||
| 7 | + | ||
| 8 | +public class LocaleProducer { | ||
| 9 | + | ||
| 10 | + @Default | ||
| 11 | + @Produces | ||
| 12 | + public Locale create() { | ||
| 13 | + return Locale.getDefault(); | ||
| 14 | + } | ||
| 15 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducerTest.java
| @@ -1,91 +0,0 @@ | @@ -1,91 +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.producer; | ||
| 38 | -// | ||
| 39 | -//import static org.easymock.EasyMock.createMock; | ||
| 40 | -//import static org.easymock.EasyMock.expect; | ||
| 41 | -//import static org.easymock.EasyMock.replay; | ||
| 42 | -//import static org.junit.Assert.assertNotNull; | ||
| 43 | -// | ||
| 44 | -//import java.lang.reflect.Member; | ||
| 45 | -// | ||
| 46 | -//import javax.enterprise.inject.spi.InjectionPoint; | ||
| 47 | -// | ||
| 48 | -//import org.junit.Test; | ||
| 49 | -//import org.slf4j.Logger; | ||
| 50 | -// | ||
| 51 | -//public class LoggerProducerTest { | ||
| 52 | -// | ||
| 53 | -// private Logger logger; | ||
| 54 | -// | ||
| 55 | -// @Test | ||
| 56 | -// @SuppressWarnings({ "unchecked", "rawtypes" }) | ||
| 57 | -// public void testCreateInjectionPoint() { | ||
| 58 | -// | ||
| 59 | -// Member member = createMock(Member.class); | ||
| 60 | -// expect(member.getDeclaringClass()).andReturn((Class) this.getClass()); | ||
| 61 | -// replay(member); | ||
| 62 | -// | ||
| 63 | -// InjectionPoint injectionPoint = createMock(InjectionPoint.class); | ||
| 64 | -// expect(injectionPoint.getMember()).andReturn(member); | ||
| 65 | -// replay(injectionPoint); | ||
| 66 | -// | ||
| 67 | -// logger = LoggerProducer.create(injectionPoint); | ||
| 68 | -// assertNotNull(logger); | ||
| 69 | -// } | ||
| 70 | -// | ||
| 71 | -// @Test | ||
| 72 | -// public void testCreateWithNullInjectionPoint() { | ||
| 73 | -// logger = LoggerProducer.create((InjectionPoint) null); | ||
| 74 | -// assertNotNull(logger); | ||
| 75 | -// } | ||
| 76 | -// | ||
| 77 | -// @Test | ||
| 78 | -// public void testCreateClass() { | ||
| 79 | -// logger = LoggerProducer.create(this.getClass()); | ||
| 80 | -// assertNotNull(logger); | ||
| 81 | -// } | ||
| 82 | -// | ||
| 83 | -// // We don't need to instantiate LoggerProducer class. But if we don't get in this way, we'll not get 100% on | ||
| 84 | -// // cobertura. | ||
| 85 | -// @Test | ||
| 86 | -// public void testLoggerFactoryDiferentNull() { | ||
| 87 | -// @SuppressWarnings("unused") | ||
| 88 | -// LoggerProducer loggerProducer = new LoggerProducer(); | ||
| 89 | -// } | ||
| 90 | -// | ||
| 91 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ResourceBundleProducerTest.java
| @@ -1,133 +0,0 @@ | @@ -1,133 +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.producer; | ||
| 38 | - | ||
| 39 | -import static org.easymock.EasyMock.expect; | ||
| 40 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 41 | -import static org.powermock.api.easymock.PowerMock.replay; | ||
| 42 | - | ||
| 43 | -import java.util.Locale; | ||
| 44 | - | ||
| 45 | -import javax.enterprise.inject.spi.Annotated; | ||
| 46 | -import javax.enterprise.inject.spi.InjectionPoint; | ||
| 47 | - | ||
| 48 | -import org.easymock.EasyMock; | ||
| 49 | -import org.junit.After; | ||
| 50 | -import org.junit.AfterClass; | ||
| 51 | -import org.junit.Assert; | ||
| 52 | -import org.junit.Before; | ||
| 53 | -import org.junit.BeforeClass; | ||
| 54 | -import org.junit.Test; | ||
| 55 | -import org.junit.runner.RunWith; | ||
| 56 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 57 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 58 | - | ||
| 59 | -import br.gov.frameworkdemoiselle.annotation.Name; | ||
| 60 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 61 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 62 | - | ||
| 63 | -@RunWith(PowerMockRunner.class) | ||
| 64 | -@PrepareForTest(Beans.class) | ||
| 65 | -public class ResourceBundleProducerTest { | ||
| 66 | - | ||
| 67 | - @BeforeClass | ||
| 68 | - public static void setUpBeforeClass() throws Exception { | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - @AfterClass | ||
| 72 | - public static void tearDownAfterClass() throws Exception { | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - @Before | ||
| 76 | - public void setUp() throws Exception { | ||
| 77 | - mockStatic(Beans.class); | ||
| 78 | - | ||
| 79 | - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); | ||
| 80 | - | ||
| 81 | - replay(Beans.class); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - @After | ||
| 85 | - public void tearDown() throws Exception { | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - @Test | ||
| 89 | - public void testResourceBundleFactory() { | ||
| 90 | - ResourceBundleProducer factory = new ResourceBundleProducer(); | ||
| 91 | - Assert.assertNotNull(factory); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - @Test | ||
| 95 | - public void testCreateNullInjectionPoint() { | ||
| 96 | - ResourceBundleProducer factory = new ResourceBundleProducer(); | ||
| 97 | - ResourceBundle resourceBundle = factory.createDefault((InjectionPoint) null); | ||
| 98 | - Assert.assertNotNull(resourceBundle); | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - @Test | ||
| 102 | - public void testCreateInjectionPointNameAnnoted() { | ||
| 103 | - Name name = EasyMock.createMock(Name.class); | ||
| 104 | - expect(name.value()).andReturn("demoiselle-core-bundle"); | ||
| 105 | - replay(name); | ||
| 106 | - | ||
| 107 | - Annotated annotated = EasyMock.createMock(Annotated.class); | ||
| 108 | - expect(annotated.getAnnotation(Name.class)).andReturn(name).anyTimes(); | ||
| 109 | - expect(annotated.isAnnotationPresent(Name.class)).andReturn(true).anyTimes(); | ||
| 110 | - replay(annotated); | ||
| 111 | - | ||
| 112 | - InjectionPoint ip = EasyMock.createMock(InjectionPoint.class); | ||
| 113 | - expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); | ||
| 114 | - replay(ip); | ||
| 115 | - | ||
| 116 | - ResourceBundleProducer factory = new ResourceBundleProducer(); | ||
| 117 | - Assert.assertNotNull(factory.createDefault(ip)); | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - // @Test | ||
| 121 | - // public void testCreateInjectionPointNameUnannoted() { | ||
| 122 | - // Annotated annotated = EasyMock.createMock(Annotated.class); | ||
| 123 | - // expect(annotated.isAnnotationPresent(Name.class)).andReturn(false).anyTimes(); | ||
| 124 | - // replay(annotated); | ||
| 125 | - // | ||
| 126 | - // InjectionPoint ip = EasyMock.createMock(InjectionPoint.class); | ||
| 127 | - // expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); | ||
| 128 | - // replay(ip); | ||
| 129 | - // | ||
| 130 | - // ResourceBundleProducer factory = new ResourceBundleProducer(); | ||
| 131 | - // Assert.assertNotNull(factory.create(ip, Locale.getDefault())); | ||
| 132 | - // } | ||
| 133 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxyTest.java
| @@ -1,628 +0,0 @@ | @@ -1,628 +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.junit.Assert.assertEquals; | ||
| 41 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 42 | - | ||
| 43 | -import org.easymock.EasyMock; | ||
| 44 | -import org.junit.Before; | ||
| 45 | -import org.junit.Test; | ||
| 46 | -import org.junit.runner.RunWith; | ||
| 47 | -import org.powermock.api.easymock.PowerMock; | ||
| 48 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 49 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 50 | -import org.slf4j.Logger; | ||
| 51 | -import org.slf4j.LoggerFactory; | ||
| 52 | -import org.slf4j.Marker; | ||
| 53 | - | ||
| 54 | -@RunWith(PowerMockRunner.class) | ||
| 55 | -@PrepareForTest(LoggerFactory.class) | ||
| 56 | -public class Slf4jLoggerProxyTest { | ||
| 57 | - | ||
| 58 | - private Logger logger; | ||
| 59 | - private Slf4jLoggerProxy slf4jLoggerProxy; | ||
| 60 | - | ||
| 61 | - @Before | ||
| 62 | - public void setUp() throws Exception { | ||
| 63 | - this.logger = EasyMock.createMock(Logger.class); | ||
| 64 | - this.slf4jLoggerProxy = new Slf4jLoggerProxy(Logger.class); | ||
| 65 | - | ||
| 66 | - mockStatic(LoggerFactory.class); | ||
| 67 | - | ||
| 68 | - expect(LoggerFactory.getLogger(EasyMock.anyObject(Class.class))).andReturn(logger); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - @Test | ||
| 72 | - public void testDebugWithMarkerAndString() { | ||
| 73 | - Marker marker = null; | ||
| 74 | - this.logger.debug(marker,""); | ||
| 75 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 76 | - this.slf4jLoggerProxy.debug(marker,""); | ||
| 77 | - PowerMock.verify(this.logger); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - @Test | ||
| 81 | - public void testDebugWithMarkerStringAndOneObject() { | ||
| 82 | - Marker marker = null; | ||
| 83 | - Object obj = null; | ||
| 84 | - this.logger.debug(marker,"",obj); | ||
| 85 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 86 | - this.slf4jLoggerProxy.debug(marker,"",obj); | ||
| 87 | - PowerMock.verify(this.logger); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - @Test | ||
| 91 | - public void testDebugWithMarkerStringAndTwoObjects() { | ||
| 92 | - Marker marker = null; | ||
| 93 | - Object obj1 = null, obj2 = null; | ||
| 94 | - this.logger.debug(marker,"",obj1,obj2); | ||
| 95 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 96 | - this.slf4jLoggerProxy.debug(marker,"",obj1,obj2); | ||
| 97 | - PowerMock.verify(this.logger); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - @Test | ||
| 101 | - public void testDebugWithMarkerStringAndObjectArray() { | ||
| 102 | - Marker marker = null; | ||
| 103 | - Object[] obj = null; | ||
| 104 | - this.logger.debug(marker,"",obj); | ||
| 105 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 106 | - this.slf4jLoggerProxy.debug(marker,"",obj); | ||
| 107 | - PowerMock.verify(this.logger); | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - @Test | ||
| 111 | - public void testDebugWithMarkerStringAndThrowable() { | ||
| 112 | - Marker marker = null; | ||
| 113 | - Throwable t = null; | ||
| 114 | - this.logger.debug(marker,"",t); | ||
| 115 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 116 | - this.slf4jLoggerProxy.debug(marker,"",t); | ||
| 117 | - PowerMock.verify(this.logger); | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - @Test | ||
| 121 | - public void testDebugWithString() { | ||
| 122 | - this.logger.debug(""); | ||
| 123 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 124 | - this.slf4jLoggerProxy.debug(""); | ||
| 125 | - PowerMock.verify(this.logger); | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - @Test | ||
| 129 | - public void testDebugWithStringAndOneObject() { | ||
| 130 | - Object obj = null; | ||
| 131 | - this.logger.debug("",obj); | ||
| 132 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 133 | - this.slf4jLoggerProxy.debug("",obj); | ||
| 134 | - PowerMock.verify(this.logger); | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - @Test | ||
| 138 | - public void testDebugWithStringAndTwoObjects() { | ||
| 139 | - Object obj1 = null, obj2 = null; | ||
| 140 | - this.logger.debug("",obj1,obj2); | ||
| 141 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 142 | - this.slf4jLoggerProxy.debug("",obj1,obj2); | ||
| 143 | - PowerMock.verify(this.logger); | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | - @Test | ||
| 147 | - public void testDebugWithStringAndObjectArray() { | ||
| 148 | - Object[] obj = null; | ||
| 149 | - this.logger.debug("",obj); | ||
| 150 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 151 | - this.slf4jLoggerProxy.debug("",obj); | ||
| 152 | - PowerMock.verify(this.logger); | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - @Test | ||
| 156 | - public void testDebugWithStringAndThrowable() { | ||
| 157 | - Throwable t = null; | ||
| 158 | - this.logger.debug("",t); | ||
| 159 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 160 | - this.slf4jLoggerProxy.debug("",t); | ||
| 161 | - PowerMock.verify(this.logger); | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - @Test | ||
| 165 | - public void testErrorWithMarkerAndString() { | ||
| 166 | - Marker marker = null; | ||
| 167 | - this.logger.error(marker,""); | ||
| 168 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 169 | - this.slf4jLoggerProxy.error(marker,""); | ||
| 170 | - PowerMock.verify(this.logger); | ||
| 171 | - } | ||
| 172 | - | ||
| 173 | - @Test | ||
| 174 | - public void testErrorWithMarkerStringAndOneObject() { | ||
| 175 | - Marker marker = null; | ||
| 176 | - Object obj = null; | ||
| 177 | - this.logger.error(marker,"",obj); | ||
| 178 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 179 | - this.slf4jLoggerProxy.error(marker,"",obj); | ||
| 180 | - PowerMock.verify(this.logger); | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | - @Test | ||
| 184 | - public void testErrorWithMarkerStringAndTwoObjects() { | ||
| 185 | - Marker marker = null; | ||
| 186 | - Object obj1 = null, obj2 = null; | ||
| 187 | - this.logger.error(marker,"",obj1,obj2); | ||
| 188 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 189 | - this.slf4jLoggerProxy.error(marker,"",obj1,obj2); | ||
| 190 | - PowerMock.verify(this.logger); | ||
| 191 | - } | ||
| 192 | - | ||
| 193 | - @Test | ||
| 194 | - public void testErrorWithMarkerStringAndObjectArray() { | ||
| 195 | - Marker marker = null; | ||
| 196 | - Object[] obj1 = null; | ||
| 197 | - this.logger.error(marker,"",obj1); | ||
| 198 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 199 | - this.slf4jLoggerProxy.error(marker,"",obj1); | ||
| 200 | - PowerMock.verify(this.logger); | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - @Test | ||
| 204 | - public void testErrorWithMarkerStringAndThrowable() { | ||
| 205 | - Marker marker = null; | ||
| 206 | - Throwable t = null; | ||
| 207 | - this.logger.error(marker,"",t); | ||
| 208 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 209 | - this.slf4jLoggerProxy.error(marker,"",t); | ||
| 210 | - PowerMock.verify(this.logger); | ||
| 211 | - } | ||
| 212 | - | ||
| 213 | - @Test | ||
| 214 | - public void testErrorWithString() { | ||
| 215 | - this.logger.error(""); | ||
| 216 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 217 | - this.slf4jLoggerProxy.error(""); | ||
| 218 | - PowerMock.verify(this.logger); | ||
| 219 | - } | ||
| 220 | - | ||
| 221 | - @Test | ||
| 222 | - public void testErrorWithStringAndOneObject() { | ||
| 223 | - Object obj = null; | ||
| 224 | - this.logger.error("",obj); | ||
| 225 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 226 | - this.slf4jLoggerProxy.error("",obj); | ||
| 227 | - PowerMock.verify(this.logger); | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - @Test | ||
| 231 | - public void testErrorWithStringAndTwoObjects() { | ||
| 232 | - Object obj1 = null,obj2 = null; | ||
| 233 | - this.logger.error("",obj1,obj2); | ||
| 234 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 235 | - this.slf4jLoggerProxy.error("",obj1,obj2); | ||
| 236 | - PowerMock.verify(this.logger); | ||
| 237 | - } | ||
| 238 | - | ||
| 239 | - @Test | ||
| 240 | - public void testErrorWithStringAndObjectArray() { | ||
| 241 | - Object[] obj = null; | ||
| 242 | - this.logger.error("",obj); | ||
| 243 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 244 | - this.slf4jLoggerProxy.error("",obj); | ||
| 245 | - PowerMock.verify(this.logger); | ||
| 246 | - } | ||
| 247 | - | ||
| 248 | - @Test | ||
| 249 | - public void testErrorWithStringAndThrowable() { | ||
| 250 | - Throwable t = null; | ||
| 251 | - this.logger.error("",t); | ||
| 252 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 253 | - this.slf4jLoggerProxy.error("",t); | ||
| 254 | - PowerMock.verify(this.logger); | ||
| 255 | - } | ||
| 256 | - | ||
| 257 | - @Test | ||
| 258 | - public void testGetName() { | ||
| 259 | - expect(this.logger.getName()).andReturn("xxx"); | ||
| 260 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 261 | - assertEquals("xxx", this.slf4jLoggerProxy.getName()); | ||
| 262 | - PowerMock.verify(this.logger); | ||
| 263 | - } | ||
| 264 | - | ||
| 265 | - @Test | ||
| 266 | - public void testInfoWithMarkerAndString() { | ||
| 267 | - Marker marker = null; | ||
| 268 | - this.logger.info(marker,""); | ||
| 269 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 270 | - this.slf4jLoggerProxy.info(marker,""); | ||
| 271 | - PowerMock.verify(this.logger); | ||
| 272 | - } | ||
| 273 | - | ||
| 274 | - @Test | ||
| 275 | - public void testInfoWithMarkerStringAndOneObject() { | ||
| 276 | - Marker marker = null; | ||
| 277 | - Object obj = null; | ||
| 278 | - this.logger.info(marker,"",obj); | ||
| 279 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 280 | - this.slf4jLoggerProxy.info(marker,"",obj); | ||
| 281 | - PowerMock.verify(this.logger); | ||
| 282 | - } | ||
| 283 | - | ||
| 284 | - @Test | ||
| 285 | - public void testInfoWithMarkerStringAndTwoObjects() { | ||
| 286 | - Marker marker = null; | ||
| 287 | - Object obj1 = null, obj2 = null; | ||
| 288 | - this.logger.info(marker,"",obj1, obj2); | ||
| 289 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 290 | - this.slf4jLoggerProxy.info(marker,"",obj1,obj2); | ||
| 291 | - PowerMock.verify(this.logger); | ||
| 292 | - } | ||
| 293 | - | ||
| 294 | - @Test | ||
| 295 | - public void testInfoWithMarkerStringAndObjectArray() { | ||
| 296 | - Marker marker = null; | ||
| 297 | - Object[] obj = null; | ||
| 298 | - this.logger.info(marker,"",obj); | ||
| 299 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 300 | - this.slf4jLoggerProxy.info(marker,"",obj); | ||
| 301 | - PowerMock.verify(this.logger); | ||
| 302 | - } | ||
| 303 | - | ||
| 304 | - @Test | ||
| 305 | - public void testInfoWithMarkerStringAndThrowable() { | ||
| 306 | - Marker marker = null; | ||
| 307 | - Throwable t = null; | ||
| 308 | - this.logger.info(marker,"",t); | ||
| 309 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 310 | - this.slf4jLoggerProxy.info(marker,"",t); | ||
| 311 | - PowerMock.verify(this.logger); | ||
| 312 | - } | ||
| 313 | - | ||
| 314 | - @Test | ||
| 315 | - public void testInfoWithString() { | ||
| 316 | - this.logger.info(""); | ||
| 317 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 318 | - this.slf4jLoggerProxy.info(""); | ||
| 319 | - PowerMock.verify(this.logger); | ||
| 320 | - } | ||
| 321 | - | ||
| 322 | - @Test | ||
| 323 | - public void testInfoWithStringAndOneObject() { | ||
| 324 | - Object obj = null; | ||
| 325 | - this.logger.info("",obj); | ||
| 326 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 327 | - this.slf4jLoggerProxy.info("",obj); | ||
| 328 | - PowerMock.verify(this.logger); | ||
| 329 | - } | ||
| 330 | - | ||
| 331 | - @Test | ||
| 332 | - public void testInfoWithStringAndTwoObjects() { | ||
| 333 | - Object obj1 = null, obj2 = null; | ||
| 334 | - this.logger.info("",obj1,obj2); | ||
| 335 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 336 | - this.slf4jLoggerProxy.info("",obj1,obj2); | ||
| 337 | - PowerMock.verify(this.logger); | ||
| 338 | - } | ||
| 339 | - | ||
| 340 | - @Test | ||
| 341 | - public void testInfoWithStringAndObjectArray() { | ||
| 342 | - Object[] obj = null; | ||
| 343 | - this.logger.info("",obj); | ||
| 344 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 345 | - this.slf4jLoggerProxy.info("",obj); | ||
| 346 | - PowerMock.verify(this.logger); | ||
| 347 | - } | ||
| 348 | - | ||
| 349 | - @Test | ||
| 350 | - public void testInfoWithStringAndThrowable() { | ||
| 351 | - Throwable t = null; | ||
| 352 | - this.logger.info("",t); | ||
| 353 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 354 | - this.slf4jLoggerProxy.info("",t); | ||
| 355 | - PowerMock.verify(this.logger); | ||
| 356 | - } | ||
| 357 | - | ||
| 358 | - @Test | ||
| 359 | - public void testIsDebugEnabled() { | ||
| 360 | - expect(this.logger.isDebugEnabled()).andReturn(true); | ||
| 361 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 362 | - assertEquals(true, this.slf4jLoggerProxy.isDebugEnabled()); | ||
| 363 | - PowerMock.verify(this.logger); | ||
| 364 | - } | ||
| 365 | - | ||
| 366 | - @Test | ||
| 367 | - public void testIsDebugEnabledWithMarker() { | ||
| 368 | - Marker marker = null; | ||
| 369 | - expect(this.logger.isDebugEnabled(marker)).andReturn(true); | ||
| 370 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 371 | - assertEquals(true, this.slf4jLoggerProxy.isDebugEnabled(marker)); | ||
| 372 | - PowerMock.verify(this.logger); | ||
| 373 | - } | ||
| 374 | - | ||
| 375 | - @Test | ||
| 376 | - public void testIsErrorEnabled() { | ||
| 377 | - expect(this.logger.isErrorEnabled()).andReturn(true); | ||
| 378 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 379 | - assertEquals(true, this.slf4jLoggerProxy.isErrorEnabled()); | ||
| 380 | - PowerMock.verify(this.logger); | ||
| 381 | - } | ||
| 382 | - | ||
| 383 | - @Test | ||
| 384 | - public void testIsErrorEnabledWithMarker() { | ||
| 385 | - Marker marker = null; | ||
| 386 | - expect(this.logger.isErrorEnabled(marker)).andReturn(true); | ||
| 387 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 388 | - assertEquals(true, this.slf4jLoggerProxy.isErrorEnabled(marker)); | ||
| 389 | - PowerMock.verify(this.logger); | ||
| 390 | - } | ||
| 391 | - | ||
| 392 | - @Test | ||
| 393 | - public void testIsInfoEnabled() { | ||
| 394 | - expect(this.logger.isInfoEnabled()).andReturn(true); | ||
| 395 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 396 | - assertEquals(true, this.slf4jLoggerProxy.isInfoEnabled()); | ||
| 397 | - PowerMock.verify(this.logger); | ||
| 398 | - } | ||
| 399 | - | ||
| 400 | - @Test | ||
| 401 | - public void testIsInfoEnabledWithMarker() { | ||
| 402 | - Marker marker = null; | ||
| 403 | - expect(this.logger.isInfoEnabled(marker)).andReturn(true); | ||
| 404 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 405 | - assertEquals(true, this.slf4jLoggerProxy.isInfoEnabled(marker)); | ||
| 406 | - PowerMock.verify(this.logger); | ||
| 407 | - } | ||
| 408 | - | ||
| 409 | - @Test | ||
| 410 | - public void testIsTRaceEnabled() { | ||
| 411 | - expect(this.logger.isTraceEnabled()).andReturn(true); | ||
| 412 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 413 | - assertEquals(true, this.slf4jLoggerProxy.isTraceEnabled()); | ||
| 414 | - PowerMock.verify(this.logger); | ||
| 415 | - } | ||
| 416 | - | ||
| 417 | - @Test | ||
| 418 | - public void testIsTraceEnabledWithMarker() { | ||
| 419 | - Marker marker = null; | ||
| 420 | - expect(this.logger.isTraceEnabled(marker)).andReturn(true); | ||
| 421 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 422 | - assertEquals(true, this.slf4jLoggerProxy.isTraceEnabled(marker)); | ||
| 423 | - PowerMock.verify(this.logger); | ||
| 424 | - } | ||
| 425 | - | ||
| 426 | - @Test | ||
| 427 | - public void testIsWarnEnabled() { | ||
| 428 | - expect(this.logger.isWarnEnabled()).andReturn(true); | ||
| 429 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 430 | - assertEquals(true, this.slf4jLoggerProxy.isWarnEnabled()); | ||
| 431 | - PowerMock.verify(this.logger); | ||
| 432 | - } | ||
| 433 | - | ||
| 434 | - @Test | ||
| 435 | - public void testIsWarnEnabledWithMarker() { | ||
| 436 | - Marker marker = null; | ||
| 437 | - expect(this.logger.isWarnEnabled(marker)).andReturn(true); | ||
| 438 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 439 | - assertEquals(true, this.slf4jLoggerProxy.isWarnEnabled(marker)); | ||
| 440 | - PowerMock.verify(this.logger); | ||
| 441 | - } | ||
| 442 | - | ||
| 443 | - @Test | ||
| 444 | - public void testTraceWithMarkerAndString() { | ||
| 445 | - Marker marker = null; | ||
| 446 | - this.logger.trace(marker,""); | ||
| 447 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 448 | - this.slf4jLoggerProxy.trace(marker,""); | ||
| 449 | - PowerMock.verify(this.logger); | ||
| 450 | - } | ||
| 451 | - | ||
| 452 | - @Test | ||
| 453 | - public void testTraceWithMarkerStringAndOneObject() { | ||
| 454 | - Marker marker = null; | ||
| 455 | - Object obj = null; | ||
| 456 | - this.logger.trace(marker,"",obj); | ||
| 457 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 458 | - this.slf4jLoggerProxy.trace(marker,"",obj); | ||
| 459 | - PowerMock.verify(this.logger); | ||
| 460 | - } | ||
| 461 | - | ||
| 462 | - @Test | ||
| 463 | - public void testTraceWithMarkerStringAndTwoObjects() { | ||
| 464 | - Marker marker = null; | ||
| 465 | - Object obj1 = null, obj2 = null; | ||
| 466 | - this.logger.trace(marker,"",obj1, obj2); | ||
| 467 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 468 | - this.slf4jLoggerProxy.trace(marker,"",obj1,obj2); | ||
| 469 | - PowerMock.verify(this.logger); | ||
| 470 | - } | ||
| 471 | - | ||
| 472 | - @Test | ||
| 473 | - public void testTraceWithMarkerStringAndObjectArray() { | ||
| 474 | - Marker marker = null; | ||
| 475 | - Object[] obj = null; | ||
| 476 | - this.logger.trace(marker,"",obj); | ||
| 477 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 478 | - this.slf4jLoggerProxy.trace(marker,"",obj); | ||
| 479 | - PowerMock.verify(this.logger); | ||
| 480 | - } | ||
| 481 | - | ||
| 482 | - @Test | ||
| 483 | - public void testTraceWithMarkerStringAndThrowable() { | ||
| 484 | - Marker marker = null; | ||
| 485 | - Throwable t = null; | ||
| 486 | - this.logger.trace(marker,"",t); | ||
| 487 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 488 | - this.slf4jLoggerProxy.trace(marker,"",t); | ||
| 489 | - PowerMock.verify(this.logger); | ||
| 490 | - } | ||
| 491 | - | ||
| 492 | - @Test | ||
| 493 | - public void testTraceWithString() { | ||
| 494 | - this.logger.trace(""); | ||
| 495 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 496 | - this.slf4jLoggerProxy.trace(""); | ||
| 497 | - PowerMock.verify(this.logger); | ||
| 498 | - } | ||
| 499 | - | ||
| 500 | - @Test | ||
| 501 | - public void testTraceWithStringAndOneObject() { | ||
| 502 | - Object obj = null; | ||
| 503 | - this.logger.trace("",obj); | ||
| 504 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 505 | - this.slf4jLoggerProxy.trace("",obj); | ||
| 506 | - PowerMock.verify(this.logger); | ||
| 507 | - } | ||
| 508 | - | ||
| 509 | - @Test | ||
| 510 | - public void testTraceWithStringAndTwoObjects() { | ||
| 511 | - Object obj1 = null, obj2 = null; | ||
| 512 | - this.logger.trace("",obj1,obj2); | ||
| 513 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 514 | - this.slf4jLoggerProxy.trace("",obj1,obj2); | ||
| 515 | - PowerMock.verify(this.logger); | ||
| 516 | - } | ||
| 517 | - | ||
| 518 | - @Test | ||
| 519 | - public void testTraceWithStringAndObjectArray() { | ||
| 520 | - Object[] obj = null; | ||
| 521 | - this.logger.trace("",obj); | ||
| 522 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 523 | - this.slf4jLoggerProxy.trace("",obj); | ||
| 524 | - PowerMock.verify(this.logger); | ||
| 525 | - } | ||
| 526 | - | ||
| 527 | - @Test | ||
| 528 | - public void testTraceWithStringAndThrowable() { | ||
| 529 | - Throwable t = null; | ||
| 530 | - this.logger.trace("",t); | ||
| 531 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 532 | - this.slf4jLoggerProxy.trace("",t); | ||
| 533 | - PowerMock.verify(this.logger); | ||
| 534 | - } | ||
| 535 | - | ||
| 536 | - @Test | ||
| 537 | - public void testWarnWithMarkerAndString() { | ||
| 538 | - Marker marker = null; | ||
| 539 | - this.logger.warn(marker,""); | ||
| 540 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 541 | - this.slf4jLoggerProxy.warn(marker,""); | ||
| 542 | - PowerMock.verify(this.logger); | ||
| 543 | - } | ||
| 544 | - | ||
| 545 | - @Test | ||
| 546 | - public void testWarnWithMarkerStringAndOneObject() { | ||
| 547 | - Marker marker = null; | ||
| 548 | - Object obj = null; | ||
| 549 | - this.logger.warn(marker,"",obj); | ||
| 550 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 551 | - this.slf4jLoggerProxy.warn(marker,"",obj); | ||
| 552 | - PowerMock.verify(this.logger); | ||
| 553 | - } | ||
| 554 | - | ||
| 555 | - @Test | ||
| 556 | - public void testWarnWithMarkerStringAndTwoObjects() { | ||
| 557 | - Marker marker = null; | ||
| 558 | - Object obj1 = null, obj2 = null; | ||
| 559 | - this.logger.warn(marker,"",obj1, obj2); | ||
| 560 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 561 | - this.slf4jLoggerProxy.warn(marker,"",obj1,obj2); | ||
| 562 | - PowerMock.verify(this.logger); | ||
| 563 | - } | ||
| 564 | - | ||
| 565 | - @Test | ||
| 566 | - public void testWarnWithMarkerStringAndObjectArray() { | ||
| 567 | - Marker marker = null; | ||
| 568 | - Object[] obj = null; | ||
| 569 | - this.logger.warn(marker,"",obj); | ||
| 570 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 571 | - this.slf4jLoggerProxy.warn(marker,"",obj); | ||
| 572 | - PowerMock.verify(this.logger); | ||
| 573 | - } | ||
| 574 | - | ||
| 575 | - @Test | ||
| 576 | - public void testWarnWithMarkerStringAndThrowable() { | ||
| 577 | - Marker marker = null; | ||
| 578 | - Throwable t = null; | ||
| 579 | - this.logger.warn(marker,"",t); | ||
| 580 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 581 | - this.slf4jLoggerProxy.warn(marker,"",t); | ||
| 582 | - PowerMock.verify(this.logger); | ||
| 583 | - } | ||
| 584 | - | ||
| 585 | - @Test | ||
| 586 | - public void testWarnWithString() { | ||
| 587 | - this.logger.warn(""); | ||
| 588 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 589 | - this.slf4jLoggerProxy.warn(""); | ||
| 590 | - PowerMock.verify(this.logger); | ||
| 591 | - } | ||
| 592 | - | ||
| 593 | - @Test | ||
| 594 | - public void testWarnWithStringAndOneObject() { | ||
| 595 | - Object obj = null; | ||
| 596 | - this.logger.warn("",obj); | ||
| 597 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 598 | - this.slf4jLoggerProxy.warn("",obj); | ||
| 599 | - PowerMock.verify(this.logger); | ||
| 600 | - } | ||
| 601 | - | ||
| 602 | - @Test | ||
| 603 | - public void testWarnWithStringAndTwoObjects() { | ||
| 604 | - Object obj1 = null, obj2 = null; | ||
| 605 | - this.logger.warn("",obj1,obj2); | ||
| 606 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 607 | - this.slf4jLoggerProxy.warn("",obj1,obj2); | ||
| 608 | - PowerMock.verify(this.logger); | ||
| 609 | - } | ||
| 610 | - | ||
| 611 | - @Test | ||
| 612 | - public void testWarnWithStringAndObjectArray() { | ||
| 613 | - Object[] obj = null; | ||
| 614 | - this.logger.warn("",obj); | ||
| 615 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 616 | - this.slf4jLoggerProxy.warn("",obj); | ||
| 617 | - PowerMock.verify(this.logger); | ||
| 618 | - } | ||
| 619 | - | ||
| 620 | - @Test | ||
| 621 | - public void testWarnWithStringAndThrowable() { | ||
| 622 | - Throwable t = null; | ||
| 623 | - this.logger.warn("",t); | ||
| 624 | - PowerMock.replay(LoggerFactory.class, this.logger); | ||
| 625 | - this.slf4jLoggerProxy.warn("",t); | ||
| 626 | - PowerMock.verify(this.logger); | ||
| 627 | - } | ||
| 628 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/message/DefaultMessageTest.java
| @@ -1,296 +0,0 @@ | @@ -1,296 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * Demoiselle Framework Copyright (C) 2010 SERPRO | ||
| 3 | - * ---------------------------------------------------------------------------- This file is part of Demoiselle | ||
| 4 | - * Framework. Demoiselle Framework is free software; you can redistribute it and/or modify it under the terms of the GNU | ||
| 5 | - * Lesser General Public License version 3 as published by the Free Software Foundation. This program is distributed in | ||
| 6 | - * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 7 | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a | ||
| 8 | - * copy of the GNU Lesser General Public License version 3 along with this program; if not, see | ||
| 9 | - * <http://www.gnu.org/licenses/> or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 10 | - * Boston, MA 02110-1301, USA. ---------------------------------------------------------------------------- Este arquivo | ||
| 11 | - * é parte do Framework Demoiselle. O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 12 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação do Software Livre (FSF). Este | ||
| 13 | - * programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de | ||
| 14 | - * ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português para | ||
| 15 | - * maiores detalhes. Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título "LICENCA.txt", junto com esse | ||
| 16 | - * programa. Se não, acesse <http://www.gnu.org/licenses/> ou escreva para a Fundação do Software Livre (FSF) Inc., 51 | ||
| 17 | - * Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 18 | - */ | ||
| 19 | -package br.gov.frameworkdemoiselle.message; | ||
| 20 | - | ||
| 21 | -import static org.easymock.EasyMock.expect; | ||
| 22 | -import static org.junit.Assert.assertEquals; | ||
| 23 | -import static org.junit.Assert.assertSame; | ||
| 24 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 25 | -import static org.powermock.api.easymock.PowerMock.replay; | ||
| 26 | -import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 27 | -import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
| 28 | - | ||
| 29 | -import java.util.Arrays; | ||
| 30 | -import java.util.Locale; | ||
| 31 | - | ||
| 32 | -import org.junit.After; | ||
| 33 | -import org.junit.Before; | ||
| 34 | -import org.junit.Test; | ||
| 35 | -import org.junit.runner.RunWith; | ||
| 36 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 37 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 38 | - | ||
| 39 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
| 40 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 41 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 42 | -import br.gov.frameworkdemoiselle.util.Strings; | ||
| 43 | - | ||
| 44 | -@RunWith(PowerMockRunner.class) | ||
| 45 | -@PrepareForTest({ Beans.class, ResourceBundle.class }) | ||
| 46 | -public class DefaultMessageTest { | ||
| 47 | - | ||
| 48 | - private Message message; | ||
| 49 | - | ||
| 50 | - private String MOCK_RESOURCE_BUNDLE_KEY = "{key}"; | ||
| 51 | - | ||
| 52 | - private String MOCK_RESOURCE_BUNDLE_VALUE = "param {0} and param {1}"; | ||
| 53 | - | ||
| 54 | - private ResourceBundle bundle; | ||
| 55 | - | ||
| 56 | - @Before | ||
| 57 | - public void setUp() throws Exception { | ||
| 58 | - Locale locale = Locale.getDefault(); | ||
| 59 | - | ||
| 60 | - mockStatic(Beans.class); | ||
| 61 | - expect(Beans.getReference(Locale.class)).andReturn(locale).anyTimes(); | ||
| 62 | - replay(Beans.class); | ||
| 63 | - | ||
| 64 | - bundle = ResourceBundleProducer.create("test-message"); | ||
| 65 | - | ||
| 66 | - mockStatic(Beans.class); | ||
| 67 | - expect(Beans.getReference(ResourceBundle.class)).andReturn(bundle).anyTimes(); | ||
| 68 | - replayAll(Beans.class); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - @After | ||
| 72 | - public void tearDown() throws Exception { | ||
| 73 | - verifyAll(); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - @Test | ||
| 77 | - public void testConstructorWithTextOnly() { | ||
| 78 | - message = new DefaultMessage(""); | ||
| 79 | - assertEquals("", message.getText()); | ||
| 80 | - | ||
| 81 | - message = new DefaultMessage("a"); | ||
| 82 | - assertEquals("a", message.getText()); | ||
| 83 | - | ||
| 84 | - message = new DefaultMessage(null); | ||
| 85 | - assertEquals(null, message.getText()); | ||
| 86 | - | ||
| 87 | - message = new DefaultMessage(MOCK_RESOURCE_BUNDLE_KEY); | ||
| 88 | - assertEquals(MOCK_RESOURCE_BUNDLE_VALUE, message.getText()); | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - @Test | ||
| 92 | - public void testCachedText() { | ||
| 93 | - message = new DefaultMessage(MOCK_RESOURCE_BUNDLE_KEY); | ||
| 94 | - assertSame(message.getText(), message.getText()); | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - @Test | ||
| 98 | - public void testDefaultSeverity() { | ||
| 99 | - message = new DefaultMessage(null); | ||
| 100 | - assertEquals(SeverityType.INFO, message.getSeverity()); | ||
| 101 | - | ||
| 102 | - assertEquals(DefaultMessage.DEFAULT_SEVERITY, message.getSeverity()); | ||
| 103 | - | ||
| 104 | - message = new DefaultMessage(null, null, new Object[] {}); | ||
| 105 | - assertEquals(DefaultMessage.DEFAULT_SEVERITY, message.getSeverity()); | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - @Test | ||
| 109 | - public void testConstructorWithParametrizedText() { | ||
| 110 | - String text; | ||
| 111 | - Object[] params; | ||
| 112 | - | ||
| 113 | - text = ""; | ||
| 114 | - params = new Object[] { "1", "2" }; | ||
| 115 | - message = new DefaultMessage(text, params); | ||
| 116 | - assertEquals(Strings.getString(text, params), message.getText()); | ||
| 117 | - | ||
| 118 | - text = "params: {0}, {1}"; | ||
| 119 | - params = new Object[] { "1", "2" }; | ||
| 120 | - message = new DefaultMessage(text, params); | ||
| 121 | - assertEquals(Strings.getString(text, params), message.getText()); | ||
| 122 | - | ||
| 123 | - text = null; | ||
| 124 | - params = new Object[] { "1" }; | ||
| 125 | - message = new DefaultMessage(text, params); | ||
| 126 | - assertEquals(Strings.getString(text, params), message.getText()); | ||
| 127 | - | ||
| 128 | - text = MOCK_RESOURCE_BUNDLE_KEY; | ||
| 129 | - params = new Object[] { "1", "2" }; | ||
| 130 | - message = new DefaultMessage(text, params); | ||
| 131 | - assertEquals(Strings.getString(bundle.getString("key"), params), message.getText()); | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - @Test | ||
| 135 | - public void testToString() throws SecurityException, NoSuchFieldException { | ||
| 136 | - String text; | ||
| 137 | - Object[] params; | ||
| 138 | - | ||
| 139 | - text = "text"; | ||
| 140 | - message = new DefaultMessage(text); | ||
| 141 | - assertEquals("DefaultMessage [originalText=" + text + ", parsedText=" + text | ||
| 142 | - + ", severity=INFO, params=[], bundle=" + bundle.toString() + "]", message.toString()); | ||
| 143 | - | ||
| 144 | - text = MOCK_RESOURCE_BUNDLE_KEY; | ||
| 145 | - params = new Object[] { "1", "2" }; | ||
| 146 | - message = new DefaultMessage(text, SeverityType.FATAL, params); | ||
| 147 | - assertEquals( | ||
| 148 | - "DefaultMessage [originalText=" + text + ", parsedText=" | ||
| 149 | - + Strings.getString(bundle.getString("key"), params) + ", severity=FATAL, params=" | ||
| 150 | - + Arrays.toString(params) + ", bundle=" + bundle.toString() + "]", message.toString()); | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - @Test | ||
| 154 | - public void testConstructorWithParametrizedTextAndSeverityType() { | ||
| 155 | - message = new DefaultMessage("", SeverityType.FATAL, ""); | ||
| 156 | - assertEquals("", message.getText()); | ||
| 157 | - assertEquals(SeverityType.FATAL, message.getSeverity()); | ||
| 158 | - | ||
| 159 | - message = new DefaultMessage("text", SeverityType.WARN, "param"); | ||
| 160 | - assertEquals("text", message.getText()); | ||
| 161 | - assertEquals(SeverityType.WARN, message.getSeverity()); | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - enum MessagesEnum implements Message { | ||
| 165 | - | ||
| 166 | - FIRST_KEY("{first-key}"), SECOND_KEY("{second-key}", SeverityType.WARN), THIRD_KEY("{THIRD_KEY}"), FOURTH_KEY("{FOURTH_KEY}",SeverityType.FATAL), LITERAL_TEXT( | ||
| 167 | - "This is a literal text"); | ||
| 168 | - | ||
| 169 | - private final DefaultMessage msg; | ||
| 170 | - | ||
| 171 | - MessagesEnum() { | ||
| 172 | - msg = new DefaultMessage(this.name()); | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - MessagesEnum(String name) { | ||
| 176 | - msg = new DefaultMessage(name); | ||
| 177 | - } | ||
| 178 | - | ||
| 179 | - MessagesEnum(SeverityType severity) { | ||
| 180 | - msg = new DefaultMessage(this.name(), severity); | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | - MessagesEnum(String name, SeverityType severity) { | ||
| 184 | - msg = new DefaultMessage(name, severity); | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - @Override | ||
| 188 | - public String getText() { | ||
| 189 | - return msg.getText(); | ||
| 190 | - } | ||
| 191 | - | ||
| 192 | - @Override | ||
| 193 | - public SeverityType getSeverity() { | ||
| 194 | - return msg.getSeverity(); | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | - } | ||
| 198 | - | ||
| 199 | - @Test | ||
| 200 | - public void testMessagesEnum() throws Exception { | ||
| 201 | - message = MessagesEnum.FIRST_KEY; | ||
| 202 | - assertEquals(SeverityType.INFO, message.getSeverity()); | ||
| 203 | - assertEquals("First message text", message.getText()); | ||
| 204 | - | ||
| 205 | - message = MessagesEnum.SECOND_KEY; | ||
| 206 | - assertEquals(SeverityType.WARN, message.getSeverity()); | ||
| 207 | - assertEquals("Second message text", message.getText()); | ||
| 208 | - | ||
| 209 | - message = MessagesEnum.THIRD_KEY; | ||
| 210 | - assertEquals(SeverityType.INFO, message.getSeverity()); | ||
| 211 | - assertEquals("Third message text", message.getText()); | ||
| 212 | - | ||
| 213 | - message = MessagesEnum.FOURTH_KEY; | ||
| 214 | - assertEquals(SeverityType.FATAL, message.getSeverity()); | ||
| 215 | - assertEquals("Fourth message text", message.getText()); | ||
| 216 | - | ||
| 217 | - message = MessagesEnum.LITERAL_TEXT; | ||
| 218 | - assertEquals(SeverityType.INFO, message.getSeverity()); | ||
| 219 | - assertEquals("This is a literal text", message.getText()); | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - enum ErrorMessages implements Message { | ||
| 223 | - | ||
| 224 | - ERROR_KEY("{error-key}"), LITERAL_ERROR_TEXT("This is a literal error text"); | ||
| 225 | - | ||
| 226 | - private final DefaultMessage msg; | ||
| 227 | - | ||
| 228 | - ErrorMessages() { | ||
| 229 | - msg = new DefaultMessage(this.name(), SeverityType.ERROR); | ||
| 230 | - } | ||
| 231 | - | ||
| 232 | - ErrorMessages(String name) { | ||
| 233 | - msg = new DefaultMessage(name, SeverityType.ERROR); | ||
| 234 | - } | ||
| 235 | - | ||
| 236 | - @Override | ||
| 237 | - public String getText() { | ||
| 238 | - return msg.getText(); | ||
| 239 | - } | ||
| 240 | - | ||
| 241 | - @Override | ||
| 242 | - public SeverityType getSeverity() { | ||
| 243 | - return msg.getSeverity(); | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - } | ||
| 247 | - | ||
| 248 | - @Test | ||
| 249 | - public void testErrorMessagesEnum() { | ||
| 250 | - message = ErrorMessages.ERROR_KEY; | ||
| 251 | - assertEquals(SeverityType.ERROR, message.getSeverity()); | ||
| 252 | - assertEquals("Error message text", message.getText()); | ||
| 253 | - | ||
| 254 | - message = ErrorMessages.LITERAL_ERROR_TEXT; | ||
| 255 | - assertEquals(SeverityType.ERROR, message.getSeverity()); | ||
| 256 | - assertEquals("This is a literal error text", message.getText()); | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - interface MessagesInterface { | ||
| 260 | - | ||
| 261 | - final Message FIRST_KEY = new DefaultMessage("{first-key}"); | ||
| 262 | - | ||
| 263 | - final Message SECOND_KEY = new DefaultMessage("{second-key}", SeverityType.WARN); | ||
| 264 | - | ||
| 265 | - final Message THIRD_KEY = new DefaultMessage("{THIRD_KEY}"); | ||
| 266 | - | ||
| 267 | - final Message FOURTH_KEY = new DefaultMessage("{FOURTH_KEY}", SeverityType.FATAL); | ||
| 268 | - | ||
| 269 | - final Message LITERAL_TEXT = new DefaultMessage("This is a literal text"); | ||
| 270 | - | ||
| 271 | - } | ||
| 272 | - | ||
| 273 | - @Test | ||
| 274 | - public void testMessagesInterface() { | ||
| 275 | - message = MessagesInterface.FIRST_KEY; | ||
| 276 | - assertEquals(SeverityType.INFO, message.getSeverity()); | ||
| 277 | - assertEquals("First message text", message.getText()); | ||
| 278 | - | ||
| 279 | - message = MessagesInterface.SECOND_KEY; | ||
| 280 | - assertEquals(SeverityType.WARN, message.getSeverity()); | ||
| 281 | - assertEquals("Second message text", message.getText()); | ||
| 282 | - | ||
| 283 | - message = MessagesInterface.THIRD_KEY; | ||
| 284 | - assertEquals(SeverityType.INFO, message.getSeverity()); | ||
| 285 | - assertEquals("Third message text", message.getText()); | ||
| 286 | - | ||
| 287 | - message = MessagesInterface.FOURTH_KEY; | ||
| 288 | - assertEquals(SeverityType.FATAL, message.getSeverity()); | ||
| 289 | - assertEquals("Fourth message text", message.getText()); | ||
| 290 | - | ||
| 291 | - message = MessagesInterface.LITERAL_TEXT; | ||
| 292 | - assertEquals(SeverityType.INFO, message.getSeverity()); | ||
| 293 | - assertEquals("This is a literal text", message.getText()); | ||
| 294 | - } | ||
| 295 | - | ||
| 296 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/template/DelegateCrudTest.java
| @@ -1,205 +0,0 @@ | @@ -1,205 +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.mockStatic; | ||
| 42 | -//import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 43 | -//import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
| 44 | -// | ||
| 45 | -//import java.util.ArrayList; | ||
| 46 | -//import java.util.List; | ||
| 47 | -// | ||
| 48 | -//import org.easymock.EasyMock; | ||
| 49 | -//import org.junit.Before; | ||
| 50 | -//import org.junit.Test; | ||
| 51 | -//import org.junit.runner.RunWith; | ||
| 52 | -//import org.powermock.api.easymock.PowerMock; | ||
| 53 | -//import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 54 | -//import org.powermock.modules.junit4.PowerMockRunner; | ||
| 55 | -//import org.powermock.reflect.Whitebox; | ||
| 56 | -// | ||
| 57 | -//import br.gov.frameworkdemoiselle.util.Beans; | ||
| 58 | -//import br.gov.frameworkdemoiselle.util.Reflections; | ||
| 59 | -// | ||
| 60 | -//@RunWith(PowerMockRunner.class) | ||
| 61 | -//@PrepareForTest({ Crud.class, Beans.class, Reflections.class }) | ||
| 62 | -//public class DelegateCrudTest { | ||
| 63 | -// | ||
| 64 | -// private DelegateCrud<Contact, Long, Delegated> delegateCrud; | ||
| 65 | -// | ||
| 66 | -// private Crud<Contact, Long> mockCrud; | ||
| 67 | -// | ||
| 68 | -// @SuppressWarnings("unchecked") | ||
| 69 | -// @Before | ||
| 70 | -// public void before() { | ||
| 71 | -// delegateCrud = new DelegateCrud<Contact, Long, Delegated>(); | ||
| 72 | -// mockCrud = PowerMock.createMock(Crud.class); | ||
| 73 | -// } | ||
| 74 | -// | ||
| 75 | -// @SuppressWarnings("unchecked") | ||
| 76 | -// @Test | ||
| 77 | -// public void testDelete() { | ||
| 78 | -// mockStatic(Beans.class); | ||
| 79 | -// mockStatic(Reflections.class); | ||
| 80 | -// | ||
| 81 | -// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Class.class), EasyMock.anyInt())).andReturn(null); | ||
| 82 | -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud).times(2); | ||
| 83 | -// | ||
| 84 | -// mockCrud.delete(1L); | ||
| 85 | -// PowerMock.expectLastCall(); | ||
| 86 | -// | ||
| 87 | -// PowerMock.replay(Reflections.class, Beans.class, mockCrud); | ||
| 88 | -// | ||
| 89 | -// delegateCrud.delete(1L); | ||
| 90 | -// | ||
| 91 | -// PowerMock.verify(); | ||
| 92 | -// } | ||
| 93 | -// | ||
| 94 | -// @SuppressWarnings("unchecked") | ||
| 95 | -// @Test | ||
| 96 | -// public void testUpdate() { | ||
| 97 | -// Whitebox.setInternalState(delegateCrud, "delegate", mockCrud); | ||
| 98 | -// | ||
| 99 | -// mockStatic(Beans.class); | ||
| 100 | -// | ||
| 101 | -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud); | ||
| 102 | -// | ||
| 103 | -// Contact update = new Contact(); | ||
| 104 | -// mockCrud.update(update); | ||
| 105 | -// replayAll(Beans.class, mockCrud); | ||
| 106 | -// | ||
| 107 | -// delegateCrud.update(update); | ||
| 108 | -// | ||
| 109 | -// verifyAll(); | ||
| 110 | -// } | ||
| 111 | -// | ||
| 112 | -// @SuppressWarnings("unchecked") | ||
| 113 | -// @Test | ||
| 114 | -// public void testInsert() { | ||
| 115 | -// Whitebox.setInternalState(delegateCrud, "delegate", mockCrud); | ||
| 116 | -// | ||
| 117 | -// mockStatic(Beans.class); | ||
| 118 | -// | ||
| 119 | -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud); | ||
| 120 | -// | ||
| 121 | -// Contact insert = new Contact(); | ||
| 122 | -// mockCrud.insert(insert); | ||
| 123 | -// replayAll(mockCrud); | ||
| 124 | -// | ||
| 125 | -// delegateCrud.insert(insert); | ||
| 126 | -// | ||
| 127 | -// verifyAll(); | ||
| 128 | -// } | ||
| 129 | -// | ||
| 130 | -// @SuppressWarnings("unchecked") | ||
| 131 | -// @Test | ||
| 132 | -// public void testFindAll() { | ||
| 133 | -// mockStatic(Beans.class); | ||
| 134 | -// mockStatic(Reflections.class); | ||
| 135 | -// | ||
| 136 | -// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Class.class), EasyMock.anyInt())).andReturn(null); | ||
| 137 | -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud); | ||
| 138 | -// | ||
| 139 | -// List<Contact> returned = new ArrayList<Contact>(); | ||
| 140 | -// expect(mockCrud.findAll()).andReturn(returned); | ||
| 141 | -// replayAll(Reflections.class, Beans.class, mockCrud); | ||
| 142 | -// | ||
| 143 | -// assertEquals(returned, delegateCrud.findAll()); | ||
| 144 | -// | ||
| 145 | -// verifyAll(); | ||
| 146 | -// } | ||
| 147 | -// | ||
| 148 | -// @SuppressWarnings("unchecked") | ||
| 149 | -// @Test | ||
| 150 | -// public void testLoad() { | ||
| 151 | -// mockStatic(Beans.class); | ||
| 152 | -// | ||
| 153 | -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud); | ||
| 154 | -// | ||
| 155 | -// Contact contact = new Contact(); | ||
| 156 | -// expect(mockCrud.load(1L)).andReturn(contact); | ||
| 157 | -// replayAll(Beans.class, mockCrud); | ||
| 158 | -// | ||
| 159 | -// Whitebox.setInternalState(delegateCrud, "delegateClass", delegateCrud.getClass(), delegateCrud.getClass()); | ||
| 160 | -// | ||
| 161 | -// assertEquals(contact, delegateCrud.load(1L)); | ||
| 162 | -// verifyAll(); | ||
| 163 | -// } | ||
| 164 | -// | ||
| 165 | -// class Contact { | ||
| 166 | -// | ||
| 167 | -// private Long id; | ||
| 168 | -// | ||
| 169 | -// public Long getId() { | ||
| 170 | -// return id; | ||
| 171 | -// } | ||
| 172 | -// | ||
| 173 | -// public void setId(Long id) { | ||
| 174 | -// this.id = id; | ||
| 175 | -// } | ||
| 176 | -// } | ||
| 177 | -// | ||
| 178 | -// @SuppressWarnings("serial") | ||
| 179 | -// class Delegated implements Crud<Contact, Long> { | ||
| 180 | -// | ||
| 181 | -// @Override | ||
| 182 | -// public void delete(Long id) { | ||
| 183 | -// } | ||
| 184 | -// | ||
| 185 | -// @Override | ||
| 186 | -// public List<Contact> findAll() { | ||
| 187 | -// return null; | ||
| 188 | -// } | ||
| 189 | -// | ||
| 190 | -// @Override | ||
| 191 | -// public void insert(Contact bean) { | ||
| 192 | -// } | ||
| 193 | -// | ||
| 194 | -// @Override | ||
| 195 | -// public Contact load(Long id) { | ||
| 196 | -// return null; | ||
| 197 | -// } | ||
| 198 | -// | ||
| 199 | -// @Override | ||
| 200 | -// public void update(Contact bean) { | ||
| 201 | -// } | ||
| 202 | -// | ||
| 203 | -// } | ||
| 204 | -// | ||
| 205 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.java
| @@ -1,185 +0,0 @@ | @@ -1,185 +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.transaction; | ||
| 38 | -// | ||
| 39 | -//import static junit.framework.Assert.assertEquals; | ||
| 40 | -//import static junit.framework.Assert.assertFalse; | ||
| 41 | -//import static junit.framework.Assert.assertTrue; | ||
| 42 | -//import static junit.framework.Assert.fail; | ||
| 43 | -//import static org.easymock.EasyMock.expect; | ||
| 44 | -//import static org.easymock.EasyMock.replay; | ||
| 45 | -//import static org.easymock.EasyMock.verify; | ||
| 46 | -//import static org.powermock.reflect.Whitebox.setInternalState; | ||
| 47 | -// | ||
| 48 | -//import javax.naming.Context; | ||
| 49 | -//import javax.naming.NamingException; | ||
| 50 | -//import javax.transaction.HeuristicMixedException; | ||
| 51 | -//import javax.transaction.HeuristicRollbackException; | ||
| 52 | -//import javax.transaction.NotSupportedException; | ||
| 53 | -//import javax.transaction.RollbackException; | ||
| 54 | -//import javax.transaction.Status; | ||
| 55 | -//import javax.transaction.SystemException; | ||
| 56 | -//import javax.transaction.UserTransaction; | ||
| 57 | -// | ||
| 58 | -//import org.easymock.EasyMock; | ||
| 59 | -//import org.junit.Before; | ||
| 60 | -//import org.junit.Test; | ||
| 61 | -//import org.powermock.api.easymock.PowerMock; | ||
| 62 | -// | ||
| 63 | -//import br.gov.frameworkdemoiselle.exception.DemoiselleException; | ||
| 64 | -//import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 65 | -// | ||
| 66 | -//public class JTATransactionTest { | ||
| 67 | -// | ||
| 68 | -// private UserTransaction userTransaction; | ||
| 69 | -// private JTATransaction jtaTransaction; | ||
| 70 | -// private Context context; | ||
| 71 | -// private ResourceBundle bundle; | ||
| 72 | -// | ||
| 73 | -// @Before | ||
| 74 | -// public void setUp() throws Exception { | ||
| 75 | -// this.jtaTransaction = new JTATransaction(); | ||
| 76 | -// | ||
| 77 | -// this.userTransaction = EasyMock.createMock(UserTransaction.class); | ||
| 78 | -// | ||
| 79 | -// this.context = EasyMock.createMock(Context.class); | ||
| 80 | -// expect(this.context.lookup("UserTransaction")).andReturn(this.userTransaction); | ||
| 81 | -// replay(this.context); | ||
| 82 | -// setInternalState(this.jtaTransaction, "context", this.context); | ||
| 83 | -// } | ||
| 84 | -// | ||
| 85 | -// @Test | ||
| 86 | -// public void testNamingException() throws Exception{ | ||
| 87 | -// | ||
| 88 | -// this.context = EasyMock.createMock(Context.class); | ||
| 89 | -// expect(this.context.lookup("UserTransaction")).andThrow(new NamingException()); | ||
| 90 | -// replay(this.context); | ||
| 91 | -// setInternalState(this.jtaTransaction, "context", this.context); | ||
| 92 | -// | ||
| 93 | -// this.bundle = PowerMock.createMock(ResourceBundle.class); | ||
| 94 | -// EasyMock.expect(this.bundle.getString("user-transaction-lookup-fail","UserTransaction")).andReturn("teste"); | ||
| 95 | -// PowerMock.replay(this.bundle); | ||
| 96 | -// setInternalState(this.jtaTransaction, "bundle", this.bundle); | ||
| 97 | -// | ||
| 98 | -// try { | ||
| 99 | -// this.jtaTransaction.isMarkedRollback(); | ||
| 100 | -// fail(); | ||
| 101 | -// }catch(DemoiselleException cause) { | ||
| 102 | -// assertTrue(true); | ||
| 103 | -// } | ||
| 104 | -// } | ||
| 105 | -// | ||
| 106 | -// @Test | ||
| 107 | -// public void testIsMarkedRollback() throws SystemException { | ||
| 108 | -// expect(this.userTransaction.getStatus()).andReturn(Status.STATUS_MARKED_ROLLBACK); | ||
| 109 | -// replay(this.userTransaction); | ||
| 110 | -// assertTrue(this.jtaTransaction.isMarkedRollback()); | ||
| 111 | -// verify(this.userTransaction); | ||
| 112 | -// } | ||
| 113 | -// | ||
| 114 | -// @Test | ||
| 115 | -// public void testIsNotMarkedRollback() throws SystemException { | ||
| 116 | -// expect(this.userTransaction.getStatus()).andReturn(2); | ||
| 117 | -// replay(this.userTransaction); | ||
| 118 | -// assertFalse(this.jtaTransaction.isMarkedRollback()); | ||
| 119 | -// verify(this.userTransaction); | ||
| 120 | -// } | ||
| 121 | -// | ||
| 122 | -// @Test | ||
| 123 | -// public void testIsAtive() throws SystemException { | ||
| 124 | -// expect(this.userTransaction.getStatus()).andReturn(Status.STATUS_ACTIVE); | ||
| 125 | -// replay(this.userTransaction); | ||
| 126 | -// assertTrue(this.jtaTransaction.isActive()); | ||
| 127 | -// verify(this.userTransaction); | ||
| 128 | -// } | ||
| 129 | -// | ||
| 130 | -// @Test | ||
| 131 | -// public void testIsNotAtiveButMarkedRollback() throws SystemException { | ||
| 132 | -// expect(this.userTransaction.getStatus()).andReturn(Status.STATUS_MARKED_ROLLBACK).times(2); | ||
| 133 | -// replay(this.userTransaction); | ||
| 134 | -// assertTrue(this.jtaTransaction.isActive()); | ||
| 135 | -// verify(this.userTransaction); | ||
| 136 | -// } | ||
| 137 | -// | ||
| 138 | -// @Test | ||
| 139 | -// public void testBegin() throws NotSupportedException, SystemException { | ||
| 140 | -// this.userTransaction.begin(); | ||
| 141 | -// replay(this.userTransaction); | ||
| 142 | -// this.jtaTransaction.begin(); | ||
| 143 | -// verify(this.userTransaction); | ||
| 144 | -// } | ||
| 145 | -// | ||
| 146 | -// @Test | ||
| 147 | -// public void testCommit() throws SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException { | ||
| 148 | -// this.userTransaction.commit(); | ||
| 149 | -// replay(this.userTransaction); | ||
| 150 | -// this.jtaTransaction.commit(); | ||
| 151 | -// verify(this.userTransaction); | ||
| 152 | -// } | ||
| 153 | -// | ||
| 154 | -// @Test | ||
| 155 | -// public void testgetStatus() throws SystemException{ | ||
| 156 | -// expect(this.userTransaction.getStatus()).andReturn(Status.STATUS_MARKED_ROLLBACK); | ||
| 157 | -// replay(this.userTransaction); | ||
| 158 | -// assertEquals(Status.STATUS_MARKED_ROLLBACK,this.jtaTransaction.getStatus()); | ||
| 159 | -// verify(this.userTransaction); | ||
| 160 | -// } | ||
| 161 | -// | ||
| 162 | -// @Test | ||
| 163 | -// public void testRollback() throws SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException { | ||
| 164 | -// this.userTransaction.rollback(); | ||
| 165 | -// replay(this.userTransaction); | ||
| 166 | -// this.jtaTransaction.rollback(); | ||
| 167 | -// verify(this.userTransaction); | ||
| 168 | -// } | ||
| 169 | -// | ||
| 170 | -// @Test | ||
| 171 | -// public void testSetRollbackOnly() throws SystemException{ | ||
| 172 | -// this.userTransaction.setRollbackOnly(); | ||
| 173 | -// replay(this.userTransaction); | ||
| 174 | -// this.jtaTransaction.setRollbackOnly(); | ||
| 175 | -// verify(this.userTransaction); | ||
| 176 | -// } | ||
| 177 | -// | ||
| 178 | -// @Test | ||
| 179 | -// public void testSetTransactionTimeout() throws SystemException{ | ||
| 180 | -// this.userTransaction.setTransactionTimeout(0); | ||
| 181 | -// replay(this.userTransaction); | ||
| 182 | -// this.jtaTransaction.setTransactionTimeout(0); | ||
| 183 | -// verify(this.userTransaction); | ||
| 184 | -// } | ||
| 185 | -//} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/TransactionExceptionTest.java
| @@ -1,20 +0,0 @@ | @@ -1,20 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.transaction; | ||
| 2 | - | ||
| 3 | -import java.sql.SQLException; | ||
| 4 | - | ||
| 5 | -import junit.framework.Assert; | ||
| 6 | - | ||
| 7 | -import org.junit.Test; | ||
| 8 | - | ||
| 9 | - | ||
| 10 | -public class TransactionExceptionTest { | ||
| 11 | - | ||
| 12 | - SQLException cause = new SQLException(); | ||
| 13 | - | ||
| 14 | - @Test | ||
| 15 | - public void testTransactionException() { | ||
| 16 | - TransactionException test = new TransactionException(cause); | ||
| 17 | - Assert.assertEquals("java.sql.SQLException", test.getCause().toString()); | ||
| 18 | - } | ||
| 19 | - | ||
| 20 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/util/BeansTest.java
impl/core/src/test/java/br/gov/frameworkdemoiselle/util/ResourceBundleTest.java
| @@ -44,8 +44,10 @@ import java.util.Enumeration; | @@ -44,8 +44,10 @@ import java.util.Enumeration; | ||
| 44 | import java.util.Locale; | 44 | import java.util.Locale; |
| 45 | 45 | ||
| 46 | import org.junit.Before; | 46 | import org.junit.Before; |
| 47 | +import org.junit.Ignore; | ||
| 47 | import org.junit.Test; | 48 | import org.junit.Test; |
| 48 | 49 | ||
| 50 | +@Ignore | ||
| 49 | public class ResourceBundleTest { | 51 | public class ResourceBundleTest { |
| 50 | 52 | ||
| 51 | /** | 53 | /** |
impl/core/src/test/java/br/gov/frameworkdemoiselle/util/StringsTest.java
| @@ -36,11 +36,11 @@ | @@ -36,11 +36,11 @@ | ||
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | package br.gov.frameworkdemoiselle.util; | 38 | package br.gov.frameworkdemoiselle.util; |
| 39 | + | ||
| 39 | import static org.junit.Assert.assertEquals; | 40 | import static org.junit.Assert.assertEquals; |
| 40 | import static org.junit.Assert.assertFalse; | 41 | import static org.junit.Assert.assertFalse; |
| 41 | import static org.junit.Assert.assertNull; | 42 | import static org.junit.Assert.assertNull; |
| 42 | import static org.junit.Assert.assertTrue; | 43 | import static org.junit.Assert.assertTrue; |
| 43 | -import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
| 44 | 44 | ||
| 45 | import org.junit.Test; | 45 | import org.junit.Test; |
| 46 | 46 | ||
| @@ -141,10 +141,7 @@ public class StringsTest { | @@ -141,10 +141,7 @@ public class StringsTest { | ||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | String result = Strings.toString(new Test()); | 143 | String result = Strings.toString(new Test()); |
| 144 | - | ||
| 145 | assertTrue(result.contains("Test [name=myName, lastname=myLastname, nullField=null, this")); | 144 | assertTrue(result.contains("Test [name=myName, lastname=myLastname, nullField=null, this")); |
| 146 | - | ||
| 147 | - verifyAll(); | ||
| 148 | } | 145 | } |
| 149 | 146 | ||
| 150 | private void testEqualsGetString(String in, String expected, Object... params) { | 147 | private void testEqualsGetString(String in, String expected, Object... params) { |
| @@ -0,0 +1,46 @@ | @@ -0,0 +1,46 @@ | ||
| 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 | +<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 38 | + xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> | ||
| 39 | + | ||
| 40 | + <!-- | ||
| 41 | + <engine> | ||
| 42 | + <property name="deploymentExportPath">target/arquillian</property> | ||
| 43 | + </engine> | ||
| 44 | + --> | ||
| 45 | + | ||
| 46 | +</arquillian> | ||
| 0 | \ No newline at end of file | 47 | \ No newline at end of file |
impl/core/src/test/resources/configuration-with-array.properties
| @@ -1,50 +0,0 @@ | @@ -1,50 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -integer.array = 2147483647, 10993, 12330, 129399 | ||
| 37 | -short.array = 32767, 123, 5512, 4212 | ||
| 38 | -byte.array = 127, 12, 51, 123, 11, 5, 1, -12 | ||
| 39 | -boolean.array = true, false | ||
| 40 | -long.array = 9223372036854775807, 0901920390123, 1235234523, 134230094, 66123413423 | ||
| 41 | -float.array = 3.4028235E38, 34.244, 2412.423444, 513.234, 10000.000 | ||
| 42 | -double.array = 1.7976931348623157E308, 1231234.00120349192348123, 1234123512341.9134828348238 | ||
| 43 | -big.decimal.array = 16578.69899, 48787.548877788, 4487787.559 | ||
| 44 | -big.integer.array = 1998987987897, 89789498171, 21474836475 | ||
| 45 | -calendar.array = 2012-06-14 10:10:00, 2012-07-14 10:10:00, 2012-06-15 18:10:00 | ||
| 46 | -date.array = 2012-08-14 18:10:50, 2012-07-14 10:10:00, 2012-06-15 18:10:00 | ||
| 47 | -color.array = #808080, #cccccc, #ABCCCC | ||
| 48 | -locale.array = en, pt_br, ca | ||
| 49 | -url.array = http://www.test.com, https://test.of.test.com, ftp://192.168.0.1 | ||
| 50 | -string.array = Test, One, Two |
impl/core/src/test/resources/configuration-with-array.xml
| @@ -1,143 +0,0 @@ | @@ -1,143 +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 | -<configuration> | ||
| 38 | - | ||
| 39 | - <integer> | ||
| 40 | - <array>2147483647</array> | ||
| 41 | - <array>10993</array> | ||
| 42 | - <array>12330</array> | ||
| 43 | - <array>129399</array> | ||
| 44 | - </integer> | ||
| 45 | - | ||
| 46 | - <short> | ||
| 47 | - <array>32767</array> | ||
| 48 | - <array>123</array> | ||
| 49 | - <array>5512</array> | ||
| 50 | - <array>4212</array> | ||
| 51 | - </short> | ||
| 52 | - | ||
| 53 | - <byte> | ||
| 54 | - <array>127</array> | ||
| 55 | - <array>12</array> | ||
| 56 | - <array>51</array> | ||
| 57 | - <array>123</array> | ||
| 58 | - <array>11</array> | ||
| 59 | - <array>5</array> | ||
| 60 | - <array>1</array> | ||
| 61 | - <array>-12</array> | ||
| 62 | - </byte> | ||
| 63 | - | ||
| 64 | - <boolean> | ||
| 65 | - <array>true</array> | ||
| 66 | - <array>false</array> | ||
| 67 | - </boolean> | ||
| 68 | - | ||
| 69 | - <long> | ||
| 70 | - <array>9223372036854775807</array> | ||
| 71 | - <array>0901920390123</array> | ||
| 72 | - <array>1235234523</array> | ||
| 73 | - <array>134230094</array> | ||
| 74 | - <array>66123413423</array> | ||
| 75 | - </long> | ||
| 76 | - | ||
| 77 | - <float> | ||
| 78 | - <array>3.4028235E38</array> | ||
| 79 | - <array>34.244</array> | ||
| 80 | - <array>2412.423444</array> | ||
| 81 | - <array>513.234</array> | ||
| 82 | - <array>10000.000</array> | ||
| 83 | - </float> | ||
| 84 | - | ||
| 85 | - <double> | ||
| 86 | - <array>1.7976931348623157E308</array> | ||
| 87 | - <array>1231234.00120349192348123</array> | ||
| 88 | - <array>1234123512341.9134828348238</array> | ||
| 89 | - </double> | ||
| 90 | - | ||
| 91 | - <big> | ||
| 92 | - <decimal> | ||
| 93 | - <array>16578.69899</array> | ||
| 94 | - <array>48787.548877788</array> | ||
| 95 | - <array>4487787.559</array> | ||
| 96 | - </decimal> | ||
| 97 | - </big> | ||
| 98 | - | ||
| 99 | - <big> | ||
| 100 | - <integer> | ||
| 101 | - <array>1998987987897</array> | ||
| 102 | - <array>89789498171</array> | ||
| 103 | - <array>21474836475</array> | ||
| 104 | - </integer> | ||
| 105 | - </big> | ||
| 106 | - | ||
| 107 | - <calendar> | ||
| 108 | - <array>2012-06-14 10:10:00</array> | ||
| 109 | - <array>2012-07-14 10:10:00</array> | ||
| 110 | - <array>2012-06-15 18:10:00</array> | ||
| 111 | - </calendar> | ||
| 112 | - | ||
| 113 | - <date> | ||
| 114 | - <array>2012-08-14 18:10:50</array> | ||
| 115 | - <array>2012-07-14 10:10:00</array> | ||
| 116 | - <array>2012-06-15 18:10:00</array> | ||
| 117 | - </date> | ||
| 118 | - | ||
| 119 | - <color> | ||
| 120 | - <array>#808080</array> | ||
| 121 | - <array>#cccccc</array> | ||
| 122 | - <array> #ABCCCC</array> | ||
| 123 | - </color> | ||
| 124 | - | ||
| 125 | - <locale> | ||
| 126 | - <array>en</array> | ||
| 127 | - <array>pt_br</array> | ||
| 128 | - <array>ca</array> | ||
| 129 | - </locale> | ||
| 130 | - | ||
| 131 | - <url> | ||
| 132 | - <array>http://www.test.com</array> | ||
| 133 | - <array>https://test.of.test.com</array> | ||
| 134 | - <array>ftp://192.168.0.1</array> | ||
| 135 | - </url> | ||
| 136 | - | ||
| 137 | - <string> | ||
| 138 | - <array>Test</array> | ||
| 139 | - <array>One</array> | ||
| 140 | - <array>Two</array> | ||
| 141 | - </string> | ||
| 142 | - | ||
| 143 | -</configuration> | ||
| 144 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/configuration-with-list.properties
| @@ -1,50 +0,0 @@ | @@ -1,50 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -integer.list = 2147483647, 10993, 12330, 129399 | ||
| 37 | -short.list = 32767, 123, 5512, 4212 | ||
| 38 | -byte.list = 127, 12, 51, 123, 11, 5, 1, -12 | ||
| 39 | -boolean.list = true, false | ||
| 40 | -long.list = 9223372036854775807, 0901920390123, 1235234523, 134230094, 66123413423 | ||
| 41 | -float.list = 3.4028235E38, 34.244, 2412.423444, 513.234, 10000.000 | ||
| 42 | -double.list = 1.7976931348623157E308, 1231234.00120349192348123, 1234123512341.9134828348238 | ||
| 43 | -big.decimal.list = 16578.69899, 48787.548877788, 4487787.559 | ||
| 44 | -big.integer.list = 1998987987897, 89789498171, 21474836475 | ||
| 45 | -calendar.list = 2012-06-14 10:10:00, 2012-07-14 10:10:00, 2012-06-15 18:10:00 | ||
| 46 | -date.list = 2012-08-14 18:10:50, 2012-07-14 10:10:00, 2012-06-15 18:10:00 | ||
| 47 | -color.list = #808080, #cccccc, #ABCCCC | ||
| 48 | -locale.list = en, pt_br, ca | ||
| 49 | -url.list = http://www.test.com, https://test.of.test.com, ftp://192.168.0.1 | ||
| 50 | -string.list = Test, One, Two |
impl/core/src/test/resources/configuration-with-list.xml
| @@ -1,144 +0,0 @@ | @@ -1,144 +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 | -<configuration> | ||
| 39 | - | ||
| 40 | - <integer> | ||
| 41 | - <list>2147483647</list> | ||
| 42 | - <list>10993</list> | ||
| 43 | - <list>12330</list> | ||
| 44 | - <list>129399</list> | ||
| 45 | - </integer> | ||
| 46 | - | ||
| 47 | - <short> | ||
| 48 | - <list>32767</list> | ||
| 49 | - <list>123</list> | ||
| 50 | - <list>5512</list> | ||
| 51 | - <list>4212</list> | ||
| 52 | - </short> | ||
| 53 | - | ||
| 54 | - <byte> | ||
| 55 | - <list>127</list> | ||
| 56 | - <list>12</list> | ||
| 57 | - <list>51</list> | ||
| 58 | - <list>123</list> | ||
| 59 | - <list>11</list> | ||
| 60 | - <list>5</list> | ||
| 61 | - <list>1</list> | ||
| 62 | - <list>-12</list> | ||
| 63 | - </byte> | ||
| 64 | - | ||
| 65 | - <boolean> | ||
| 66 | - <list>true</list> | ||
| 67 | - <list>false</list> | ||
| 68 | - </boolean> | ||
| 69 | - | ||
| 70 | - <long> | ||
| 71 | - <list>9223372036854775807</list> | ||
| 72 | - <list>0901920390123</list> | ||
| 73 | - <list>1235234523</list> | ||
| 74 | - <list>134230094</list> | ||
| 75 | - <list>66123413423</list> | ||
| 76 | - </long> | ||
| 77 | - | ||
| 78 | - <float> | ||
| 79 | - <list>3.4028235E38</list> | ||
| 80 | - <list>34.244</list> | ||
| 81 | - <list>2412.423444</list> | ||
| 82 | - <list>513.234</list> | ||
| 83 | - <list>10000.000</list> | ||
| 84 | - </float> | ||
| 85 | - | ||
| 86 | - <double> | ||
| 87 | - <list>1.7976931348623157E308</list> | ||
| 88 | - <list>1231234.00120349192348123</list> | ||
| 89 | - <list>1234123512341.9134828348238</list> | ||
| 90 | - </double> | ||
| 91 | - | ||
| 92 | - <big> | ||
| 93 | - <decimal> | ||
| 94 | - <list>16578.69899</list> | ||
| 95 | - <list>48787.548877788</list> | ||
| 96 | - <list>4487787.559</list> | ||
| 97 | - </decimal> | ||
| 98 | - </big> | ||
| 99 | - | ||
| 100 | - <big> | ||
| 101 | - <integer> | ||
| 102 | - <list>1998987987897</list> | ||
| 103 | - <list>89789498171</list> | ||
| 104 | - <list>21474836475</list> | ||
| 105 | - </integer> | ||
| 106 | - </big> | ||
| 107 | - | ||
| 108 | - <calendar> | ||
| 109 | - <list>2012-06-14 10:10:00</list> | ||
| 110 | - <list>2012-07-14 10:10:00</list> | ||
| 111 | - <list>2012-06-15 18:10:00</list> | ||
| 112 | - </calendar> | ||
| 113 | - | ||
| 114 | - <date> | ||
| 115 | - <list>2012-08-14 18:10:50</list> | ||
| 116 | - <list>2012-07-14 10:10:00</list> | ||
| 117 | - <list>2012-06-15 18:10:00</list> | ||
| 118 | - </date> | ||
| 119 | - | ||
| 120 | - <color> | ||
| 121 | - <list>#808080</list> | ||
| 122 | - <list>#cccccc</list> | ||
| 123 | - <list> #ABCCCC</list> | ||
| 124 | - </color> | ||
| 125 | - | ||
| 126 | - <locale> | ||
| 127 | - <list>en</list> | ||
| 128 | - <list>pt_br</list> | ||
| 129 | - <list>ca</list> | ||
| 130 | - </locale> | ||
| 131 | - | ||
| 132 | - <url> | ||
| 133 | - <list>http://www.test.com</list> | ||
| 134 | - <list>https://test.of.test.com</list> | ||
| 135 | - <list>ftp://192.168.0.1</list> | ||
| 136 | - </url> | ||
| 137 | - | ||
| 138 | - <string> | ||
| 139 | - <list>Test</list> | ||
| 140 | - <list>One</list> | ||
| 141 | - <list>Two</list> | ||
| 142 | - </string> | ||
| 143 | - | ||
| 144 | -</configuration> | ||
| 145 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/configuration.properties
| @@ -1,50 +0,0 @@ | @@ -1,50 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -key=value | ||
| 37 | - | ||
| 38 | -framework.stringValue=value | ||
| 39 | -framework.integerValue=10 | ||
| 40 | -framework.intValue=10 | ||
| 41 | -framework.listValue=value1, value2, value3 | ||
| 42 | - | ||
| 43 | -prefix.key1 = value1 | ||
| 44 | -prefix.key2 = value2 | ||
| 45 | -prefix.key3 = value3 | ||
| 46 | - | ||
| 47 | -interpolation = interx | ||
| 48 | - | ||
| 49 | -#get from var.${interpolation}-${interpolation}.prop | ||
| 50 | -var.interx-interx.prop = value |
impl/core/src/test/resources/configuration.xml
| @@ -1,46 +0,0 @@ | @@ -1,46 +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 | -<configuration> | ||
| 38 | - <framework> | ||
| 39 | - <stringValue>value</stringValue> | ||
| 40 | - <integerValue>10</integerValue> | ||
| 41 | - <intValue>10</intValue> | ||
| 42 | - <listValue>value1</listValue> | ||
| 43 | - <listValue>value2</listValue> | ||
| 44 | - <listValue>value3</listValue> | ||
| 45 | - </framework> | ||
| 46 | -</configuration> | ||
| 47 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/configuration/fields/basic/demoiselle.properties
0 → 100644
impl/core/src/test/resources/configuration2.properties
| @@ -1,36 +0,0 @@ | @@ -1,36 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -key2=value2 | ||
| 37 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/demoiselle-core-bundle.properties
| @@ -1,95 +0,0 @@ | @@ -1,95 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -engine-on=Ligando os motores do Demoiselle ${project.version} | ||
| 37 | -more-than-one-exceptionhandler-defined-for-same-class=Foi definido mais de um m\u00E9todo na classe {0} para tratar a exce\u00E7\u00E3o {1} | ||
| 38 | -handling-exception=Tratando a exce\u00E7\u00E3o {0} | ||
| 39 | -proxy-detected=Detectado o proxy {0} da classe {1} | ||
| 40 | -ambiguous-key=Existe mais de uma chave declarada no arquivo de configura\u00E7\u00E3o para o campo {0} da classe {1}. Indique qual a chave correta utilizando a anota\u00E7\u00E3o Name | ||
| 41 | -taking-off=O Demoiselle ${project.version} decolou | ||
| 42 | -engine-off=Desligando os motores do Demoiselle ${project.version} | ||
| 43 | -setting-up-bean-manager=BeanManager dispon\u00EDvel atrav\u00E9s do utilit\u00E1rio {0} | ||
| 44 | - | ||
| 45 | -user-transaction-lookup-fail=N\u00E3o foi encontrada nenhuma transa\u00E7\u00E3o com o nome {0} no contexto JNDI | ||
| 46 | -transactional-execution=Execu\u00E7\u00E3o transacional de {0} | ||
| 47 | -begin-transaction=Transa\u00E7\u00E3o iniciada | ||
| 48 | -transaction-marked-rollback=Transa\u00E7\u00E3o marcada para rollback [{0}] | ||
| 49 | -transaction-already-finalized=A transa\u00E7\u00E3o j\u00E1 havia sido finalizada | ||
| 50 | -transaction-commited=Transa\u00E7\u00E3o finalizada com sucesso | ||
| 51 | -transaction-rolledback=Transa\u00E7\u00E3o finalizada com rollback | ||
| 52 | - | ||
| 53 | -bootstrap.configuration.processing=Processando {0} | ||
| 54 | - | ||
| 55 | -loading-configuration-class=Carregando a classe de configura\u00E7\u00E3o {0} | ||
| 56 | -configuration-field-loaded=Configura\u00E7\u00E3o {0} atribu\u00EDda \u00E0 {1} com o valor {2} | ||
| 57 | -configuration-attribute-is-mandatory=A configura\u00E7\u00E3o {0} \u00E9 obrigat\u00F3ria, mas n\u00E3o foi encontrada em {1} | ||
| 58 | -configuration-name-attribute-cant-be-empty=A nota\u00E7\u00E3o Name n\u00E3o pode estar em branco | ||
| 59 | -configuration-key-not-found=Chave de configura\u00E7\u00E3o "{0}" n\u00E3o encontrada. Conven\u00E7\u00F5es verificadas\: "{1}" | ||
| 60 | - | ||
| 61 | -transaction-not-defined=Nenhuma transa\u00E7\u00E3o foi definida. Para utilizar @{0} \u00E9 preciso definir a estrat\u00E9gia de transa\u00E7\u00E3o desejada no arquivo beans.xml | ||
| 62 | -executing-all=Executando todos os \: {0} | ||
| 63 | -custom-context-was-registered=O contexto {0} foi registrado | ||
| 64 | -custom-context-was-unregistered=O contexto {0} foi removido | ||
| 65 | - | ||
| 66 | -error-creating-configuration-from-resource=Error creating configuration from resource named "{0}" | ||
| 67 | -configuration-type-not-implemented-yet=Configuration type "{0}" is not implemented yet | ||
| 68 | -error-converting-to-type=Error converting to type "{0}" | ||
| 69 | -error-creating-new-instance-for=Error creating a new instance for "{0}" | ||
| 70 | -executed-successfully=\ {0} execultado com sucesso | ||
| 71 | -must-declare-one-single-parameter=Voc\u00EA deve declarar um par\u00E2metro \u00FAnico em {0} | ||
| 72 | -loading-default-transaction-manager=Carregando o gerenciador de transa\u00E7\u00E3o padr\u00E3o {0} | ||
| 73 | -transaction-class-not-found=A classe de transa\u00E7\u00E3o "{0}" informada n\u00E3o foi encontrada. | ||
| 74 | -transaction-class-must-be-of-type=A classe de transa\u00E7\u00E3o "{0}" informada deve ser do tipo {1} | ||
| 75 | -results-count-greater-page-size=Quantidade de resultados {0} \u00E9 maior que o tamanho da p\u00E1gina {1} | ||
| 76 | -page-result=Resultado paginado [p\u00E1gina\={0}, total de resultados\={1}] | ||
| 77 | -page=P\u00E1gina [n\u00FAmero\={0}, tamanho\={1}] | ||
| 78 | -processing=Processando\: {0} | ||
| 79 | -processing-fail=Falha no processamento devido a uma exce\u00E7\u00E3o lan\u00E7ada pela aplica\u00E7\u00E3o | ||
| 80 | -for= \ para\: | ||
| 81 | -file-not-found=O arquivo {0} n\u00E3o foi encontrado | ||
| 82 | - | ||
| 83 | -adding-message-to-context=Adicionando uma mensagem no contexto: [{0}] | ||
| 84 | -cleaning-message-context=Limpando o contexto de mensagens | ||
| 85 | -access-checking=Verificando permiss\u00E3o do usu\u00E1rio "{0}" para executar a a\u00E7\u00E3o "{1}" no recurso "{2}" | ||
| 86 | -access-allowed=O usu\u00E1rio "{0}" acessou o recurso "{2}" com a a\u00E7\u00E3o "{1}" | ||
| 87 | -access-denied=O usu\u00E1rio "{0}" n\u00E3o possui permiss\u00E3o para executar a a\u00E7\u00E3o "{1}" no recurso "{2}" | ||
| 88 | -access-denied-ui=Voc\u00EA n\u00E3o est\u00E1 autorizado a executar a a\u00E7\u00E3o {1} no recurso {0} | ||
| 89 | -authorizer-not-defined=Nenhuma regra de resolu\u00E7\u00E3o de permiss\u00F5es foi definida. Para utilizar @{0} \u00E9 preciso definir a estrat\u00E9gia de resolu\u00E7\u00E3o de permiss\u00F5es desejada no arquivo beans.xml | ||
| 90 | -user-not-authenticated=Usu\u00E1rio n\u00E3o autenticado | ||
| 91 | -has-role-verification=Verificando se o usu\u00E1rio {0} possui a(s) role(s)\: {1} | ||
| 92 | -does-not-have-role=Usu\u00E1rio {0} n\u00E3o possui a(s) role(s)\: {1} | ||
| 93 | -does-not-have-role-ui=Para acessar este recurso \u00E9 necess\u00E1rio ser {0} | ||
| 94 | -user-has-role=Usu\u00E1rio {0} possui a(s) role(s)\: {1} | ||
| 95 | -authenticator-not-defined=Nenhum mecanismo de autentica\u00E7\u00E3o foi definido. Para utilizar {0} \u00E9 preciso definir o mecanismo de autentica\u00E7\u00E3o desejado no arquivo beans.xml | ||
| 96 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/demoiselle-core-bundle_pt_BR.properties
| @@ -1,95 +0,0 @@ | @@ -1,95 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -engine-on=Ligando os motores do Demoiselle ${project.version} | ||
| 37 | -more-than-one-exceptionhandler-defined-for-same-class=Foi definido mais de um m\u00E9todo na classe {0} para tratar a exce\u00E7\u00E3o {1} | ||
| 38 | -handling-exception=Tratando a exce\u00E7\u00E3o {0} | ||
| 39 | -proxy-detected=Detectado o proxy {0} da classe {1} | ||
| 40 | -ambiguous-key=Existe mais de uma chave declarada no arquivo de configura\u00E7\u00E3o para o campo {0} da classe {1}. Indique qual a chave correta utilizando a anota\u00E7\u00E3o Name | ||
| 41 | -taking-off=O Demoiselle ${project.version} decolou | ||
| 42 | -engine-off=Desligando os motores do Demoiselle ${project.version} | ||
| 43 | -setting-up-bean-manager=BeanManager dispon\u00EDvel atrav\u00E9s do utilit\u00E1rio {0} | ||
| 44 | - | ||
| 45 | -user-transaction-lookup-fail=N\u00E3o foi encontrada nenhuma transa\u00E7\u00E3o com o nome {0} no contexto JNDI | ||
| 46 | -transactional-execution=Execu\u00E7\u00E3o transacional de {0} | ||
| 47 | -begin-transaction=Transa\u00E7\u00E3o inciada | ||
| 48 | -transaction-marked-rollback=Transa\u00E7\u00E3o marcada para rollback [{0}] | ||
| 49 | -transaction-already-finalized=A transa\u00E7\u00E3o j\u00E1 havia sido finalizada | ||
| 50 | -transaction-commited=Transa\u00E7\u00E3o finalizada com sucesso | ||
| 51 | -transaction-rolledback=Transa\u00E7\u00E3o finalizada com rollback | ||
| 52 | - | ||
| 53 | -bootstrap.configuration.processing=Processando {0} | ||
| 54 | - | ||
| 55 | -loading-configuration-class=Carregando a classe de configura\u00E7\u00E3o {0} | ||
| 56 | -configuration-field-loaded=Configura\u00E7\u00E3o {0} atribu\u00EDda \u00E0 {1} com o valor {2} | ||
| 57 | -configuration-attribute-is-mandatory=A configura\u00E7\u00E3o {0} \u00E9 obrigat\u00F3ria, mas n\u00E3o foi encontrada em {1} | ||
| 58 | -configuration-name-attribute-cant-be-empty=A nota\u00E7\u00E3o Name n\u00E3o pode estar em branco | ||
| 59 | -configuration-key-not-found=Chave de configura\u00E7\u00E3o "{0}" n\u00E3o encontrada. Conven\u00E7\u00F5es verificadas\: "{1}" | ||
| 60 | - | ||
| 61 | -transaction-not-defined=Nenhuma transa\u00E7\u00E3o foi definida. Para utilizar @{0} \u00E9 preciso definir a estrat\u00E9gia de transa\u00E7\u00E3o desejada no arquivo beans.xml | ||
| 62 | -executing-all=Executando todos os \: {0} | ||
| 63 | -custom-context-was-registered=O contexto {0} foi registrado | ||
| 64 | -custom-context-was-unregistered=O contexto {0} foi removido | ||
| 65 | - | ||
| 66 | -error-creating-configuration-from-resource=Error creating configuration from resource named "{0}" | ||
| 67 | -configuration-type-not-implemented-yet=Configuration type "{0}" is not implemented yet | ||
| 68 | -error-converting-to-type=Error converting to type "{0}" | ||
| 69 | -error-creating-new-instance-for=Error creating a new instance for "{0}" | ||
| 70 | -executed-successfully=\ {0} execultado com sucesso | ||
| 71 | -must-declare-one-single-parameter=Voc\u00EA deve declarar um par\u00E2metro \u00FAnico em {0} | ||
| 72 | -loading-default-transaction-manager=Carregando o gerenciador de transa\u00E7\u00E3o padr\u00E3o {0} | ||
| 73 | -transaction-class-not-found=A classe de transa\u00E7\u00E3o "{0}" informada n\u00E3o foi encontrada. | ||
| 74 | -transaction-class-must-be-of-type=A classe de transa\u00E7\u00E3o "{0}" informada deve ser do tipo {1} | ||
| 75 | -results-count-greater-page-size=Quantidade de resultados {0} \u00E9 maior que o tamanho da p\u00E1gina {1} | ||
| 76 | -page-result=Resultado paginado [p\u00E1gina\={0}, total de resultados\={1}] | ||
| 77 | -page=P\u00E1gina [n\u00FAmero\={0}, tamanho\={1}] | ||
| 78 | -processing=Processando\: {0} | ||
| 79 | -processing-fail=Falha no processamento devido a uma exce\u00E7\u00E3o lan\u00E7ada pela aplica\u00E7\u00E3o | ||
| 80 | -for= \ para\: | ||
| 81 | -file-not-found=O arquivo {0} n\u00E3o foi encontrado | ||
| 82 | - | ||
| 83 | -adding-message-to-context=Adicionando uma mensagem no contexto: [{0}] | ||
| 84 | -cleaning-message-context=Limpando o contexto de mensagens | ||
| 85 | -access-checking=Verificando permiss\u00E3o do usu\u00E1rio "{0}" para executar a a\u00E7\u00E3o "{1}" no recurso "{2}" | ||
| 86 | -access-allowed=O usu\u00E1rio "{0}" acessou o recurso "{2}" com a a\u00E7\u00E3o "{1}" | ||
| 87 | -access-denied=O usu\u00E1rio "{0}" n\u00E3o possui permiss\u00E3o para executar a a\u00E7\u00E3o "{1}" no recurso "{2}" | ||
| 88 | -access-denied-ui=Voc\u00EA n\u00E3o est\u00E1 autorizado a executar a a\u00E7\u00E3o {1} no recurso {0} | ||
| 89 | -authorizer-not-defined=Nenhuma regra de resolu\u00E7\u00E3o de permiss\u00F5es foi definida. Para utilizar @{0} \u00E9 preciso definir a estrat\u00E9gia de resolu\u00E7\u00E3o de permiss\u00F5es desejada no arquivo beans.xml | ||
| 90 | -user-not-authenticated=Usu\u00E1rio n\u00E3o autenticado | ||
| 91 | -has-role-verification=Verificando se o usu\u00E1rio {0} possui a(s) role(s)\: {1} | ||
| 92 | -does-not-have-role=Usu\u00E1rio {0} n\u00E3o possui a(s) role(s)\: {1} | ||
| 93 | -does-not-have-role-ui=Para acessar este recurso \u00E9 necess\u00E1rio ser {0} | ||
| 94 | -user-has-role=Usu\u00E1rio {0} possui a(s) role(s)\: {1} | ||
| 95 | -authenticator-not-defined=Nenhum mecanismo de autentica\u00E7\u00E3o foi definido. Para utilizar {0} \u00E9 preciso definir o mecanismo de autentica\u00E7\u00E3o desejado no arquivo beans.xml | ||
| 96 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/demoiselle.properties
| @@ -1,81 +0,0 @@ | @@ -1,81 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -frameworkdemoiselle.core.bootstrap.observed= | ||
| 37 | -frameworkdemoiselle.persistence.unit= | ||
| 38 | - | ||
| 39 | -frameworkdemoiselle.pagination.page_size=50 | ||
| 40 | -frameworkdemoiselle.pagination.max_page_links=10 | ||
| 41 | - | ||
| 42 | -br.gov.frameworkdemoiselle.success=Success | ||
| 43 | -frameworkdemoiselle.configurationtest.nameConfiguration=ConfigurationTest | ||
| 44 | -frameworkdemoiselle.configurationtest.name=ConfigurationTest2 | ||
| 45 | -nameConfiguration=ConfigurationTest | ||
| 46 | -isNameConfiguration=true | ||
| 47 | -byteConfiguration=75 | ||
| 48 | -doubleConfiguration=7.5 | ||
| 49 | -floatConfiguration=0.0f | ||
| 50 | -integerConfiguration=75 | ||
| 51 | -longConfiguration=75 | ||
| 52 | -shortConfiguration=-75 | ||
| 53 | -bigDecimalConfiguration=7.5 | ||
| 54 | -bigIntegerConfiguration=75 | ||
| 55 | -listConfiguration=azul,verde | ||
| 56 | -stringArrayConfiguration=azul,verde | ||
| 57 | -intArrayConfiguration=1,2 | ||
| 58 | -objectConfiguration=null | ||
| 59 | -propertiesConfiguration.valor1=azul | ||
| 60 | -propertiesConfiguration.valor2=verde | ||
| 61 | -fourConfiguration=quatro | ||
| 62 | -four.configuration=quatro | ||
| 63 | -four_configuration=quatro | ||
| 64 | -fourconfiguration=quatro | ||
| 65 | -threeConfiguration=três | ||
| 66 | -three.configuration=três | ||
| 67 | -three_configuration=três | ||
| 68 | -twoConfiguration=dois | ||
| 69 | -two.configuration=dois | ||
| 70 | -typeOneConfiguration=tipo um | ||
| 71 | -type.two.configuration=tipo dois | ||
| 72 | -type_three_configuration=tipo tres | ||
| 73 | -typefourconfiguration=tipo quatro | ||
| 74 | -convention_underline=Convention Underline | ||
| 75 | -convention.dot=Convention Dot | ||
| 76 | -conventionalllowercase=All LowerCase | ||
| 77 | -CONVENTIONALLUPPERCASE=ALL UPPERCASE | ||
| 78 | -complexObject=null | ||
| 79 | -properties.1=teste1 | ||
| 80 | -properties.2=teste2 | ||
| 81 | -classe=br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderTest | ||
| 82 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/demoiselle.xml
| @@ -1,52 +0,0 @@ | @@ -1,52 +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 | -<gui-definition> | ||
| 38 | - <conventionalllowercase>All LowerCase</conventionalllowercase> | ||
| 39 | - <CONVENTIONALLUPPERCASE>ALL UPPERCASE</CONVENTIONALLUPPERCASE> | ||
| 40 | - <convention_underline>Convention_Underline</convention_underline> | ||
| 41 | - <convention> | ||
| 42 | - <dot>convention.dot</dot> | ||
| 43 | - </convention> | ||
| 44 | - <nameConfiguration>ConfigurationTest</nameConfiguration> | ||
| 45 | - <br> | ||
| 46 | - <gov> | ||
| 47 | - <frameworkdemoiselle> | ||
| 48 | - <nameConfiguration>ConfigurationTest</nameConfiguration> | ||
| 49 | - </frameworkdemoiselle> | ||
| 50 | - </gov> | ||
| 51 | - </br> | ||
| 52 | -</gui-definition> | ||
| 53 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/messages.properties
| @@ -1,47 +0,0 @@ | @@ -1,47 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -teste=teste | ||
| 37 | - | ||
| 38 | -# Message test | ||
| 39 | -testGetStringMessageDefaultResourceName.message=Testando mensagens usando o resourceName padrão | ||
| 40 | - | ||
| 41 | -first-key=First message text | ||
| 42 | -second-key=Second message text | ||
| 43 | -THIRD_KEY=Third message text | ||
| 44 | -FOURTH_KEY=Fourth message text | ||
| 45 | - | ||
| 46 | -FIRST_ERROR_KEY=First error message text | ||
| 47 | -second-error-key=Second error message text | ||
| 48 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/resource-bundle_pt.properties
impl/core/src/test/resources/test-message.properties
impl/core/src/test/resources/testGetStringMessage.properties
| @@ -1,37 +0,0 @@ | @@ -1,37 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -DefaultMessageTest.s1=Rodando {0} para {1} | ||
| 37 | -DefaultMessageTest.no-locale=Usando o locale default | ||
| 38 | \ No newline at end of file | 0 | \ No newline at end of file |
impl/core/src/test/resources/testGetStringMessage_en.properties
| @@ -1,36 +0,0 @@ | @@ -1,36 +0,0 @@ | ||
| 1 | -# Demoiselle Framework | ||
| 2 | -# Copyright (C) 2010 SERPRO | ||
| 3 | -# ---------------------------------------------------------------------------- | ||
| 4 | -# This file is part of Demoiselle Framework. | ||
| 5 | -# | ||
| 6 | -# Demoiselle Framework is free software; you can redistribute it and/or | ||
| 7 | -# modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 8 | -# as published by the Free Software Foundation. | ||
| 9 | -# | ||
| 10 | -# This program is distributed in the hope that it will be useful, | ||
| 11 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | -# GNU General Public License for more details. | ||
| 14 | -# | ||
| 15 | -# You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 16 | -# along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 17 | -# or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 18 | -# Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 19 | -# ---------------------------------------------------------------------------- | ||
| 20 | -# Este arquivo é parte do Framework Demoiselle. | ||
| 21 | -# | ||
| 22 | -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 23 | -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 24 | -# do Software Livre (FSF). | ||
| 25 | -# | ||
| 26 | -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 27 | -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 28 | -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 29 | -# para maiores detalhes. | ||
| 30 | -# | ||
| 31 | -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 32 | -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 33 | -# ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 34 | -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 35 | - | ||
| 36 | -DefaultMessageTest.s1=Running {0} for {1} | ||
| 37 | \ No newline at end of file | 0 | \ No newline at end of file |