Commit 3588662662db27afc3d41667ed7dfe61738ab6e9
1 parent
b9a3c893
Exists in
master
Adicionados testes de configuração com tipos básicos utilizando arquivo
xml
Showing
14 changed files
with
180 additions
and
128 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/AbstractConfigurationTest.java
| @@ -45,7 +45,10 @@ public abstract class AbstractConfigurationTest { | @@ -45,7 +45,10 @@ public abstract class AbstractConfigurationTest { | ||
| 45 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") | 45 | .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") |
| 46 | .addAsResource( | 46 | .addAsResource( |
| 47 | new FileAsset(new File("src/test/resources/configuration/fields/basic/demoiselle.properties")), | 47 | new FileAsset(new File("src/test/resources/configuration/fields/basic/demoiselle.properties")), |
| 48 | - "demoiselle.properties") | 48 | + "demoiselle.properties"). |
| 49 | + addAsResource( | ||
| 50 | + new FileAsset(new File("src/test/resources/configuration/fields/basic/demoiselle.xml")), | ||
| 51 | + "demoiselle.xml") | ||
| 49 | .addAsManifestResource( | 52 | .addAsManifestResource( |
| 50 | new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), | 53 | new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), |
| 51 | "services/javax.enterprise.inject.spi.Extension"); | 54 | "services/javax.enterprise.inject.spi.Extension"); |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/basic/AbstractBasicFieldConfig.java
0 → 100644
| @@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.field.basic; | ||
| 2 | + | ||
| 3 | +public abstract class AbstractBasicFieldConfig { | ||
| 4 | + | ||
| 5 | + private int primitiveInteger; | ||
| 6 | + | ||
| 7 | + private Integer wrappedInteger; | ||
| 8 | + | ||
| 9 | + private String stringWithSpace; | ||
| 10 | + | ||
| 11 | + private String stringWithComma; | ||
| 12 | + | ||
| 13 | + public Integer getWrappedInteger() { | ||
| 14 | + return wrappedInteger; | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public void setWrappedInteger(Integer wrappedInteger) { | ||
| 18 | + this.wrappedInteger = wrappedInteger; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public int getPrimitiveInteger() { | ||
| 22 | + return primitiveInteger; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public void setPrimitiveInteger(int primitiveInteger) { | ||
| 26 | + this.primitiveInteger = primitiveInteger; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public String getStringWithSpace() { | ||
| 30 | + return stringWithSpace; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public void setStringWithSpace(String stringWithSpace) { | ||
| 34 | + this.stringWithSpace = stringWithSpace; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public String getStringWithComma() { | ||
| 38 | + return stringWithComma; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setStringWithComma(String stringWithComma) { | ||
| 42 | + this.stringWithComma = stringWithComma; | ||
| 43 | + } | ||
| 44 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/basic/ConfigurationBasicFieldTest.java
0 → 100644
| @@ -0,0 +1,60 @@ | @@ -0,0 +1,60 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.field.basic; | ||
| 2 | + | ||
| 3 | +import static junit.framework.Assert.assertEquals; | ||
| 4 | + | ||
| 5 | +import javax.inject.Inject; | ||
| 6 | + | ||
| 7 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
| 8 | +import org.jboss.arquillian.junit.Arquillian; | ||
| 9 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
| 10 | +import org.junit.Test; | ||
| 11 | +import org.junit.runner.RunWith; | ||
| 12 | + | ||
| 13 | +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; | ||
| 14 | + | ||
| 15 | +@RunWith(Arquillian.class) | ||
| 16 | +public class ConfigurationBasicFieldTest extends AbstractConfigurationTest { | ||
| 17 | + | ||
| 18 | + @Inject | ||
| 19 | + private PropertiesBasicFieldConfig propertiesConfig; | ||
| 20 | + | ||
| 21 | + @Inject | ||
| 22 | + private XMLBasicFieldConfig xmlConfig; | ||
| 23 | + | ||
| 24 | + @Deployment | ||
| 25 | + public static JavaArchive createDeployment() { | ||
| 26 | + return createConfigurationDeployment().addPackages(true, ConfigurationBasicFieldTest.class.getPackage()); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Test | ||
| 30 | + public void loadPrimitiveInteger() { | ||
| 31 | + int expected = 1; | ||
| 32 | + | ||
| 33 | + assertEquals(expected, propertiesConfig.getPrimitiveInteger()); | ||
| 34 | + assertEquals(expected, xmlConfig.getPrimitiveInteger()); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Test | ||
| 38 | + public void loadWrappedInteger() { | ||
| 39 | + Integer expected = 2; | ||
| 40 | + | ||
| 41 | + assertEquals(expected, propertiesConfig.getWrappedInteger()); | ||
| 42 | + assertEquals(expected, xmlConfig.getWrappedInteger()); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Test | ||
| 46 | + public void loadStringWithSpace() { | ||
| 47 | + String expected = "demoiselle framework"; | ||
| 48 | + | ||
| 49 | + assertEquals(expected, propertiesConfig.getStringWithSpace()); | ||
| 50 | + assertEquals(expected, xmlConfig.getStringWithSpace()); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | +// @Test | ||
| 54 | + public void loadStringWithComma() { | ||
| 55 | + String expected = "demoiselle,framework"; | ||
| 56 | + | ||
| 57 | + assertEquals(expected, propertiesConfig.getStringWithComma()); | ||
| 58 | + assertEquals(expected, xmlConfig.getStringWithComma()); | ||
| 59 | + } | ||
| 60 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/basic/PropertiesBasicFieldConfig.java
0 → 100644
| @@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.field.basic; | ||
| 2 | + | ||
| 3 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; | ||
| 4 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 5 | + | ||
| 6 | +@Configuration(type = PROPERTIES) | ||
| 7 | +public class PropertiesBasicFieldConfig extends AbstractBasicFieldConfig { | ||
| 8 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/basic/SystemBasicFieldConfig.java
0 → 100644
| @@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.field.basic; | ||
| 2 | + | ||
| 3 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.SYSTEM; | ||
| 4 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 5 | + | ||
| 6 | +@Configuration(type = SYSTEM) | ||
| 7 | +public class SystemBasicFieldConfig extends AbstractBasicFieldConfig { | ||
| 8 | + | ||
| 9 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/basic/XMLBasicFieldConfig.java
0 → 100644
| @@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.configuration.field.basic; | ||
| 2 | + | ||
| 3 | +import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; | ||
| 4 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 5 | + | ||
| 6 | +@Configuration(type = XML) | ||
| 7 | +public class XMLBasicFieldConfig extends AbstractBasicFieldConfig { | ||
| 8 | + | ||
| 9 | +} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/AbstractBasicFieldsConfig.java
| @@ -1,44 +0,0 @@ | @@ -1,44 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | - | ||
| 3 | -public abstract class AbstractBasicFieldsConfig { | ||
| 4 | - | ||
| 5 | - private int primitiveInteger; | ||
| 6 | - | ||
| 7 | - private Integer wrappedInteger; | ||
| 8 | - | ||
| 9 | - private String stringWithSpace; | ||
| 10 | - | ||
| 11 | - private String stringWithComma; | ||
| 12 | - | ||
| 13 | - public Integer getWrappedInteger() { | ||
| 14 | - return wrappedInteger; | ||
| 15 | - } | ||
| 16 | - | ||
| 17 | - public void setWrappedInteger(Integer wrappedInteger) { | ||
| 18 | - this.wrappedInteger = wrappedInteger; | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | - public int getPrimitiveInteger() { | ||
| 22 | - return primitiveInteger; | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - public void setPrimitiveInteger(int primitiveInteger) { | ||
| 26 | - this.primitiveInteger = primitiveInteger; | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - public String getStringWithSpace() { | ||
| 30 | - return stringWithSpace; | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - public void setStringWithSpace(String stringWithSpace) { | ||
| 34 | - this.stringWithSpace = stringWithSpace; | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - public String getStringWithComma() { | ||
| 38 | - return stringWithComma; | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - public void setStringWithComma(String stringWithComma) { | ||
| 42 | - this.stringWithComma = stringWithComma; | ||
| 43 | - } | ||
| 44 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/ConfigurationBasicFieldsTest.java
| @@ -1,53 +0,0 @@ | @@ -1,53 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | - | ||
| 3 | -import static junit.framework.Assert.assertEquals; | ||
| 4 | - | ||
| 5 | -import javax.inject.Inject; | ||
| 6 | - | ||
| 7 | -import org.jboss.arquillian.container.test.api.Deployment; | ||
| 8 | -import org.jboss.arquillian.junit.Arquillian; | ||
| 9 | -import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
| 10 | -import org.junit.Test; | ||
| 11 | -import org.junit.runner.RunWith; | ||
| 12 | - | ||
| 13 | -import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest; | ||
| 14 | - | ||
| 15 | -@RunWith(Arquillian.class) | ||
| 16 | -public class ConfigurationBasicFieldsTest extends AbstractConfigurationTest { | ||
| 17 | - | ||
| 18 | - @Inject | ||
| 19 | - private PropertiesBasicFieldsConfig propertiesConfig; | ||
| 20 | - | ||
| 21 | - @Deployment | ||
| 22 | - public static JavaArchive createDeployment() { | ||
| 23 | - return createConfigurationDeployment().addPackages(true, ConfigurationBasicFieldsTest.class.getPackage()); | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - @Test | ||
| 27 | - public void loadPrimitiveInteger() { | ||
| 28 | - int expected = 1; | ||
| 29 | - | ||
| 30 | - assertEquals(expected, propertiesConfig.getPrimitiveInteger()); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - @Test | ||
| 34 | - public void loadWrappedInteger() { | ||
| 35 | - Integer expected = 2; | ||
| 36 | - | ||
| 37 | - assertEquals(expected, propertiesConfig.getWrappedInteger()); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - @Test | ||
| 41 | - public void loadStringWithSpace() { | ||
| 42 | - String expected = "demoiselle framework"; | ||
| 43 | - | ||
| 44 | - assertEquals(expected, propertiesConfig.getStringWithSpace()); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | -// @Test | ||
| 48 | - public void loadStringWithComma() { | ||
| 49 | - String expected = "demoiselle,framework"; | ||
| 50 | - | ||
| 51 | - assertEquals(expected, propertiesConfig.getStringWithComma()); | ||
| 52 | - } | ||
| 53 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/PropertiesBasicFieldsConfig.java
| @@ -1,8 +0,0 @@ | @@ -1,8 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | - | ||
| 3 | -import static br.gov.frameworkdemoiselle.configuration.ConfigType.PROPERTIES; | ||
| 4 | -import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 5 | - | ||
| 6 | -@Configuration(type = PROPERTIES) | ||
| 7 | -public class PropertiesBasicFieldsConfig extends AbstractBasicFieldsConfig { | ||
| 8 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/SystemBasicFieldsConfig.java
| @@ -1,9 +0,0 @@ | @@ -1,9 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | - | ||
| 3 | -import static br.gov.frameworkdemoiselle.configuration.ConfigType.SYSTEM; | ||
| 4 | -import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 5 | - | ||
| 6 | -@Configuration(type = SYSTEM) | ||
| 7 | -public class SystemBasicFieldsConfig extends AbstractBasicFieldsConfig { | ||
| 8 | - | ||
| 9 | -} |
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/fields/basic/XMLBasicFieldsConfig.java
| @@ -1,9 +0,0 @@ | @@ -1,9 +0,0 @@ | ||
| 1 | -package br.gov.frameworkdemoiselle.configuration.fields.basic; | ||
| 2 | - | ||
| 3 | -import static br.gov.frameworkdemoiselle.configuration.ConfigType.XML; | ||
| 4 | -import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 5 | - | ||
| 6 | -@Configuration(type = XML) | ||
| 7 | -public class XMLBasicFieldsConfig extends AbstractBasicFieldsConfig { | ||
| 8 | - | ||
| 9 | -} |
impl/core/src/test/resources/configuration/field/basic/demoiselle.properties
0 → 100644
impl/core/src/test/resources/configuration/field/basic/demoiselle.xml
0 → 100644
| @@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
| 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 | +<definitions> | ||
| 38 | + <primitiveInteger>1</primitiveInteger> | ||
| 39 | + <wrappedInteger>2</wrappedInteger> | ||
| 40 | + <stringWithSpace>demoiselle framework</stringWithSpace> | ||
| 41 | + <stringWithComma>demoiselle,framework</stringWithComma> | ||
| 42 | +</definitions> | ||
| 0 | \ No newline at end of file | 43 | \ No newline at end of file |
impl/core/src/test/resources/configuration/fields/basic/demoiselle.properties