Commit 8e309ba046a99d676e785aa6444f15bbaa5f2a5f
1 parent
62d7edd7
Exists in
master
Inclusão dos testes de personalização do carregador de configuração
Showing
12 changed files
with
382 additions
and
6 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationClassValueExtractor.java
| @@ -56,10 +56,8 @@ public class ConfigurationClassValueExtractor implements ConfigurationValueExtra | @@ -56,10 +56,8 @@ public class ConfigurationClassValueExtractor implements ConfigurationValueExtra | ||
| 56 | String canonicalName = configuration.getString(prefix + key); | 56 | String canonicalName = configuration.getString(prefix + key); |
| 57 | 57 | ||
| 58 | if (canonicalName != null) { | 58 | if (canonicalName != null) { |
| 59 | - ClassLoader classLoader = Reflections.getClassLoaderForClass(canonicalName); | ||
| 60 | - | ||
| 61 | try { | 59 | try { |
| 62 | - value = Class.forName(canonicalName, true, classLoader); | 60 | + value = Reflections.forName(canonicalName); |
| 63 | } catch (ClassNotFoundException cause) { | 61 | } catch (ClassNotFoundException cause) { |
| 64 | // TODO Lançar a mensagem correta | 62 | // TODO Lançar a mensagem correta |
| 65 | throw new ConfigurationException(null, cause); | 63 | throw new ConfigurationException(null, cause); |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationLoader.java
| @@ -51,6 +51,7 @@ import org.apache.commons.configuration.FileConfiguration; | @@ -51,6 +51,7 @@ import org.apache.commons.configuration.FileConfiguration; | ||
| 51 | import org.apache.commons.configuration.PropertiesConfiguration; | 51 | import org.apache.commons.configuration.PropertiesConfiguration; |
| 52 | import org.apache.commons.configuration.SystemConfiguration; | 52 | import org.apache.commons.configuration.SystemConfiguration; |
| 53 | import org.apache.commons.configuration.XMLConfiguration; | 53 | import org.apache.commons.configuration.XMLConfiguration; |
| 54 | +import org.slf4j.Logger; | ||
| 54 | 55 | ||
| 55 | import br.gov.frameworkdemoiselle.annotation.Ignore; | 56 | import br.gov.frameworkdemoiselle.annotation.Ignore; |
| 56 | import br.gov.frameworkdemoiselle.annotation.Name; | 57 | import br.gov.frameworkdemoiselle.annotation.Name; |
| @@ -60,7 +61,9 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | @@ -60,7 +61,9 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | ||
| 60 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | 61 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| 61 | import br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap; | 62 | import br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap; |
| 62 | import br.gov.frameworkdemoiselle.util.Beans; | 63 | import br.gov.frameworkdemoiselle.util.Beans; |
| 64 | +import br.gov.frameworkdemoiselle.util.NameQualifier; | ||
| 63 | import br.gov.frameworkdemoiselle.util.Reflections; | 65 | import br.gov.frameworkdemoiselle.util.Reflections; |
| 66 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
| 64 | 67 | ||
| 65 | /** | 68 | /** |
| 66 | * This component loads a config class annotated with {@link Configuration} by filling its attributes with {@link Param} | 69 | * This component loads a config class annotated with {@link Configuration} by filling its attributes with {@link Param} |
| @@ -72,6 +75,10 @@ public class ConfigurationLoader implements Serializable { | @@ -72,6 +75,10 @@ public class ConfigurationLoader implements Serializable { | ||
| 72 | 75 | ||
| 73 | private static final long serialVersionUID = 1L; | 76 | private static final long serialVersionUID = 1L; |
| 74 | 77 | ||
| 78 | + private static ResourceBundle bundle; | ||
| 79 | + | ||
| 80 | + private static Logger logger; | ||
| 81 | + | ||
| 75 | private Object object; | 82 | private Object object; |
| 76 | 83 | ||
| 77 | private ConfigType type; | 84 | private ConfigType type; |
| @@ -85,6 +92,8 @@ public class ConfigurationLoader implements Serializable { | @@ -85,6 +92,8 @@ public class ConfigurationLoader implements Serializable { | ||
| 85 | private Collection<Field> fields; | 92 | private Collection<Field> fields; |
| 86 | 93 | ||
| 87 | public void load(Object object) throws ConfigurationException { | 94 | public void load(Object object) throws ConfigurationException { |
| 95 | + getLogger().debug(getBundle().getString("loading-configuration-class", object.getClass().getName())); | ||
| 96 | + | ||
| 88 | this.object = object; | 97 | this.object = object; |
| 89 | 98 | ||
| 90 | loadFields(); | 99 | loadFields(); |
| @@ -220,6 +229,7 @@ public class ConfigurationLoader implements Serializable { | @@ -220,6 +229,7 @@ public class ConfigurationLoader implements Serializable { | ||
| 220 | if (elected == null) { | 229 | if (elected == null) { |
| 221 | // TODO lançar exceção informando que nenhum extrator foi encontrado para o field e ensinar como implementar | 230 | // TODO lançar exceção informando que nenhum extrator foi encontrado para o field e ensinar como implementar |
| 222 | // um extrator personalizado. | 231 | // um extrator personalizado. |
| 232 | + throw new ConfigurationException(""); | ||
| 223 | } | 233 | } |
| 224 | 234 | ||
| 225 | return elected; | 235 | return elected; |
| @@ -253,4 +263,20 @@ public class ConfigurationLoader implements Serializable { | @@ -253,4 +263,20 @@ public class ConfigurationLoader implements Serializable { | ||
| 253 | // TODO: Pegar mensagem do Bundle e verificar como as mensagens de log estão implementadas | 263 | // TODO: Pegar mensagem do Bundle e verificar como as mensagens de log estão implementadas |
| 254 | } | 264 | } |
| 255 | } | 265 | } |
| 266 | + | ||
| 267 | + private static ResourceBundle getBundle() { | ||
| 268 | + if (bundle == null) { | ||
| 269 | + bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")); | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + return bundle; | ||
| 273 | + } | ||
| 274 | + | ||
| 275 | + private static Logger getLogger() { | ||
| 276 | + if (logger == null) { | ||
| 277 | + logger = Beans.getReference(Logger.class, new NameQualifier(ConfigurationLoader.class.getName())); | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + return logger; | ||
| 281 | + } | ||
| 256 | } | 282 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/StrategySelector.java
| @@ -100,7 +100,9 @@ public final class StrategySelector implements Serializable { | @@ -100,7 +100,9 @@ public final class StrategySelector implements Serializable { | ||
| 100 | } | 100 | } |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | - checkForAmbiguity(type, selected, options); | 103 | + if (selected != null) { |
| 104 | + checkForAmbiguity(type, selected, options); | ||
| 105 | + } | ||
| 104 | 106 | ||
| 105 | return selected; | 107 | return selected; |
| 106 | } | 108 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducer.java
| @@ -56,18 +56,21 @@ import javax.enterprise.inject.spi.InjectionPoint; | @@ -56,18 +56,21 @@ import javax.enterprise.inject.spi.InjectionPoint; | ||
| 56 | 56 | ||
| 57 | import org.slf4j.Logger; | 57 | import org.slf4j.Logger; |
| 58 | 58 | ||
| 59 | +import br.gov.frameworkdemoiselle.DemoiselleException; | ||
| 60 | +import br.gov.frameworkdemoiselle.annotation.Name; | ||
| 59 | import br.gov.frameworkdemoiselle.internal.proxy.Slf4jLoggerProxy; | 61 | import br.gov.frameworkdemoiselle.internal.proxy.Slf4jLoggerProxy; |
| 62 | +import br.gov.frameworkdemoiselle.util.Reflections; | ||
| 60 | 63 | ||
| 61 | public class LoggerProducer implements Serializable { | 64 | public class LoggerProducer implements Serializable { |
| 62 | 65 | ||
| 63 | private static final long serialVersionUID = 1L; | 66 | private static final long serialVersionUID = 1L; |
| 64 | 67 | ||
| 65 | - @Produces | ||
| 66 | @Default | 68 | @Default |
| 69 | + @Produces | ||
| 67 | public Logger create(final InjectionPoint ip) { | 70 | public Logger create(final InjectionPoint ip) { |
| 68 | Class<?> type; | 71 | Class<?> type; |
| 69 | 72 | ||
| 70 | - if (ip != null) { | 73 | + if (ip.getMember() != null) { |
| 71 | type = ip.getMember().getDeclaringClass(); | 74 | type = ip.getMember().getDeclaringClass(); |
| 72 | } else { | 75 | } else { |
| 73 | type = LoggerProducer.class; | 76 | type = LoggerProducer.class; |
| @@ -76,6 +79,24 @@ public class LoggerProducer implements Serializable { | @@ -76,6 +79,24 @@ public class LoggerProducer implements Serializable { | ||
| 76 | return create(type); | 79 | return create(type); |
| 77 | } | 80 | } |
| 78 | 81 | ||
| 82 | + @Name("") | ||
| 83 | + @Produces | ||
| 84 | + public Logger createNamed(final InjectionPoint ip) throws ClassNotFoundException { | ||
| 85 | + Class<?> type; | ||
| 86 | + | ||
| 87 | + try { | ||
| 88 | + String canonicalName = ip.getAnnotated().getAnnotation(Name.class).value(); | ||
| 89 | + type = Reflections.forName(canonicalName); | ||
| 90 | + | ||
| 91 | + } catch (ClassCastException cause) { | ||
| 92 | + // TODO Colocar a mensgaem apropriada mostrando como utilizar a anotação @Name corretamente com a injeção de | ||
| 93 | + // Logger. | ||
| 94 | + throw new DemoiselleException(null, cause); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + return create(type); | ||
| 98 | + } | ||
| 99 | + | ||
| 79 | public static <T> Logger create(Class<T> type) { | 100 | public static <T> Logger create(Class<T> type) { |
| 80 | return new Slf4jLoggerProxy(type); | 101 | return new Slf4jLoggerProxy(type); |
| 81 | } | 102 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java
| @@ -191,4 +191,10 @@ public final class Reflections { | @@ -191,4 +191,10 @@ public final class Reflections { | ||
| 191 | ClassLoader classLoader = getClassLoaderForResource(resource); | 191 | ClassLoader classLoader = getClassLoaderForResource(resource); |
| 192 | return classLoader != null ? classLoader.getResource(resource) : null; | 192 | return classLoader != null ? classLoader.getResource(resource) : null; |
| 193 | } | 193 | } |
| 194 | + | ||
| 195 | + @SuppressWarnings("unchecked") | ||
| 196 | + public static <T> Class<T> forName(final String className) throws ClassNotFoundException { | ||
| 197 | + ClassLoader classLoader = getClassLoaderForClass(className); | ||
| 198 | + return (Class<T>) Class.forName(className, true, classLoader); | ||
| 199 | + } | ||
| 194 | } | 200 | } |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/custom/ConfigurationCustomFieldTest.java
0 → 100644
| @@ -0,0 +1,89 @@ | @@ -0,0 +1,89 @@ | ||
| 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.custom; | ||
| 38 | + | ||
| 39 | +import static junit.framework.Assert.assertNotNull; | ||
| 40 | +import static junit.framework.Assert.fail; | ||
| 41 | + | ||
| 42 | +import java.io.File; | ||
| 43 | + | ||
| 44 | +import javax.inject.Inject; | ||
| 45 | + | ||
| 46 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
| 47 | +import org.jboss.arquillian.junit.Arquillian; | ||
| 48 | +import org.jboss.shrinkwrap.api.asset.FileAsset; | ||
| 49 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
| 50 | +import org.junit.Test; | ||
| 51 | +import org.junit.runner.RunWith; | ||
| 52 | + | ||
| 53 | +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; | ||
| 54 | +import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | ||
| 55 | + | ||
| 56 | +@RunWith(Arquillian.class) | ||
| 57 | +public class ConfigurationCustomFieldTest extends AbstractConfigurationTest { | ||
| 58 | + | ||
| 59 | + @Inject | ||
| 60 | + private CustomMappedFieldConfig mappedField; | ||
| 61 | + | ||
| 62 | + @Inject | ||
| 63 | + private CustomUnmappedFieldConfig unmappedField; | ||
| 64 | + | ||
| 65 | + @Deployment | ||
| 66 | + public static JavaArchive createDeployment() { | ||
| 67 | + JavaArchive deployment = createConfigurationDeployment(); | ||
| 68 | + | ||
| 69 | + deployment.addPackages(true, ConfigurationCustomFieldTest.class.getPackage()); | ||
| 70 | + deployment.addAsResource(new FileAsset(new File( | ||
| 71 | + "src/test/resources/configuration/field/custom/demoiselle.properties")), "demoiselle.properties"); | ||
| 72 | + | ||
| 73 | + return deployment; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Test | ||
| 77 | + public void loadMappedClass() { | ||
| 78 | + assertNotNull(mappedField.getMappedClass()); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Test | ||
| 82 | + public void loadUnmappedClass() { | ||
| 83 | + try { | ||
| 84 | + unmappedField.getUnmappedClass(); | ||
| 85 | + fail(); | ||
| 86 | + } catch (ConfigurationException cause) { | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/custom/CustomMappedFieldConfig.java
0 → 100644
| @@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
| 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.custom; | ||
| 38 | + | ||
| 39 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 40 | + | ||
| 41 | +@Configuration | ||
| 42 | +public class CustomMappedFieldConfig { | ||
| 43 | + | ||
| 44 | + private MappedClass mappedClass; | ||
| 45 | + | ||
| 46 | + public MappedClass getMappedClass() { | ||
| 47 | + return mappedClass; | ||
| 48 | + } | ||
| 49 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/custom/CustomUnmappedFieldConfig.java
0 → 100644
| @@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
| 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.custom; | ||
| 38 | + | ||
| 39 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 40 | + | ||
| 41 | +@Configuration | ||
| 42 | +public class CustomUnmappedFieldConfig { | ||
| 43 | + | ||
| 44 | + private UnmappedClass unmappedClass; | ||
| 45 | + | ||
| 46 | + public UnmappedClass getUnmappedClass() { | ||
| 47 | + return unmappedClass; | ||
| 48 | + } | ||
| 49 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/custom/MappedClass.java
0 → 100644
| @@ -0,0 +1,41 @@ | @@ -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.custom; | ||
| 38 | + | ||
| 39 | +public class MappedClass { | ||
| 40 | + | ||
| 41 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/custom/MyValueExtractor.java
0 → 100644
| @@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.field.custom; | ||
| 2 | + | ||
| 3 | +import java.lang.reflect.Field; | ||
| 4 | + | ||
| 5 | +import org.apache.commons.configuration.Configuration; | ||
| 6 | + | ||
| 7 | +import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | ||
| 8 | + | ||
| 9 | +public class MyValueExtractor implements ConfigurationValueExtractor { | ||
| 10 | + | ||
| 11 | + @Override | ||
| 12 | + public Object getValue(String prefix, String key, Field field, Configuration configuration, Object defaultValue) { | ||
| 13 | + return new MappedClass(); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + @Override | ||
| 17 | + public boolean isSupported(Field field) { | ||
| 18 | + return field.getType() == MappedClass.class; | ||
| 19 | + } | ||
| 20 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/custom/UnmappedClass.java
0 → 100644
| @@ -0,0 +1,41 @@ | @@ -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.custom; | ||
| 38 | + | ||
| 39 | +public class UnmappedClass { | ||
| 40 | + | ||
| 41 | +} |
impl/core/src/test/resources/configuration/field/custom/demoiselle.properties
0 → 100644
| @@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
| 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. |