Commit 0d26fbc0e804eedcc5f6d360d9e5ee7b48c4c272
Exists in
master
Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0
Showing
5 changed files
with
316 additions
and
0 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/clazz/AbstractClassFieldConfig.java
0 → 100644
| ... | ... | @@ -0,0 +1,73 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.configuration.field.clazz; | |
| 38 | + | |
| 39 | +public abstract class AbstractClassFieldConfig { | |
| 40 | + | |
| 41 | + private Class<MyClass> existentTypedClass; | |
| 42 | + | |
| 43 | + private Class<?> existentUntypedClass; | |
| 44 | + | |
| 45 | + private Class<MyClass> nonExistentTypedClass; | |
| 46 | + | |
| 47 | + private Class<?> nonExistentUntypedClass; | |
| 48 | + | |
| 49 | + private Class<MyClass> forcingClassCastException; | |
| 50 | + | |
| 51 | + public Class<MyClass> getExistentTypedClass() { | |
| 52 | + return existentTypedClass; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public Class<?> getExistentUntypedClass() { | |
| 56 | + return existentUntypedClass; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public Class<MyClass> getNonExistentTypedClass() { | |
| 60 | + return nonExistentTypedClass; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public Class<?> getNonExistentUntypedClass() { | |
| 64 | + return nonExistentUntypedClass; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public Class<MyClass> getForcingClassCastException() { | |
| 68 | + return forcingClassCastException; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public static class MyClass { | |
| 72 | + } | |
| 73 | +} | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/clazz/ConfigurationClassFieldTest.java
0 → 100644
| ... | ... | @@ -0,0 +1,118 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.configuration.field.clazz; | |
| 38 | + | |
| 39 | +import static junit.framework.Assert.assertEquals; | |
| 40 | + | |
| 41 | +import java.io.File; | |
| 42 | + | |
| 43 | +import javax.inject.Inject; | |
| 44 | + | |
| 45 | +import junit.framework.Assert; | |
| 46 | + | |
| 47 | +import org.jboss.arquillian.container.test.api.Deployment; | |
| 48 | +import org.jboss.arquillian.junit.Arquillian; | |
| 49 | +import org.jboss.shrinkwrap.api.asset.FileAsset; | |
| 50 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | |
| 51 | +import org.junit.Test; | |
| 52 | +import org.junit.runner.RunWith; | |
| 53 | + | |
| 54 | +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; | |
| 55 | +import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | |
| 56 | +import br.gov.frameworkdemoiselle.configuration.field.clazz.AbstractClassFieldConfig.MyClass; | |
| 57 | + | |
| 58 | +@RunWith(Arquillian.class) | |
| 59 | +public class ConfigurationClassFieldTest extends AbstractConfigurationTest { | |
| 60 | + | |
| 61 | + @Inject | |
| 62 | + private PropertiesClassFieldConfig propertiesConfig; | |
| 63 | + | |
| 64 | + @Deployment | |
| 65 | + public static JavaArchive createDeployment() { | |
| 66 | + JavaArchive deployment = createConfigurationDeployment(); | |
| 67 | + | |
| 68 | + deployment.addPackages(true, ConfigurationClassFieldTest.class.getPackage()); | |
| 69 | + deployment.addAsResource( | |
| 70 | + new FileAsset(new File("src/test/resources/configuration/field/class/demoiselle.properties")), | |
| 71 | + "demoiselle.properties").addAsResource( | |
| 72 | + new FileAsset(new File("src/test/resources/configuration/field/class/demoiselle.xml")), | |
| 73 | + "demoiselle.xml"); | |
| 74 | + | |
| 75 | + return deployment; | |
| 76 | + } | |
| 77 | + | |
| 78 | + @Test | |
| 79 | + public void loadExistentTypedClass() { | |
| 80 | + Class<MyClass> expected = MyClass.class; | |
| 81 | + | |
| 82 | + assertEquals(expected, propertiesConfig.getExistentTypedClass()); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @Test | |
| 86 | + public void loadExistentUntypedClass() { | |
| 87 | + Class<?> expected = MyClass.class; | |
| 88 | + | |
| 89 | + assertEquals(expected, propertiesConfig.getExistentUntypedClass()); | |
| 90 | + } | |
| 91 | + | |
| 92 | + @Test | |
| 93 | + public void loadNonExistentTypedClass() { | |
| 94 | + try { | |
| 95 | + propertiesConfig.getNonExistentTypedClass(); | |
| 96 | + } catch (ConfigurationException cause) { | |
| 97 | + Assert.assertEquals(ClassNotFoundException.class, cause.getCause()); | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 101 | + @Test | |
| 102 | + public void loadNonExistentUntypedClass() { | |
| 103 | + try { | |
| 104 | + propertiesConfig.getNonExistentUntypedClass(); | |
| 105 | + } catch (ConfigurationException cause) { | |
| 106 | + Assert.assertEquals(ClassNotFoundException.class, cause.getCause()); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + | |
| 110 | + @Test | |
| 111 | + public void loadForcingClassCastException() { | |
| 112 | + try { | |
| 113 | + propertiesConfig.getForcingClassCastException(); | |
| 114 | + } catch (ConfigurationException cause) { | |
| 115 | + Assert.assertEquals(ClassCastException.class, cause.getCause()); | |
| 116 | + } | |
| 117 | + } | |
| 118 | +} | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/clazz/PropertiesClassFieldConfig.java
0 → 100644
| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.configuration.field.clazz; | |
| 38 | + | |
| 39 | +public class PropertiesClassFieldConfig extends AbstractClassFieldConfig { | |
| 40 | + | |
| 41 | +} | ... | ... |
impl/core/src/test/resources/configuration/field/class/demoiselle.properties
0 → 100644
| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | +# Demoiselle Framework | |
| 2 | +# Copyright (C) 2010 SERPRO | |
| 3 | +# ---------------------------------------------------------------------------- | |
| 4 | +# This file is part of Demoiselle Framework. | |
| 5 | +# | |
| 6 | +# Demoiselle Framework is free software; you can redistribute it and/or | |
| 7 | +# modify it under the terms of the GNU Lesser General Public License version 3 | |
| 8 | +# as published by the Free Software Foundation. | |
| 9 | +# | |
| 10 | +# This program is distributed in the hope that it will be useful, | |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | +# GNU General Public License for more details. | |
| 14 | +# | |
| 15 | +# You should have received a copy of the GNU Lesser General Public License version 3 | |
| 16 | +# along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 17 | +# or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 18 | +# Fifth Floor, Boston, MA 02110-1301, USA. | |
| 19 | +# ---------------------------------------------------------------------------- | |
| 20 | +# Este arquivo é parte do Framework Demoiselle. | |
| 21 | +# | |
| 22 | +# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 23 | +# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 24 | +# do Software Livre (FSF). | |
| 25 | +# | |
| 26 | +# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 27 | +# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 28 | +# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 29 | +# para maiores detalhes. | |
| 30 | +# | |
| 31 | +# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 32 | +# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 33 | +# ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 34 | +# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 35 | + | |
| 36 | +existentTypedClass=br.gov.frameworkdemoiselle.configuration.field.clazz.AbstractClassFieldConfig.MyClass | |
| 37 | +existentUntypedClass=br.gov.frameworkdemoiselle.configuration.field.clazz.AbstractClassFieldConfig.MyClass | |
| 38 | +nonExistentTypedClass=com.fake.NonExistentClass | |
| 39 | +nonExistentUntypedClass=com.fake.NonExistentClass | |
| 40 | +forcingTypedClassCastException=java.lang.String | |
| 41 | +forcingClassCastException=java.lang.String | ... | ... |
impl/core/src/test/resources/configuration/field/class/demoiselle.xml
0 → 100644
| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | +<!-- | |
| 2 | + Demoiselle Framework | |
| 3 | + Copyright (C) 2010 SERPRO | |
| 4 | + ============================================================================ | |
| 5 | + This file is part of Demoiselle Framework. | |
| 6 | + | |
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + as published by the Free Software Foundation. | |
| 10 | + | |
| 11 | + This program is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + GNU General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses /> | |
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + ============================================================================ | |
| 21 | + Este arquivo é parte do Framework Demoiselle. | |
| 22 | + | |
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + do Software Livre (FSF). | |
| 26 | + | |
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + para maiores detalhes. | |
| 31 | + | |
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses /> | |
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | +--> | |
| 37 | + | |
| 38 | +<configuration> | |
| 39 | + <primitiveInteger>1</primitiveInteger> | |
| 40 | + <wrappedInteger>2</wrappedInteger> | |
| 41 | + <stringWithSpace>demoiselle framework</stringWithSpace> | |
| 42 | + <stringWithComma>demoiselle,framework</stringWithComma> | |
| 43 | +</configuration> | ... | ... |