Commit c602e2d98daf4a84dfce9a1fb438a14a4406e787

Authored by Cleverson Sacramento
1 parent b9a3c893
Exists in master

Implementando os testes de configurações do tipo Array

impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/AbstractConfigurationTest.java
@@ -43,9 +43,6 @@ public abstract class AbstractConfigurationTest { @@ -43,9 +43,6 @@ public abstract class AbstractConfigurationTest {
43 .create(JavaArchive.class) 43 .create(JavaArchive.class)
44 .addClasses(getConfigurationClasses()) 44 .addClasses(getConfigurationClasses())
45 .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") 45 .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
46 - .addAsResource(  
47 - new FileAsset(new File("src/test/resources/configuration/fields/basic/demoiselle.properties")),  
48 - "demoiselle.properties")  
49 .addAsManifestResource( 46 .addAsManifestResource(
50 new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), 47 new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
51 "services/javax.enterprise.inject.spi.Extension"); 48 "services/javax.enterprise.inject.spi.Extension");
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/AbstractArrayFieldConfig.java 0 → 100644
@@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
  1 +package br.gov.frameworkdemoiselle.configuration.field.array;
  2 +
  3 +public abstract class AbstractArrayFieldConfig {
  4 +
  5 + private int[] primitiveIntegers;
  6 +
  7 + private Integer[] wrappedIntegers;
  8 +
  9 + private String[] strings;
  10 +
  11 + private double[] primitiveDoubles;
  12 +
  13 + private Double[] wrappedDoubles;
  14 +
  15 + public int[] getPrimitiveIntegers() {
  16 + return primitiveIntegers;
  17 + }
  18 +
  19 + public void setPrimitiveIntegers(int[] primitiveIntegers) {
  20 + this.primitiveIntegers = primitiveIntegers;
  21 + }
  22 +
  23 + public Integer[] getWrappedIntegers() {
  24 + return wrappedIntegers;
  25 + }
  26 +
  27 + public void setWrappedIntegers(Integer[] wrappedIntegers) {
  28 + this.wrappedIntegers = wrappedIntegers;
  29 + }
  30 +
  31 + public String[] getStrings() {
  32 + return strings;
  33 + }
  34 +
  35 + public void setStrings(String[] strings) {
  36 + this.strings = strings;
  37 + }
  38 +
  39 + public double[] getPrimitiveDoubles() {
  40 + return primitiveDoubles;
  41 + }
  42 +
  43 + public void setPrimitiveDoubles(double[] primitiveDoubles) {
  44 + this.primitiveDoubles = primitiveDoubles;
  45 + }
  46 +
  47 + public Double[] getWrappedDoubles() {
  48 + return wrappedDoubles;
  49 + }
  50 +
  51 + public void setWrappedDoubles(Double[] wrappedDoubles) {
  52 + this.wrappedDoubles = wrappedDoubles;
  53 + }
  54 +}
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/ConfigurationArrayFieldTest.java 0 → 100644
@@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
  1 +package br.gov.frameworkdemoiselle.configuration.field.array;
  2 +
  3 +import static org.junit.Assert.assertArrayEquals;
  4 +
  5 +import java.io.File;
  6 +
  7 +import javax.inject.Inject;
  8 +
  9 +import org.jboss.arquillian.container.test.api.Deployment;
  10 +import org.jboss.arquillian.junit.Arquillian;
  11 +import org.jboss.shrinkwrap.api.asset.FileAsset;
  12 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  13 +import org.junit.Test;
  14 +import org.junit.runner.RunWith;
  15 +
  16 +import br.gov.frameworkdemoiselle.configuration.AbstractConfigurationTest;
  17 +
  18 +@RunWith(Arquillian.class)
  19 +public class ConfigurationArrayFieldTest extends AbstractConfigurationTest {
  20 +
  21 + @Inject
  22 + private PropertiesArrayFieldConfig propertiesConfig;
  23 +
  24 + @Deployment
  25 + public static JavaArchive createDeployment() {
  26 + JavaArchive deployment = createConfigurationDeployment();
  27 +
  28 + deployment.addPackages(true, ConfigurationArrayFieldTest.class.getPackage());
  29 + deployment.addAsResource(new FileAsset(new File(
  30 + "src/test/resources/configuration/field/array/demoiselle.properties")), "demoiselle.properties");
  31 +
  32 + return deployment;
  33 + }
  34 +
  35 + @Test
  36 + public void loadPrimitiveInteger() {
  37 + int[] expected = { 1, 20, 0 };
  38 +
  39 + assertArrayEquals(expected, propertiesConfig.getPrimitiveIntegers());
  40 + }
  41 +
  42 + // private int[] primitiveIntegers;
  43 +
  44 + // private Integer[] wrappedIntegers;
  45 + //
  46 + // private String[] strings;
  47 + //
  48 + // private double[] primitiveDoubles;
  49 + //
  50 + // private Double[] wrappedDoubles;
  51 +}
impl/core/src/test/java/br/gov/frameworkdemoiselle/configuration/field/array/PropertiesArrayFieldConfig.java 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +package br.gov.frameworkdemoiselle.configuration.field.array;
  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 PropertiesArrayFieldConfig extends AbstractArrayFieldConfig {
  8 +}
impl/core/src/test/java/br/gov/frameworkdemoiselle/util/BeansTest.java
@@ -1,120 +0,0 @@ @@ -1,120 +0,0 @@
1 -package br.gov.frameworkdemoiselle.util;  
2 -///*  
3 -// * Demoiselle Framework  
4 -// * Copyright (C) 2010 SERPRO  
5 -// * ----------------------------------------------------------------------------  
6 -// * This file is part of Demoiselle Framework.  
7 -// *  
8 -// * Demoiselle Framework is free software; you can redistribute it and/or  
9 -// * modify it under the terms of the GNU Lesser General Public License version 3  
10 -// * as published by the Free Software Foundation.  
11 -// *  
12 -// * This program is distributed in the hope that it will be useful,  
13 -// * but WITHOUT ANY WARRANTY; without even the implied warranty of  
14 -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
15 -// * GNU General Public License for more details.  
16 -// *  
17 -// * You should have received a copy of the GNU Lesser General Public License version 3  
18 -// * along with this program; if not, see <http://www.gnu.org/licenses/>  
19 -// * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
20 -// * Fifth Floor, Boston, MA 02110-1301, USA.  
21 -// * ----------------------------------------------------------------------------  
22 -// * Este arquivo é parte do Framework Demoiselle.  
23 -// *  
24 -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
25 -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
26 -// * do Software Livre (FSF).  
27 -// *  
28 -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
29 -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
30 -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
31 -// * para maiores detalhes.  
32 -// *  
33 -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
34 -// * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
35 -// * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
36 -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
37 -// */  
38 -//package br.gov.frameworkdemoiselle.util;  
39 -//  
40 -//import static junit.framework.Assert.assertEquals;  
41 -//import static org.easymock.EasyMock.expect;  
42 -//import static org.powermock.api.easymock.PowerMock.replayAll;  
43 -//import static org.powermock.api.easymock.PowerMock.verifyAll;  
44 -//  
45 -//import java.util.HashSet;  
46 -//import java.util.Set;  
47 -//  
48 -//import javax.enterprise.context.spi.Contextual;  
49 -//import javax.enterprise.context.spi.CreationalContext;  
50 -//import javax.enterprise.inject.spi.Bean;  
51 -//import javax.enterprise.inject.spi.BeanManager;  
52 -//  
53 -//import org.easymock.EasyMock;  
54 -//import org.junit.Test;  
55 -//import org.junit.runner.RunWith;  
56 -//import org.powermock.api.easymock.PowerMock;  
57 -//import org.powermock.core.classloader.annotations.PrepareForTest;  
58 -//import org.powermock.modules.junit4.PowerMockRunner;  
59 -//  
60 -//@RunWith(PowerMockRunner.class)  
61 -//@PrepareForTest({ BeanManager.class, Bean.class })  
62 -//public class BeansTest {  
63 -//  
64 -// @SuppressWarnings("unchecked")  
65 -// @Test  
66 -// public void testGetReferenceByClass() {  
67 -// BeanManager beanManager = PowerMock.createMock(BeanManager.class);  
68 -//  
69 -// Set<Bean<?>> collection = new HashSet<Bean<?>>();  
70 -// Bean<?> bean = PowerMock.createMock(Bean.class);  
71 -// collection.add(bean);  
72 -//  
73 -// String object = "object";  
74 -//  
75 -// expect(beanManager.createCreationalContext(EasyMock.anyObject(Contextual.class))).andReturn(null);  
76 -// expect(beanManager.getBeans(EasyMock.anyObject(Class.class))).andReturn(collection);  
77 -// expect(  
78 -// beanManager.getReference(EasyMock.anyObject(Bean.class), EasyMock.anyObject(Class.class),  
79 -// EasyMock.anyObject(CreationalContext.class))).andReturn(object);  
80 -//  
81 -// replayAll(beanManager, bean);  
82 -//  
83 -// Beans.setBeanManager(beanManager);  
84 -// String returned = Beans.getReference(String.class);  
85 -//  
86 -// assertEquals(returned, object);  
87 -// assertEquals(beanManager, Beans.getBeanManager());  
88 -//  
89 -// verifyAll();  
90 -// }  
91 -//  
92 -// @Test  
93 -// @SuppressWarnings("unchecked")  
94 -// public void testGetReferenceByString() {  
95 -// BeanManager beanManager = PowerMock.createMock(BeanManager.class);  
96 -//  
97 -// Set<Bean<?>> collection = new HashSet<Bean<?>>();  
98 -// Bean<?> bean = PowerMock.createMock(Bean.class);  
99 -// collection.add(bean);  
100 -//  
101 -// String object = "object";  
102 -//  
103 -// expect(bean.getBeanClass()).andReturn(null);  
104 -// expect(beanManager.createCreationalContext(EasyMock.anyObject(Contextual.class))).andReturn(null);  
105 -// expect(beanManager.getBeans("something")).andReturn(collection);  
106 -// expect(  
107 -// beanManager.getReference(EasyMock.anyObject(Bean.class), EasyMock.anyObject(Class.class),  
108 -// EasyMock.anyObject(CreationalContext.class))).andReturn(object);  
109 -//  
110 -// replayAll(beanManager, bean);  
111 -//  
112 -// Beans.setBeanManager(beanManager);  
113 -// String returned = Beans.getReference("something");  
114 -//  
115 -// assertEquals(returned, object);  
116 -// assertEquals(beanManager, Beans.getBeanManager());  
117 -//  
118 -// verifyAll();  
119 -// }  
120 -//}  
impl/core/src/test/java/br/gov/frameworkdemoiselle/util/StringsTest.java
@@ -199,5 +199,4 @@ public class StringsTest { @@ -199,5 +199,4 @@ public class StringsTest {
199 assertEquals("0" + string, Strings.insertZeros(string, string.length() + 1)); 199 assertEquals("0" + string, Strings.insertZeros(string, string.length() + 1));
200 assertEquals("00" + string, Strings.insertZeros(string, string.length() + 2)); 200 assertEquals("00" + string, Strings.insertZeros(string, string.length() + 2));
201 } 201 }
202 -  
203 } 202 }
impl/core/src/test/resources/configuration/field/array/demoiselle.properties 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +primitiveIntegers=1,20,0