From b9a3c893c3818aa6e6b51d9e2950588740efa7c7 Mon Sep 17 00:00:00 2001 From: Cleverson Sacramento Date: Fri, 22 Mar 2013 10:13:00 -0300 Subject: [PATCH] Inclusão das dependências com o Arquillian para substituição dos testes --- impl/core/pom.xml | 35 ++++++++++++++++++++++++++++------- impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java | 15 ++++++++++++++- impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationImpl.java | 2 ++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/AbstractConfigurationTest.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/AbstractBasicFieldsConfig.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/ConfigurationBasicFieldsTest.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/PropertiesBasicFieldsConfig.java | 8 ++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/SystemBasicFieldsConfig.java | 9 +++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/XMLBasicFieldsConfig.java | 9 +++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrapTest.java | 165 --------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrapTest.java | 8 -------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/MyStartupAnnotatedClass.java | 70 ---------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrapTest.java | 200 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrapTest.java | 262 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassExtendsFromClassThanImplementsTransactionInterface.java | 44 -------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassImplementsTransactionInterface.java | 80 -------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassThanImplementsInterfaceThanExtendsFromTransactionInterface.java | 79 ------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java | 523 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java | 545 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java | 546 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/InterfaceExtendsFromTransactionInterface.java | 44 -------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfigTest.java | 63 --------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java | 49 ------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/TransactionConfigTest.java | 23 ----------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextStoreTest.java | 89 ----------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextsTest.java | 221 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalContextTest.java | 231 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java | 65 ----------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java | 55 ------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java | 110 -------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImplTest.java | 254 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationContextImplTest.java | 131 ----------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationImplTest.java | 322 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImplTest.java | 393 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionContextImplTest.java | 124 ---------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfoTest.java | 85 ------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptorTest.java | 341 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredPermissionInterceptorTest.java | 407 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredRoleInterceptorTest.java | 296 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptorTest.java | 202 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LocaleProducer.java | 15 +++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducerTest.java | 91 ------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ResourceBundleProducerTest.java | 133 ------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxyTest.java | 628 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/message/DefaultMessageTest.java | 296 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/template/DelegateCrudTest.java | 205 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.java | 185 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/TransactionExceptionTest.java | 20 -------------------- impl/core/src/test/java/br/gov/frameworkdemoiselle/util/BeansTest.java | 1 + impl/core/src/test/java/br/gov/frameworkdemoiselle/util/ResourceBundleTest.java | 2 ++ impl/core/src/test/java/br/gov/frameworkdemoiselle/util/StringsTest.java | 5 +---- impl/core/src/test/resources/arquillian.xml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration-with-array.properties | 50 -------------------------------------------------- impl/core/src/test/resources/configuration-with-array.xml | 143 ----------------------------------------------------------------------------------------------------------------------------------------------- impl/core/src/test/resources/configuration-with-list.properties | 50 -------------------------------------------------- impl/core/src/test/resources/configuration-with-list.xml | 144 ------------------------------------------------------------------------------------------------------------------------------------------------ impl/core/src/test/resources/configuration.properties | 50 -------------------------------------------------- impl/core/src/test/resources/configuration.xml | 46 ---------------------------------------------- impl/core/src/test/resources/configuration/fields/basic/demoiselle.properties | 4 ++++ impl/core/src/test/resources/configuration2.properties | 36 ------------------------------------ impl/core/src/test/resources/demoiselle-core-bundle.properties | 95 ----------------------------------------------------------------------------------------------- impl/core/src/test/resources/demoiselle-core-bundle_pt_BR.properties | 95 ----------------------------------------------------------------------------------------------- impl/core/src/test/resources/demoiselle.properties | 81 --------------------------------------------------------------------------------- impl/core/src/test/resources/demoiselle.xml | 52 ---------------------------------------------------- impl/core/src/test/resources/messages.properties | 47 ----------------------------------------------- impl/core/src/test/resources/resource-bundle_pt.properties | 2 -- impl/core/src/test/resources/test-message.properties | 6 ------ impl/core/src/test/resources/testGetStringMessage.properties | 37 ------------------------------------- impl/core/src/test/resources/testGetStringMessage_en.properties | 36 ------------------------------------ 69 files changed, 289 insertions(+), 8567 deletions(-) create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/AbstractConfigurationTest.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/AbstractBasicFieldsConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/ConfigurationBasicFieldsTest.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/PropertiesBasicFieldsConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/SystemBasicFieldsConfig.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/XMLBasicFieldsConfig.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrapTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrapTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/MyStartupAnnotatedClass.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrapTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrapTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassExtendsFromClassThanImplementsTransactionInterface.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassImplementsTransactionInterface.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassThanImplementsInterfaceThanExtendsFromTransactionInterface.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/InterfaceExtendsFromTransactionInterface.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfigTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/TransactionConfigTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextStoreTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextsTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalContextTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImplTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationContextImplTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationImplTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImplTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionContextImplTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfoTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptorTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredPermissionInterceptorTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredRoleInterceptorTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptorTest.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LocaleProducer.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducerTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ResourceBundleProducerTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxyTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/message/DefaultMessageTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/template/DelegateCrudTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.java delete mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/TransactionExceptionTest.java create mode 100644 impl/core/src/test/resources/arquillian.xml delete mode 100644 impl/core/src/test/resources/configuration-with-array.properties delete mode 100644 impl/core/src/test/resources/configuration-with-array.xml delete mode 100644 impl/core/src/test/resources/configuration-with-list.properties delete mode 100644 impl/core/src/test/resources/configuration-with-list.xml delete mode 100644 impl/core/src/test/resources/configuration.properties delete mode 100644 impl/core/src/test/resources/configuration.xml create mode 100644 impl/core/src/test/resources/configuration/fields/basic/demoiselle.properties delete mode 100644 impl/core/src/test/resources/configuration2.properties delete mode 100644 impl/core/src/test/resources/demoiselle-core-bundle.properties delete mode 100644 impl/core/src/test/resources/demoiselle-core-bundle_pt_BR.properties delete mode 100644 impl/core/src/test/resources/demoiselle.properties delete mode 100644 impl/core/src/test/resources/demoiselle.xml delete mode 100644 impl/core/src/test/resources/messages.properties delete mode 100644 impl/core/src/test/resources/resource-bundle_pt.properties delete mode 100644 impl/core/src/test/resources/test-message.properties delete mode 100644 impl/core/src/test/resources/testGetStringMessage.properties delete mode 100644 impl/core/src/test/resources/testGetStringMessage_en.properties diff --git a/impl/core/pom.xml b/impl/core/pom.xml index 47a3d4f..bb5feaf 100755 --- a/impl/core/pom.xml +++ b/impl/core/pom.xml @@ -34,7 +34,8 @@ ou escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. --> - + 4.0.0 @@ -76,6 +77,15 @@ import pom + @@ -152,25 +162,30 @@ test - org.easymock - easymock + org.jboss.arquillian.junit + arquillian-junit-container + ${arquillian.version} test - org.powermock - powermock-module-junit4 + org.jboss.arquillian.container + arquillian-weld-se-embedded-1.1 + ${arquillian.weld.se.embedded.version} test - org.powermock - powermock-api-easymock + org.jboss.weld.se + weld-se-core + ${weld.se.version} test + org.slf4j slf4j-log4j12 @@ -202,4 +217,10 @@ + + + 1.0.3.Final + 1.0.0.CR6 + 1.1.8.Final + diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java index 216679c..8b9c512 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java @@ -37,6 +37,7 @@ package br.gov.frameworkdemoiselle.internal.bootstrap; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -47,6 +48,7 @@ import javassist.CtClass; import javassist.CtMethod; import javassist.CtNewMethod; import javassist.LoaderClassPath; +import javassist.NotFoundException; import javax.enterprise.event.Observes; import javax.enterprise.inject.spi.AfterBeanDiscovery; @@ -83,6 +85,17 @@ public class ConfigurationBootstrap implements Extension { } } + private static List getMethods(CtClass type) throws NotFoundException { + List fields = new ArrayList(); + + if (type != null && !type.getName().equals(Object.class.getName())) { + fields.addAll(Arrays.asList(type.getDeclaredMethods())); + fields.addAll(getMethods(type.getSuperclass())); + } + + return fields; + } + @SuppressWarnings("unchecked") private Class createProxy(Class type) throws Exception { String superClassName = type.getCanonicalName(); @@ -112,7 +125,7 @@ public class ConfigurationBootstrap implements Extension { ctChieldClass.setSuperclass(ctSuperClass); CtMethod ctChieldMethod; - for (CtMethod ctSuperMethod : ctSuperClass.getDeclaredMethods()) { + for (CtMethod ctSuperMethod : getMethods(ctSuperClass)) { ctChieldMethod = CtNewMethod.delegator(ctSuperMethod, ctChieldClass); ctChieldMethod.insertBefore("load(this);"); diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationImpl.java index 4c96204..b1b06d6 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationImpl.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationImpl.java @@ -2,6 +2,7 @@ package br.gov.frameworkdemoiselle.internal.implementation; import java.io.Serializable; +import br.gov.frameworkdemoiselle.annotation.Ignore; import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; import br.gov.frameworkdemoiselle.util.Beans; @@ -9,6 +10,7 @@ public class ConfigurationImpl implements Serializable { private static final long serialVersionUID = 1L; + @Ignore private boolean loaded = false; @SuppressWarnings("unused") diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/AbstractConfigurationTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/AbstractConfigurationTest.java new file mode 100644 index 0000000..abf530a --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/AbstractConfigurationTest.java @@ -0,0 +1,53 @@ +package br.gov.frameworkdemoiselle.configuration; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.asset.FileAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; + +import br.gov.frameworkdemoiselle.annotation.Ignore; +import br.gov.frameworkdemoiselle.annotation.Name; +import br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap; +import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; +import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; +import br.gov.frameworkdemoiselle.internal.producer.LocaleProducer; +import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; +import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; +import br.gov.frameworkdemoiselle.util.Beans; + +public abstract class AbstractConfigurationTest { + + protected static Class[] getConfigurationClasses() { + List> result = new ArrayList>(); + + result.add(Ignore.class); + result.add(Name.class); + result.add(Configuration.class); + result.add(CoreBootstrap.class); + result.add(ConfigurationBootstrap.class); + result.add(ConfigurationLoader.class); + result.add(Beans.class); + result.add(ResourceBundleProducer.class); + result.add(LoggerProducer.class); + result.add(LocaleProducer.class); + + return result.toArray(new Class[0]); + } + + public static JavaArchive createConfigurationDeployment() { + return ShrinkWrap + .create(JavaArchive.class) + .addClasses(getConfigurationClasses()) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") + .addAsResource( + new FileAsset(new File("src/test/resources/configuration/fields/basic/demoiselle.properties")), + "demoiselle.properties") + .addAsManifestResource( + new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), + "services/javax.enterprise.inject.spi.Extension"); + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/AbstractBasicFieldsConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/AbstractBasicFieldsConfig.java new file mode 100644 index 0000000..83665d5 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/AbstractBasicFieldsConfig.java @@ -0,0 +1,44 @@ +package br.gov.frameworkdemoiselle.configuration.fields.basic; + +public abstract class AbstractBasicFieldsConfig { + + private int primitiveInteger; + + private Integer wrappedInteger; + + private String stringWithSpace; + + private String stringWithComma; + + public Integer getWrappedInteger() { + return wrappedInteger; + } + + public void setWrappedInteger(Integer wrappedInteger) { + this.wrappedInteger = wrappedInteger; + } + + public int getPrimitiveInteger() { + return primitiveInteger; + } + + public void setPrimitiveInteger(int primitiveInteger) { + this.primitiveInteger = primitiveInteger; + } + + public String getStringWithSpace() { + return stringWithSpace; + } + + public void setStringWithSpace(String stringWithSpace) { + this.stringWithSpace = stringWithSpace; + } + + public String getStringWithComma() { + return stringWithComma; + } + + public void setStringWithComma(String stringWithComma) { + this.stringWithComma = stringWithComma; + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/ConfigurationBasicFieldsTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/ConfigurationBasicFieldsTest.java new file mode 100644 index 0000000..179389e --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/ConfigurationBasicFieldsTest.java @@ -0,0 +1,53 @@ +package br.gov.frameworkdemoiselle.configuration.fields.basic; + +import static junit.framework.Assert.assertEquals; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; + +@RunWith(Arquillian.class) +public class ConfigurationBasicFieldsTest extends AbstractConfigurationTest { + + @Inject + private PropertiesBasicFieldsConfig propertiesConfig; + + @Deployment + public static JavaArchive createDeployment() { + return createConfigurationDeployment().addPackages(true, ConfigurationBasicFieldsTest.class.getPackage()); + } + + @Test + public void loadPrimitiveInteger() { + int expected = 1; + + assertEquals(expected, propertiesConfig.getPrimitiveInteger()); + } + + @Test + public void loadWrappedInteger() { + Integer expected = 2; + + assertEquals(expected, propertiesConfig.getWrappedInteger()); + } + + @Test + public void loadStringWithSpace() { + String expected = "demoiselle framework"; + + assertEquals(expected, propertiesConfig.getStringWithSpace()); + } + +// @Test + public void loadStringWithComma() { + String expected = "demoiselle,framework"; + + assertEquals(expected, propertiesConfig.getStringWithComma()); + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/PropertiesBasicFieldsConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/PropertiesBasicFieldsConfig.java new file mode 100644 index 0000000..17f79c3 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/PropertiesBasicFieldsConfig.java @@ -0,0 +1,8 @@ +package br.gov.frameworkdemoiselle.configuration.fields.basic; + +import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(type = PROPERTIES) +public class PropertiesBasicFieldsConfig extends AbstractBasicFieldsConfig { +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/SystemBasicFieldsConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/SystemBasicFieldsConfig.java new file mode 100644 index 0000000..8fa8241 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/SystemBasicFieldsConfig.java @@ -0,0 +1,9 @@ +package br.gov.frameworkdemoiselle.configuration.fields.basic; + +import static br.gov.frameworkdemoiselle.configuration.ConfigType.SYSTEM; +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(type = SYSTEM) +public class SystemBasicFieldsConfig extends AbstractBasicFieldsConfig { + +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/XMLBasicFieldsConfig.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/XMLBasicFieldsConfig.java new file mode 100644 index 0000000..12a2de7 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/XMLBasicFieldsConfig.java @@ -0,0 +1,9 @@ +package br.gov.frameworkdemoiselle.configuration.fields.basic; + +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; +import br.gov.frameworkdemoiselle.configuration.Configuration; + +@Configuration(type = XML) +public class XMLBasicFieldsConfig extends AbstractBasicFieldsConfig { + +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrapTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrapTest.java deleted file mode 100644 index 5b304ec..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrapTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.bootstrap; - -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.powermock.api.easymock.PowerMock.replayAll; -import static org.powermock.api.easymock.PowerMock.verifyAll; - -import java.lang.reflect.Field; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.enterprise.context.ConversationScoped; -import javax.enterprise.context.RequestScoped; -import javax.enterprise.context.SessionScoped; -import javax.enterprise.inject.spi.AnnotatedMethod; -import javax.enterprise.inject.spi.AnnotatedType; -import javax.enterprise.inject.spi.BeanManager; -import javax.enterprise.inject.spi.ProcessAnnotatedType; - -import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; - -import br.gov.frameworkdemoiselle.annotation.ViewScoped; -import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; -import br.gov.frameworkdemoiselle.internal.context.Contexts; -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; -import br.gov.frameworkdemoiselle.internal.implementation.AnnotatedMethodProcessor; -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; -import br.gov.frameworkdemoiselle.lifecycle.Startup; - -@RunWith(PowerMockRunner.class) -@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) -public class AbstractLifecycleBootstrapTest { - - private ProcessAnnotatedType event; - - private BeanManager beanManager; - - private AnnotatedType annotatedType; - - private StartupBootstrap startupBootstrap; - - private ShutdownBootstrap shutdownBootstrap; - - private Class annotationClass; - - @Before - public void before() { - event = createMock(ProcessAnnotatedType.class); - annotatedType = createMock(AnnotatedType.class); - beanManager = null; - annotationClass = null; - } - - private List getActions(AbstractLifecycleBootstrap bootstrap) - throws IllegalArgumentException, IllegalAccessException { - - Field fields = Whitebox.getField(AbstractLifecycleBootstrap.class, "processors"); - List list = (List) fields.get(bootstrap); - return list; - } - - @Test - public void processAnnotatedTypeStartup() throws IllegalArgumentException, IllegalAccessException { - startupBootstrap = new StartupBootstrap(); - List list = getActions(startupBootstrap); - - assertNotNull(list); - assertTrue(list.isEmpty()); - - AnnotatedMethod am1 = createMock(AnnotatedMethod.class); - AnnotatedMethod am2 = createMock(AnnotatedMethod.class); - AnnotatedMethod am3 = createMock(AnnotatedMethod.class); - - Set set = new HashSet(); - set.add(am1); - set.add(am2); - set.add(am3); - - expect(am1.isAnnotationPresent(Startup.class)).andReturn(true); - expect(am2.isAnnotationPresent(Startup.class)).andReturn(true); - expect(am3.isAnnotationPresent(Startup.class)).andReturn(false); - expect(event.getAnnotatedType()).andReturn(annotatedType); - expect(annotatedType.getMethods()).andReturn(set); - - EasyMock.replay(event, annotatedType, am1, am2, am3); - startupBootstrap.processAnnotatedType(event); - EasyMock.verify(event, annotatedType); - - list = getActions(startupBootstrap); - assertNotNull(list); - assertFalse(list.isEmpty()); - assertTrue(list.size() == 2); - } - - @Test - public void testLoadTempContexts() { - startupBootstrap = new StartupBootstrap(); - - List tempContexts = Whitebox.getInternalState(startupBootstrap, "tempContexts"); - - assertNotNull(tempContexts); - assertTrue(tempContexts.isEmpty()); - - replayAll(); - startupBootstrap.loadTempContexts(null); - verifyAll(); - - assertNotNull(tempContexts); - Assert.assertEquals(4, tempContexts.size()); - for (ThreadLocalContext tlc : tempContexts) { - if (!tlc.getScope().equals(SessionScoped.class) && !tlc.getScope().equals(ConversationScoped.class) - && !tlc.getScope().equals(RequestScoped.class) && !tlc.getScope().equals(ViewScoped.class)) { - Assert.fail(); - } - } - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrapTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrapTest.java deleted file mode 100644 index 32f4c8f..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrapTest.java +++ /dev/null @@ -1,8 +0,0 @@ -package br.gov.frameworkdemoiselle.internal.bootstrap; - -import org.junit.Ignore; - -@Ignore -public class CoreBootstrapTest { - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/MyStartupAnnotatedClass.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/MyStartupAnnotatedClass.java deleted file mode 100644 index 582b5a5..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/MyStartupAnnotatedClass.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.bootstrap; - -import java.util.Stack; - -import br.gov.frameworkdemoiselle.annotation.Priority; -import br.gov.frameworkdemoiselle.lifecycle.Startup; - -public class MyStartupAnnotatedClass { - - public static Stack stackOfMethods = new Stack(); - - @Startup - @Priority(1) - public void startMethod1(){ - addMethodExecuted("startMethod1"); - } - - @Startup - @Priority(1) - public void startMethod2(){ - addMethodExecuted("startMethod2"); - } - - @Startup - @Priority(0) - public void startMethod3(){ - addMethodExecuted("startMethod3"); - } - - private void addMethodExecuted(String name) { - stackOfMethods.push(name); - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrapTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrapTest.java deleted file mode 100644 index 1dd88b0..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrapTest.java +++ /dev/null @@ -1,200 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.bootstrap; -// -//import static org.easymock.EasyMock.expect; -//import static org.easymock.EasyMock.replay; -//import static org.easymock.EasyMock.verify; -//import static org.junit.Assert.assertFalse; -//import static org.junit.Assert.assertNotNull; -//import static org.junit.Assert.assertTrue; -// -//import java.lang.reflect.Field; -//import java.util.ArrayList; -//import java.util.HashSet; -//import java.util.List; -//import java.util.Locale; -//import java.util.Set; -// -//import javax.enterprise.inject.spi.AfterBeanDiscovery; -//import javax.enterprise.inject.spi.AnnotatedMethod; -//import javax.enterprise.inject.spi.AnnotatedType; -//import javax.enterprise.inject.spi.BeanManager; -//import javax.enterprise.inject.spi.ProcessAnnotatedType; -// -//import org.easymock.EasyMock; -//import org.junit.Before; -//import org.junit.Ignore; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.api.easymock.PowerMock; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -//import org.powermock.reflect.Whitebox; -//import org.slf4j.Logger; -// -//import br.gov.frameworkdemoiselle.annotation.Shutdown; -//import br.gov.frameworkdemoiselle.internal.context.Contexts; -//import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; -//import br.gov.frameworkdemoiselle.internal.processor.ShutdownProcessor; -//import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; -//import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; -//import br.gov.frameworkdemoiselle.util.ResourceBundle; -// -//@Ignore -//@RunWith(PowerMockRunner.class) -//@PrepareForTest({ Contexts.class, LoggerProducer.class, ResourceBundle.class, ResourceBundleProducer.class }) -//@SuppressWarnings("rawtypes") -//public class ShutdownBootstrapTest { -// -// private ProcessAnnotatedType event; -// -// private BeanManager beanManager; -// -// private AnnotatedType annotatedType; -// -// @Before -// public void before() { -// event = EasyMock.createMock(ProcessAnnotatedType.class); -// annotatedType = EasyMock.createMock(AnnotatedType.class); -// beanManager = null; -// } -// -// @SuppressWarnings("unchecked") -// private List getProcessors(ShutdownBootstrap bootstrap) throws IllegalArgumentException, -// IllegalAccessException { -// Set fields = Whitebox.getAllStaticFields(ShutdownBootstrap.class); -// List list = new ArrayList(); -// for (Field field : fields) { -// if (field.getName().equals("processors")) { -// list = (List) field.get(bootstrap); -// } -// } -// return list; -// } -// -// @SuppressWarnings({ "unchecked" }) -// @Test -// public void processAnnotatedType() throws IllegalArgumentException, IllegalAccessException { -// ShutdownBootstrap bootstrap = new ShutdownBootstrap(); -// List list = getProcessors(bootstrap); -// -// assertTrue(list.isEmpty()); -// -// AnnotatedMethod am1 = PowerMock.createMock(AnnotatedMethod.class); -// AnnotatedMethod am2 = PowerMock.createMock(AnnotatedMethod.class); -// AnnotatedMethod am3 = PowerMock.createMock(AnnotatedMethod.class); -// -// Set set = new HashSet(); -// set.add(am1); -// set.add(am2); -// set.add(am3); -// -// expect(am1.isAnnotationPresent(Shutdown.class)).andReturn(true); -// expect(am2.isAnnotationPresent(Shutdown.class)).andReturn(true); -// expect(am3.isAnnotationPresent(Shutdown.class)).andReturn(false); -// expect(event.getAnnotatedType()).andReturn(annotatedType); -// expect(annotatedType.getMethods()).andReturn(set); -// -// replay(event, annotatedType, am1, am2, am3); -// bootstrap.processAnnotatedType(event, beanManager); -// verify(event, annotatedType); -// -// list = getProcessors(bootstrap); -// assertNotNull(list); -// assertFalse(list.isEmpty()); -// assertTrue(list.size() == 2); -// } -// -// @SuppressWarnings({ "unchecked", "static-access" }) -// @Test -// public void testShuttingDown() throws Throwable { -// ShutdownBootstrap bootstrap = new ShutdownBootstrap(); -// -// PowerMock.mockStatic(Contexts.class); -// PowerMock.mockStatic(LoggerProducer.class); -// -// Logger logger = PowerMock.createMock(Logger.class); -// ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class); -// ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class); -// -// expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger).anyTimes(); -// expect(bundleFactory.create(EasyMock.anyObject(String.class), EasyMock.anyObject(Locale.class))).andReturn( -// bundle).anyTimes(); -// expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn("") -// .anyTimes(); -// -// logger.debug(EasyMock.anyObject(String.class)); -// logger.trace(EasyMock.anyObject(String.class)); -// EasyMock.expectLastCall().anyTimes(); -// -// Whitebox.setInternalState(AbstractBootstrap.class, ResourceBundleProducer.class, bundleFactory); -// -// List list = getProcessors(bootstrap); -// list.clear(); -// -// MyShuttingDownProcessor processor = PowerMock.createMock(MyShuttingDownProcessor.class); -// list.add(processor); -// expect(processor.process()).andReturn(true).times(1); -// -// Contexts.add(EasyMock.anyObject(ThreadLocalContext.class), EasyMock.anyObject(AfterBeanDiscovery.class)); -// EasyMock.expectLastCall().anyTimes(); -// -// Contexts.remove(EasyMock.anyObject(ThreadLocalContext.class)); -// EasyMock.expectLastCall().anyTimes(); -// -// PowerMock.replayAll(); -// ShutdownBootstrap.shutdown(); -// -// assertTrue(list.isEmpty()); -// PowerMock.verifyAll(); -// } -//} -// -//@SuppressWarnings("rawtypes") -//class MyShuttingDownProcessor extends ShutdownProcessor { -// -// @SuppressWarnings("unchecked") -// public MyShuttingDownProcessor(AnnotatedMethod annotatedMethod, BeanManager beanManager) { -// super(annotatedMethod, beanManager); -// } -// -// @Override -// public int compareTo(final ShutdownProcessor other) { -// return 1; -// } -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrapTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrapTest.java deleted file mode 100644 index 54e5fdd..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrapTest.java +++ /dev/null @@ -1,262 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.bootstrap; -// -//import static junit.framework.Assert.assertEquals; -//import static org.easymock.EasyMock.expect; -//import static org.easymock.EasyMock.replay; -//import static org.easymock.EasyMock.verify; -//import static org.junit.Assert.assertFalse; -//import static org.junit.Assert.assertNotNull; -//import static org.junit.Assert.assertTrue; -//import static org.junit.Assert.fail; -// -//import java.lang.reflect.Field; -//import java.util.HashSet; -//import java.util.List; -//import java.util.Locale; -//import java.util.Set; -// -//import javax.enterprise.context.ConversationScoped; -//import javax.enterprise.context.RequestScoped; -//import javax.enterprise.context.SessionScoped; -//import javax.enterprise.inject.spi.AfterBeanDiscovery; -//import javax.enterprise.inject.spi.AnnotatedMethod; -//import javax.enterprise.inject.spi.AnnotatedType; -//import javax.enterprise.inject.spi.BeanManager; -//import javax.enterprise.inject.spi.ProcessAnnotatedType; -// -//import junit.framework.Assert; -// -//import org.easymock.EasyMock; -//import org.junit.Before; -//import org.junit.Ignore; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.api.easymock.PowerMock; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -//import org.powermock.reflect.Whitebox; -//import org.slf4j.Logger; -// -//import br.gov.frameworkdemoiselle.annotation.Startup; -//import br.gov.frameworkdemoiselle.annotation.ViewScoped; -//import br.gov.frameworkdemoiselle.internal.context.Contexts; -//import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; -//import br.gov.frameworkdemoiselle.internal.processor.StartupProcessor; -//import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; -//import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; -//import br.gov.frameworkdemoiselle.util.ResourceBundle; -// -//@Ignore -//@RunWith(PowerMockRunner.class) -//@PrepareForTest({ Contexts.class, LoggerProducer.class, ResourceBundle.class, ResourceBundleProducer.class }) -//@SuppressWarnings({ "rawtypes", "unchecked" }) -//public class StartupBootstrapTest { -// -// private ProcessAnnotatedType event; -// -// private BeanManager beanManager; -// -// private AnnotatedType annotatedType; -// -// @Before -// public void before() { -// event = EasyMock.createMock(ProcessAnnotatedType.class); -// annotatedType = EasyMock.createMock(AnnotatedType.class); -// beanManager = null; -// } -// -// private List getActions(StartupBootstrap bootstrap) throws IllegalArgumentException, -// IllegalAccessException { -// Set fields = Whitebox.getAllStaticFields(StartupBootstrap.class); -// List list = null; -// for (Field field : fields) { -// if (field.getName().equals("processors")) { -// list = (List) field.get(bootstrap); -// } -// } -// return list; -// } -// -// @Test -// public void processAnnotatedType() throws IllegalArgumentException, IllegalAccessException { -// StartupBootstrap bootstrap = new StartupBootstrap(); -// List list = getActions(bootstrap); -// -// assertNotNull(list); -// assertTrue(list.isEmpty()); -// -// AnnotatedMethod am1 = PowerMock.createMock(AnnotatedMethod.class); -// AnnotatedMethod am2 = PowerMock.createMock(AnnotatedMethod.class); -// AnnotatedMethod am3 = PowerMock.createMock(AnnotatedMethod.class); -// -// Set set = new HashSet(); -// set.add(am1); -// set.add(am2); -// set.add(am3); -// -// expect(am1.isAnnotationPresent(Startup.class)).andReturn(true); -// expect(am2.isAnnotationPresent(Startup.class)).andReturn(true); -// expect(am3.isAnnotationPresent(Startup.class)).andReturn(false); -// expect(event.getAnnotatedType()).andReturn(annotatedType); -// expect(annotatedType.getMethods()).andReturn(set); -// -// replay(event, annotatedType, am1, am2, am3); -// bootstrap.processAnnotatedType(event, beanManager); -// verify(event, annotatedType); -// -// list = getActions(bootstrap); -// assertNotNull(list); -// assertFalse(list.isEmpty()); -// assertTrue(list.size() == 2); -// } -// -// @SuppressWarnings("static-access") -// @Test -// public void testLoadTempContexts() { -// StartupBootstrap bootstrap = new StartupBootstrap(); -// -// Logger logger = PowerMock.createMock(Logger.class); -// ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class); -// ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class); -// -// PowerMock.mockStatic(Contexts.class); -// PowerMock.mockStatic(LoggerProducer.class); -// -// List tempContexts = Whitebox.getInternalState(bootstrap, "tempContexts"); -// -// assertNotNull(tempContexts); -// assertTrue(tempContexts.isEmpty()); -// -// expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger).anyTimes(); -// expect(bundleFactory.create(EasyMock.anyObject(String.class), EasyMock.anyObject(Locale.class))).andReturn( -// bundle).anyTimes(); -// expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn("") -// .anyTimes(); -// -// logger.trace(EasyMock.anyObject(String.class)); -// EasyMock.expectLastCall().anyTimes(); -// -// Contexts.add(EasyMock.anyObject(ThreadLocalContext.class), EasyMock.anyObject(AfterBeanDiscovery.class)); -// EasyMock.expectLastCall().anyTimes(); -// -// Whitebox.setInternalState(AbstractBootstrap.class, ResourceBundleProducer.class, bundleFactory); -// -// PowerMock.replayAll(); -// bootstrap.loadTempContexts(null); -// PowerMock.verifyAll(); -// -// assertNotNull(tempContexts); -// assertEquals(4, tempContexts.size()); -// -// for (ThreadLocalContext tlc : tempContexts) { -// if (!tlc.getScope().equals(SessionScoped.class) && !tlc.getScope().equals(ConversationScoped.class) -// && !tlc.getScope().equals(RequestScoped.class) && !tlc.getScope().equals(ViewScoped.class)) { -// fail(); -// } -// } -// } -// -// @SuppressWarnings("static-access") -// @Test -// public void testStartup() throws Throwable { -// StartupBootstrap bootstrap = new StartupBootstrap(); -// -// PowerMock.mockStatic(Contexts.class); -// PowerMock.mockStatic(LoggerProducer.class); -// -// Logger logger = PowerMock.createMock(Logger.class); -// ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class); -// ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class); -// -// expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger).anyTimes(); -// expect(bundleFactory.create(EasyMock.anyObject(String.class), EasyMock.anyObject(Locale.class))).andReturn( -// bundle).anyTimes(); -// expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn("") -// .anyTimes(); -// -// logger.debug(EasyMock.anyObject(String.class)); -// EasyMock.expectLastCall().anyTimes(); -// -// Whitebox.setInternalState(AbstractBootstrap.class, ResourceBundleProducer.class, bundleFactory); -// -// List list = getActions(bootstrap); -// list.clear(); -// -// MyProcessor processor = PowerMock.createMock(MyProcessor.class); -// list.add(processor); -// expect(processor.process()).andReturn(true).times(1); -// -// PowerMock.replayAll(); -// bootstrap.startup(); -// -// assertTrue(list.isEmpty()); -// PowerMock.verifyAll(); -// } -// -// @SuppressWarnings("static-access") -// @Test -// public void testLoadTempContextsAndStartup() { -// -// StartupBootstrap bootstrap = new StartupBootstrap(); -// -// bootstrap.loadTempContexts(null); -// Assert.assertFalse(Contexts.getActiveContexts().isEmpty()); -// -// try { -// bootstrap.startup(); -// Assert.assertTrue(Contexts.getActiveContexts().isEmpty()); -// } catch (Throwable e) { -// fail(); -// } -// } -//} -// -//@SuppressWarnings("rawtypes") -//class MyProcessor extends StartupProcessor { -// -// @SuppressWarnings("unchecked") -// public MyProcessor(AnnotatedMethod annotatedMethod, BeanManager beanManager) { -// super(annotatedMethod, beanManager); -// } -// -// @Override -// public int compareTo(final StartupProcessor other) { -// return 1; -// } -// } diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassExtendsFromClassThanImplementsTransactionInterface.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassExtendsFromClassThanImplementsTransactionInterface.java deleted file mode 100644 index f615ff2..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassExtendsFromClassThanImplementsTransactionInterface.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.configuration; - - -public class ClassExtendsFromClassThanImplementsTransactionInterface extends ClassImplementsTransactionInterface{ - - private static final long serialVersionUID = 1L; - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassImplementsTransactionInterface.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassImplementsTransactionInterface.java deleted file mode 100644 index 9c9182c..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassImplementsTransactionInterface.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.configuration; - -import br.gov.frameworkdemoiselle.transaction.Transaction; - -public class ClassImplementsTransactionInterface implements Transaction { - - private static final long serialVersionUID = 1L; - - @Override - public void begin() { - // TODO Auto-generated method stub - - } - - @Override - public void commit() { - // TODO Auto-generated method stub - - } - - @Override - public void rollback() { - // TODO Auto-generated method stub - - } - - @Override - public void setRollbackOnly() { - // TODO Auto-generated method stub - - } - - @Override - public boolean isActive() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isMarkedRollback() { - // TODO Auto-generated method stub - return false; - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassThanImplementsInterfaceThanExtendsFromTransactionInterface.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassThanImplementsInterfaceThanExtendsFromTransactionInterface.java deleted file mode 100644 index 0f1d796..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassThanImplementsInterfaceThanExtendsFromTransactionInterface.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.configuration; - -public class ClassThanImplementsInterfaceThanExtendsFromTransactionInterface implements - InterfaceExtendsFromTransactionInterface { - - private static final long serialVersionUID = 1L; - - @Override - public boolean isActive() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isMarkedRollback() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void begin() { - // TODO Auto-generated method stub - - } - - @Override - public void commit() { - // TODO Auto-generated method stub - - } - - @Override - public void rollback() { - // TODO Auto-generated method stub - - } - - @Override - public void setRollbackOnly() { - // TODO Auto-generated method stub - - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java deleted file mode 100644 index 67c0092..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java +++ /dev/null @@ -1,523 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.configuration; -// -//import static org.easymock.EasyMock.expect; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.assertNull; -//import static org.junit.Assert.assertTrue; -//import static org.junit.Assert.fail; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -// -//import java.util.Locale; -//import java.util.Properties; -// -//import javax.validation.constraints.NotNull; -// -//import org.junit.After; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.api.easymock.PowerMock; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -//import br.gov.frameworkdemoiselle.annotation.Ignore; -//import br.gov.frameworkdemoiselle.annotation.Name; -//import br.gov.frameworkdemoiselle.configuration.ConfigType; -//import br.gov.frameworkdemoiselle.configuration.Configuration; -//import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; -//import br.gov.frameworkdemoiselle.util.Beans; -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(Beans.class) -//public class ConfigurationLoaderTest { -// -// private ConfigurationLoader configurationLoader; -// -// private CoreBootstrap coreBootstrap; -// -// @Configuration -// public class ConfigurationSuccessfulPropertiesWithClassField { -// -// protected Class classe; -// -// } -// -// @Configuration -// public class ConfigurationSuccessfulPropertiesWithPropertiesField { -// -// protected Properties properties; -// -// } -// -// @Configuration -// public class ConfigurationSuccessfulProperties { -// -// @Name("frameworkdemoiselle.configurationtest.nameConfiguration") -// protected String nameConfiguration; -// -// } -// -// @Configuration -// public class ConfigurationSuccessfulProperties2 { -// -// @Name("frameworkdemoiselle.configurationtest.name") -// protected String name; -// -// } -// -// @Configuration(resource = "absentFile") -// public class ConfigurationPropertiesWithAbsentFile { -// -// @Name("frameworkdemoiselle.configurationtest.nameConfiguration") -// protected String nameConfiguration; -// -// } -// -// @Configuration -// public class ConfigurationWithEmptyName { -// -// @Name("") -// protected String nameConfiguration; -// -// } -// -// @Configuration -// public class ConfigurationWithoutNameAnnotation { -// -// protected String nameConfiguration; -// -// } -// -// @Configuration -// public class ConfigurationWithIgnoreAnnotation { -// -// @Ignore -// protected String nameConfiguration; -// -// } -// -// @Configuration(prefix = "frameworkdemoiselle.configurationtest.") -// public class ConfigurationWithPrefix { -// -// @Name("nameConfiguration") -// protected String nameConfiguration; -// -// } -// -// @Configuration -// public class ConfigurationWithKeyNotFoundInProperties { -// -// protected Integer notExistKey; -// } -// -// @Configuration -// public class ConfigurationWithNotNullFieldButValueIsNull { -// -// @Name("notexistKey") -// @NotNull -// protected int nameConfiguration; -// -// } -// -// @Configuration -// public class ConfigurationWithNotNullFieldAndValueIsNotNull { -// -// @Name("nameConfiguration") -// @NotNull -// protected String nameConfiguration; -// -// } -// -// @Configuration -// public class ConfigurationWithNonPrimitiveFieldValueNull { -// -// @Name("notexistKey") -// protected String nameConfiguration; -// -// } -// -// @Configuration -// public class ConfigurationWithPrimitiveFieldValueNull { -// -// @Name("notexistKey") -// protected int nameConfiguration = 1; -// -// } -// -// @Configuration(type = ConfigType.SYSTEM) -// public class ConfigurationWithKeyFromSystem { -// -// @Name("os.name") -// protected String nameConfiguration; -// -// } -// -// @Configuration(type = ConfigType.XML) -// public class ConfigurationWithKeyFromXML { -// -// @Name("nameConfiguration") -// protected String nameConfiguration; -// -// } -// -// @Configuration(type = ConfigType.XML, prefix = "br.gov.frameworkdemoiselle") -// public class ConfigurationFromXMLWithPrefix { -// -// @Name("nameConfiguration") -// protected String nameConfiguration; -// -// } -// -// @Configuration -// public class ConfigurationWithConventionAllUpperCase { -// -// protected String conventionAllUpperCase; -// -// } -// -// @Configuration(type = ConfigType.XML) -// public class ConfigurationXMLWithConventionAllUpperCase { -// -// protected String conventionAllUpperCase; -// -// } -// -// @Configuration -// public class ConfigurationWithConventionAllLowerCase { -// -// protected String conventionAllLowerCase; -// -// } -// -// @Configuration(type = ConfigType.XML) -// public class ConfigurationXMLWithConventionAllLowerCase { -// -// protected String conventionAllLowerCase; -// -// } -// -// @Configuration(prefix = "br.gov.frameworkdemoiselle.") -// public class ConfigurationPropertiesSuccessWithPrefixNonAmbiguous { -// -// protected String success; -// -// } -// -// @Configuration -// public class ConfigurationPropertiesErrorWithComplexObject { -// -// protected ConfigurationWithConventionAllLowerCase complexObject; -// } -// -// @Before -// public void setUp() throws Exception { -// this.configurationLoader = new ConfigurationLoader(); -// mockStatic(Beans.class); -// this.coreBootstrap = PowerMock.createMock(CoreBootstrap.class); -// -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); -// } -// -// @After -// public void tearDown() throws Exception { -// } -// -// @Test -// public void testConfigurationSuccessfulPropertiesWithClassField() { -// ConfigurationSuccessfulPropertiesWithClassField config = new ConfigurationSuccessfulPropertiesWithClassField(); -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// configurationLoader.load(config); -// assertEquals(ConfigurationLoaderTest.class, config.classe); -// } -// -// @Test -// public void testConfigurationSuccessfulPropertiesWithPropertiesField() { -// ConfigurationSuccessfulPropertiesWithPropertiesField config = new ConfigurationSuccessfulPropertiesWithPropertiesField(); -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// configurationLoader.load(config); -// assertEquals("teste1", config.properties.getProperty("1")); -// assertEquals("teste2", config.properties.getProperty("2")); -// assertTrue(config.properties.containsKey("1")); -// assertTrue(config.properties.containsKey("2")); -// } -// -// @Test -// public void testConfigurationSuccessfulPropertiesPossibleConventions() { -// ConfigurationSuccessfulProperties config = new ConfigurationSuccessfulProperties(); -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// configurationLoader.load(config); -// assertEquals("ConfigurationTest", config.nameConfiguration); -// -// } -// -// @Test -// public void testConfigurationSuccessfulPropertiesNoConventions() { -// ConfigurationSuccessfulProperties2 config = new ConfigurationSuccessfulProperties2(); -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// configurationLoader.load(config); -// assertEquals("ConfigurationTest2", config.name); -// } -// -// // @Test -// // public void ConfigurationPropertiesWithAbsentFile() { -// // ConfigurationPropertiesWithAbsentFile config = new ConfigurationPropertiesWithAbsentFile(); -// // -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// // -// // try { -// // configurationLoader.load(config); -// // fail(); -// // } catch (Exception e) { -// // } -// // } -// -// @Test -// public void testConfigurationProcessorWithNameEmpty() { -// ConfigurationWithEmptyName config = new ConfigurationWithEmptyName(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// try { -// configurationLoader.load(config); -// fail(); -// } catch (Exception e) { -// } -// } -// -// @Test -// public void testConfigurationWithoutNameAnnotation() { -// ConfigurationWithoutNameAnnotation config = new ConfigurationWithoutNameAnnotation(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertEquals("ConfigurationTest", config.nameConfiguration); -// } -// -// @Test -// public void testConfigurationWithIgnoreAnnotation() { -// ConfigurationWithIgnoreAnnotation config = new ConfigurationWithIgnoreAnnotation(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertNull(config.nameConfiguration); -// } -// -// @Test -// public void testConfigurationWithPrefix() { -// ConfigurationWithPrefix config = new ConfigurationWithPrefix(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertEquals("ConfigurationTest", config.nameConfiguration); -// } -// -// @Test -// public void testConfigurationWithKeyNotFoundInProperties() { -// ConfigurationWithKeyNotFoundInProperties config = new ConfigurationWithKeyNotFoundInProperties(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertNull(config.notExistKey); -// } -// -// @Test -// public void testConfigurationWithNotNullFieldButValueIsNull() { -// ConfigurationWithNotNullFieldButValueIsNull config = new ConfigurationWithNotNullFieldButValueIsNull(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// try { -// configurationLoader.load(config); -// fail(); -// } catch (Exception e) { -// assertTrue(true); -// } -// } -// -// @Test -// public void testConfigurationWithNotNullFieldAndValueIsNotNull() { -// ConfigurationWithNotNullFieldAndValueIsNotNull config = new ConfigurationWithNotNullFieldAndValueIsNotNull(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertEquals("ConfigurationTest", config.nameConfiguration); -// } -// -// @Test -// public void testConfigurationWithNonPrimitiveFieldValueNull() { -// ConfigurationWithNonPrimitiveFieldValueNull config = new ConfigurationWithNonPrimitiveFieldValueNull(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertNull(config.nameConfiguration); -// } -// -// @Test -// public void testConfigurationWithPrimitiveFieldValueNull() { -// ConfigurationWithPrimitiveFieldValueNull config = new ConfigurationWithPrimitiveFieldValueNull(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertEquals(1, config.nameConfiguration); -// } -// -// @Test -// public void testConfigurationWithKeyFromSystem() { -// ConfigurationWithKeyFromSystem config = new ConfigurationWithKeyFromSystem(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertEquals(System.getProperty("os.name"), config.nameConfiguration); -// } -// -// @Test -// public void testConfigurationWithKeyFromXML() { -// ConfigurationWithKeyFromXML config = new ConfigurationWithKeyFromXML(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertEquals("ConfigurationTest", config.nameConfiguration); -// } -// -// @Test -// public void testConfigurationWithPrefixNotAmbiguous() { -// ConfigurationPropertiesSuccessWithPrefixNonAmbiguous config = new ConfigurationPropertiesSuccessWithPrefixNonAmbiguous(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// configurationLoader.load(config); -// assertEquals("Success", config.success); -// } -// -// // @Test -// // public void testConfigurationWithConventionAllLowerCase() { -// // ConfigurationWithConventionAllLowerCase config = new ConfigurationWithConventionAllLowerCase(); -// // -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// // -// // configurationLoader.load(config); -// // assertEquals("All LowerCase", config.conventionAllLowerCase); -// // } -// -// // @Test -// // public void testConfigurationWithConventionAllUpperCase() { -// // ConfigurationWithConventionAllUpperCase config = new ConfigurationWithConventionAllUpperCase(); -// // -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// // -// // configurationLoader.load(config); -// // assertEquals("ALL UPPERCASE", config.conventionAllUpperCase); -// // } -// -// @Test -// public void testConfigurationPropertiesErrorWithComplexObject() { -// ConfigurationPropertiesErrorWithComplexObject config = new ConfigurationPropertiesErrorWithComplexObject(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// -// try { -// configurationLoader.load(config); -// fail(); -// } catch (Throwable throwable) { -// } -// } -// -// // @Test -// // public void testConfigurationFromXMLWithPrefix() { -// // ConfigurationFromXMLWithPrefix config = new ConfigurationFromXMLWithPrefix(); -// // -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// // -// // configurationLoader.load(config); -// // assertEquals("ConfigurationTest", config.nameConfiguration); -// // } -// -// // @Test -// // public void testConfigurationXMLWithConventionAllUpperCase() { -// // ConfigurationXMLWithConventionAllUpperCase config = new ConfigurationXMLWithConventionAllUpperCase(); -// // -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// // -// // configurationLoader.load(config); -// // assertEquals("ALL UPPERCASE", config.conventionAllUpperCase); -// // } -// -// // @Test -// // public void testConfigurationXMLWithConventionAllLowerCase() { -// // ConfigurationXMLWithConventionAllLowerCase config = new ConfigurationXMLWithConventionAllLowerCase(); -// // -// // expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// // PowerMock.replayAll(CoreBootstrap.class, Beans.class); -// // -// // configurationLoader.load(config); -// // assertEquals("All LowerCase", config.conventionAllLowerCase); -// // } -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java deleted file mode 100644 index 31263c4..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java +++ /dev/null @@ -1,545 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.configuration; -// -//import static org.easymock.EasyMock.expect; -//import static org.junit.Assert.assertEquals; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -// -//import java.awt.Color; -//import java.math.BigDecimal; -//import java.math.BigInteger; -//import java.net.URL; -//import java.util.Calendar; -//import java.util.Date; -//import java.util.GregorianCalendar; -//import java.util.Locale; -// -//import org.junit.After; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.api.easymock.PowerMock; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -//import br.gov.frameworkdemoiselle.configuration.ConfigType; -//import br.gov.frameworkdemoiselle.configuration.Configuration; -//import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; -//import br.gov.frameworkdemoiselle.util.Beans; -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(Beans.class) -//public class ConfigurationLoaderWithArrayTest { -// -// private ConfigurationLoader configurationLoader; -// -// @Configuration(type = ConfigType.PROPERTIES, resource = "configuration-with-array") -// public class ConfigurationPropertiesWithArray { -// -// /* -// * All methods supported by org.apache.commons.configuration.DataConfiguration class for array -// */ -// -// protected BigDecimal[] bigDecimalArray; -// -// protected BigInteger[] bigIntegerArray; -// -// protected boolean[] booleanArray; -// -// protected byte[] byteArray; -// -// protected Calendar[] calendarArray; -// -// protected Color[] colorArray; -// -// protected Date[] dateArray; -// -// protected double[] doubleArray; -// -// protected float[] floatArray; -// -// protected int[] integerArray; -// -// protected Locale[] localeArray; -// -// protected long[] longArray; -// -// protected short[] shortArray; -// -// protected URL[] urlArray; -// -// protected String[] stringArray; -// -// } -// -// @Configuration(type = ConfigType.XML, resource = "configuration-with-array") -// public class ConfigurationXMLWithArray { -// -// /* -// * All methods supported by org.apache.commons.configuration.DataConfiguration class for array -// */ -// -// protected BigDecimal[] bigDecimalArray; -// -// protected BigInteger[] bigIntegerArray; -// -// protected boolean[] booleanArray; -// -// protected byte[] byteArray; -// -// protected Calendar[] calendarArray; -// -// protected Color[] colorArray; -// -// protected Date[] dateArray; -// -// protected double[] doubleArray; -// -// protected float[] floatArray; -// -// protected int[] integerArray; -// -// protected Locale[] localeArray; -// -// protected long[] longArray; -// -// protected short[] shortArray; -// -// protected URL[] urlArray; -// -// protected String[] stringArray; -// -// } -// -// @Before -// public void setUp() throws Exception { -// configurationLoader = new ConfigurationLoader(); -// } -// -// @After -// public void tearDown() throws Exception { -// } -// -// @Test -// public void testConfigurationPropertiesWithIntegerArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Integer integerValue = config.integerArray[0]; -// -// assertEquals(Integer.class, integerValue.getClass()); -// assertEquals(Integer.MAX_VALUE, integerValue.intValue()); -// assertEquals(4, config.integerArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithShortArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Short shortValue = config.shortArray[0]; -// -// assertEquals(Short.class, shortValue.getClass()); -// assertEquals(Short.MAX_VALUE, shortValue.shortValue()); -// assertEquals(4, config.shortArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithByteArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Byte byteValue = config.byteArray[0]; -// -// assertEquals(Byte.class, byteValue.getClass()); -// assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); -// assertEquals(8, config.byteArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithBooleanArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Boolean booleanValue = config.booleanArray[0]; -// -// assertEquals(Boolean.class, booleanValue.getClass()); -// assertEquals(2, config.booleanArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithLongArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Long longValue = config.longArray[0]; -// -// assertEquals(Long.class, longValue.getClass()); -// assertEquals(Long.MAX_VALUE, longValue.longValue()); -// assertEquals(5, config.longArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithFloatArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Float floatValue = config.floatArray[0]; -// -// assertEquals(Float.class, floatValue.getClass()); -// assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); -// assertEquals(5, config.floatArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithDoubleArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Double doubleValue = config.doubleArray[0]; -// -// assertEquals(Double.class, doubleValue.getClass()); -// assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1); -// assertEquals(3, config.doubleArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithBigDecimalArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// BigDecimal bigDecimalValue = config.bigDecimalArray[0]; -// -// assertEquals(BigDecimal.class, bigDecimalValue.getClass()); -// assertEquals(3, config.bigDecimalArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithBigIntegerArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// BigInteger bigIntegerValue = config.bigIntegerArray[0]; -// -// assertEquals(BigInteger.class, bigIntegerValue.getClass()); -// assertEquals(3, config.bigIntegerArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithCalendarArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Calendar calendarValue = config.calendarArray[0]; -// -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); -// -// assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); -// assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); -// assertEquals(3, config.calendarArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithDateArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Date dateValue = config.dateArray[0]; -// -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); -// -// Date date = new Date(calendar.getTimeInMillis()); -// -// assertEquals(Date.class, dateValue.getClass()); -// assertEquals(date.getTime(), dateValue.getTime()); -// assertEquals(3, config.dateArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithColorArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Color colorValue = config.colorArray[0]; -// -// assertEquals(Color.class, colorValue.getClass()); -// assertEquals(Color.gray, colorValue); -// assertEquals(3, config.colorArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithLocaleArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// Locale localeValue = config.localeArray[0]; -// Locale localeValue2 = config.localeArray[1]; -// -// assertEquals(Locale.class, localeValue.getClass()); -// assertEquals(Locale.ENGLISH, localeValue); -// assertEquals("BR", localeValue2.getCountry()); -// assertEquals(3, config.localeArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithURLArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// URL urlValue = config.urlArray[0]; -// -// URL otherURL = null; -// -// try { -// otherURL = new URL("http://www.test.com"); -// } catch (Exception e) { -// -// } -// -// assertEquals(URL.class, urlValue.getClass()); -// assertEquals(otherURL, urlValue); -// assertEquals(3, config.urlArray.length); -// } -// -// @Test -// public void testConfigurationPropertiesWithStringArray() { -// ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); -// -// String stringValue = config.stringArray[0]; -// -// assertEquals(String.class, stringValue.getClass()); -// assertEquals("Test", stringValue); -// assertEquals(3, config.stringArray.length); -// } -// -// private ConfigurationPropertiesWithArray prepareConfigurationPropertiesWithArray() { -// mockStatic(Beans.class); -// ConfigurationPropertiesWithArray config = new ConfigurationPropertiesWithArray(); -// CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); -// -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// -// PowerMock.replayAll(CoreBootstrap.class,Beans.class); -// -// configurationLoader.load(config); -// return config; -// } -// -// @Test -// public void testConfigurationXMLWithIntegerArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Integer integerValue = config.integerArray[0]; -// -// assertEquals(Integer.class, integerValue.getClass()); -// assertEquals(Integer.MAX_VALUE, integerValue.intValue()); -// assertEquals(4, config.integerArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithShortArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Short shortValue = config.shortArray[0]; -// -// assertEquals(Short.class, shortValue.getClass()); -// assertEquals(Short.MAX_VALUE, shortValue.shortValue()); -// assertEquals(4, config.shortArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithByteArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Byte byteValue = config.byteArray[0]; -// -// assertEquals(Byte.class, byteValue.getClass()); -// assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); -// assertEquals(8, config.byteArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithBooleanArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Boolean booleanValue = config.booleanArray[0]; -// -// assertEquals(Boolean.class, booleanValue.getClass()); -// assertEquals(2, config.booleanArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithLongArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Long longValue = config.longArray[0]; -// -// assertEquals(Long.class, longValue.getClass()); -// assertEquals(Long.MAX_VALUE, longValue.longValue()); -// assertEquals(5, config.longArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithFloatArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Float floatValue = config.floatArray[0]; -// -// assertEquals(Float.class, floatValue.getClass()); -// assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); -// assertEquals(5, config.floatArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithDoubleArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Double doubleValue = config.doubleArray[0]; -// -// assertEquals(Double.class, doubleValue.getClass()); -// assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1); -// assertEquals(3, config.doubleArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithBigDecimalArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// BigDecimal bigDecimalValue = config.bigDecimalArray[0]; -// -// assertEquals(BigDecimal.class, bigDecimalValue.getClass()); -// assertEquals(3, config.bigDecimalArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithBigIntegerArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// BigInteger bigIntegerValue = config.bigIntegerArray[0]; -// -// assertEquals(BigInteger.class, bigIntegerValue.getClass()); -// assertEquals(3, config.bigIntegerArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithCalendarArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Calendar calendarValue = config.calendarArray[0]; -// -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); -// -// assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); -// assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); -// assertEquals(3, config.calendarArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithDateArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Date dateValue = config.dateArray[0]; -// -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); -// -// Date date = new Date(calendar.getTimeInMillis()); -// -// assertEquals(Date.class, dateValue.getClass()); -// assertEquals(date.getTime(), dateValue.getTime()); -// assertEquals(3, config.dateArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithColorArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Color colorValue = config.colorArray[0]; -// -// assertEquals(Color.class, colorValue.getClass()); -// assertEquals(Color.gray, colorValue); -// assertEquals(3, config.colorArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithLocaleArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// Locale localeValue = config.localeArray[0]; -// Locale localeValue2 = config.localeArray[1]; -// -// assertEquals(Locale.class, localeValue.getClass()); -// assertEquals(Locale.ENGLISH, localeValue); -// assertEquals("BR", localeValue2.getCountry()); -// assertEquals(3, config.localeArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithURLArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// URL urlValue = config.urlArray[0]; -// -// URL otherURL = null; -// -// try { -// otherURL = new URL("http://www.test.com"); -// } catch (Exception e) { -// -// } -// -// assertEquals(URL.class, urlValue.getClass()); -// assertEquals(otherURL, urlValue); -// assertEquals(3, config.urlArray.length); -// } -// -// @Test -// public void testConfigurationXMLWithStringArray() { -// ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); -// -// String stringValue = config.stringArray[0]; -// -// assertEquals(String.class, stringValue.getClass()); -// assertEquals("Test", stringValue); -// assertEquals(3, config.stringArray.length); -// } -// -// private ConfigurationXMLWithArray prepareConfigurationXMLWithArray() { -// mockStatic(Beans.class); -// ConfigurationXMLWithArray config = new ConfigurationXMLWithArray(); -// CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); -// -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// -// PowerMock.replayAll(CoreBootstrap.class,Beans.class); -// -// configurationLoader.load(config); -// return config; -// } -// } diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java deleted file mode 100644 index 8a0dee5..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java +++ /dev/null @@ -1,546 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.configuration; -// -//import static org.easymock.EasyMock.expect; -//import static org.junit.Assert.assertEquals; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -// -//import java.awt.Color; -//import java.math.BigDecimal; -//import java.math.BigInteger; -//import java.net.URL; -//import java.util.Calendar; -//import java.util.Date; -//import java.util.GregorianCalendar; -//import java.util.List; -//import java.util.Locale; -// -//import org.junit.After; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.api.easymock.PowerMock; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -//import br.gov.frameworkdemoiselle.configuration.ConfigType; -//import br.gov.frameworkdemoiselle.configuration.Configuration; -//import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; -//import br.gov.frameworkdemoiselle.util.Beans; -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(Beans.class) -//public class ConfigurationLoaderWithListTest { -// -// private ConfigurationLoader configurationLoader; -// -// @Configuration(type = ConfigType.PROPERTIES, resource = "configuration-with-list") -// public class ConfigurationPropertiesWithList { -// -// /* -// * All methods supported by org.apache.commons.configuration.DataConfiguration class for List type -// */ -// -// protected List bigDecimalList; -// -// protected List bigIntegerList; -// -// protected List booleanList; -// -// protected List byteList; -// -// protected List calendarList; -// -// protected List colorList; -// -// protected List dateList; -// -// protected List doubleList; -// -// protected List floatList; -// -// protected List integerList; -// -// protected List localeList; -// -// protected List longList; -// -// protected List shortList; -// -// protected List urlList; -// -// protected List stringList; -// } -// -// @Configuration(type = ConfigType.XML, resource = "configuration-with-list") -// public class ConfigurationXMLWithList { -// -// /* -// * All methods supported by org.apache.commons.configuration.DataConfiguration class for List type -// */ -// -// protected List bigDecimalList; -// -// protected List bigIntegerList; -// -// protected List booleanList; -// -// protected List byteList; -// -// protected List calendarList; -// -// protected List colorList; -// -// protected List dateList; -// -// protected List doubleList; -// -// protected List floatList; -// -// protected List integerList; -// -// protected List localeList; -// -// protected List longList; -// -// protected List shortList; -// -// protected List urlList; -// -// protected List stringList; -// } -// -// @Before -// public void setUp() throws Exception { -// configurationLoader = new ConfigurationLoader(); -// } -// -// @After -// public void tearDown() throws Exception { -// } -// -// @Test -// public void testConfigurationPropertiesWithIntegerList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Integer integerValue = config.integerList.get(0); -// -// assertEquals(Integer.class, integerValue.getClass()); -// assertEquals(Integer.MAX_VALUE, integerValue.intValue()); -// assertEquals(4, config.integerList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithShortList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Short shortValue = config.shortList.get(0); -// -// assertEquals(Short.class, shortValue.getClass()); -// assertEquals(Short.MAX_VALUE, shortValue.shortValue()); -// assertEquals(4, config.shortList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithByteList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Byte byteValue = config.byteList.get(0); -// -// assertEquals(Byte.class, byteValue.getClass()); -// assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); -// assertEquals(8, config.byteList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithBooleanList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Boolean booleanValue = config.booleanList.get(0); -// -// assertEquals(Boolean.class, booleanValue.getClass()); -// assertEquals(2, config.booleanList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithLongList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Long longValue = config.longList.get(0); -// -// assertEquals(Long.class, longValue.getClass()); -// assertEquals(Long.MAX_VALUE, longValue.longValue()); -// assertEquals(5, config.longList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithFloatList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Float floatValue = config.floatList.get(0); -// -// assertEquals(Float.class, floatValue.getClass()); -// assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); -// assertEquals(5, config.floatList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithDoubleList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Double doubleValue = config.doubleList.get(0); -// -// assertEquals(Double.class, doubleValue.getClass()); -// assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1); -// assertEquals(3, config.doubleList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithBigDecimalList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// BigDecimal bigDecimalValue = config.bigDecimalList.get(0); -// -// assertEquals(BigDecimal.class, bigDecimalValue.getClass()); -// assertEquals(3, config.bigDecimalList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithBigIntegerList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// BigInteger bigIntegerValue = config.bigIntegerList.get(0); -// -// assertEquals(BigInteger.class, bigIntegerValue.getClass()); -// assertEquals(3, config.bigIntegerList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithCalendarList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Calendar calendarValue = config.calendarList.get(0); -// -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); -// -// assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); -// assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); -// assertEquals(3, config.calendarList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithDateList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Date dateValue = config.dateList.get(0); -// -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); -// -// Date date = new Date(calendar.getTimeInMillis()); -// -// assertEquals(Date.class, dateValue.getClass()); -// assertEquals(date.getTime(), dateValue.getTime()); -// assertEquals(3, config.dateList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithColorList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Color colorValue = config.colorList.get(0); -// -// assertEquals(Color.class, colorValue.getClass()); -// assertEquals(Color.gray, colorValue); -// assertEquals(3, config.colorList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithLocaleList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// Locale localeValue = config.localeList.get(0); -// Locale localeValue2 = config.localeList.get(1); -// -// assertEquals(Locale.class, localeValue.getClass()); -// assertEquals(Locale.ENGLISH, localeValue); -// assertEquals("BR", localeValue2.getCountry()); -// assertEquals(3, config.localeList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithURLList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// URL urlValue = config.urlList.get(0); -// -// URL otherURL = null; -// -// try { -// otherURL = new URL("http://www.test.com"); -// } catch (Exception e) { -// -// } -// -// assertEquals(URL.class, urlValue.getClass()); -// assertEquals(otherURL, urlValue); -// assertEquals(3, config.urlList.size()); -// } -// -// @Test -// public void testConfigurationPropertiesWithStringList() { -// ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); -// -// String stringValue = config.stringList.get(0); -// -// assertEquals(String.class, stringValue.getClass()); -// assertEquals("Test", stringValue); -// assertEquals(3, config.stringList.size()); -// } -// -// private ConfigurationPropertiesWithList prepareConfigurationPropertiesWithList() { -// mockStatic(Beans.class); -// CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); -// -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); -// -// ConfigurationPropertiesWithList config = new ConfigurationPropertiesWithList(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// -// PowerMock.replayAll(CoreBootstrap.class,Beans.class); -// -// configurationLoader.load(config); -// return config; -// } -// -// @Test -// public void testConfigurationXMLWithIntegerList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Integer integerValue = config.integerList.get(0); -// -// assertEquals(Integer.class, integerValue.getClass()); -// assertEquals(Integer.MAX_VALUE, integerValue.intValue()); -// assertEquals(4, config.integerList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithShortList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Short shortValue = config.shortList.get(0); -// -// assertEquals(Short.class, shortValue.getClass()); -// assertEquals(Short.MAX_VALUE, shortValue.shortValue()); -// assertEquals(4, config.shortList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithByteList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Byte byteValue = config.byteList.get(0); -// -// assertEquals(Byte.class, byteValue.getClass()); -// assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); -// assertEquals(8, config.byteList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithBooleanList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Boolean booleanValue = config.booleanList.get(0); -// -// assertEquals(Boolean.class, booleanValue.getClass()); -// assertEquals(2, config.booleanList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithLongList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Long longValue = config.longList.get(0); -// -// assertEquals(Long.class, longValue.getClass()); -// assertEquals(Long.MAX_VALUE, longValue.longValue()); -// assertEquals(5, config.longList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithFloatList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Float floatValue = config.floatList.get(0); -// -// assertEquals(Float.class, floatValue.getClass()); -// assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); -// assertEquals(5, config.floatList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithDoubleList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Double doubleValue = config.doubleList.get(0); -// -// assertEquals(Double.class, doubleValue.getClass()); -// assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1); -// assertEquals(3, config.doubleList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithBigDecimalList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// BigDecimal bigDecimalValue = config.bigDecimalList.get(0); -// -// assertEquals(BigDecimal.class, bigDecimalValue.getClass()); -// assertEquals(3, config.bigDecimalList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithBigIntegerList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// BigInteger bigIntegerValue = config.bigIntegerList.get(0); -// -// assertEquals(BigInteger.class, bigIntegerValue.getClass()); -// assertEquals(3, config.bigIntegerList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithCalendarList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Calendar calendarValue = config.calendarList.get(0); -// -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); -// -// assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); -// assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); -// assertEquals(3, config.calendarList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithDateList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Date dateValue = config.dateList.get(0); -// -// GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); -// -// Date date = new Date(calendar.getTimeInMillis()); -// -// assertEquals(Date.class, dateValue.getClass()); -// assertEquals(date.getTime(), dateValue.getTime()); -// assertEquals(3, config.dateList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithColorList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Color colorValue = config.colorList.get(0); -// -// assertEquals(Color.class, colorValue.getClass()); -// assertEquals(Color.gray, colorValue); -// assertEquals(3, config.colorList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithLocaleList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// Locale localeValue = config.localeList.get(0); -// Locale localeValue2 = config.localeList.get(1); -// -// assertEquals(Locale.class, localeValue.getClass()); -// assertEquals(Locale.ENGLISH, localeValue); -// assertEquals("BR", localeValue2.getCountry()); -// assertEquals(3, config.localeList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithURLList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// URL urlValue = config.urlList.get(0); -// -// URL otherURL = null; -// -// try { -// otherURL = new URL("http://www.test.com"); -// } catch (Exception e) { -// -// } -// -// assertEquals(URL.class, urlValue.getClass()); -// assertEquals(otherURL, urlValue); -// assertEquals(3, config.urlList.size()); -// } -// -// @Test -// public void testConfigurationXMLWithStringList() { -// ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); -// -// String stringValue = config.stringList.get(0); -// -// assertEquals(String.class, stringValue.getClass()); -// assertEquals("Test", stringValue); -// assertEquals(3, config.stringList.size()); -// } -// -// private ConfigurationXMLWithList prepareConfigurationXMLWithList() { -// mockStatic(Beans.class); -// CoreBootstrap coreBootstrap = PowerMock.createMock(CoreBootstrap.class); -// -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(coreBootstrap); -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); -// -// ConfigurationXMLWithList config = new ConfigurationXMLWithList(); -// -// expect(coreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); -// -// PowerMock.replayAll(CoreBootstrap.class,Beans.class); -// -// configurationLoader.load(config); -// return config; -// } -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/InterfaceExtendsFromTransactionInterface.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/InterfaceExtendsFromTransactionInterface.java deleted file mode 100644 index e7b1d7f..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/InterfaceExtendsFromTransactionInterface.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.configuration; - -import br.gov.frameworkdemoiselle.transaction.Transaction; - - -public interface InterfaceExtendsFromTransactionInterface extends Transaction{ - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfigTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfigTest.java deleted file mode 100644 index 1110081..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfigTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.configuration; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -public class PaginationConfigTest { - - private PaginationConfig config; - - @Before - public void setUp() throws Exception { - this.config = new PaginationConfig(); - } - - @Test - public void testGetMaxPageLinks() { - assertEquals(5, config.getMaxPageLinks()); - } - - @Test - public void testGetPageSize() { - assertEquals(10, config.getPageSize()); - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java deleted file mode 100644 index 911c033..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package br.gov.frameworkdemoiselle.internal.configuration; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthenticator; -import br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthorizer; -import br.gov.frameworkdemoiselle.security.Authenticator; -import br.gov.frameworkdemoiselle.security.Authorizer; - -public class SecurityConfigTest { - - private SecurityConfig config; - - @Before - public void setUp() throws Exception { - this.config = new SecurityConfig(); - } - - @Test - public void testIsEnabled() { - assertEquals(true, config.isEnabled()); - } - - @Test - public void testSetEnabled() { - config.setEnabled(false); - assertEquals(false, config.isEnabled()); - } - - @Test - public void testSetAuthenticatorClass() { - Authenticator authenticator = new DefaultAuthenticator(); - config.setAuthenticatorClass(authenticator.getClass()); - assertEquals("br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthenticator", config - .getAuthenticatorClass().getName()); - } - - @Test - public void testSetAuthorizerClass() { - Authorizer authorizer = new DefaultAuthorizer(); - config.setAuthorizerClass(authorizer.getClass()); - assertEquals("br.gov.frameworkdemoiselle.internal.implementation.DefaultAuthorizer", config - .getAuthorizerClass().getName()); - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/TransactionConfigTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/TransactionConfigTest.java deleted file mode 100644 index 82b74f8..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/TransactionConfigTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package br.gov.frameworkdemoiselle.internal.configuration; - -import junit.framework.Assert; - -import org.junit.Before; -import org.junit.Test; - - -public class TransactionConfigTest { - - TransactionConfig transactionConfig; - - @Before - public void setUp() { - transactionConfig = new TransactionConfig(); - } - - @Test - public void testGetTransactionClass() { - Assert.assertNull(transactionConfig.getTransactionClass()); - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextStoreTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextStoreTest.java deleted file mode 100644 index 913a2fd..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextStoreTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.context; - -import java.util.Map; -import java.util.TreeMap; - -import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.powermock.api.easymock.PowerMock; -import org.powermock.reflect.Whitebox; - -public class ContextStoreTest { - - private ContextStore store; - - private Map map; - - @SuppressWarnings("unchecked") - @Before - public void setUp() { - store = new ContextStore(); - map = PowerMock.createMock(Map.class); - Whitebox.setInternalState(store, "map", map); - } - - @Test - public void testContains() { - EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(true); - EasyMock.replay(map); - - Assert.assertTrue(store.contains("")); - EasyMock.verify(map); - } - - @Test - public void testGet() { - EasyMock.expect(map.get(EasyMock.anyObject(String.class))).andReturn("testing"); - EasyMock.replay(map); - - Assert.assertEquals("testing", store.get("")); - EasyMock.verify(map); - } - - @Test - public void testPut() { - Map map = new TreeMap(); - Whitebox.setInternalState(store, "map", map); - store.put("testing", map); - Assert.assertTrue(map.containsKey("testing")); - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextsTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextsTest.java deleted file mode 100644 index 59f7072..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextsTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.context; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replay; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.RequestScoped; -import javax.enterprise.context.SessionScoped; -import javax.enterprise.inject.spi.AfterBeanDiscovery; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import br.gov.frameworkdemoiselle.annotation.ViewScoped; -import br.gov.frameworkdemoiselle.util.Beans; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(Beans.class) -public class ContextsTest { - - private AfterBeanDiscovery event; - - @Before - public void setUp() throws Exception { - Contexts.clear(); - mockStatic(Beans.class); - - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); - - replay(Beans.class); - } - - @Test - public void testRemovingInexistentContext() { - Contexts.remove(new ThreadLocalContext(SessionScoped.class)); - } - - @Test - public void testRemovingLastInactiveContext() { - ThreadLocalContext context1 = new ThreadLocalContext(RequestScoped.class); - ThreadLocalContext context2 = new ThreadLocalContext(RequestScoped.class); - ThreadLocalContext context3 = new ThreadLocalContext(RequestScoped.class); - - Contexts.add(context1, event); - Contexts.add(context2, event); - Contexts.add(context3, event); - Contexts.remove(context3); - assertFalse(Contexts.getInactiveContexts().contains(context3)); - } - - @Test - public void testRemovingActiveContextAndActivatingInactiveContext() { - ThreadLocalContext context1 = new ThreadLocalContext(SessionScoped.class); - ThreadLocalContext context2 = new ThreadLocalContext(SessionScoped.class); - ThreadLocalContext context3 = new ThreadLocalContext(SessionScoped.class); - - Contexts.add(context1, event); - Contexts.add(context2, event); - Contexts.add(context3, event); - assertTrue(context1.isActive()); - assertFalse(context2.isActive()); - assertFalse(context3.isActive()); - - Contexts.remove(context1); - assertTrue(context2.isActive()); - assertFalse(context3.isActive()); - - Contexts.remove(context2); - assertTrue(context3.isActive()); - } - - @Test - public void testRemovingActiveContext() { - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class); - - Contexts.add(context, event); - Contexts.remove(context); - assertEquals(0, Contexts.getActiveContexts().size()); - } - - @Test - public void testRemovingInactiveContext() { - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class); - - Contexts.add(new ThreadLocalContext(SessionScoped.class), event); - Contexts.add(context, event); - Contexts.remove(context); - assertEquals(0, Contexts.getInactiveContexts().size()); - } - - @Test - public void testClear() { - List list = new ArrayList(); - - list.add(new ThreadLocalContext(SessionScoped.class)); - list.add(new ThreadLocalContext(SessionScoped.class)); - list.add(new ThreadLocalContext(ApplicationScoped.class)); - - for (ThreadLocalContext context : list) { - Contexts.add(context, event); - } - - Contexts.clear(); - assertEquals(0, Contexts.getActiveContexts().size()); - assertEquals(0, Contexts.getInactiveContexts().size()); - - for (ThreadLocalContext context : list) { - assertFalse(context.isActive()); - } - } - - @Test - public void testAdd() { - Contexts.add(new ThreadLocalContext(SessionScoped.class), event); - assertEquals(1, Contexts.getActiveContexts().size()); - } - - @Test - public void testAddingRepeatedScopeType() { - Contexts.add(new ThreadLocalContext(SessionScoped.class), event); - assertEquals(1, Contexts.getActiveContexts().size()); - assertEquals(0, Contexts.getInactiveContexts().size()); - - Contexts.add(new ThreadLocalContext(SessionScoped.class), event); - assertEquals(1, Contexts.getActiveContexts().size()); - assertEquals(1, Contexts.getInactiveContexts().size()); - } - - @Test - public void testAddingRepeatedScopeInstance() { - ThreadLocalContext context1 = new ThreadLocalContext(SessionScoped.class); - ThreadLocalContext context2 = new ThreadLocalContext(SessionScoped.class); - - Contexts.add(context1, event); - Contexts.add(context2, event); - - assertTrue(context1.isActive()); - assertFalse(context2.isActive()); - - assertEquals(1, Contexts.getActiveContexts().size()); - assertEquals(1, Contexts.getInactiveContexts().size()); - } - - @Test - public void testIsActive() { - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class); - - Contexts.add(context, event); - assertTrue(context.isActive()); - } - - @Test - public void testIsInactive() { - ThreadLocalContext context = new ThreadLocalContext(ViewScoped.class); - - Contexts.add(new ThreadLocalContext(ViewScoped.class), event); - Contexts.add(context, event); - assertFalse(context.isActive()); - } - - @Test - public void testAddWithEventNotNull() { - event = createMock(AfterBeanDiscovery.class); - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class); - event.addContext(context); - expectLastCall(); - replay(event); - - Contexts.add(context, event); - assertEquals(1, Contexts.getActiveContexts().size()); - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalContextTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalContextTest.java deleted file mode 100644 index 21220e6..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalContextTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.context; - -import static org.easymock.EasyMock.expect; -import static org.junit.Assert.fail; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.util.Set; - -import javax.enterprise.context.ContextNotActiveException; -import javax.enterprise.context.spi.CreationalContext; -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.InjectionPoint; -import javax.inject.Scope; - -import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.easymock.PowerMock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ Bean.class }) -public class ThreadLocalContextTest { - - private ThreadLocalContext context; - - @Before - public void before() { - context = new ThreadLocalContext(Scope.class); - } - - @Test - public void testContextNotActive() { - try { - context.setActive(false); - context.get(null); - fail(); - } catch (ContextNotActiveException exception) { - } - } - - @SuppressWarnings({ "unchecked" }) - @Test - public void testStoreContainsInstance() { - String instance = "instance"; - - ContextStore store = PowerMock.createMock(ContextStore.class); - expect(store.get(EasyMock.anyObject(String.class))).andReturn(instance); - expect(store.contains(EasyMock.anyObject(String.class))).andReturn(true); - - ThreadLocal threadLocal = PowerMock.createMock(ThreadLocal.class); - expect(threadLocal.get()).andReturn(store).times(4); - - Whitebox.setInternalState(context, "threadLocal", threadLocal); - - Bean contextual = new MyBean(); - PowerMock.replayAll(threadLocal, store); - - context.setActive(true); - Assert.assertEquals(instance, context.get(contextual)); - } - - @SuppressWarnings("unchecked") - @Test - public void testStoreDoesNotContainsInstance() { - String instance = "instance"; - - ContextStore store = PowerMock.createMock(ContextStore.class); - expect(store.get(EasyMock.anyObject(String.class))).andReturn(instance); - expect(store.contains(EasyMock.anyObject(String.class))).andReturn(false).times(1); - - ThreadLocal threadLocal = PowerMock.createMock(ThreadLocal.class); - expect(threadLocal.get()).andReturn(store).times(8); - - Whitebox.setInternalState(context, "threadLocal", threadLocal); - - Bean contextual = new MyBean(); - - CreationalContext creationalContext = PowerMock.createMock(CreationalContext.class); - store.put("java.lang.String", instance); - - PowerMock.replayAll(threadLocal, store); - - context.setActive(true); - Assert.assertEquals(instance, context.get(contextual, creationalContext)); - } - - @Test - public void testStoreDoesNotContainsInstanceAndCreationalContextIsNull() { - String instance = "instance"; - - ContextStore store = PowerMock.createMock(ContextStore.class); - expect(store.get(EasyMock.anyObject(String.class))).andReturn(instance); - expect(store.contains(EasyMock.anyObject(String.class))).andReturn(false); - - @SuppressWarnings("unchecked") - ThreadLocal threadLocal = PowerMock.createMock(ThreadLocal.class); - expect(threadLocal.get()).andReturn(store).times(4); - - Whitebox.setInternalState(context, "threadLocal", threadLocal); - - Bean contextual = new MyBean(); - PowerMock.replayAll(threadLocal, store); - - context.setActive(true); - Assert.assertNull(context.get(contextual)); - } - - @Test - public void testContextStoreIsNull() { - String instance = "instance"; - - @SuppressWarnings("unchecked") - ThreadLocal threadLocal = PowerMock.createMock(ThreadLocal.class); - expect(threadLocal.get()).andReturn(null); - threadLocal.set(EasyMock.anyObject(ContextStore.class)); - PowerMock.expectLastCall(); - - ContextStore store = PowerMock.createMock(ContextStore.class); - expect(store.get(EasyMock.anyObject(String.class))).andReturn(instance); - expect(threadLocal.get()).andReturn(store).times(4); - expect(store.contains(EasyMock.anyObject(String.class))).andReturn(true); - - Whitebox.setInternalState(context, "threadLocal", threadLocal); - - Bean contextual = new MyBean(); - PowerMock.replayAll(threadLocal, store); - - context.setActive(true); - Assert.assertEquals(instance, context.get(contextual)); - } - - class MyBean implements Bean { - - @Override - public String create(CreationalContext creationalContext) { - return "instance"; - } - - @Override - public void destroy(String instance, CreationalContext creationalContext) { - } - - @Override - public Set getTypes() { - return null; - } - - @Override - public Set getQualifiers() { - return null; - } - - @Override - public Class getScope() { - return null; - } - - @Override - public String getName() { - return null; - } - - @Override - public Set> getStereotypes() { - return null; - } - - @Override - public Class getBeanClass() { - return String.class; - } - - @Override - public boolean isAlternative() { - return false; - } - - @Override - public boolean isNullable() { - return false; - } - - @Override - public Set getInjectionPoints() { - return null; - } - - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java deleted file mode 100644 index 3c58a6d..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package br.gov.frameworkdemoiselle.internal.implementation; - -import static org.easymock.EasyMock.expect; -import static org.junit.Assert.assertTrue; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replay; - -import java.util.Locale; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import br.gov.frameworkdemoiselle.DemoiselleException; -import br.gov.frameworkdemoiselle.util.Beans; - -/** - * @author SERPRO - * @see DefaultAuthenticator - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(Beans.class) -public class DefaultAuthenticatorTest { - - private DefaultAuthenticator authenticator; - - @Before - public void setUp() throws Exception { - authenticator = new DefaultAuthenticator(); - - mockStatic(Beans.class); - - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); - - replay(Beans.class); - } - - @After - public void tearDown() { - authenticator = null; - } - - @Test - public void testAuthenticate() { - try { - authenticator.authenticate(); - } catch (Exception e) { - assertTrue(e instanceof DemoiselleException); - } - } - - @Test(expected = DemoiselleException.class) - public void testUnAuthenticate() { - authenticator.unAuthenticate(); - } - - @Test(expected = DemoiselleException.class) - public void testGetUser() { - authenticator.getUser(); - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java deleted file mode 100644 index f673bca..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package br.gov.frameworkdemoiselle.internal.implementation; - -import static org.easymock.EasyMock.expect; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replay; - -import java.util.Locale; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import br.gov.frameworkdemoiselle.DemoiselleException; -import br.gov.frameworkdemoiselle.util.Beans; - -/** - * @author SERPRO - * @see DefaultAuthorizer - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(Beans.class) -public class DefaultAuthorizerTest { - - private DefaultAuthorizer authorizer; - - @Before - public void setUp() throws Exception { - authorizer = new DefaultAuthorizer(); - - mockStatic(Beans.class); - - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); - - replay(Beans.class); - } - - @After - public void tearDown() { - authorizer = null; - } - - @Test(expected = DemoiselleException.class) - public void testHasRole() { - authorizer.hasRole(null); - } - - @Test(expected = DemoiselleException.class) - public void testHasPermission() { - authorizer.hasPermission(null, null); - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java deleted file mode 100644 index 9031ef8..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.implementation; - -import static org.easymock.EasyMock.expect; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replay; - -import java.util.Locale; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import br.gov.frameworkdemoiselle.DemoiselleException; -import br.gov.frameworkdemoiselle.util.Beans; - -/** - * @author SERPRO - * @see DefaultTransaction - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(Beans.class) -public class DefaultTransactionTest { - - private DefaultTransaction tx; - - @Before - public void setUp() throws Exception { - tx = new DefaultTransaction(); - - mockStatic(Beans.class); - - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); - - replay(Beans.class); - } - - @After - public void tearDown() { - tx = null; - } - - @Test(expected=DemoiselleException.class) - public void testBegin() { - tx.begin(); - } - - @Test(expected=DemoiselleException.class) - public void testCommit() { - tx.commit(); - } - - @Test(expected=DemoiselleException.class) - public void testIsActive() { - tx.isActive(); - } - - @Test(expected=DemoiselleException.class) - public void testIsMarkedRollback() { - tx.isMarkedRollback(); - } - - @Test(expected=DemoiselleException.class) - public void testRollback() { - tx.rollback(); - } - - @Test(expected=DemoiselleException.class) - public void testSetRollbackOnly() { - tx.setRollbackOnly(); - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImplTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImplTest.java deleted file mode 100644 index f7ed8be..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImplTest.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.implementation; - -import static org.easymock.EasyMock.expect; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replayAll; - -import java.util.Locale; - -import junit.framework.Assert; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.easymock.PowerMock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.slf4j.Logger; - -import br.gov.frameworkdemoiselle.message.Message; -import br.gov.frameworkdemoiselle.message.MessageContext; -import br.gov.frameworkdemoiselle.message.SeverityType; -import br.gov.frameworkdemoiselle.util.Beans; -import br.gov.frameworkdemoiselle.util.ResourceBundle; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ Beans.class, ResourceBundle.class }) -public class MessageContextImplTest { - - MessageContext messageContext; - - Message m1; - - private ResourceBundle bundle; - - @SuppressWarnings("unused") - @Before - public void before() { - messageContext = new MessageContextImpl(); - - Locale locale = Locale.getDefault(); - - mockStatic(Beans.class); - expect(Beans.getReference(Locale.class)).andReturn(locale).anyTimes(); - - expect(Beans.getReference(ResourceBundle.class)).andReturn(bundle).anyTimes(); - replayAll(Beans.class); - - Logger logger = PowerMock.createMock(Logger.class); - - m1 = new Message() { - - private String key = "m1.message"; - - private String resourceName = "messages"; - - private Locale locale = Locale.getDefault(); - - private SeverityType severityType = SeverityType.INFO; - - private Object[] parameters = {}; - - public String getText() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public Locale getLocale() { - return locale; - } - - public void setLocale(Locale locale) { - this.locale = locale; - } - - public SeverityType getSeverity() { - return severityType; - } - - public void setSeverityType(SeverityType severityType) { - this.severityType = severityType; - } - - public Object[] getParameters() { - return parameters; - } - - public Message setParameters(Object[] parameters) { - this.parameters = parameters; - return this; - } - - public String getStringMessage() { - return "stringMessage"; - } - }; - } - - @Test - public void testAddMessage() { - messageContext.add(m1); - Assert.assertTrue(messageContext.getMessages().size() == 1); - Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(m1.getText())); - Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(m1.getSeverity())); - } - - @Test - public void testClearMessages() { - Assert.assertTrue(messageContext.getMessages().isEmpty()); - - messageContext.add(m1); - messageContext.add(m1, (Object[]) null); - - Assert.assertTrue(messageContext.getMessages().size() == 2); - - messageContext.clear(); - - Assert.assertTrue(messageContext.getMessages().isEmpty()); - } - - @Test - public void testGetMessages() { - Assert.assertNotNull(messageContext.getMessages()); - Assert.assertTrue(messageContext.getMessages().isEmpty()); - - messageContext.add("key1"); - Assert.assertTrue(messageContext.getMessages().size() == 1); - - messageContext.add("key2"); - Assert.assertTrue(messageContext.getMessages().size() == 2); - - Assert.assertTrue(messageContext.getMessages().get(0).getText().equals("key1")); - Assert.assertTrue(messageContext.getMessages().get(1).getText().equals("key2")); - } - - // @Test - // public void testAddMessageObjectArray() { - // Object[] param = { "1", "2" }; - // messageContext.add(m1, param); - - // Assert.assertTrue(messageContext.getMessages().size() == 1); - // Assert.assertTrue(messageContext.getMessages().contains(m1)); - // Assert.assertNotNull(messageContext.getMessages().get(0).getParameters()); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); - // } - - // @Test - // public void testAddStringObjectArray() { - // String key = "my.key"; - // Object[] param = { "1", "2" }; - // messageContext.add(key, param); - // - // Assert.assertTrue(messageContext.getMessages().size() == 1); - // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); - // } - // - // @Test - // public void testAddStringLocaleObjectArray() { - // String key = "my.key"; - // Object[] param = { "1", "2" }; - // Locale locale = Locale.CANADA_FRENCH; - // messageContext.add(key, locale, param); - // - // Assert.assertTrue(messageContext.getMessages().size() == 1); - // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); - // Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); - // } - // - // @Test - // public void testAddStringLocaleSeverityTypeObjectArray() { - // String key = "my.key"; - // Object[] param = { "1", "2" }; - // Locale locale = Locale.CANADA_FRENCH; - // SeverityType severity = SeverityType.ERROR; - // messageContext.add(key, locale, severity, param); - // - // Assert.assertTrue(messageContext.getMessages().size() == 1); - // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); - // Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); - // Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(severity)); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); - // } - // - // @Test - // public void testAddStringLocaleSeverityTypeStringObjectArray() { - // String key = "my.key"; - // Object[] param = { "1", "2" }; - // Locale locale = Locale.CANADA_FRENCH; - // SeverityType severity = SeverityType.ERROR; - // String resource = "myresourcename"; - // messageContext.add(key, locale, severity, resource, param); - // - // Assert.assertTrue(messageContext.getMessages().size() == 1); - // Assert.assertTrue(messageContext.getMessages().get(0).getText().equals(key)); - // Assert.assertTrue(messageContext.getMessages().get(0).getLocale().equals(locale)); - // Assert.assertTrue(messageContext.getMessages().get(0).getSeverity().equals(severity)); - // Assert.assertTrue(messageContext.getMessages().get(0).getResourceName().equals(resource)); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[0] == param[0]); - // Assert.assertTrue(messageContext.getMessages().get(0).getParameters()[1] == param[1]); - // } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationContextImplTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationContextImplTest.java deleted file mode 100644 index b78b6c2..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationContextImplTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.implementation; - -import static org.easymock.EasyMock.expect; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replayAll; - -import java.util.HashMap; -import java.util.Map; - -import org.easymock.EasyMock; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.easymock.PowerMock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; - -import br.gov.frameworkdemoiselle.internal.configuration.PaginationConfig; -import br.gov.frameworkdemoiselle.pagination.Pagination; -import br.gov.frameworkdemoiselle.pagination.PaginationContext; -import br.gov.frameworkdemoiselle.util.Beans; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(Beans.class) -public class PaginationContextImplTest { - - private PaginationContext context; - - private PaginationConfig config = new PaginationConfig(); - - private Pagination pagination; - - public void setUp() { - context = new PaginationContextImpl(); - - PaginationConfig config = PowerMock.createMock(PaginationConfig.class); - EasyMock.expect(config.getPageSize()).andReturn(10).anyTimes(); - EasyMock.replay(config); - - Whitebox.setInternalState(context, "config", config); - Whitebox.setInternalState(context, "cache", getInitialMap()); - } - - @After - public void tearDown() { - context = null; - } - - private Map, Pagination> getInitialMap() { - Map, Pagination> map = new HashMap, Pagination>(); - pagination = new PaginationImpl(); - map.put(getClass(), pagination); - - return map; - } - - @Test - public void testNullPaginationConfig() { - context = new PaginationContextImpl(); - - mockStatic(Beans.class); - expect(Beans.getReference(PaginationConfig.class)).andReturn(config).anyTimes(); - replayAll(Beans.class); - - assertNotNull(context.getPagination(Object.class, true)); - } - - @Test - public void testGetPaginationWithoutCreateParameter() { - setUp(); - - assertEquals(pagination, context.getPagination(getClass())); - assertNull(context.getPagination(Object.class)); - } - - @Test - public void testGetPaginationWithCreateParameterTrueValued() { - setUp(); - - assertEquals(pagination, context.getPagination(getClass(), true)); - assertNotNull(context.getPagination(Object.class, true)); - } - - @Test - public void testGetPaginationWithCreateParameterFalseValued() { - setUp(); - - assertEquals(pagination, context.getPagination(getClass(), false)); - assertNull(context.getPagination(Object.class, false)); - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationImplTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationImplTest.java deleted file mode 100644 index 932f2b7..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationImplTest.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.implementation; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import br.gov.frameworkdemoiselle.pagination.Pagination; -import br.gov.frameworkdemoiselle.util.Strings; - -/** - * @author SERPRO - */ - -public class PaginationImplTest { - - private Pagination pagination; - - @Before - public void setUp() { - pagination = new PaginationImpl(); - } - - @After - public void tearDown() { - pagination = null; - } - - @Test - public void testConstructor() { - assertEquals(0, pagination.getCurrentPage()); - assertEquals(0, pagination.getTotalResults()); - assertEquals(0, pagination.getTotalPages()); - assertEquals(0, pagination.getFirstResult()); - } - - @Test - public void testCurrentPageProperty() { - pagination.setCurrentPage(0); - assertEquals(0, pagination.getCurrentPage()); - - pagination.setCurrentPage(1); - assertEquals(1, pagination.getCurrentPage()); - } - - @Test - public void testPageSizeProperty() { - pagination.setPageSize(0); - assertEquals(0, pagination.getPageSize()); - - pagination.setPageSize(1); - assertEquals(1, pagination.getPageSize()); - } - - @Test - public void testTotalResultsProperty() { - pagination.setTotalResults(0); - assertEquals(0, pagination.getTotalResults()); - - pagination.setTotalResults(1); - assertEquals(1, pagination.getTotalResults()); - } - - @Test - public void testTotalPagesWhenTotalResultsChanges() { - pagination.setPageSize(10); - - pagination.setTotalResults(0); - assertEquals(0, pagination.getTotalPages()); - - pagination.setTotalResults(9); - assertEquals(1, pagination.getTotalPages()); - - pagination.setTotalResults(10); - assertEquals(1, pagination.getTotalPages()); - - pagination.setTotalResults(11); - assertEquals(2, pagination.getTotalPages()); - } - - @Test - public void testIndexOutOfBoundsException() { - try { - pagination.setCurrentPage(-1); - fail(); - } catch (IndexOutOfBoundsException cause) { - } - - try { - pagination.setFirstResult(-1); - fail(); - } catch (IndexOutOfBoundsException cause) { - } - - try { - pagination.setPageSize(-1); - fail(); - } catch (IndexOutOfBoundsException cause) { - } - - try { - pagination.setTotalResults(-1); - fail(); - } catch (IndexOutOfBoundsException cause) { - } - - try { - pagination.setTotalResults(1); - pagination.setFirstResult(1); - fail(); - } catch (IndexOutOfBoundsException cause) { - } - - try { - pagination.setTotalResults(1); - pagination.setFirstResult(2); - fail(); - } catch (IndexOutOfBoundsException cause) { - } - - try { - pagination.setPageSize(2); - pagination.setTotalResults(3); - pagination.setCurrentPage(2); - fail(); - } catch (IndexOutOfBoundsException cause) { - } - - try { - pagination.setPageSize(2); - pagination.setTotalResults(3); - pagination.setCurrentPage(3); - fail(); - } catch (IndexOutOfBoundsException cause) { - } - - try { - pagination.setTotalResults(0); - pagination.setFirstResult(0); - } catch (IndexOutOfBoundsException cause) { - fail(); - } - } - - @Test - public void testTotalPagesWhenPageSizeChanges() { - pagination.setTotalResults(10); - - pagination.setPageSize(0); - assertEquals(0, pagination.getTotalPages()); - - pagination.setPageSize(9); - assertEquals(2, pagination.getTotalPages()); - - pagination.setPageSize(10); - assertEquals(1, pagination.getTotalPages()); - - pagination.setPageSize(11); - assertEquals(1, pagination.getTotalPages()); - } - - @Test - public void testCurrentPageWhenPageSizeChanges() { - pagination.setTotalResults(10); - - pagination.setPageSize(5); - pagination.setCurrentPage(1); - pagination.setPageSize(0); - assertEquals(0, pagination.getCurrentPage()); - - pagination.setPageSize(5); - pagination.setCurrentPage(1); - pagination.setPageSize(9); - assertEquals(1, pagination.getCurrentPage()); - - pagination.setPageSize(5); - pagination.setCurrentPage(1); - pagination.setPageSize(10); - assertEquals(0, pagination.getCurrentPage()); - - pagination.setPageSize(5); - pagination.setCurrentPage(0); - pagination.setPageSize(11); - assertEquals(0, pagination.getCurrentPage()); - } - - @Test - public void testCurrentPageWhenTotalResultsChanges() { - pagination.setPageSize(10); - - pagination.setTotalResults(11); - pagination.setCurrentPage(1); - pagination.setTotalResults(0); - assertEquals(0, pagination.getCurrentPage()); - - pagination.setTotalResults(11); - pagination.setCurrentPage(1); - pagination.setTotalResults(9); - assertEquals(0, pagination.getCurrentPage()); - - pagination.setTotalResults(11); - pagination.setCurrentPage(1); - pagination.setTotalResults(10); - assertEquals(0, pagination.getCurrentPage()); - - pagination.setTotalResults(12); - pagination.setCurrentPage(1); - pagination.setTotalResults(11); - assertEquals(1, pagination.getCurrentPage()); - } - - @Test - public void testCurrentPageWhenFirstResultChanges() { - pagination.setPageSize(10); - pagination.setTotalResults(100); - - pagination.setFirstResult(0); - assertEquals(0, pagination.getCurrentPage()); - - pagination.setFirstResult(1); - assertEquals(0, pagination.getCurrentPage()); - - pagination.setFirstResult(98); - assertEquals(9, pagination.getCurrentPage()); - - pagination.setFirstResult(99); - assertEquals(9, pagination.getCurrentPage()); - } - - @Test - public void testFirstResultWhenPageSizeChanges() { - pagination.setTotalResults(10); - - pagination.setPageSize(10); - pagination.setFirstResult(5); - pagination.setPageSize(0); - assertEquals(0, pagination.getFirstResult()); - - pagination.setPageSize(10); - pagination.setFirstResult(9); - pagination.setPageSize(1); - assertEquals(0, pagination.getFirstResult()); - } - - @Test - public void testFirstResultWhenTotalResultsChanges() { - pagination.setPageSize(10); - - pagination.setTotalResults(50); - pagination.setFirstResult(49); - pagination.setTotalResults(0); - assertEquals(0, pagination.getFirstResult()); - - pagination.setTotalResults(50); - pagination.setFirstResult(49); - pagination.setTotalResults(1); - assertEquals(0, pagination.getFirstResult()); - - pagination.setTotalResults(50); - pagination.setFirstResult(49); - pagination.setTotalResults(49); - assertEquals(40, pagination.getFirstResult()); - } - - @Test - public void testFirstResultWhenCurrentPageChanges() { - pagination.setPageSize(10); - pagination.setTotalResults(100); - - pagination.setCurrentPage(0); - assertEquals(0, pagination.getFirstResult()); - - pagination.setCurrentPage(1); - assertEquals(10, pagination.getFirstResult()); - - pagination.setCurrentPage(9); - assertEquals(90, pagination.getFirstResult()); - } - - @Test - public void testToStringFormat() { - assertEquals(Strings.toString(pagination), pagination.toString()); - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImplTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImplTest.java deleted file mode 100644 index 224a696..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImplTest.java +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.implementation; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replay; -import static org.powermock.api.easymock.PowerMock.replayAll; -import static org.powermock.reflect.Whitebox.setInternalState; - -import java.security.Principal; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import javax.enterprise.inject.spi.BeanManager; - -import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.easymock.PowerMock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap; -import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfig; -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; -import br.gov.frameworkdemoiselle.security.Authenticator; -import br.gov.frameworkdemoiselle.security.Authorizer; -import br.gov.frameworkdemoiselle.security.NotLoggedInException; -import br.gov.frameworkdemoiselle.util.Beans; -import br.gov.frameworkdemoiselle.util.ResourceBundle; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ Beans.class, ResourceBundle.class }) -public class SecurityContextImplTest { - - private SecurityContextImpl context; - - private SecurityConfig config; - - private ResourceBundle bundle; - - @Before - public void setUpConfig() { - context = new SecurityContextImpl(); - config = createMock(SecurityConfig.class); - - mockStatic(Beans.class); - expect(Beans.getReference(SecurityConfig.class)).andReturn(config).anyTimes(); - } - - @Test - public void testHasPermissionWithSecurityDisabled() { - expect(config.isEnabled()).andReturn(false); - replayAll(Beans.class, config); - - try { - assertTrue(context.hasPermission(null, null)); - } catch (NotLoggedInException e) { - fail(); - } - } - - public void mockGetAuthenticator() { - Class cache = AuthenticatorImpl.class; - List> cacheList = new ArrayList>(); - cacheList.add(cache); - - AuthenticatorBootstrap bootstrap = PowerMock.createMock(AuthenticatorBootstrap.class); - - expect(Beans.getReference(AuthenticatorBootstrap.class)).andReturn(bootstrap).anyTimes(); - expect(config.getAuthenticatorClass()).andReturn(null).anyTimes(); - expect(bootstrap.getCache()).andReturn(cacheList); - expect(Beans.getReference(AuthenticatorImpl.class)).andReturn(new AuthenticatorImpl()); - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes(); - } - - @Test - public void testHasPermissionWithSecurityEnabledAndNotLoggedIn() { - mockGetAuthenticator(); - - expect(config.isEnabled()).andReturn(true).anyTimes(); - replayAll(Beans.class, config); - - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); - - try { - context.hasPermission(null, null); - fail(); - } catch (NotLoggedInException e) { - assertTrue(e.getMessage().equals(bundle.getString("user-not-authenticated"))); - } - } - - // @Test - // public void testHasPermissionWithSecurityEnabledAndLoggedIn() { - // expect(config.isEnabled()).andReturn(true).anyTimes(); - // replay(config); - // - // loginSuccessfully(); - // - // Authorizer authorizer = createMock(Authorizer.class); - // expect(authorizer.hasPermission(null, null)).andReturn(true); - // - // setInternalState(context, "authorizer", authorizer); - // - // replay(authorizer); - // - // try { - // assertTrue(context.hasPermission(null, null)); - // } catch (NotLoggedInException e) { - // fail(); - // } - // } - - private void loginSuccessfully() { - Authenticator authenticator = createMock(Authenticator.class); - // expect(authenticator.authenticate()).andReturn(true); - - BeanManager manager = createMock(BeanManager.class); - expect(Beans.getBeanManager()).andReturn(manager); - manager.fireEvent(EasyMock.anyObject(Class.class)); - PowerMock.expectLastCall(); - - Principal user = createMock(Principal.class); - expect(authenticator.getUser()).andReturn(user).anyTimes(); - - setInternalState(context, "authenticator", authenticator); - - replayAll(authenticator, user, Beans.class, manager); - - context.login(); - assertTrue(context.isLoggedIn()); - } - - @Test - public void testHasRoleWithSecurityDisabled() { - expect(config.isEnabled()).andReturn(false); - replayAll(Beans.class, config); - - try { - assertTrue(context.hasRole(null)); - } catch (NotLoggedInException e) { - fail(); - } - } - - @Test - public void testHasRoleWithSecurityEnabledAndNotLoggedIn() { - mockGetAuthenticator(); - - expect(config.isEnabled()).andReturn(true).anyTimes(); - replayAll(Beans.class, config); - - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); - - try { - context.hasRole(null); - fail(); - } catch (NotLoggedInException e) { - assertTrue(e.getMessage().equals(bundle.getString("user-not-authenticated"))); - } - } - - // @Test - // public void testHasRoleWithSecurityEnabledAndLoggedIn() { - // expect(config.isEnabled()).andReturn(true).anyTimes(); - // replay(config); - // - // loginSuccessfully(); - // - // Authorizer authorizer = createMock(Authorizer.class); - // expect(authorizer.hasRole(null)).andReturn(true); - // - // setInternalState(context, "authorizer", authorizer); - // - // replay(authorizer); - // - // try { - // assertTrue(context.hasRole(null)); - // } catch (NotLoggedInException e) { - // fail(); - // } - // } - - @Test - public void testIsLoggedInWithSecurityEnabled() { - Authenticator authenticator = createMock(Authenticator.class); - expect(authenticator.getUser()).andReturn(null).anyTimes(); - expect(config.isEnabled()).andReturn(true).anyTimes(); - - setInternalState(context, "authenticator", authenticator); - - replayAll(config, authenticator); - - assertFalse(context.isLoggedIn()); - } - - @Test - public void testIsLoggedInWithSecurityDisabled() { - expect(config.isEnabled()).andReturn(false); - replayAll(config, Beans.class); - - assertTrue(context.isLoggedIn()); - } - - @Test - public void testLoginWithSecurityDisabled() { - expect(config.isEnabled()).andReturn(false).times(2); - replayAll(config, Beans.class); - context.login(); - - assertTrue(context.isLoggedIn()); - } - - // @Test - // public void testLoginWithAuthenticationFail() { - // Authenticator authenticator = createMock(Authenticator.class); - // - // expect(config.isEnabled()).andReturn(true).anyTimes(); - // expect(authenticator.getUser()).andReturn(null).anyTimes(); - // - // setInternalState(context, "authenticator", authenticator); - // - // replayAll(authenticator, config); - // - // context.login(); - // assertFalse(context.isLoggedIn()); - // } - - @Test - public void testLogOutWithSecurityDisabled() { - expect(config.isEnabled()).andReturn(false).times(2); - - replayAll(config, Beans.class); - - try { - context.logout(); - assertTrue(context.isLoggedIn()); - } catch (NotLoggedInException e) { - fail(); - } - } - - @Test - public void testLogOutWithoutPreviousLogin() { - Authenticator authenticator = createMock(Authenticator.class); - - expect(authenticator.getUser()).andReturn(null).anyTimes(); - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes(); - expect(config.isEnabled()).andReturn(true).anyTimes(); - - setInternalState(context, "authenticator", authenticator); - - replayAll(config, authenticator, Beans.class); - - bundle = ResourceBundleProducer.create("demoiselle-core-bundle"); - - try { - context.logout(); - fail(); - } catch (NotLoggedInException e) { - assertTrue(e.getMessage().equals(bundle.getString("user-not-authenticated"))); - } - } - - // @Test - // public void testLogOutAfterSuccessfulLogin() { - // expect(config.isEnabled()).andReturn(true).anyTimes(); - // - // Authenticator authenticator = createMock(Authenticator.class); - // authenticator.unAuthenticate(); - // PowerMock.expectLastCall(); - // - // Principal user = createMock(Principal.class); - // expect(authenticator.getUser()).andReturn(user); - // expect(authenticator.getUser()).andReturn(null); - // - // BeanManager manager = createMock(BeanManager.class); - // expect(Beans.getBeanManager()).andReturn(manager).times(2); - // manager.fireEvent(EasyMock.anyObject(Class.class)); - // PowerMock.expectLastCall().times(2); - // - // setInternalState(context, "authenticator", authenticator); - // - // replayAll(Beans.class, authenticator, user, manager, config); - // - // context.login(); - // context.logout(); - // - // assertFalse(context.isLoggedIn()); - // } - - @Test - public void testGetUserWhenSecurityIsDisabled() { - Authenticator authenticator = createMock(Authenticator.class); - expect(authenticator.getUser()).andReturn(null).anyTimes(); - expect(config.isEnabled()).andReturn(false).anyTimes(); - replay(config, authenticator, Beans.class); - - setInternalState(context, "authenticator", authenticator); - - assertNotNull(context.getCurrentUser()); - assertNotNull(context.getCurrentUser().getName()); - } - - @Test - public void testGetUserWhenSecurityIsEnabled() { - Authenticator authenticator = createMock(Authenticator.class); - expect(authenticator.getUser()).andReturn(null).anyTimes(); - expect(config.isEnabled()).andReturn(true); - replay(config, authenticator, Beans.class); - - setInternalState(context, "authenticator", authenticator); - - assertNull(context.getCurrentUser()); - } - - @Test - public void testGetUserWhenSecurityIsEnabledAndUserIsNotNull() { - Principal user = createMock(Principal.class); - - Authenticator authenticator = createMock(Authenticator.class); - expect(authenticator.getUser()).andReturn(user).anyTimes(); - expect(config.isEnabled()).andReturn(true).anyTimes(); - replay(config, user, authenticator, Beans.class); - - setInternalState(context, "authenticator", authenticator); - - assertEquals(context.getCurrentUser(), user); - } - - class AuthenticatorImpl implements Authenticator { - - private static final long serialVersionUID = 1L; - - @Override - public void authenticate() { - } - - @Override - public void unAuthenticate() { - } - - @Override - public Principal getUser() { - return null; - } - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionContextImplTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionContextImplTest.java deleted file mode 100644 index 3a5d522..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionContextImplTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.implementation; - -import static org.easymock.EasyMock.expect; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replayAll; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.Assert; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.easymock.PowerMock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import br.gov.frameworkdemoiselle.internal.bootstrap.TransactionBootstrap; -import br.gov.frameworkdemoiselle.internal.configuration.TransactionConfig; -import br.gov.frameworkdemoiselle.transaction.Transaction; -import br.gov.frameworkdemoiselle.transaction.TransactionContext; -import br.gov.frameworkdemoiselle.util.Beans; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ Beans.class, StrategySelector.class }) -public class TransactionContextImplTest { - - private TransactionContext context; - - private Transaction transaction; - - // @Test - // public void testGetTransactionNull() { - // context = new TransactionContextImpl(); - // - // Class cache = TransactionImpl.class; - // - // List> cacheList = new ArrayList>(); - // cacheList.add(cache); - // - // TransactionBootstrap bootstrap = PowerMock.createMock(TransactionBootstrap.class); - // TransactionConfig config = PowerMock.createMock(TransactionConfig.class); - // - // mockStatic(Beans.class); - // expect(Beans.getReference(TransactionBootstrap.class)).andReturn(bootstrap).anyTimes(); - // expect(Beans.getReference(TransactionConfig.class)).andReturn(config); - // expect(config.getTransactionClass()).andReturn(null).anyTimes(); - // expect(bootstrap.getCache()).andReturn(cacheList); - // expect(Beans.getReference(TransactionImpl.class)).andReturn(new TransactionImpl()); - // - // replayAll(Beans.class); - // - // transaction = context.getCurrentTransaction(); - // Assert.assertEquals(transaction.getClass(),TransactionImpl.class); - // } - - class TransactionImpl implements Transaction { - - private static final long serialVersionUID = 1L; - - @Override - public boolean isActive() { - return false; - } - - @Override - public boolean isMarkedRollback() { - return false; - } - - @Override - public void begin() { - } - - @Override - public void commit() { - } - - @Override - public void rollback() { - } - - @Override - public void setRollbackOnly() { - } - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfoTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfoTest.java deleted file mode 100644 index 9e488b6..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfoTest.java +++ /dev/null @@ -1,85 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.implementation; -// -//import org.junit.Assert; -//import org.junit.Test; -// -// -//public class TransactionInfoTest { -// -// private TransactionInfo transactionInfo = new TransactionInfo(); -// -// @Test -// public void testMarkAsOwner(){ -// transactionInfo.markAsOwner(); -// Assert.assertTrue(transactionInfo.isOwner()); -// } -// -// @Test -// public void testIncrementCounter() { -// int count = transactionInfo.getCounter(); -// -// transactionInfo.incrementCounter(); -// Assert.assertEquals(count+1, transactionInfo.getCounter()); -// -// transactionInfo.incrementCounter(); -// Assert.assertEquals(count+2, transactionInfo.getCounter()); -// } -// -// @Test -// public void testDecrementCounter() { -// int count = transactionInfo.getCounter(); -// -// transactionInfo.incrementCounter(); -// Assert.assertEquals(count+1, transactionInfo.getCounter()); -// -// transactionInfo.decrementCounter(); -// Assert.assertEquals(count, transactionInfo.getCounter()); -// } -// -// @Test -// public void testClear() { -// transactionInfo.incrementCounter(); -// transactionInfo.markAsOwner(); -// -// transactionInfo.clear(); -// -// Assert.assertEquals(0, transactionInfo.getCounter()); -// Assert.assertFalse(transactionInfo.isOwner()); -// } -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptorTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptorTest.java deleted file mode 100644 index 0e2826b..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptorTest.java +++ /dev/null @@ -1,341 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.interceptor; -// -//import static org.easymock.EasyMock.expect; -//import static org.easymock.EasyMock.verify; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.assertNull; -//import static org.junit.Assert.assertTrue; -//import static org.junit.Assert.fail; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -//import static org.powermock.api.easymock.PowerMock.replay; -//import static org.powermock.api.easymock.PowerMock.replayAll; -//import static org.powermock.api.easymock.PowerMock.verifyAll; -// -//import java.util.Locale; -// -//import javax.interceptor.InvocationContext; -// -//import org.easymock.EasyMock; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.api.easymock.PowerMock; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -//import org.slf4j.Logger; -// -//import br.gov.frameworkdemoiselle.DemoiselleException; -//import br.gov.frameworkdemoiselle.exception.ExceptionHandler; -//import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; -//import br.gov.frameworkdemoiselle.util.Beans; -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(Beans.class) -//public class ExceptionHandlerInterceptorTest { -// -// private ExceptionHandlerInterceptor interceptor; -// -// private InvocationContext context; -// -// private Logger logger; -// -// private CoreBootstrap coreBootstrap; -// -// class TestException extends DemoiselleException { -// -// private static final long serialVersionUID = 1L; -// -// public TestException(String message) { -// super(message); -// } -// } -// -// class ClassWithMethodsAnnotatedWithExceptionHandler { -// -// int times = 0; -// -// @ExceptionHandler -// public void methodWithExceptionHandlerAnotation(DemoiselleException cause) { -// times++; -// } -// -// @ExceptionHandler -// public void methodWithExceptionHandlerAnotationAndGenericException(Exception cause) { -// times++; -// } -// -// } -// -// class ClassWithoutMethodsAnnotatedWithExceptionHandler { -// -// public void methodWithoutExceptionHandlerAnotation(DemoiselleException cause) { -// } -// } -// -// class ClassWithMethodsAnnotatedWithExceptionHandlerAndThrowException { -// -// int times = 0; -// -// @ExceptionHandler -// public void methodWithExceptionHandlerAnotation(DemoiselleException cause) { -// times++; -// throw new RuntimeException(); -// } -// } -// -// class ClassWithMethodWithoutParameterAnnotatedWithExceptionHandler { -// -// @ExceptionHandler -// public void methodWithExceptionHandlerAnotation() { -// } -// -// } -// -// class ClassWithExceptionHandlerMethodThatRethrowException { -// -// int times = 0; -// -// @ExceptionHandler -// public void methodThatRethrowException(TestException cause) { -// times++; -// throw cause; -// } -// -// } -// -// @Before -// public void setUp() throws Exception { -// -// this.interceptor = new ExceptionHandlerInterceptor(); -// this.context = PowerMock.createMock(InvocationContext.class); -// this.coreBootstrap = PowerMock.createMock(CoreBootstrap.class); -// -// mockStatic(Beans.class); -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()).anyTimes(); -// expect(Beans.getReference(CoreBootstrap.class)).andReturn(this.coreBootstrap).anyTimes(); -// -// } -// -// @Test -// public void manageSuccessfully() throws Throwable { -// expect(this.context.proceed()).andReturn(null); -// expect(this.context.getTarget()).andReturn(null); -// replayAll(); -// assertEquals(null, this.interceptor.manage(this.context)); -// verify(); -// } -// -// @Test -// public void manageWithClassThatDoesNotContainHandleMethod() throws Exception { -// ClassWithoutMethodsAnnotatedWithExceptionHandler classWithoutException = new ClassWithoutMethodsAnnotatedWithExceptionHandler(); -// -// expect(this.context.getTarget()).andReturn(classWithoutException); -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); -// expect(this.coreBootstrap.isAnnotatedType(ClassWithoutMethodsAnnotatedWithExceptionHandler.class)).andReturn( -// true); -// -// replayAll(this.context, this.coreBootstrap, Beans.class); -// -// try { -// this.interceptor.manage(this.context); -// fail(); -// } catch (DemoiselleException e) { -// assertTrue(true); -// } -// -// verifyAll(); -// } -// -// @Test -// public void manageWithClassThatContainsHandleMethod() throws Exception { -// ClassWithMethodsAnnotatedWithExceptionHandler classWithException = new ClassWithMethodsAnnotatedWithExceptionHandler(); -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandler.class)).andReturn(true); -// -// replayAll(this.context, this.coreBootstrap, Beans.class); -// -// assertNull(this.interceptor.manage(this.context)); -// assertEquals(1, classWithException.times); -// verifyAll(); -// } -// -// @Test -// public void manageWithClassThatContainsParentExceptionHandleMethod() throws Exception { -// ClassWithMethodsAnnotatedWithExceptionHandler classWithException = new ClassWithMethodsAnnotatedWithExceptionHandler(); -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandler.class)).andReturn(true); -// replayAll(this.context, this.coreBootstrap, Beans.class); -// -// assertNull(this.interceptor.manage(this.context)); -// assertEquals(1, classWithException.times); -// verifyAll(); -// } -// -// @Test -// public void manageWithClassThatContainsHandleMethodWithDiferentException() throws Exception { -// ClassWithMethodsAnnotatedWithExceptionHandler classWithException = new ClassWithMethodsAnnotatedWithExceptionHandler(); -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); -// expect(this.context.proceed()).andThrow(new TestException("")); -// replay(this.context); -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandler.class)).andReturn(true); -// replayAll(this.context, this.coreBootstrap, Beans.class); -// -// try { -// this.interceptor.manage(this.context); -// fail(); -// } catch (TestException e) { -// assertEquals(0, classWithException.times); -// } -// -// verify(); -// } -// -// @Test -// public void manageWithClassThatContainsHandleMethodThatThrowsAnotherException() throws Exception { -// ClassWithMethodsAnnotatedWithExceptionHandlerAndThrowException classWithException = new ClassWithMethodsAnnotatedWithExceptionHandlerAndThrowException(); -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandlerAndThrowException.class)) -// .andReturn(true); -// replayAll(this.context, this.coreBootstrap, Beans.class); -// -// try { -// this.interceptor.manage(this.context); -// fail(); -// } catch (RuntimeException e) { -// assertEquals(1, classWithException.times); -// } -// -// verifyAll(); -// } -// -// @Test -// public void manageWithClassThatContainsHandleMethodsAndIsInvokedTwice() throws Exception { -// ClassWithMethodsAnnotatedWithExceptionHandler classWithException = new ClassWithMethodsAnnotatedWithExceptionHandler(); -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodsAnnotatedWithExceptionHandler.class)).andReturn(true) -// .anyTimes(); -// replayAll(this.context, this.coreBootstrap, Beans.class); -// -// assertNull(this.interceptor.manage(this.context)); -// assertEquals(1, classWithException.times); -// -// this.context = PowerMock.createMock(InvocationContext.class); -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); -// expect(this.context.proceed()).andThrow(new Exception("")); -// replayAll(this.context); -// -// assertNull(this.interceptor.manage(this.context)); -// assertEquals(2, classWithException.times); -// verifyAll(); -// -// } -// -// @Test -// public void manageWithClassThatContainsHandleMethodWithoutParameter() throws Exception { -// ClassWithMethodWithoutParameterAnnotatedWithExceptionHandler classWithException = new ClassWithMethodWithoutParameterAnnotatedWithExceptionHandler(); -// expect(this.context.getTarget()).andReturn(classWithException).anyTimes(); -// expect(this.context.proceed()).andThrow(new DemoiselleException("")); -// expect(this.coreBootstrap.isAnnotatedType(ClassWithMethodWithoutParameterAnnotatedWithExceptionHandler.class)) -// .andReturn(true); -// replayAll(this.context, this.coreBootstrap, Beans.class); -// -// try { -// this.interceptor.manage(this.context); -// fail(); -// } catch (DemoiselleException e) { -// assertTrue(true); -// } -// -// verifyAll(); -// } -// -// @Test -// public void manageHandlerMethodThatRethrowExpectedException() throws Exception { -// ClassWithExceptionHandlerMethodThatRethrowException testClass = new ClassWithExceptionHandlerMethodThatRethrowException(); -// expect(this.context.getTarget()).andReturn(testClass).anyTimes(); -// expect(this.context.proceed()).andThrow(new TestException("")); -// expect(this.coreBootstrap.isAnnotatedType(ClassWithExceptionHandlerMethodThatRethrowException.class)) -// .andReturn(true); -// replayAll(this.context, this.coreBootstrap, Beans.class); -// -// try { -// this.interceptor.manage(this.context); -// fail(); -// } catch (TestException e) { -// assertEquals(1, testClass.times); -// } -// -// verifyAll(); -// } -// -// /** -// * Tests an exception handler when the class that contains the method is a proxy. This is the case when using -// * injection. -// * -// * @throws Exception -// */ -// @Test -// public void manageHandlerMethodInsideProxyClass() throws Exception { -// // creates a proxy class -// ClassWithExceptionHandlerMethodThatRethrowException testClass = PowerMock -// .createNicePartialMockForAllMethodsExcept(ClassWithExceptionHandlerMethodThatRethrowException.class, -// "methodThatRethrowException"); -// expect(this.context.getTarget()).andReturn(testClass).anyTimes(); -// expect(this.context.proceed()).andThrow(new TestException("")); -// expect(this.coreBootstrap.isAnnotatedType(testClass.getClass())).andReturn(false); -// -// this.logger = PowerMock.createMock(Logger.class); -// this.logger.info(EasyMock.anyObject(String.class)); -// this.logger.debug(EasyMock.anyObject(String.class)); -// replayAll(testClass, this.context, this.coreBootstrap, logger, Beans.class); -// -// this.interceptor = new ExceptionHandlerInterceptor(); -// -// try { -// this.interceptor.manage(this.context); -// fail(); -// } catch (TestException e) { -// assertEquals(1, testClass.times); -// } -// } -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredPermissionInterceptorTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredPermissionInterceptorTest.java deleted file mode 100644 index 725fc3c..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredPermissionInterceptorTest.java +++ /dev/null @@ -1,407 +0,0 @@ -//package br.gov.frameworkdemoiselle.internal.interceptor; -// -//import static org.easymock.EasyMock.createMock; -//import static org.easymock.EasyMock.expect; -//import static org.easymock.EasyMock.expectLastCall; -//import static org.junit.Assert.fail; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -//import static org.powermock.api.easymock.PowerMock.replay; -// -//import java.util.Locale; -// -//import javax.enterprise.inject.Instance; -//import javax.interceptor.InvocationContext; -// -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -//import br.gov.frameworkdemoiselle.annotation.Name; -//import br.gov.frameworkdemoiselle.security.NotLoggedInException; -//import br.gov.frameworkdemoiselle.security.RequiredPermission; -//import br.gov.frameworkdemoiselle.security.SecurityContext; -//import br.gov.frameworkdemoiselle.security.SecurityException; -//import br.gov.frameworkdemoiselle.security.User; -//import br.gov.frameworkdemoiselle.util.Beans; -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(Beans.class) -//public class RequiredPermissionInterceptorTest { -// -// private RequiredPermissionInterceptor interceptor; -// -// private InvocationContext ic; -// -// private SecurityContext securityContext; -// -// class UnnamedClass { -// -// @RequiredPermission -// public void requiredPermissionWithoutDeclaredResourceAndOperation() { -// } -// -// @RequiredPermission(operation = "insert") -// public void requiredPermissionWithDeclaredOperation() { -// } -// -// @RequiredPermission(resource = "contact") -// public void requiredPermissionWithDeclaredResource() { -// } -// -// @RequiredPermission(resource = "contact", operation = "insert") -// public void requiredPermissionWithDeclaredResourceAndOperation() { -// } -// } -// -// @Name("contact2") -// class NamedClass { -// -// @RequiredPermission -// public void requiredPermissionWithoutDeclaredResourceAndOperation() { -// } -// -// @RequiredPermission(operation = "insert") -// public void requiredPermissionWithDeclaredOperation() { -// } -// -// @RequiredPermission(resource = "contact") -// public void requiredPermissionWithDeclaredResource() { -// } -// -// @RequiredPermission(resource = "contact", operation = "insert") -// public void requiredPermissionWithDeclaredResourceAndOperation() { -// } -// } -// -// @Name("contact2") -// class NamedClassWithNamedMethods { -// -// @Name("delete") -// @RequiredPermission -// public void requiredPermissionWithoutDeclaredResourceAndOperation() { -// } -// -// @Name("delete") -// @RequiredPermission(operation = "insert") -// public void requiredPermissionWithDeclaredOperation() { -// } -// -// @Name("delete") -// @RequiredPermission(resource = "contact") -// public void requiredPermissionWithDeclaredResource() { -// } -// -// @Name("delete") -// @RequiredPermission(resource = "contact", operation = "insert") -// public void requiredPermissionWithDeclaredResourceAndOperation() { -// } -// } -// -// @RequiredPermission -// class ClassAnnotedWithRequiredPermission { -// -// public void withoutRequiredPermissionAnnotation() { -// } -// -// @RequiredPermission(operation = "insert") -// public void requiredPermissionWithDeclaredOperation() { -// } -// } -// -// @Before -// public void setUp() throws Exception { -// @SuppressWarnings("unchecked") -// Instance securityContextInstance = createMock(Instance.class); -// -// User user = createMock(User.class); -// -// this.securityContext = createMock(SecurityContext.class); -// this.ic = createMock(InvocationContext.class); -// -// mockStatic(Beans.class); -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); -// expect(Beans.getReference(SecurityContext.class)).andReturn(this.securityContext); -// -// expect(user.getId()).andReturn("UserName").anyTimes(); -// expect(this.securityContext.getUser()).andReturn(user).anyTimes(); -// expect(securityContextInstance.get()).andReturn(securityContext).anyTimes(); -// expect(this.ic.proceed()).andReturn(null); -// replay(securityContextInstance, user, Beans.class); -// -// this.interceptor = new RequiredPermissionInterceptor(); -// } -// -// private void prepareMock(Object target, String methodName, String expectedResource, String expectedOperation, -// boolean hasPermission, boolean isLoggedUser) throws Exception { -// -// expect(this.securityContext.isLoggedIn()).andReturn(isLoggedUser).anyTimes(); -// -// this.securityContext.hasPermission(expectedResource, expectedOperation); -// -// if (isLoggedUser) { -// expectLastCall().andReturn(hasPermission); -// } else { -// expectLastCall().andThrow(new NotLoggedInException("")); -// } -// -// expect(this.ic.getTarget()).andReturn(target).anyTimes(); -// expect(this.ic.getMethod()).andReturn(target.getClass().getMethod(methodName)).anyTimes(); -// replay(this.ic, this.securityContext); -// } -// -// /* Testing UnnamedClass */ -// -// @Test -// public void testManageUnnamedClassAtRequiredPermissionWithoutDeclaredResourceAndOperationMethod() throws Exception { -// try { -// Object target = new UnnamedClass(); -// String methodName = "requiredPermissionWithoutDeclaredResourceAndOperation"; -// String expectedResource = target.getClass().getSimpleName(); -// String expectedOperation = methodName; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageUnnamedClassAtRequiredPermissionWithDeclaredOperationMethod() throws Exception { -// try { -// Object target = new UnnamedClass(); -// String methodName = "requiredPermissionWithDeclaredOperation"; -// String expectedResource = target.getClass().getSimpleName(); -// String expectedOperation = "insert"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageUnnamedClassAtRequiredPermissionWithDeclaredResourceMethod() throws Exception { -// try { -// Object target = new UnnamedClass(); -// String methodName = "requiredPermissionWithDeclaredResource"; -// String expectedResource = "contact"; -// String expectedOperation = methodName; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageUnnamedClassAtRequiredPermissionWithDeclaredResourceAndOperation() throws Exception { -// try { -// Object target = new UnnamedClass(); -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; -// String expectedResource = "contact"; -// String expectedOperation = "insert"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// /* Testing NamedClass */ -// -// @Test -// public void testManageNamedClassAtRequiredPermissionWithoutDeclaredResourceAndOperationMethod() throws Exception { -// try { -// Object target = new NamedClass(); -// String methodName = "requiredPermissionWithoutDeclaredResourceAndOperation"; -// String expectedResource = "contact2"; -// String expectedOperation = methodName; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageNamedClassAtRequiredPermissionWithDeclaredOperationMethod() throws Exception { -// try { -// Object target = new NamedClass(); -// String methodName = "requiredPermissionWithDeclaredOperation"; -// String expectedResource = "contact2"; -// String expectedOperation = "insert"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageNamedClassAtRequiredPermissionWithDeclaredResourceMethod() throws Exception { -// try { -// Object target = new NamedClass(); -// String methodName = "requiredPermissionWithDeclaredResource"; -// String expectedResource = "contact"; -// String expectedOperation = methodName; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageNamedClassAtRequiredPermissionWithDeclaredResourceAndOperation() throws Exception { -// try { -// Object target = new NamedClass(); -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; -// String expectedResource = "contact"; -// String expectedOperation = "insert"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// /* Testing NamedClassWithNamedMethods */ -// -// @Test -// public void testManageNamedClassWithNamedMethodsAtRequiredPermissionWithoutDeclaredResourceAndOperationMethod() -// throws Exception { -// try { -// Object target = new NamedClassWithNamedMethods(); -// String methodName = "requiredPermissionWithoutDeclaredResourceAndOperation"; -// String expectedResource = "contact2"; -// String expectedOperation = "delete"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageNamedClassWithNamedMethodsAtRequiredPermissionWithDeclaredOperationMethod() throws Exception { -// try { -// Object target = new NamedClassWithNamedMethods(); -// String methodName = "requiredPermissionWithDeclaredOperation"; -// String expectedResource = "contact2"; -// String expectedOperation = "insert"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageNamedClassWithNamedMethodsAtRequiredPermissionWithDeclaredResourceMethod() throws Exception { -// try { -// Object target = new NamedClassWithNamedMethods(); -// String methodName = "requiredPermissionWithDeclaredResource"; -// String expectedResource = "contact"; -// String expectedOperation = "delete"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageNamedClassWithNamedMethodsAtRequiredPermissionWithDeclaredResourceAndOperation() -// throws Exception { -// try { -// Object target = new NamedClassWithNamedMethods(); -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; -// String expectedResource = "contact"; -// String expectedOperation = "insert"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// /* Testing ClassAnnotedWithRequiredPermission */ -// -// @Test -// public void testManageClassAnnotedWithRequiredPermissionAtWithoutRequiredPermissionAnnotation() throws Exception { -// try { -// Object target = new ClassAnnotedWithRequiredPermission(); -// String methodName = "withoutRequiredPermissionAnnotation"; -// String expectedResource = target.getClass().getSimpleName(); -// String expectedOperation = methodName; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// @Test -// public void testManageClassAnnotedWithRequiredPermissionAtRequiredPermissionWithDeclaredOperation() -// throws Exception { -// try { -// Object target = new ClassAnnotedWithRequiredPermission(); -// String methodName = "requiredPermissionWithDeclaredOperation"; -// String expectedResource = target.getClass().getSimpleName(); -// String expectedOperation = "insert"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, true); -// -// interceptor.manage(this.ic); -// } catch (SecurityException cause) { -// fail(); -// } -// } -// -// /* Other tests */ -// -// @Test -// public void testManagePermissionNotAllowed() throws Exception { -// try { -// Object target = new UnnamedClass(); -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; -// String expectedResource = "contact"; -// String expectedOperation = "insert"; -// prepareMock(target, methodName, expectedResource, expectedOperation, false, true); -// -// interceptor.manage(this.ic); -// fail(); -// } catch (SecurityException cause) { -// } -// } -// -// @Test -// public void testUserNotLoggedIn() throws Exception { -// try { -// Object target = new UnnamedClass(); -// String methodName = "requiredPermissionWithDeclaredResourceAndOperation"; -// String expectedResource = "contact"; -// String expectedOperation = "insert"; -// prepareMock(target, methodName, expectedResource, expectedOperation, true, false); -// -// interceptor.manage(this.ic); -// fail(); -// } catch (SecurityException cause) { -// } -// } -// -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredRoleInterceptorTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredRoleInterceptorTest.java deleted file mode 100644 index 2d608fc..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredRoleInterceptorTest.java +++ /dev/null @@ -1,296 +0,0 @@ -//package br.gov.frameworkdemoiselle.internal.interceptor; -// -//import static org.easymock.EasyMock.expect; -//import static org.junit.Assert.fail; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -//import static org.powermock.api.easymock.PowerMock.replay; -// -//import java.util.Locale; -// -//import javax.enterprise.inject.Instance; -//import javax.interceptor.InvocationContext; -// -//import org.easymock.EasyMock; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -//import br.gov.frameworkdemoiselle.security.AuthorizationException; -//import br.gov.frameworkdemoiselle.security.NotLoggedInException; -//import br.gov.frameworkdemoiselle.security.RequiredRole; -//import br.gov.frameworkdemoiselle.security.SecurityContext; -//import br.gov.frameworkdemoiselle.security.User; -//import br.gov.frameworkdemoiselle.util.Beans; -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(Beans.class) -//public class RequiredRoleInterceptorTest { -// -// private RequiredRoleInterceptor interceptor; -// -// private InvocationContext ic; -// -// private SecurityContext securityContext; -// -// class ClassNotAnnoted { -// -// @RequiredRole("simpleRoleName") -// public void requiredRoleWithSingleRole() { -// } -// -// @RequiredRole({ "firstRole", "secondRole", "thirdRole", "fourthRole", "fifthRole" }) -// public void requiredRoleWithArrayOfRoles() { -// } -// -// @RequiredRole({ "firstRole, secondRole" }) -// public void requiredRoleWithArrayOfSingleRoleComma() { -// } -// -// @RequiredRole("firstRole, secondRole") -// public void requiredRoleWithSingleRoleComma() { -// } -// -// @RequiredRole("") -// public void requiredRoleWithEmptyValue() { -// } -// -// @RequiredRole({}) -// public void requiredRoleWithEmptyArray() { -// } -// -// @RequiredRole({ "" }) -// public void requiredRoleWithArrayOfEmptyString() { -// } -// -// public void methodNotAnnoted() { -// } -// } -// -// @RequiredRole("classRole") -// class ClassAnnotedWithRequiredRole { -// -// public void withoutRole() { -// } -// -// @RequiredRole("simpleRoleName") -// public void requiredRoleWithSingleRole() { -// } -// } -// -// @Before -// public void setUp() throws Exception { -// -// @SuppressWarnings("unchecked") -// Instance securityContextInstance = EasyMock.createMock(Instance.class); -// User user = EasyMock.createMock(User.class); -// -// this.securityContext = EasyMock.createMock(SecurityContext.class); -// this.ic = EasyMock.createMock(InvocationContext.class); -// -// mockStatic(Beans.class); -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); -// expect(Beans.getReference(SecurityContext.class)).andReturn(this.securityContext); -// -// expect(user.getId()).andReturn("UserName").anyTimes(); -// expect(this.securityContext.getUser()).andReturn(user).anyTimes(); -// expect(securityContextInstance.get()).andReturn(securityContext).anyTimes(); -// expect(this.ic.proceed()).andReturn(null); -// replay(securityContextInstance, user, Beans.class); -// -// this.interceptor = new RequiredRoleInterceptor(); -// } -// -// private void prepareMock(Object target, String methodName, String[] expectedRoles, boolean hasHole, -// boolean isLoggedUser) throws Exception { -// -// expect(this.securityContext.isLoggedIn()).andReturn(isLoggedUser).anyTimes(); -// -// for (String role : expectedRoles) { -// this.securityContext.hasRole(role); -// if (isLoggedUser) { -// EasyMock.expectLastCall().andReturn(hasHole); -// } else { -// EasyMock.expectLastCall().andThrow(new NotLoggedInException("")); -// } -// } -// -// expect(this.ic.getTarget()).andReturn(target).anyTimes(); -// expect(this.ic.getMethod()).andReturn(target.getClass().getMethod(methodName)).anyTimes(); -// replay(this.ic, this.securityContext); -// } -// -// // @Test -// // public void testManageClassNotAnnotedAtRequiredRoleWithSingleRole() throws Exception { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithSingleRole"; -// // String[] expectedRoles = { "simpleRoleName" }; -// // prepareMock(target, methodName, expectedRoles, true, true); -// // -// // interceptor.manage(this.ic); -// // } -// -// // @Test -// // public void testManageClassNotAnnotedAtRequiredRoleWithArrayOfRoles() throws Exception { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithArrayOfRoles"; -// // String[] expectedRoles = { "firstRole", "secondRole", "thirdRole", "fourthRole", "fifthRole" }; -// // prepareMock(target, methodName, expectedRoles, true, true); -// // -// // interceptor.manage(this.ic); -// // } -// -// // @Test -// // public void testManageClassNotAnnotedAtRequiredRoleWithArrayOfSingleRoleComma() throws Exception { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithArrayOfSingleRoleComma"; -// // String[] expectedRoles = { "firstRole, secondRole" }; -// // prepareMock(target, methodName, expectedRoles, true, true); -// // -// // interceptor.manage(this.ic); -// // } -// -// // @Test -// // public void testManageClassNotAnnotedAtRequiredRoleWithSingleRoleComma() throws Exception { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithSingleRoleComma"; -// // String[] expectedRoles = { "firstRole, secondRole" }; -// // prepareMock(target, methodName, expectedRoles, true, true); -// // -// // interceptor.manage(this.ic); -// // } -// -// // @Test -// // public void testManageClassNotAnnotedAtRequiredRoleWithEmptyValue() throws Exception { -// // try { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithEmptyValue"; -// // String[] expectedRoles = { "" }; -// // prepareMock(target, methodName, expectedRoles, false, true); -// // -// // interceptor.manage(this.ic); -// // fail(); -// // } catch (AuthorizationException cause) { -// // } -// // } -// -// // @Test -// // public void testManageClassNotAnnotedAtRequiredRoleWithEmptyArray() throws Exception { -// // try { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithEmptyArray"; -// // String[] expectedRoles = { "" }; -// // prepareMock(target, methodName, expectedRoles, false, true); -// // -// // interceptor.manage(this.ic); -// // fail(); -// // } catch (AuthorizationException cause) { -// // } -// // } -// -// // @Test -// // public void testManageClassNotAnnotedAtRequiredRoleWithArrayOfEmptyString() throws Exception { -// // try { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithArrayOfEmptyString"; -// // String[] expectedRoles = { "" }; -// // prepareMock(target, methodName, expectedRoles, false, true); -// // -// // interceptor.manage(this.ic); -// // fail(); -// // } catch (AuthorizationException cause) { -// // } -// // } -// -// // @Test -// // public void testManageClassNotAnnotedAtMethodNotAnnoted() throws Exception { -// // try { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "methodNotAnnoted"; -// // String[] expectedRoles = { "" }; -// // prepareMock(target, methodName, expectedRoles, false, true); -// // -// // interceptor.manage(this.ic); -// // fail(); -// // } catch (AuthorizationException cause) { -// // } -// // } -// -// // @Test -// // public void testManageClassAnnotedWithRequiredRoleAtWithoutRole() throws Exception { -// // Object target = new ClassAnnotedWithRequiredRole(); -// // String methodName = "withoutRole"; -// // String[] expectedRoles = { "classRole" }; -// // prepareMock(target, methodName, expectedRoles, true, true); -// // -// // interceptor.manage(this.ic); -// // } -// -// // @Test -// // public void testManageClassAnnotedWithRequiredRoleAtRequiredRoleWithSingleRole() throws Exception { -// // Object target = new ClassAnnotedWithRequiredRole(); -// // String methodName = "requiredRoleWithSingleRole"; -// // String[] expectedRoles = { "simpleRoleName" }; -// // prepareMock(target, methodName, expectedRoles, true, true); -// // -// // interceptor.manage(this.ic); -// // } -// -// // @Test -// // public void testDoesNotHaveSingleRole() throws Exception { -// // try { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithSingleRole"; -// // String[] expectedRoles = { "simpleRoleName" }; -// // prepareMock(target, methodName, expectedRoles, false, true); -// // -// // interceptor.manage(this.ic); -// // fail(); -// // } catch (AuthorizationException cause) { -// // } -// // } -// -// @Test -// public void testUserNotLoggedIn() throws Exception { -// try { -// Object target = new ClassNotAnnoted(); -// String methodName = "requiredRoleWithSingleRole"; -// String[] expectedRoles = { "simpleRoleName" }; -// prepareMock(target, methodName, expectedRoles, true, false); -// -// interceptor.manage(this.ic); -// fail(); -// } catch (NotLoggedInException cause) { -// } -// } -// -// // @Test -// // public void testDoesNotHaveOneOrMoreRolesOfArray() throws Exception { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithArrayOfRoles"; -// // String[] expectedRoles = { "thirdRole", "fourthRole", "fifthRole" }; -// // -// // expect(this.securityContext.hasRole("firstRole")).andReturn(false); -// // expect(this.securityContext.hasRole("secondRole")).andReturn(false); -// // -// // prepareMock(target, methodName, expectedRoles, true, true); -// // -// // interceptor.manage(this.ic); -// // } -// -// // @Test -// // public void testHasMoreRolesThenArray() throws Exception { -// // Object target = new ClassNotAnnoted(); -// // String methodName = "requiredRoleWithArrayOfRoles"; -// // String[] expectedRoles = { "thirdRole", "fourthRole", "fifthRole" }; -// // -// // expect(this.securityContext.hasRole("firstRole")).andReturn(false); -// // expect(this.securityContext.hasRole("secondRole")).andReturn(false); -// // expect(this.securityContext.hasRole("sixthRole")).andReturn(true); -// // -// // prepareMock(target, methodName, expectedRoles, true, true); -// // -// // interceptor.manage(this.ic); -// // } -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptorTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptorTest.java deleted file mode 100644 index 71875c3..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptorTest.java +++ /dev/null @@ -1,202 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.interceptor; -// -//import static org.easymock.EasyMock.expect; -//import static org.easymock.EasyMock.verify; -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.assertTrue; -//import static org.junit.Assert.fail; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -//import static org.powermock.api.easymock.PowerMock.replay; -//import static org.powermock.api.easymock.PowerMock.replayAll; -// -//import java.util.Locale; -// -//import javax.enterprise.inject.Instance; -//import javax.interceptor.InvocationContext; -// -//import org.easymock.EasyMock; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -//import br.gov.frameworkdemoiselle.DemoiselleException; -//import br.gov.frameworkdemoiselle.internal.implementation.TransactionInfo; -//import br.gov.frameworkdemoiselle.transaction.Transaction; -//import br.gov.frameworkdemoiselle.transaction.TransactionContext; -//import br.gov.frameworkdemoiselle.util.Beans; -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(Beans.class) -//public class TransactionalInterceptorTest { -// -// private TransactionalInterceptor interceptor; -// -// private InvocationContext ic; -// -// private Transaction transaction; -// -// private TransactionContext transactionContext; -// -// class ClassWithMethod { -// -// public void method() { -// System.out.println("test method"); -// } -// } -// -// @Before -// @SuppressWarnings("unchecked") -// public void setUp() throws Exception { -// Instance transactionInstance = EasyMock.createMock(Instance.class); -// Instance transactionInfoInstance = EasyMock.createMock(Instance.class); -// Instance transactionContextInstance = EasyMock.createMock(Instance.class); -// -// TransactionInfo transactionInfo = new TransactionInfo(); -// transaction = EasyMock.createMock(Transaction.class); -// this.transactionContext = EasyMock.createMock(TransactionContext.class); -// this.ic = EasyMock.createMock(InvocationContext.class); -// -// mockStatic(Beans.class); -// expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); -// expect(Beans.getReference(TransactionContext.class)).andReturn(transactionContext); -// expect(Beans.getReference(TransactionInfo.class)).andReturn(transactionInfo); -// -// expect(transactionInstance.get()).andReturn(transaction).anyTimes(); -// expect(transactionContextInstance.get()).andReturn(transactionContext).anyTimes(); -// expect(transactionInfoInstance.get()).andReturn(transactionInfo).anyTimes(); -// expect(transactionContext.getCurrentTransaction()).andReturn(transaction).anyTimes(); -// expect(this.ic.proceed()).andReturn(null); -// expect(this.ic.getMethod()).andReturn(ClassWithMethod.class.getMethod("method")); -// replayAll(Beans.class, this.ic, transactionContextInstance, transactionInfoInstance, transactionInstance, -// transactionContext); -// -// this.interceptor = new TransactionalInterceptor(); -// -// } -// -// @Test -// public void testManageWithInativeTransactionAndTransactionInterceptorBeginAndDoNotIsMarkedRollback() -// throws Exception { -// expect(this.transaction.isActive()).andReturn(false).times(1); -// expect(this.transaction.isActive()).andReturn(true).times(2); -// expect(this.transaction.isMarkedRollback()).andReturn(false).anyTimes(); -// this.transaction.begin(); -// this.transaction.commit(); -// replay(this.transaction); -// -// assertEquals(null, this.interceptor.manage(this.ic)); -// verify(); -// } -// -// @Test -// public void testManageWithInativeTransactionAndTransactionInterceptorBeginAndIsMarkedRollback() throws Exception { -// expect(this.transaction.isActive()).andReturn(false).times(1); -// expect(this.transaction.isActive()).andReturn(true).times(2); -// expect(this.transaction.isMarkedRollback()).andReturn(true).anyTimes(); -// this.transaction.begin(); -// this.transaction.rollback(); -// replay(this.transaction); -// -// assertEquals(null, this.interceptor.manage(this.ic)); -// verify(); -// } -// -// @Test -// public void testManageWithAtiveTransaction() throws Exception { -// expect(this.transaction.isActive()).andReturn(true).anyTimes(); -// replay(this.transaction); -// -// assertEquals(null, this.interceptor.manage(this.ic)); -// verify(); -// } -// -// @Test -// public void testManageWithAtiveTransactionButTheTransactionWasInative() throws Exception { -// expect(this.transaction.isActive()).andReturn(true).times(1); -// expect(this.transaction.isActive()).andReturn(false).times(2); -// replay(this.transaction); -// -// assertEquals(null, this.interceptor.manage(this.ic)); -// verify(); -// } -// -// @Test -// public void testManageWithAtiveTransactionAndMethodThrowExceptionAndDoNotIsMarkedRollback() throws Exception { -// expect(this.transaction.isActive()).andReturn(true).anyTimes(); -// expect(this.transaction.isMarkedRollback()).andReturn(false).anyTimes(); -// this.transaction.setRollbackOnly(); -// replay(this.transaction); -// -// this.ic = EasyMock.createMock(InvocationContext.class); -// expect(this.ic.proceed()).andThrow(new DemoiselleException("")); -// expect(this.ic.getMethod()).andReturn(ClassWithMethod.class.getMethod("method")); -// replay(this.ic); -// -// try { -// this.interceptor.manage(this.ic); -// fail(); -// } catch (DemoiselleException cause) { -// assertTrue(true); -// } -// verify(); -// } -// -// @Test -// public void testManageWithAtiveTransactionAndMethodThrowExceptionAndIsMarkedRollback() throws Exception { -// expect(this.transaction.isActive()).andReturn(true).anyTimes(); -// expect(this.transaction.isMarkedRollback()).andReturn(true).anyTimes(); -// this.transaction.setRollbackOnly(); -// replay(this.transaction); -// -// this.ic = EasyMock.createMock(InvocationContext.class); -// expect(this.ic.proceed()).andThrow(new DemoiselleException("")); -// expect(this.ic.getMethod()).andReturn(ClassWithMethod.class.getMethod("method")); -// replay(this.ic); -// -// try { -// this.interceptor.manage(this.ic); -// fail(); -// } catch (DemoiselleException cause) { -// assertTrue(true); -// } -// verify(); -// } -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LocaleProducer.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LocaleProducer.java new file mode 100644 index 0000000..733ad75 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LocaleProducer.java @@ -0,0 +1,15 @@ +package br.gov.frameworkdemoiselle.internal.producer; + +import java.util.Locale; + +import javax.enterprise.inject.Default; +import javax.enterprise.inject.Produces; + +public class LocaleProducer { + + @Default + @Produces + public Locale create() { + return Locale.getDefault(); + } +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducerTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducerTest.java deleted file mode 100644 index 514156d..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducerTest.java +++ /dev/null @@ -1,91 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.producer; -// -//import static org.easymock.EasyMock.createMock; -//import static org.easymock.EasyMock.expect; -//import static org.easymock.EasyMock.replay; -//import static org.junit.Assert.assertNotNull; -// -//import java.lang.reflect.Member; -// -//import javax.enterprise.inject.spi.InjectionPoint; -// -//import org.junit.Test; -//import org.slf4j.Logger; -// -//public class LoggerProducerTest { -// -// private Logger logger; -// -// @Test -// @SuppressWarnings({ "unchecked", "rawtypes" }) -// public void testCreateInjectionPoint() { -// -// Member member = createMock(Member.class); -// expect(member.getDeclaringClass()).andReturn((Class) this.getClass()); -// replay(member); -// -// InjectionPoint injectionPoint = createMock(InjectionPoint.class); -// expect(injectionPoint.getMember()).andReturn(member); -// replay(injectionPoint); -// -// logger = LoggerProducer.create(injectionPoint); -// assertNotNull(logger); -// } -// -// @Test -// public void testCreateWithNullInjectionPoint() { -// logger = LoggerProducer.create((InjectionPoint) null); -// assertNotNull(logger); -// } -// -// @Test -// public void testCreateClass() { -// logger = LoggerProducer.create(this.getClass()); -// assertNotNull(logger); -// } -// -// // We don't need to instantiate LoggerProducer class. But if we don't get in this way, we'll not get 100% on -// // cobertura. -// @Test -// public void testLoggerFactoryDiferentNull() { -// @SuppressWarnings("unused") -// LoggerProducer loggerProducer = new LoggerProducer(); -// } -// -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ResourceBundleProducerTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ResourceBundleProducerTest.java deleted file mode 100644 index e26b501..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/producer/ResourceBundleProducerTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.producer; - -import static org.easymock.EasyMock.expect; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replay; - -import java.util.Locale; - -import javax.enterprise.inject.spi.Annotated; -import javax.enterprise.inject.spi.InjectionPoint; - -import org.easymock.EasyMock; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import br.gov.frameworkdemoiselle.annotation.Name; -import br.gov.frameworkdemoiselle.util.Beans; -import br.gov.frameworkdemoiselle.util.ResourceBundle; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(Beans.class) -public class ResourceBundleProducerTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - mockStatic(Beans.class); - - expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); - - replay(Beans.class); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testResourceBundleFactory() { - ResourceBundleProducer factory = new ResourceBundleProducer(); - Assert.assertNotNull(factory); - } - - @Test - public void testCreateNullInjectionPoint() { - ResourceBundleProducer factory = new ResourceBundleProducer(); - ResourceBundle resourceBundle = factory.createDefault((InjectionPoint) null); - Assert.assertNotNull(resourceBundle); - } - - @Test - public void testCreateInjectionPointNameAnnoted() { - Name name = EasyMock.createMock(Name.class); - expect(name.value()).andReturn("demoiselle-core-bundle"); - replay(name); - - Annotated annotated = EasyMock.createMock(Annotated.class); - expect(annotated.getAnnotation(Name.class)).andReturn(name).anyTimes(); - expect(annotated.isAnnotationPresent(Name.class)).andReturn(true).anyTimes(); - replay(annotated); - - InjectionPoint ip = EasyMock.createMock(InjectionPoint.class); - expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); - replay(ip); - - ResourceBundleProducer factory = new ResourceBundleProducer(); - Assert.assertNotNull(factory.createDefault(ip)); - } - - // @Test - // public void testCreateInjectionPointNameUnannoted() { - // Annotated annotated = EasyMock.createMock(Annotated.class); - // expect(annotated.isAnnotationPresent(Name.class)).andReturn(false).anyTimes(); - // replay(annotated); - // - // InjectionPoint ip = EasyMock.createMock(InjectionPoint.class); - // expect(ip.getAnnotated()).andReturn(annotated).anyTimes(); - // replay(ip); - // - // ResourceBundleProducer factory = new ResourceBundleProducer(); - // Assert.assertNotNull(factory.create(ip, Locale.getDefault())); - // } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxyTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxyTest.java deleted file mode 100644 index 3a56d68..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxyTest.java +++ /dev/null @@ -1,628 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.proxy; - -import static org.easymock.EasyMock.expect; -import static org.junit.Assert.assertEquals; -import static org.powermock.api.easymock.PowerMock.mockStatic; - -import org.easymock.EasyMock; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.easymock.PowerMock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.Marker; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(LoggerFactory.class) -public class Slf4jLoggerProxyTest { - - private Logger logger; - private Slf4jLoggerProxy slf4jLoggerProxy; - - @Before - public void setUp() throws Exception { - this.logger = EasyMock.createMock(Logger.class); - this.slf4jLoggerProxy = new Slf4jLoggerProxy(Logger.class); - - mockStatic(LoggerFactory.class); - - expect(LoggerFactory.getLogger(EasyMock.anyObject(Class.class))).andReturn(logger); - } - - @Test - public void testDebugWithMarkerAndString() { - Marker marker = null; - this.logger.debug(marker,""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug(marker,""); - PowerMock.verify(this.logger); - } - - @Test - public void testDebugWithMarkerStringAndOneObject() { - Marker marker = null; - Object obj = null; - this.logger.debug(marker,"",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug(marker,"",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testDebugWithMarkerStringAndTwoObjects() { - Marker marker = null; - Object obj1 = null, obj2 = null; - this.logger.debug(marker,"",obj1,obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug(marker,"",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testDebugWithMarkerStringAndObjectArray() { - Marker marker = null; - Object[] obj = null; - this.logger.debug(marker,"",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug(marker,"",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testDebugWithMarkerStringAndThrowable() { - Marker marker = null; - Throwable t = null; - this.logger.debug(marker,"",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug(marker,"",t); - PowerMock.verify(this.logger); - } - - @Test - public void testDebugWithString() { - this.logger.debug(""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug(""); - PowerMock.verify(this.logger); - } - - @Test - public void testDebugWithStringAndOneObject() { - Object obj = null; - this.logger.debug("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testDebugWithStringAndTwoObjects() { - Object obj1 = null, obj2 = null; - this.logger.debug("",obj1,obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug("",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testDebugWithStringAndObjectArray() { - Object[] obj = null; - this.logger.debug("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testDebugWithStringAndThrowable() { - Throwable t = null; - this.logger.debug("",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.debug("",t); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithMarkerAndString() { - Marker marker = null; - this.logger.error(marker,""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error(marker,""); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithMarkerStringAndOneObject() { - Marker marker = null; - Object obj = null; - this.logger.error(marker,"",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error(marker,"",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithMarkerStringAndTwoObjects() { - Marker marker = null; - Object obj1 = null, obj2 = null; - this.logger.error(marker,"",obj1,obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error(marker,"",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithMarkerStringAndObjectArray() { - Marker marker = null; - Object[] obj1 = null; - this.logger.error(marker,"",obj1); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error(marker,"",obj1); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithMarkerStringAndThrowable() { - Marker marker = null; - Throwable t = null; - this.logger.error(marker,"",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error(marker,"",t); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithString() { - this.logger.error(""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error(""); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithStringAndOneObject() { - Object obj = null; - this.logger.error("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithStringAndTwoObjects() { - Object obj1 = null,obj2 = null; - this.logger.error("",obj1,obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error("",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithStringAndObjectArray() { - Object[] obj = null; - this.logger.error("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testErrorWithStringAndThrowable() { - Throwable t = null; - this.logger.error("",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.error("",t); - PowerMock.verify(this.logger); - } - - @Test - public void testGetName() { - expect(this.logger.getName()).andReturn("xxx"); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals("xxx", this.slf4jLoggerProxy.getName()); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithMarkerAndString() { - Marker marker = null; - this.logger.info(marker,""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info(marker,""); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithMarkerStringAndOneObject() { - Marker marker = null; - Object obj = null; - this.logger.info(marker,"",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info(marker,"",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithMarkerStringAndTwoObjects() { - Marker marker = null; - Object obj1 = null, obj2 = null; - this.logger.info(marker,"",obj1, obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info(marker,"",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithMarkerStringAndObjectArray() { - Marker marker = null; - Object[] obj = null; - this.logger.info(marker,"",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info(marker,"",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithMarkerStringAndThrowable() { - Marker marker = null; - Throwable t = null; - this.logger.info(marker,"",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info(marker,"",t); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithString() { - this.logger.info(""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info(""); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithStringAndOneObject() { - Object obj = null; - this.logger.info("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithStringAndTwoObjects() { - Object obj1 = null, obj2 = null; - this.logger.info("",obj1,obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info("",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithStringAndObjectArray() { - Object[] obj = null; - this.logger.info("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testInfoWithStringAndThrowable() { - Throwable t = null; - this.logger.info("",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.info("",t); - PowerMock.verify(this.logger); - } - - @Test - public void testIsDebugEnabled() { - expect(this.logger.isDebugEnabled()).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isDebugEnabled()); - PowerMock.verify(this.logger); - } - - @Test - public void testIsDebugEnabledWithMarker() { - Marker marker = null; - expect(this.logger.isDebugEnabled(marker)).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isDebugEnabled(marker)); - PowerMock.verify(this.logger); - } - - @Test - public void testIsErrorEnabled() { - expect(this.logger.isErrorEnabled()).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isErrorEnabled()); - PowerMock.verify(this.logger); - } - - @Test - public void testIsErrorEnabledWithMarker() { - Marker marker = null; - expect(this.logger.isErrorEnabled(marker)).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isErrorEnabled(marker)); - PowerMock.verify(this.logger); - } - - @Test - public void testIsInfoEnabled() { - expect(this.logger.isInfoEnabled()).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isInfoEnabled()); - PowerMock.verify(this.logger); - } - - @Test - public void testIsInfoEnabledWithMarker() { - Marker marker = null; - expect(this.logger.isInfoEnabled(marker)).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isInfoEnabled(marker)); - PowerMock.verify(this.logger); - } - - @Test - public void testIsTRaceEnabled() { - expect(this.logger.isTraceEnabled()).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isTraceEnabled()); - PowerMock.verify(this.logger); - } - - @Test - public void testIsTraceEnabledWithMarker() { - Marker marker = null; - expect(this.logger.isTraceEnabled(marker)).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isTraceEnabled(marker)); - PowerMock.verify(this.logger); - } - - @Test - public void testIsWarnEnabled() { - expect(this.logger.isWarnEnabled()).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isWarnEnabled()); - PowerMock.verify(this.logger); - } - - @Test - public void testIsWarnEnabledWithMarker() { - Marker marker = null; - expect(this.logger.isWarnEnabled(marker)).andReturn(true); - PowerMock.replay(LoggerFactory.class, this.logger); - assertEquals(true, this.slf4jLoggerProxy.isWarnEnabled(marker)); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithMarkerAndString() { - Marker marker = null; - this.logger.trace(marker,""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace(marker,""); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithMarkerStringAndOneObject() { - Marker marker = null; - Object obj = null; - this.logger.trace(marker,"",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace(marker,"",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithMarkerStringAndTwoObjects() { - Marker marker = null; - Object obj1 = null, obj2 = null; - this.logger.trace(marker,"",obj1, obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace(marker,"",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithMarkerStringAndObjectArray() { - Marker marker = null; - Object[] obj = null; - this.logger.trace(marker,"",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace(marker,"",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithMarkerStringAndThrowable() { - Marker marker = null; - Throwable t = null; - this.logger.trace(marker,"",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace(marker,"",t); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithString() { - this.logger.trace(""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace(""); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithStringAndOneObject() { - Object obj = null; - this.logger.trace("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithStringAndTwoObjects() { - Object obj1 = null, obj2 = null; - this.logger.trace("",obj1,obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace("",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithStringAndObjectArray() { - Object[] obj = null; - this.logger.trace("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testTraceWithStringAndThrowable() { - Throwable t = null; - this.logger.trace("",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.trace("",t); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithMarkerAndString() { - Marker marker = null; - this.logger.warn(marker,""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn(marker,""); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithMarkerStringAndOneObject() { - Marker marker = null; - Object obj = null; - this.logger.warn(marker,"",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn(marker,"",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithMarkerStringAndTwoObjects() { - Marker marker = null; - Object obj1 = null, obj2 = null; - this.logger.warn(marker,"",obj1, obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn(marker,"",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithMarkerStringAndObjectArray() { - Marker marker = null; - Object[] obj = null; - this.logger.warn(marker,"",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn(marker,"",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithMarkerStringAndThrowable() { - Marker marker = null; - Throwable t = null; - this.logger.warn(marker,"",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn(marker,"",t); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithString() { - this.logger.warn(""); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn(""); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithStringAndOneObject() { - Object obj = null; - this.logger.warn("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithStringAndTwoObjects() { - Object obj1 = null, obj2 = null; - this.logger.warn("",obj1,obj2); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn("",obj1,obj2); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithStringAndObjectArray() { - Object[] obj = null; - this.logger.warn("",obj); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn("",obj); - PowerMock.verify(this.logger); - } - - @Test - public void testWarnWithStringAndThrowable() { - Throwable t = null; - this.logger.warn("",t); - PowerMock.replay(LoggerFactory.class, this.logger); - this.slf4jLoggerProxy.warn("",t); - PowerMock.verify(this.logger); - } -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/message/DefaultMessageTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/message/DefaultMessageTest.java deleted file mode 100644 index 186d17d..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/message/DefaultMessageTest.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Demoiselle Framework Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- This file is part of Demoiselle - * Framework. Demoiselle Framework is free software; you can redistribute it and/or modify it under the terms of the GNU - * Lesser General Public License version 3 as published by the Free Software Foundation. This program is distributed in - * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a - * copy of the GNU Lesser General Public License version 3 along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. ---------------------------------------------------------------------------- Este arquivo - * é parte do Framework Demoiselle. O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação do Software Livre (FSF). Este - * programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de - * ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português para - * maiores detalhes. Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título "LICENCA.txt", junto com esse - * programa. Se não, acesse ou escreva para a Fundação do Software Livre (FSF) Inc., 51 - * Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.message; - -import static org.easymock.EasyMock.expect; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.powermock.api.easymock.PowerMock.mockStatic; -import static org.powermock.api.easymock.PowerMock.replay; -import static org.powermock.api.easymock.PowerMock.replayAll; -import static org.powermock.api.easymock.PowerMock.verifyAll; - -import java.util.Arrays; -import java.util.Locale; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; -import br.gov.frameworkdemoiselle.util.Beans; -import br.gov.frameworkdemoiselle.util.ResourceBundle; -import br.gov.frameworkdemoiselle.util.Strings; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ Beans.class, ResourceBundle.class }) -public class DefaultMessageTest { - - private Message message; - - private String MOCK_RESOURCE_BUNDLE_KEY = "{key}"; - - private String MOCK_RESOURCE_BUNDLE_VALUE = "param {0} and param {1}"; - - private ResourceBundle bundle; - - @Before - public void setUp() throws Exception { - Locale locale = Locale.getDefault(); - - mockStatic(Beans.class); - expect(Beans.getReference(Locale.class)).andReturn(locale).anyTimes(); - replay(Beans.class); - - bundle = ResourceBundleProducer.create("test-message"); - - mockStatic(Beans.class); - expect(Beans.getReference(ResourceBundle.class)).andReturn(bundle).anyTimes(); - replayAll(Beans.class); - } - - @After - public void tearDown() throws Exception { - verifyAll(); - } - - @Test - public void testConstructorWithTextOnly() { - message = new DefaultMessage(""); - assertEquals("", message.getText()); - - message = new DefaultMessage("a"); - assertEquals("a", message.getText()); - - message = new DefaultMessage(null); - assertEquals(null, message.getText()); - - message = new DefaultMessage(MOCK_RESOURCE_BUNDLE_KEY); - assertEquals(MOCK_RESOURCE_BUNDLE_VALUE, message.getText()); - } - - @Test - public void testCachedText() { - message = new DefaultMessage(MOCK_RESOURCE_BUNDLE_KEY); - assertSame(message.getText(), message.getText()); - } - - @Test - public void testDefaultSeverity() { - message = new DefaultMessage(null); - assertEquals(SeverityType.INFO, message.getSeverity()); - - assertEquals(DefaultMessage.DEFAULT_SEVERITY, message.getSeverity()); - - message = new DefaultMessage(null, null, new Object[] {}); - assertEquals(DefaultMessage.DEFAULT_SEVERITY, message.getSeverity()); - } - - @Test - public void testConstructorWithParametrizedText() { - String text; - Object[] params; - - text = ""; - params = new Object[] { "1", "2" }; - message = new DefaultMessage(text, params); - assertEquals(Strings.getString(text, params), message.getText()); - - text = "params: {0}, {1}"; - params = new Object[] { "1", "2" }; - message = new DefaultMessage(text, params); - assertEquals(Strings.getString(text, params), message.getText()); - - text = null; - params = new Object[] { "1" }; - message = new DefaultMessage(text, params); - assertEquals(Strings.getString(text, params), message.getText()); - - text = MOCK_RESOURCE_BUNDLE_KEY; - params = new Object[] { "1", "2" }; - message = new DefaultMessage(text, params); - assertEquals(Strings.getString(bundle.getString("key"), params), message.getText()); - } - - @Test - public void testToString() throws SecurityException, NoSuchFieldException { - String text; - Object[] params; - - text = "text"; - message = new DefaultMessage(text); - assertEquals("DefaultMessage [originalText=" + text + ", parsedText=" + text - + ", severity=INFO, params=[], bundle=" + bundle.toString() + "]", message.toString()); - - text = MOCK_RESOURCE_BUNDLE_KEY; - params = new Object[] { "1", "2" }; - message = new DefaultMessage(text, SeverityType.FATAL, params); - assertEquals( - "DefaultMessage [originalText=" + text + ", parsedText=" - + Strings.getString(bundle.getString("key"), params) + ", severity=FATAL, params=" - + Arrays.toString(params) + ", bundle=" + bundle.toString() + "]", message.toString()); - } - - @Test - public void testConstructorWithParametrizedTextAndSeverityType() { - message = new DefaultMessage("", SeverityType.FATAL, ""); - assertEquals("", message.getText()); - assertEquals(SeverityType.FATAL, message.getSeverity()); - - message = new DefaultMessage("text", SeverityType.WARN, "param"); - assertEquals("text", message.getText()); - assertEquals(SeverityType.WARN, message.getSeverity()); - } - - enum MessagesEnum implements Message { - - FIRST_KEY("{first-key}"), SECOND_KEY("{second-key}", SeverityType.WARN), THIRD_KEY("{THIRD_KEY}"), FOURTH_KEY("{FOURTH_KEY}",SeverityType.FATAL), LITERAL_TEXT( - "This is a literal text"); - - private final DefaultMessage msg; - - MessagesEnum() { - msg = new DefaultMessage(this.name()); - } - - MessagesEnum(String name) { - msg = new DefaultMessage(name); - } - - MessagesEnum(SeverityType severity) { - msg = new DefaultMessage(this.name(), severity); - } - - MessagesEnum(String name, SeverityType severity) { - msg = new DefaultMessage(name, severity); - } - - @Override - public String getText() { - return msg.getText(); - } - - @Override - public SeverityType getSeverity() { - return msg.getSeverity(); - } - - } - - @Test - public void testMessagesEnum() throws Exception { - message = MessagesEnum.FIRST_KEY; - assertEquals(SeverityType.INFO, message.getSeverity()); - assertEquals("First message text", message.getText()); - - message = MessagesEnum.SECOND_KEY; - assertEquals(SeverityType.WARN, message.getSeverity()); - assertEquals("Second message text", message.getText()); - - message = MessagesEnum.THIRD_KEY; - assertEquals(SeverityType.INFO, message.getSeverity()); - assertEquals("Third message text", message.getText()); - - message = MessagesEnum.FOURTH_KEY; - assertEquals(SeverityType.FATAL, message.getSeverity()); - assertEquals("Fourth message text", message.getText()); - - message = MessagesEnum.LITERAL_TEXT; - assertEquals(SeverityType.INFO, message.getSeverity()); - assertEquals("This is a literal text", message.getText()); - } - - enum ErrorMessages implements Message { - - ERROR_KEY("{error-key}"), LITERAL_ERROR_TEXT("This is a literal error text"); - - private final DefaultMessage msg; - - ErrorMessages() { - msg = new DefaultMessage(this.name(), SeverityType.ERROR); - } - - ErrorMessages(String name) { - msg = new DefaultMessage(name, SeverityType.ERROR); - } - - @Override - public String getText() { - return msg.getText(); - } - - @Override - public SeverityType getSeverity() { - return msg.getSeverity(); - } - - } - - @Test - public void testErrorMessagesEnum() { - message = ErrorMessages.ERROR_KEY; - assertEquals(SeverityType.ERROR, message.getSeverity()); - assertEquals("Error message text", message.getText()); - - message = ErrorMessages.LITERAL_ERROR_TEXT; - assertEquals(SeverityType.ERROR, message.getSeverity()); - assertEquals("This is a literal error text", message.getText()); - } - - interface MessagesInterface { - - final Message FIRST_KEY = new DefaultMessage("{first-key}"); - - final Message SECOND_KEY = new DefaultMessage("{second-key}", SeverityType.WARN); - - final Message THIRD_KEY = new DefaultMessage("{THIRD_KEY}"); - - final Message FOURTH_KEY = new DefaultMessage("{FOURTH_KEY}", SeverityType.FATAL); - - final Message LITERAL_TEXT = new DefaultMessage("This is a literal text"); - - } - - @Test - public void testMessagesInterface() { - message = MessagesInterface.FIRST_KEY; - assertEquals(SeverityType.INFO, message.getSeverity()); - assertEquals("First message text", message.getText()); - - message = MessagesInterface.SECOND_KEY; - assertEquals(SeverityType.WARN, message.getSeverity()); - assertEquals("Second message text", message.getText()); - - message = MessagesInterface.THIRD_KEY; - assertEquals(SeverityType.INFO, message.getSeverity()); - assertEquals("Third message text", message.getText()); - - message = MessagesInterface.FOURTH_KEY; - assertEquals(SeverityType.FATAL, message.getSeverity()); - assertEquals("Fourth message text", message.getText()); - - message = MessagesInterface.LITERAL_TEXT; - assertEquals(SeverityType.INFO, message.getSeverity()); - assertEquals("This is a literal text", message.getText()); - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/template/DelegateCrudTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/template/DelegateCrudTest.java deleted file mode 100644 index e57703e..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/template/DelegateCrudTest.java +++ /dev/null @@ -1,205 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.template; -// -//import static org.easymock.EasyMock.expect; -//import static org.junit.Assert.assertEquals; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -//import static org.powermock.api.easymock.PowerMock.replayAll; -//import static org.powermock.api.easymock.PowerMock.verifyAll; -// -//import java.util.ArrayList; -//import java.util.List; -// -//import org.easymock.EasyMock; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.api.easymock.PowerMock; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -//import org.powermock.reflect.Whitebox; -// -//import br.gov.frameworkdemoiselle.util.Beans; -//import br.gov.frameworkdemoiselle.util.Reflections; -// -//@RunWith(PowerMockRunner.class) -//@PrepareForTest({ Crud.class, Beans.class, Reflections.class }) -//public class DelegateCrudTest { -// -// private DelegateCrud delegateCrud; -// -// private Crud mockCrud; -// -// @SuppressWarnings("unchecked") -// @Before -// public void before() { -// delegateCrud = new DelegateCrud(); -// mockCrud = PowerMock.createMock(Crud.class); -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testDelete() { -// mockStatic(Beans.class); -// mockStatic(Reflections.class); -// -// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Class.class), EasyMock.anyInt())).andReturn(null); -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud).times(2); -// -// mockCrud.delete(1L); -// PowerMock.expectLastCall(); -// -// PowerMock.replay(Reflections.class, Beans.class, mockCrud); -// -// delegateCrud.delete(1L); -// -// PowerMock.verify(); -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testUpdate() { -// Whitebox.setInternalState(delegateCrud, "delegate", mockCrud); -// -// mockStatic(Beans.class); -// -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud); -// -// Contact update = new Contact(); -// mockCrud.update(update); -// replayAll(Beans.class, mockCrud); -// -// delegateCrud.update(update); -// -// verifyAll(); -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testInsert() { -// Whitebox.setInternalState(delegateCrud, "delegate", mockCrud); -// -// mockStatic(Beans.class); -// -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud); -// -// Contact insert = new Contact(); -// mockCrud.insert(insert); -// replayAll(mockCrud); -// -// delegateCrud.insert(insert); -// -// verifyAll(); -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testFindAll() { -// mockStatic(Beans.class); -// mockStatic(Reflections.class); -// -// expect(Reflections.getGenericTypeArgument(EasyMock.anyObject(Class.class), EasyMock.anyInt())).andReturn(null); -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud); -// -// List returned = new ArrayList(); -// expect(mockCrud.findAll()).andReturn(returned); -// replayAll(Reflections.class, Beans.class, mockCrud); -// -// assertEquals(returned, delegateCrud.findAll()); -// -// verifyAll(); -// } -// -// @SuppressWarnings("unchecked") -// @Test -// public void testLoad() { -// mockStatic(Beans.class); -// -// expect(Beans.getReference(EasyMock.anyObject(Class.class))).andReturn(mockCrud); -// -// Contact contact = new Contact(); -// expect(mockCrud.load(1L)).andReturn(contact); -// replayAll(Beans.class, mockCrud); -// -// Whitebox.setInternalState(delegateCrud, "delegateClass", delegateCrud.getClass(), delegateCrud.getClass()); -// -// assertEquals(contact, delegateCrud.load(1L)); -// verifyAll(); -// } -// -// class Contact { -// -// private Long id; -// -// public Long getId() { -// return id; -// } -// -// public void setId(Long id) { -// this.id = id; -// } -// } -// -// @SuppressWarnings("serial") -// class Delegated implements Crud { -// -// @Override -// public void delete(Long id) { -// } -// -// @Override -// public List findAll() { -// return null; -// } -// -// @Override -// public void insert(Contact bean) { -// } -// -// @Override -// public Contact load(Long id) { -// return null; -// } -// -// @Override -// public void update(Contact bean) { -// } -// -// } -// -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.java deleted file mode 100644 index 5fd1968..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/JTATransactionTest.java +++ /dev/null @@ -1,185 +0,0 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.transaction; -// -//import static junit.framework.Assert.assertEquals; -//import static junit.framework.Assert.assertFalse; -//import static junit.framework.Assert.assertTrue; -//import static junit.framework.Assert.fail; -//import static org.easymock.EasyMock.expect; -//import static org.easymock.EasyMock.replay; -//import static org.easymock.EasyMock.verify; -//import static org.powermock.reflect.Whitebox.setInternalState; -// -//import javax.naming.Context; -//import javax.naming.NamingException; -//import javax.transaction.HeuristicMixedException; -//import javax.transaction.HeuristicRollbackException; -//import javax.transaction.NotSupportedException; -//import javax.transaction.RollbackException; -//import javax.transaction.Status; -//import javax.transaction.SystemException; -//import javax.transaction.UserTransaction; -// -//import org.easymock.EasyMock; -//import org.junit.Before; -//import org.junit.Test; -//import org.powermock.api.easymock.PowerMock; -// -//import br.gov.frameworkdemoiselle.exception.DemoiselleException; -//import br.gov.frameworkdemoiselle.util.ResourceBundle; -// -//public class JTATransactionTest { -// -// private UserTransaction userTransaction; -// private JTATransaction jtaTransaction; -// private Context context; -// private ResourceBundle bundle; -// -// @Before -// public void setUp() throws Exception { -// this.jtaTransaction = new JTATransaction(); -// -// this.userTransaction = EasyMock.createMock(UserTransaction.class); -// -// this.context = EasyMock.createMock(Context.class); -// expect(this.context.lookup("UserTransaction")).andReturn(this.userTransaction); -// replay(this.context); -// setInternalState(this.jtaTransaction, "context", this.context); -// } -// -// @Test -// public void testNamingException() throws Exception{ -// -// this.context = EasyMock.createMock(Context.class); -// expect(this.context.lookup("UserTransaction")).andThrow(new NamingException()); -// replay(this.context); -// setInternalState(this.jtaTransaction, "context", this.context); -// -// this.bundle = PowerMock.createMock(ResourceBundle.class); -// EasyMock.expect(this.bundle.getString("user-transaction-lookup-fail","UserTransaction")).andReturn("teste"); -// PowerMock.replay(this.bundle); -// setInternalState(this.jtaTransaction, "bundle", this.bundle); -// -// try { -// this.jtaTransaction.isMarkedRollback(); -// fail(); -// }catch(DemoiselleException cause) { -// assertTrue(true); -// } -// } -// -// @Test -// public void testIsMarkedRollback() throws SystemException { -// expect(this.userTransaction.getStatus()).andReturn(Status.STATUS_MARKED_ROLLBACK); -// replay(this.userTransaction); -// assertTrue(this.jtaTransaction.isMarkedRollback()); -// verify(this.userTransaction); -// } -// -// @Test -// public void testIsNotMarkedRollback() throws SystemException { -// expect(this.userTransaction.getStatus()).andReturn(2); -// replay(this.userTransaction); -// assertFalse(this.jtaTransaction.isMarkedRollback()); -// verify(this.userTransaction); -// } -// -// @Test -// public void testIsAtive() throws SystemException { -// expect(this.userTransaction.getStatus()).andReturn(Status.STATUS_ACTIVE); -// replay(this.userTransaction); -// assertTrue(this.jtaTransaction.isActive()); -// verify(this.userTransaction); -// } -// -// @Test -// public void testIsNotAtiveButMarkedRollback() throws SystemException { -// expect(this.userTransaction.getStatus()).andReturn(Status.STATUS_MARKED_ROLLBACK).times(2); -// replay(this.userTransaction); -// assertTrue(this.jtaTransaction.isActive()); -// verify(this.userTransaction); -// } -// -// @Test -// public void testBegin() throws NotSupportedException, SystemException { -// this.userTransaction.begin(); -// replay(this.userTransaction); -// this.jtaTransaction.begin(); -// verify(this.userTransaction); -// } -// -// @Test -// public void testCommit() throws SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException { -// this.userTransaction.commit(); -// replay(this.userTransaction); -// this.jtaTransaction.commit(); -// verify(this.userTransaction); -// } -// -// @Test -// public void testgetStatus() throws SystemException{ -// expect(this.userTransaction.getStatus()).andReturn(Status.STATUS_MARKED_ROLLBACK); -// replay(this.userTransaction); -// assertEquals(Status.STATUS_MARKED_ROLLBACK,this.jtaTransaction.getStatus()); -// verify(this.userTransaction); -// } -// -// @Test -// public void testRollback() throws SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException { -// this.userTransaction.rollback(); -// replay(this.userTransaction); -// this.jtaTransaction.rollback(); -// verify(this.userTransaction); -// } -// -// @Test -// public void testSetRollbackOnly() throws SystemException{ -// this.userTransaction.setRollbackOnly(); -// replay(this.userTransaction); -// this.jtaTransaction.setRollbackOnly(); -// verify(this.userTransaction); -// } -// -// @Test -// public void testSetTransactionTimeout() throws SystemException{ -// this.userTransaction.setTransactionTimeout(0); -// replay(this.userTransaction); -// this.jtaTransaction.setTransactionTimeout(0); -// verify(this.userTransaction); -// } -//} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/TransactionExceptionTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/TransactionExceptionTest.java deleted file mode 100644 index 3c33ae9..0000000 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/transaction/TransactionExceptionTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package br.gov.frameworkdemoiselle.transaction; - -import java.sql.SQLException; - -import junit.framework.Assert; - -import org.junit.Test; - - -public class TransactionExceptionTest { - - SQLException cause = new SQLException(); - - @Test - public void testTransactionException() { - TransactionException test = new TransactionException(cause); - Assert.assertEquals("java.sql.SQLException", test.getCause().toString()); - } - -} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/BeansTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/BeansTest.java index 8dab363..9fcd0af 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/BeansTest.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/BeansTest.java @@ -1,3 +1,4 @@ +package br.gov.frameworkdemoiselle.util; ///* // * Demoiselle Framework // * Copyright (C) 2010 SERPRO diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/ResourceBundleTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/ResourceBundleTest.java index f266178..a1d8dbc 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/ResourceBundleTest.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/ResourceBundleTest.java @@ -44,8 +44,10 @@ import java.util.Enumeration; import java.util.Locale; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; +@Ignore public class ResourceBundleTest { /** diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/StringsTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/StringsTest.java index 395f210..006b00c 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/StringsTest.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/util/StringsTest.java @@ -36,11 +36,11 @@ */ package br.gov.frameworkdemoiselle.util; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.powermock.api.easymock.PowerMock.verifyAll; import org.junit.Test; @@ -141,10 +141,7 @@ public class StringsTest { } String result = Strings.toString(new Test()); - assertTrue(result.contains("Test [name=myName, lastname=myLastname, nullField=null, this")); - - verifyAll(); } private void testEqualsGetString(String in, String expected, Object... params) { diff --git a/impl/core/src/test/resources/arquillian.xml b/impl/core/src/test/resources/arquillian.xml new file mode 100644 index 0000000..6e3cb7a --- /dev/null +++ b/impl/core/src/test/resources/arquillian.xml @@ -0,0 +1,46 @@ + + + + + + \ No newline at end of file diff --git a/impl/core/src/test/resources/configuration-with-array.properties b/impl/core/src/test/resources/configuration-with-array.properties deleted file mode 100644 index 65d02fc..0000000 --- a/impl/core/src/test/resources/configuration-with-array.properties +++ /dev/null @@ -1,50 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -integer.array = 2147483647, 10993, 12330, 129399 -short.array = 32767, 123, 5512, 4212 -byte.array = 127, 12, 51, 123, 11, 5, 1, -12 -boolean.array = true, false -long.array = 9223372036854775807, 0901920390123, 1235234523, 134230094, 66123413423 -float.array = 3.4028235E38, 34.244, 2412.423444, 513.234, 10000.000 -double.array = 1.7976931348623157E308, 1231234.00120349192348123, 1234123512341.9134828348238 -big.decimal.array = 16578.69899, 48787.548877788, 4487787.559 -big.integer.array = 1998987987897, 89789498171, 21474836475 -calendar.array = 2012-06-14 10:10:00, 2012-07-14 10:10:00, 2012-06-15 18:10:00 -date.array = 2012-08-14 18:10:50, 2012-07-14 10:10:00, 2012-06-15 18:10:00 -color.array = #808080, #cccccc, #ABCCCC -locale.array = en, pt_br, ca -url.array = http://www.test.com, https://test.of.test.com, ftp://192.168.0.1 -string.array = Test, One, Two diff --git a/impl/core/src/test/resources/configuration-with-array.xml b/impl/core/src/test/resources/configuration-with-array.xml deleted file mode 100644 index 4232a25..0000000 --- a/impl/core/src/test/resources/configuration-with-array.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - 2147483647 - 10993 - 12330 - 129399 - - - - 32767 - 123 - 5512 - 4212 - - - - 127 - 12 - 51 - 123 - 11 - 5 - 1 - -12 - - - - true - false - - - - 9223372036854775807 - 0901920390123 - 1235234523 - 134230094 - 66123413423 - - - - 3.4028235E38 - 34.244 - 2412.423444 - 513.234 - 10000.000 - - - - 1.7976931348623157E308 - 1231234.00120349192348123 - 1234123512341.9134828348238 - - - - - 16578.69899 - 48787.548877788 - 4487787.559 - - - - - - 1998987987897 - 89789498171 - 21474836475 - - - - - 2012-06-14 10:10:00 - 2012-07-14 10:10:00 - 2012-06-15 18:10:00 - - - - 2012-08-14 18:10:50 - 2012-07-14 10:10:00 - 2012-06-15 18:10:00 - - - - #808080 - #cccccc - #ABCCCC - - - - en - pt_br - ca - - - - http://www.test.com - https://test.of.test.com - ftp://192.168.0.1 - - - - Test - One - Two - - - \ No newline at end of file diff --git a/impl/core/src/test/resources/configuration-with-list.properties b/impl/core/src/test/resources/configuration-with-list.properties deleted file mode 100644 index cea3a15..0000000 --- a/impl/core/src/test/resources/configuration-with-list.properties +++ /dev/null @@ -1,50 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -integer.list = 2147483647, 10993, 12330, 129399 -short.list = 32767, 123, 5512, 4212 -byte.list = 127, 12, 51, 123, 11, 5, 1, -12 -boolean.list = true, false -long.list = 9223372036854775807, 0901920390123, 1235234523, 134230094, 66123413423 -float.list = 3.4028235E38, 34.244, 2412.423444, 513.234, 10000.000 -double.list = 1.7976931348623157E308, 1231234.00120349192348123, 1234123512341.9134828348238 -big.decimal.list = 16578.69899, 48787.548877788, 4487787.559 -big.integer.list = 1998987987897, 89789498171, 21474836475 -calendar.list = 2012-06-14 10:10:00, 2012-07-14 10:10:00, 2012-06-15 18:10:00 -date.list = 2012-08-14 18:10:50, 2012-07-14 10:10:00, 2012-06-15 18:10:00 -color.list = #808080, #cccccc, #ABCCCC -locale.list = en, pt_br, ca -url.list = http://www.test.com, https://test.of.test.com, ftp://192.168.0.1 -string.list = Test, One, Two diff --git a/impl/core/src/test/resources/configuration-with-list.xml b/impl/core/src/test/resources/configuration-with-list.xml deleted file mode 100644 index 8565809..0000000 --- a/impl/core/src/test/resources/configuration-with-list.xml +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - 2147483647 - 10993 - 12330 - 129399 - - - - 32767 - 123 - 5512 - 4212 - - - - 127 - 12 - 51 - 123 - 11 - 5 - 1 - -12 - - - - true - false - - - - 9223372036854775807 - 0901920390123 - 1235234523 - 134230094 - 66123413423 - - - - 3.4028235E38 - 34.244 - 2412.423444 - 513.234 - 10000.000 - - - - 1.7976931348623157E308 - 1231234.00120349192348123 - 1234123512341.9134828348238 - - - - - 16578.69899 - 48787.548877788 - 4487787.559 - - - - - - 1998987987897 - 89789498171 - 21474836475 - - - - - 2012-06-14 10:10:00 - 2012-07-14 10:10:00 - 2012-06-15 18:10:00 - - - - 2012-08-14 18:10:50 - 2012-07-14 10:10:00 - 2012-06-15 18:10:00 - - - - #808080 - #cccccc - #ABCCCC - - - - en - pt_br - ca - - - - http://www.test.com - https://test.of.test.com - ftp://192.168.0.1 - - - - Test - One - Two - - - \ No newline at end of file diff --git a/impl/core/src/test/resources/configuration.properties b/impl/core/src/test/resources/configuration.properties deleted file mode 100644 index 27c3d1b..0000000 --- a/impl/core/src/test/resources/configuration.properties +++ /dev/null @@ -1,50 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -key=value - -framework.stringValue=value -framework.integerValue=10 -framework.intValue=10 -framework.listValue=value1, value2, value3 - -prefix.key1 = value1 -prefix.key2 = value2 -prefix.key3 = value3 - -interpolation = interx - -#get from var.${interpolation}-${interpolation}.prop -var.interx-interx.prop = value diff --git a/impl/core/src/test/resources/configuration.xml b/impl/core/src/test/resources/configuration.xml deleted file mode 100644 index 5cac4b2..0000000 --- a/impl/core/src/test/resources/configuration.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - value - 10 - 10 - value1 - value2 - value3 - - \ No newline at end of file diff --git a/impl/core/src/test/resources/configuration/fields/basic/demoiselle.properties b/impl/core/src/test/resources/configuration/fields/basic/demoiselle.properties new file mode 100644 index 0000000..2804f98 --- /dev/null +++ b/impl/core/src/test/resources/configuration/fields/basic/demoiselle.properties @@ -0,0 +1,4 @@ +primitiveInteger=1 +wrappedInteger=2 +stringWithSpace=demoiselle framework +stringWithComma=demoiselle,framework diff --git a/impl/core/src/test/resources/configuration2.properties b/impl/core/src/test/resources/configuration2.properties deleted file mode 100644 index 2d5e539..0000000 --- a/impl/core/src/test/resources/configuration2.properties +++ /dev/null @@ -1,36 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -key2=value2 \ No newline at end of file diff --git a/impl/core/src/test/resources/demoiselle-core-bundle.properties b/impl/core/src/test/resources/demoiselle-core-bundle.properties deleted file mode 100644 index 9a85572..0000000 --- a/impl/core/src/test/resources/demoiselle-core-bundle.properties +++ /dev/null @@ -1,95 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -engine-on=Ligando os motores do Demoiselle ${project.version} -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} -handling-exception=Tratando a exce\u00E7\u00E3o {0} -proxy-detected=Detectado o proxy {0} da classe {1} -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 -taking-off=O Demoiselle ${project.version} decolou -engine-off=Desligando os motores do Demoiselle ${project.version} -setting-up-bean-manager=BeanManager dispon\u00EDvel atrav\u00E9s do utilit\u00E1rio {0} - -user-transaction-lookup-fail=N\u00E3o foi encontrada nenhuma transa\u00E7\u00E3o com o nome {0} no contexto JNDI -transactional-execution=Execu\u00E7\u00E3o transacional de {0} -begin-transaction=Transa\u00E7\u00E3o iniciada -transaction-marked-rollback=Transa\u00E7\u00E3o marcada para rollback [{0}] -transaction-already-finalized=A transa\u00E7\u00E3o j\u00E1 havia sido finalizada -transaction-commited=Transa\u00E7\u00E3o finalizada com sucesso -transaction-rolledback=Transa\u00E7\u00E3o finalizada com rollback - -bootstrap.configuration.processing=Processando {0} - -loading-configuration-class=Carregando a classe de configura\u00E7\u00E3o {0} -configuration-field-loaded=Configura\u00E7\u00E3o {0} atribu\u00EDda \u00E0 {1} com o valor {2} -configuration-attribute-is-mandatory=A configura\u00E7\u00E3o {0} \u00E9 obrigat\u00F3ria, mas n\u00E3o foi encontrada em {1} -configuration-name-attribute-cant-be-empty=A nota\u00E7\u00E3o Name n\u00E3o pode estar em branco -configuration-key-not-found=Chave de configura\u00E7\u00E3o "{0}" n\u00E3o encontrada. Conven\u00E7\u00F5es verificadas\: "{1}" - -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 -executing-all=Executando todos os \: {0} -custom-context-was-registered=O contexto {0} foi registrado -custom-context-was-unregistered=O contexto {0} foi removido - -error-creating-configuration-from-resource=Error creating configuration from resource named "{0}" -configuration-type-not-implemented-yet=Configuration type "{0}" is not implemented yet -error-converting-to-type=Error converting to type "{0}" -error-creating-new-instance-for=Error creating a new instance for "{0}" -executed-successfully=\ {0} execultado com sucesso -must-declare-one-single-parameter=Voc\u00EA deve declarar um par\u00E2metro \u00FAnico em {0} -loading-default-transaction-manager=Carregando o gerenciador de transa\u00E7\u00E3o padr\u00E3o {0} -transaction-class-not-found=A classe de transa\u00E7\u00E3o "{0}" informada n\u00E3o foi encontrada. -transaction-class-must-be-of-type=A classe de transa\u00E7\u00E3o "{0}" informada deve ser do tipo {1} -results-count-greater-page-size=Quantidade de resultados {0} \u00E9 maior que o tamanho da p\u00E1gina {1} -page-result=Resultado paginado [p\u00E1gina\={0}, total de resultados\={1}] -page=P\u00E1gina [n\u00FAmero\={0}, tamanho\={1}] -processing=Processando\: {0} -processing-fail=Falha no processamento devido a uma exce\u00E7\u00E3o lan\u00E7ada pela aplica\u00E7\u00E3o -for= \ para\: -file-not-found=O arquivo {0} n\u00E3o foi encontrado - -adding-message-to-context=Adicionando uma mensagem no contexto: [{0}] -cleaning-message-context=Limpando o contexto de mensagens -access-checking=Verificando permiss\u00E3o do usu\u00E1rio "{0}" para executar a a\u00E7\u00E3o "{1}" no recurso "{2}" -access-allowed=O usu\u00E1rio "{0}" acessou o recurso "{2}" com a a\u00E7\u00E3o "{1}" -access-denied=O usu\u00E1rio "{0}" n\u00E3o possui permiss\u00E3o para executar a a\u00E7\u00E3o "{1}" no recurso "{2}" -access-denied-ui=Voc\u00EA n\u00E3o est\u00E1 autorizado a executar a a\u00E7\u00E3o {1} no recurso {0} -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 -user-not-authenticated=Usu\u00E1rio n\u00E3o autenticado -has-role-verification=Verificando se o usu\u00E1rio {0} possui a(s) role(s)\: {1} -does-not-have-role=Usu\u00E1rio {0} n\u00E3o possui a(s) role(s)\: {1} -does-not-have-role-ui=Para acessar este recurso \u00E9 necess\u00E1rio ser {0} -user-has-role=Usu\u00E1rio {0} possui a(s) role(s)\: {1} -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 \ No newline at end of file diff --git a/impl/core/src/test/resources/demoiselle-core-bundle_pt_BR.properties b/impl/core/src/test/resources/demoiselle-core-bundle_pt_BR.properties deleted file mode 100644 index d9229e3..0000000 --- a/impl/core/src/test/resources/demoiselle-core-bundle_pt_BR.properties +++ /dev/null @@ -1,95 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -engine-on=Ligando os motores do Demoiselle ${project.version} -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} -handling-exception=Tratando a exce\u00E7\u00E3o {0} -proxy-detected=Detectado o proxy {0} da classe {1} -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 -taking-off=O Demoiselle ${project.version} decolou -engine-off=Desligando os motores do Demoiselle ${project.version} -setting-up-bean-manager=BeanManager dispon\u00EDvel atrav\u00E9s do utilit\u00E1rio {0} - -user-transaction-lookup-fail=N\u00E3o foi encontrada nenhuma transa\u00E7\u00E3o com o nome {0} no contexto JNDI -transactional-execution=Execu\u00E7\u00E3o transacional de {0} -begin-transaction=Transa\u00E7\u00E3o inciada -transaction-marked-rollback=Transa\u00E7\u00E3o marcada para rollback [{0}] -transaction-already-finalized=A transa\u00E7\u00E3o j\u00E1 havia sido finalizada -transaction-commited=Transa\u00E7\u00E3o finalizada com sucesso -transaction-rolledback=Transa\u00E7\u00E3o finalizada com rollback - -bootstrap.configuration.processing=Processando {0} - -loading-configuration-class=Carregando a classe de configura\u00E7\u00E3o {0} -configuration-field-loaded=Configura\u00E7\u00E3o {0} atribu\u00EDda \u00E0 {1} com o valor {2} -configuration-attribute-is-mandatory=A configura\u00E7\u00E3o {0} \u00E9 obrigat\u00F3ria, mas n\u00E3o foi encontrada em {1} -configuration-name-attribute-cant-be-empty=A nota\u00E7\u00E3o Name n\u00E3o pode estar em branco -configuration-key-not-found=Chave de configura\u00E7\u00E3o "{0}" n\u00E3o encontrada. Conven\u00E7\u00F5es verificadas\: "{1}" - -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 -executing-all=Executando todos os \: {0} -custom-context-was-registered=O contexto {0} foi registrado -custom-context-was-unregistered=O contexto {0} foi removido - -error-creating-configuration-from-resource=Error creating configuration from resource named "{0}" -configuration-type-not-implemented-yet=Configuration type "{0}" is not implemented yet -error-converting-to-type=Error converting to type "{0}" -error-creating-new-instance-for=Error creating a new instance for "{0}" -executed-successfully=\ {0} execultado com sucesso -must-declare-one-single-parameter=Voc\u00EA deve declarar um par\u00E2metro \u00FAnico em {0} -loading-default-transaction-manager=Carregando o gerenciador de transa\u00E7\u00E3o padr\u00E3o {0} -transaction-class-not-found=A classe de transa\u00E7\u00E3o "{0}" informada n\u00E3o foi encontrada. -transaction-class-must-be-of-type=A classe de transa\u00E7\u00E3o "{0}" informada deve ser do tipo {1} -results-count-greater-page-size=Quantidade de resultados {0} \u00E9 maior que o tamanho da p\u00E1gina {1} -page-result=Resultado paginado [p\u00E1gina\={0}, total de resultados\={1}] -page=P\u00E1gina [n\u00FAmero\={0}, tamanho\={1}] -processing=Processando\: {0} -processing-fail=Falha no processamento devido a uma exce\u00E7\u00E3o lan\u00E7ada pela aplica\u00E7\u00E3o -for= \ para\: -file-not-found=O arquivo {0} n\u00E3o foi encontrado - -adding-message-to-context=Adicionando uma mensagem no contexto: [{0}] -cleaning-message-context=Limpando o contexto de mensagens -access-checking=Verificando permiss\u00E3o do usu\u00E1rio "{0}" para executar a a\u00E7\u00E3o "{1}" no recurso "{2}" -access-allowed=O usu\u00E1rio "{0}" acessou o recurso "{2}" com a a\u00E7\u00E3o "{1}" -access-denied=O usu\u00E1rio "{0}" n\u00E3o possui permiss\u00E3o para executar a a\u00E7\u00E3o "{1}" no recurso "{2}" -access-denied-ui=Voc\u00EA n\u00E3o est\u00E1 autorizado a executar a a\u00E7\u00E3o {1} no recurso {0} -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 -user-not-authenticated=Usu\u00E1rio n\u00E3o autenticado -has-role-verification=Verificando se o usu\u00E1rio {0} possui a(s) role(s)\: {1} -does-not-have-role=Usu\u00E1rio {0} n\u00E3o possui a(s) role(s)\: {1} -does-not-have-role-ui=Para acessar este recurso \u00E9 necess\u00E1rio ser {0} -user-has-role=Usu\u00E1rio {0} possui a(s) role(s)\: {1} -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 \ No newline at end of file diff --git a/impl/core/src/test/resources/demoiselle.properties b/impl/core/src/test/resources/demoiselle.properties deleted file mode 100644 index 7330774..0000000 --- a/impl/core/src/test/resources/demoiselle.properties +++ /dev/null @@ -1,81 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -frameworkdemoiselle.core.bootstrap.observed= -frameworkdemoiselle.persistence.unit= - -frameworkdemoiselle.pagination.page_size=50 -frameworkdemoiselle.pagination.max_page_links=10 - -br.gov.frameworkdemoiselle.success=Success -frameworkdemoiselle.configurationtest.nameConfiguration=ConfigurationTest -frameworkdemoiselle.configurationtest.name=ConfigurationTest2 -nameConfiguration=ConfigurationTest -isNameConfiguration=true -byteConfiguration=75 -doubleConfiguration=7.5 -floatConfiguration=0.0f -integerConfiguration=75 -longConfiguration=75 -shortConfiguration=-75 -bigDecimalConfiguration=7.5 -bigIntegerConfiguration=75 -listConfiguration=azul,verde -stringArrayConfiguration=azul,verde -intArrayConfiguration=1,2 -objectConfiguration=null -propertiesConfiguration.valor1=azul -propertiesConfiguration.valor2=verde -fourConfiguration=quatro -four.configuration=quatro -four_configuration=quatro -fourconfiguration=quatro -threeConfiguration=três -three.configuration=três -three_configuration=três -twoConfiguration=dois -two.configuration=dois -typeOneConfiguration=tipo um -type.two.configuration=tipo dois -type_three_configuration=tipo tres -typefourconfiguration=tipo quatro -convention_underline=Convention Underline -convention.dot=Convention Dot -conventionalllowercase=All LowerCase -CONVENTIONALLUPPERCASE=ALL UPPERCASE -complexObject=null -properties.1=teste1 -properties.2=teste2 -classe=br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderTest \ No newline at end of file diff --git a/impl/core/src/test/resources/demoiselle.xml b/impl/core/src/test/resources/demoiselle.xml deleted file mode 100644 index 8a0ba2d..0000000 --- a/impl/core/src/test/resources/demoiselle.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - All LowerCase - ALL UPPERCASE - Convention_Underline - - convention.dot - - ConfigurationTest -
- - - ConfigurationTest - - -
-
\ No newline at end of file diff --git a/impl/core/src/test/resources/messages.properties b/impl/core/src/test/resources/messages.properties deleted file mode 100644 index a447696..0000000 --- a/impl/core/src/test/resources/messages.properties +++ /dev/null @@ -1,47 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -teste=teste - -# Message test -testGetStringMessageDefaultResourceName.message=Testando mensagens usando o resourceName padrão - -first-key=First message text -second-key=Second message text -THIRD_KEY=Third message text -FOURTH_KEY=Fourth message text - -FIRST_ERROR_KEY=First error message text -second-error-key=Second error message text \ No newline at end of file diff --git a/impl/core/src/test/resources/resource-bundle_pt.properties b/impl/core/src/test/resources/resource-bundle_pt.properties deleted file mode 100644 index 0af46d9..0000000 --- a/impl/core/src/test/resources/resource-bundle_pt.properties +++ /dev/null @@ -1,2 +0,0 @@ -msgWithoutParams=no params -msgWithParams=params: {0}, {1} \ No newline at end of file diff --git a/impl/core/src/test/resources/test-message.properties b/impl/core/src/test/resources/test-message.properties deleted file mode 100644 index 9de9f9e..0000000 --- a/impl/core/src/test/resources/test-message.properties +++ /dev/null @@ -1,6 +0,0 @@ -first-key=First message text -second-key=Second message text -THIRD_KEY=Third message text -FOURTH_KEY=Fourth message text -key=param {0} and param {1} -error-key=Error message text \ No newline at end of file diff --git a/impl/core/src/test/resources/testGetStringMessage.properties b/impl/core/src/test/resources/testGetStringMessage.properties deleted file mode 100644 index f3146dd..0000000 --- a/impl/core/src/test/resources/testGetStringMessage.properties +++ /dev/null @@ -1,37 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -DefaultMessageTest.s1=Rodando {0} para {1} -DefaultMessageTest.no-locale=Usando o locale default \ No newline at end of file diff --git a/impl/core/src/test/resources/testGetStringMessage_en.properties b/impl/core/src/test/resources/testGetStringMessage_en.properties deleted file mode 100644 index fed5586..0000000 --- a/impl/core/src/test/resources/testGetStringMessage_en.properties +++ /dev/null @@ -1,36 +0,0 @@ -# Demoiselle Framework -# Copyright (C) 2010 SERPRO -# ---------------------------------------------------------------------------- -# This file is part of Demoiselle Framework. -# -# Demoiselle Framework is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License version 3 -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License version 3 -# along with this program; if not, see -# or write to the Free Software Foundation, Inc., 51 Franklin Street, -# Fifth Floor, Boston, MA 02110-1301, USA. -# ---------------------------------------------------------------------------- -# Este arquivo é parte do Framework Demoiselle. -# -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -# do Software Livre (FSF). -# -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -# para maiores detalhes. -# -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -# "LICENCA.txt", junto com esse programa. Se não, acesse -# ou escreva para a Fundação do Software Livre (FSF) Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - -DefaultMessageTest.s1=Running {0} for {1} \ No newline at end of file -- libgit2 0.21.2