From a435deee86a6aeafb0f63ef824710e77d3b6b397 Mon Sep 17 00:00:00 2001 From: Clovis Junior Date: Thu, 14 Jun 2012 11:55:00 -0300 Subject: [PATCH] Adicionado novos tipos para o Configuration do Demoiselle --- impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java | 2 +- impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java | 520 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java | 516 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration-with-array.properties | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration-with-array.xml | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration-with-list.properties | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/resources/configuration-with-list.xml | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 1541 insertions(+), 7 deletions(-) create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java create mode 100644 impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java create mode 100644 impl/core/src/test/resources/configuration-with-array.properties create mode 100644 impl/core/src/test/resources/configuration-with-array.xml create mode 100644 impl/core/src/test/resources/configuration-with-list.properties create mode 100644 impl/core/src/test/resources/configuration-with-list.xml diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java index b633000..fc0cdca 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java @@ -38,6 +38,8 @@ package br.gov.frameworkdemoiselle.internal.configuration; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; import java.util.HashSet; import java.util.Iterator; import java.util.Properties; @@ -46,6 +48,7 @@ import java.util.Set; import javax.inject.Inject; import javax.validation.constraints.NotNull; +import org.apache.commons.configuration.DataConfiguration; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.configuration.SystemConfiguration; import org.apache.commons.configuration.XMLConfiguration; @@ -105,7 +108,8 @@ public class ConfigurationLoader { org.apache.commons.configuration.Configuration config = getConfiguration(resource, type); String key = getKey(field, clazz, config); - Object value = getValue(key, field.getType(), config); + //Object value = getValue(key, field.getType(), config); + Object value = getValue(key, field, config); validate(field, key, value, resource); setValue(field, key, object, value); @@ -211,11 +215,11 @@ public class ConfigurationLoader { break; case PROPERTIES: - config = new PropertiesConfiguration(resource + ".properties"); + config = new DataConfiguration(new PropertiesConfiguration(resource + ".properties")); break; case XML: - config = new XMLConfiguration(resource + ".xml"); + config = new DataConfiguration(new XMLConfiguration(resource + ".xml")); break; default: @@ -239,7 +243,7 @@ public class ConfigurationLoader { * @param fieldClass * @return the value */ - @SuppressWarnings("unchecked") + /*@SuppressWarnings("unchecked") private T getValue(String key, Class fieldClass, org.apache.commons.configuration.Configuration config) { Object value; @@ -254,9 +258,27 @@ public class ConfigurationLoader { } return (T) value; - } + }*/ + + @SuppressWarnings("unchecked") + private T getValue(String key, Field field, org.apache.commons.configuration.Configuration config) { + Object value; + + Class fieldClass = (Class) field.getType(); + + if (fieldClass.isArray()) { + value = getArray(key, field, config); + } else if (fieldClass.equals(Properties.class)) { + value = getProperty(key, config); - private Object getBasic(String key, Class fieldClass, org.apache.commons.configuration.Configuration config) { + } else { + value = getBasic(key, field, config); + } + + return (T) value; + } + + /*private Object getBasic(String key, Class fieldClass, org.apache.commons.configuration.Configuration config) { Object value = null; try { @@ -266,6 +288,7 @@ public class ConfigurationLoader { if (!fieldClass.isPrimitive()) { method = config.getClass().getMethod(methodName, String.class, fieldClass); value = method.invoke(config, key, null); + } else if (config.containsKey(key)) { method = config.getClass().getMethod(methodName, String.class); value = method.invoke(config, key); @@ -276,8 +299,93 @@ public class ConfigurationLoader { } return value; + }*/ + + private Object getArray(String key, Field field, org.apache.commons.configuration.Configuration config) { + Object value = null; + + Class fieldClass = (Class) field.getType(); + + try { + Method method; + + String methodName = "get"; + + methodName += Strings.firstToUpper(fieldClass.getSimpleName()); + methodName = Strings.removeChars(methodName, '[', ']'); + + methodName += "Array"; + + method = config.getClass().getMethod(methodName, String.class); + value = method.invoke(config, key); + + } catch (Throwable cause) { + throw new ConfigurationException(bundle.getString("error-converting-to-type", fieldClass.getName()), cause); + } + + return value; } + private Object getBasic(String key, Field field, org.apache.commons.configuration.Configuration config) { + Object value = null; + + Class fieldClass = (Class) field.getType(); + + try { + Method method; + + String methodName = "get"; + + methodName += discoveryGenericType(field); + + methodName += Strings.firstToUpper(fieldClass.getSimpleName()); + + if (!fieldClass.isPrimitive()) { + method = config.getClass().getMethod(methodName, String.class, fieldClass); + value = method.invoke(config, key, null); + + } else if (config.containsKey(key)) { + method = config.getClass().getMethod(methodName, String.class); + value = method.invoke(config, key); + } + + } catch (Throwable cause) { + throw new ConfigurationException(bundle.getString("error-converting-to-type", fieldClass.getName()), cause); + } + + return value; + } + + /** + * Discovery the Generic's type. + * + * for example: the generic's type of List list is an Integer type + * + * @param field + * @return + */ + private String discoveryGenericType(Field field) { + + Type genericFieldType = field.getGenericType(); + + if(genericFieldType instanceof ParameterizedType){ + ParameterizedType type = (ParameterizedType) genericFieldType; + Type[] fieldArgumentTypes = type.getActualTypeArguments(); + for(Type fieldArgumentType : fieldArgumentTypes){ + @SuppressWarnings("rawtypes") + Class fieldArgumentClass = (Class) fieldArgumentType; + + if("String".equals(fieldArgumentClass.getSimpleName())) { + return ""; + } + + return fieldArgumentClass.getSimpleName(); + } + } + + return ""; + } + private Object getProperty(String key, org.apache.commons.configuration.Configuration config) { Object value = null; 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 index 4995537..1ab4187 100644 --- 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 @@ -277,7 +277,7 @@ public class ConfigurationLoaderTest { protected ConfigurationWithConventionAllLowerCase complexObject; } - + @Before public void setUp() throws Exception { Logger logger; 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 new file mode 100644 index 0000000..faae51d --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithArrayTest.java @@ -0,0 +1,520 @@ +/* + * 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 org.powermock.reflect.Whitebox; +import org.slf4j.Logger; + +import br.gov.frameworkdemoiselle.configuration.ConfigType; +import br.gov.frameworkdemoiselle.configuration.Configuration; +import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(CoreBootstrap.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 { + Logger logger; + ResourceBundle bundle; + logger = PowerMock.createMock(Logger.class); + bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); + configurationLoader = new ConfigurationLoader(); + Whitebox.setInternalState(this.configurationLoader, "bundle", bundle); + Whitebox.setInternalState(this.configurationLoader, "logger", logger); + } + + @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() { + ConfigurationPropertiesWithArray config = new ConfigurationPropertiesWithArray(); + + mockStatic(CoreBootstrap.class); + expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); + PowerMock.replay(CoreBootstrap.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() { + ConfigurationXMLWithArray config = new ConfigurationXMLWithArray(); + + mockStatic(CoreBootstrap.class); + expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); + PowerMock.replay(CoreBootstrap.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 new file mode 100644 index 0000000..f2eced6 --- /dev/null +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderWithListTest.java @@ -0,0 +1,516 @@ +/* + * 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 org.powermock.reflect.Whitebox; +import org.slf4j.Logger; + +import br.gov.frameworkdemoiselle.configuration.ConfigType; +import br.gov.frameworkdemoiselle.configuration.Configuration; +import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(CoreBootstrap.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 { + Logger logger; + ResourceBundle bundle; + logger = PowerMock.createMock(Logger.class); + bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle")); + configurationLoader = new ConfigurationLoader(); + Whitebox.setInternalState(this.configurationLoader, "bundle", bundle); + Whitebox.setInternalState(this.configurationLoader, "logger", logger); + } + + @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() { + ConfigurationPropertiesWithList config = new ConfigurationPropertiesWithList(); + + mockStatic(CoreBootstrap.class); + expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); + PowerMock.replay(CoreBootstrap.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() { + ConfigurationXMLWithList config = new ConfigurationXMLWithList(); + + mockStatic(CoreBootstrap.class); + expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true); + PowerMock.replay(CoreBootstrap.class); + + configurationLoader.load(config); + return config; + } +} diff --git a/impl/core/src/test/resources/configuration-with-array.properties b/impl/core/src/test/resources/configuration-with-array.properties new file mode 100644 index 0000000..65d02fc --- /dev/null +++ b/impl/core/src/test/resources/configuration-with-array.properties @@ -0,0 +1,50 @@ +# 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 new file mode 100644 index 0000000..d88ff3c --- /dev/null +++ b/impl/core/src/test/resources/configuration-with-array.xml @@ -0,0 +1,145 @@ + + + + + + + 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 new file mode 100644 index 0000000..cea3a15 --- /dev/null +++ b/impl/core/src/test/resources/configuration-with-list.properties @@ -0,0 +1,50 @@ +# 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 new file mode 100644 index 0000000..38154d3 --- /dev/null +++ b/impl/core/src/test/resources/configuration-with-list.xml @@ -0,0 +1,145 @@ + + + + + + + 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 -- libgit2 0.21.2