Commit 929acded03505fd33c5a850c2a4a9a28124cd69d

Authored by Emerson Oliveira
2 parents 8968457b 4ba9dc19
Exists in master

Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0

impl/core/pom.xml
... ... @@ -99,59 +99,20 @@
99 99 <artifactId>cobertura-maven-plugin</artifactId>
100 100 </plugin>
101 101  
102   - <!--
103   - <plugin>
104   - <groupId>org.jacoco</groupId>
105   - <artifactId>jacoco-maven-plugin</artifactId>
106   - <version>${jacoco.version}</version>
107   - <executions>
108   - <execution>
109   - <goals>
110   - <goal>prepare-agent</goal>
111   - </goals>
112   - </execution>
113   - <execution>
114   - <id>report</id>
115   - <phase>prepare-package</phase>
116   - <goals>
117   - <goal>report</goal>
118   - </goals>
119   - </execution>
120   - </executions>
121   - </plugin>
122   - -->
  102 + <!-- <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId>
  103 + <version>${jacoco.version}</version> <executions> <execution> <goals> <goal>prepare-agent</goal>
  104 + </goals> </execution> <execution> <id>report</id> <phase>prepare-package</phase>
  105 + <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> -->
123 106 </plugins>
124   -
125   - <!--
126   - <pluginManagement>
127   - <plugins>
128   - <plugin>
129   - <groupId>org.eclipse.m2e</groupId>
130   - <artifactId>lifecycle-mapping</artifactId>
131   - <version>1.0.0</version>
132   - <configuration>
133   - <lifecycleMappingMetadata>
134   - <pluginExecutions>
135   - <pluginExecution>
136   - <pluginExecutionFilter>
137   - <groupId>org.jacoco</groupId>
138   - <artifactId>jacoco-maven-plugin</artifactId>
139   - <versionRange>[${jacoco.version},)</versionRange>
140   - <goals>
141   - <goal>prepare-agent</goal>
142   - </goals>
143   - </pluginExecutionFilter>
144   - <action>
145   - <ignore></ignore>
146   - </action>
147   - </pluginExecution>
148   - </pluginExecutions>
149   - </lifecycleMappingMetadata>
150   - </configuration>
151   - </plugin>
152   - </plugins>
153   - </pluginManagement>
154   - -->
  107 +
  108 + <!-- <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId>
  109 + <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration>
  110 + <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter>
  111 + <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId>
  112 + <versionRange>[${jacoco.version},)</versionRange> <goals> <goal>prepare-agent</goal>
  113 + </goals> </pluginExecutionFilter> <action> <ignore></ignore> </action> </pluginExecution>
  114 + </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin>
  115 + </plugins> </pluginManagement> -->
155 116 </build>
156 117  
157 118 <dependencies>
... ... @@ -202,50 +163,28 @@
202 163 <artifactId>hibernate-validator</artifactId>
203 164 <scope>test</scope>
204 165 </dependency>
205   -
206   - <!--
207   - <dependency>
208   - <groupId>org.jboss.arquillian.extension</groupId>
209   - <artifactId>arquillian-jacoco</artifactId>
210   - <version>1.0.0.Alpha5</version>
211   - <scope>test</scope>
212   - </dependency>
213   - <dependency>
214   - <groupId>org.jacoco</groupId>
215   - <artifactId>org.jacoco.core</artifactId>
216   - <version>${jacoco.version}</version>
217   - <scope>test</scope>
218   - </dependency>
219   - -->
220   -
221   - <!--
222 166 <dependency>
223   - <groupId>org.jboss.shrinkwrap.descriptors</groupId>
224   - <artifactId>shrinkwrap-descriptors-spi</artifactId>
225   - <version>2.0.0-alpha-4</version>
  167 + <groupId>javax.servlet</groupId>
  168 + <artifactId>servlet-api</artifactId>
226 169 <scope>test</scope>
227 170 </dependency>
228   - -->
229 171  
230   - <!--
231   - <dependency>
232   - <groupId>javax.el</groupId>
233   - <artifactId>el-api</artifactId>
234   - <scope>test</scope>
235   - </dependency>
236   - -->
  172 + <!-- <dependency> <groupId>org.jboss.arquillian.extension</groupId> <artifactId>arquillian-jacoco</artifactId>
  173 + <version>1.0.0.Alpha5</version> <scope>test</scope> </dependency> <dependency>
  174 + <groupId>org.jacoco</groupId> <artifactId>org.jacoco.core</artifactId> <version>${jacoco.version}</version>
  175 + <scope>test</scope> </dependency> -->
  176 +
  177 + <!-- <dependency> <groupId>org.jboss.shrinkwrap.descriptors</groupId> <artifactId>shrinkwrap-descriptors-spi</artifactId>
  178 + <version>2.0.0-alpha-4</version> <scope>test</scope> </dependency> -->
  179 +
  180 + <!-- <dependency> <groupId>javax.el</groupId> <artifactId>el-api</artifactId>
  181 + <scope>test</scope> </dependency> -->
237 182 <dependency>
238 183 <groupId>org.slf4j</groupId>
239 184 <artifactId>slf4j-log4j12</artifactId>
240 185 <scope>test</scope>
241 186 </dependency>
242   -
243   - <dependency>
244   - <groupId>br.gov.frameworkdemoiselle.component</groupId>
245   - <artifactId>demoiselle-validation</artifactId>
246   - <scope>test</scope>
247   - <version>${demoiselle.validation.version}</version>
248   - </dependency>
  187 +
249 188 </dependencies>
250 189  
251 190 <repositories>
... ... @@ -274,9 +213,7 @@
274 213 </repositories>
275 214  
276 215 <properties>
277   - <!--
278   - <jacoco.version>0.6.0.201210061924</jacoco.version>
279   - -->
  216 + <!-- <jacoco.version>0.6.0.201210061924</jacoco.version> -->
280 217 <demoiselle.validation.version>2.4.0-BETA2-SNAPSHOT</demoiselle.validation.version>
281 218 </properties>
282 219 </project>
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/Management.java
... ... @@ -241,11 +241,22 @@ public class Management {
241 241 errorBuffer.append(violation.getMessage()).append('\r').append('\n');
242 242 }
243 243  
244   - throw new DemoiselleException(bundle.getString("validation-constraint-violation",managedType.getType().getCanonicalName(),errorBuffer.toString()));
  244 + if (errorBuffer.length()>0){
  245 + errorBuffer.insert(0, "\r\n");
  246 + errorBuffer.insert(errorBuffer.length(), "\r\n");
  247 + }
  248 +
  249 + throw new DemoiselleException(
  250 + bundle.getString(
  251 + "management-validation-constraint-violation"
  252 + ,managedType.getType().getCanonicalName()
  253 + ,propertyName,errorBuffer.toString()
  254 + )
  255 + );
245 256 }
246 257 }
247 258 else{
248   - logger.warn(bundle.getString("validation-validator-not-found"));
  259 + logger.warn(bundle.getString("management-validation-validator-not-found"));
249 260 }
250 261  
251 262 Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod();
... ...
impl/core/src/main/resources/demoiselle-core-bundle.properties
... ... @@ -114,5 +114,5 @@ management-debug-stoping-custom-context=Desligando contexto {0} para classe gere
114 114 management-debug-registering-managed-type=Registrando classe gerenciada [{0}]
115 115 management-debug-processing-management-extension=Processando extens\u00E3o de gerenciamento [{0}]
116 116 management-debug-removing-management-extension=Desativando extens\u00E3o de gerenciamento [{0}]
117   -
118   -validation-validator-not-found=Nenhum provedor de valida\u00E7\u00E3o de beans encontrado, as anota\u00E7\u00F5es de valida\u00E7\u00E3o n\u00E3o ser\u00E3o processadas
  117 +management-validation-constraint-violation=Ocorreu um erro de valida\u00E7\u00E3o na classe [{0}] ao definir um valor para a propriedade [{1}]\: [{2}]
  118 +management-validation-validator-not-found=Nenhum provedor de valida\u00E7\u00E3o de beans encontrado, as anota\u00E7\u00F5es de valida\u00E7\u00E3o n\u00E3o ser\u00E3o processadas
... ...
impl/core/src/test/java/management/AnnotationTestCase.java 0 → 100644
... ... @@ -0,0 +1,95 @@
  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 management;
  38 +
  39 +import java.io.File;
  40 +
  41 +import management.testclasses.DummyManagementExtension;
  42 +import management.testclasses.ManagedClassStore;
  43 +
  44 +import org.jboss.arquillian.container.test.api.Deployer;
  45 +import org.jboss.arquillian.container.test.api.Deployment;
  46 +import org.jboss.arquillian.junit.Arquillian;
  47 +import org.jboss.arquillian.test.api.ArquillianResource;
  48 +import org.jboss.shrinkwrap.api.ShrinkWrap;
  49 +import org.jboss.shrinkwrap.api.asset.FileAsset;
  50 +import org.jboss.shrinkwrap.api.spec.JavaArchive;
  51 +import org.junit.Assert;
  52 +import org.junit.Test;
  53 +import org.junit.runner.RunWith;
  54 +
  55 +import test.LocaleProducer;
  56 +
  57 +@RunWith(Arquillian.class)
  58 +// @Ignore
  59 +public class AnnotationTestCase {
  60 +
  61 + /**
  62 + * Deployment containing a malformed managed class. Tests using this deployment will check if deployment fails (it
  63 + * has to).
  64 + */
  65 + @Deployment(name = "wrong_annotation", managed = false)
  66 + public static JavaArchive createWrongAnnotationDeployment() {
  67 + return ShrinkWrap
  68 + .create(JavaArchive.class)
  69 + .addClass(LocaleProducer.class)
  70 + .addPackages(true, "br")
  71 + .addAsResource(new FileAsset(new File("src/test/resources/test/beans.xml")), "beans.xml")
  72 + .addAsManifestResource(
  73 + new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
  74 + "services/javax.enterprise.inject.spi.Extension")
  75 + .addPackages(false, ManagementBootstrapTestCase.class.getPackage())
  76 + //.addClasses(DummyManagementExtension.class, DummyManagedClassPropertyError.class, ManagedClassStore.class);
  77 + .addClasses(DummyManagementExtension.class, ManagedClassStore.class);
  78 + }
  79 +
  80 + @Test
  81 + public void testWrongAnnotation(@ArquillianResource Deployer deployer) {
  82 +
  83 + try {
  84 + deployer.deploy("wrong_annotation");
  85 +
  86 + // O processo de deploy precisa falhar, pois temos uma classe anotada com falhas.
  87 + Assert.fail();
  88 + } catch (Exception e) {
  89 + //SUCCESS
  90 + } finally {
  91 + deployer.undeploy("wrong_annotation");
  92 + }
  93 + }
  94 +
  95 +}
... ...
impl/core/src/test/java/management/ManagementBootstrapTestCase.java
... ... @@ -39,15 +39,14 @@ package management;
39 39 import java.io.File;
40 40 import java.util.List;
41 41  
  42 +import javax.enterprise.inject.spi.BeforeShutdown;
  43 +
42 44 import management.testclasses.DummyManagedClass;
43   -import management.testclasses.DummyManagedClassPropertyError;
44 45 import management.testclasses.DummyManagementExtension;
45 46 import management.testclasses.ManagedClassStore;
46 47  
47   -import org.jboss.arquillian.container.test.api.Deployer;
48 48 import org.jboss.arquillian.container.test.api.Deployment;
49 49 import org.jboss.arquillian.junit.Arquillian;
50   -import org.jboss.arquillian.test.api.ArquillianResource;
51 50 import org.jboss.shrinkwrap.api.ShrinkWrap;
52 51 import org.jboss.shrinkwrap.api.asset.FileAsset;
53 52 import org.jboss.shrinkwrap.api.spec.JavaArchive;
... ... @@ -63,14 +62,11 @@ import br.gov.frameworkdemoiselle.util.Beans;
63 62 @RunWith(Arquillian.class)
64 63 public class ManagementBootstrapTestCase {
65 64  
66   - @ArquillianResource
67   - private Deployer deployer;
68   -
69 65 /**
70 66 * Deployment to test normal deployment behaviour
71 67 *
72 68 */
73   - @Deployment(name = "default",managed=false,testable=false)
  69 + @Deployment
74 70 public static JavaArchive createDeployment() {
75 71 return ShrinkWrap
76 72 .create(JavaArchive.class)
... ... @@ -85,39 +81,16 @@ public class ManagementBootstrapTestCase {
85 81 }
86 82  
87 83 /**
88   - * Deployment containing a malformed managed class. Tests using this deployment will
89   - * check if deployment fails (it has to).
90   - *
91   - */
92   - @Deployment(name = "wrong_annotation",managed=false,testable=false)
93   - public static JavaArchive createWrongAnnotationDeployment() {
94   - return ShrinkWrap
95   - .create(JavaArchive.class)
96   - .addClass(LocaleProducer.class)
97   - .addPackages(true, "br")
98   - .addAsResource(new FileAsset(new File("src/test/resources/test/beans.xml")), "beans.xml")
99   - .addAsManifestResource(
100   - new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
101   - "services/javax.enterprise.inject.spi.Extension")
102   - .addPackages(false, ManagementBootstrapTestCase.class.getPackage())
103   - .addClasses(DummyManagementExtension.class,DummyManagedClassPropertyError.class,ManagedClassStore.class);
104   - }
105   -
106   - /**
107 84 * Test if a a management extension (a library that implements {@link ManagementExtension}) is correctly detected.
108 85 */
109 86 @Test
110 87 public void testManagementExtensionRegistration() {
111   - deployer.deploy("default");
112   -
113 88 // "store" é application scoped e é usado pelo DummyManagementExtension para
114 89 // armazenar todos os beans anotados com @ManagementController. Se o bootstrap rodou corretamente,
115 90 // ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos.
116 91 ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
117 92  
118 93 Assert.assertEquals(1, store.getManagedTypes().size());
119   -
120   - deployer.undeploy("default");
121 94 }
122 95  
123 96 /**
... ... @@ -126,8 +99,6 @@ public class ManagementBootstrapTestCase {
126 99 */
127 100 @Test
128 101 public void testManagementExtensionShutdown() {
129   - deployer.deploy("default");
130   -
131 102 // "store" é application scoped e é usado pelo DummyManagementExtension para
132 103 // armazenar todos os beans anotados com @ManagementController. Se o bootstrap rodou corretamente,
133 104 // ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos.
... ... @@ -137,25 +108,11 @@ public class ManagementBootstrapTestCase {
137 108 //Detecta se a classe anotada foi detectada
138 109 List<ManagedType> managedTypes = store.getManagedTypes();
139 110 Assert.assertEquals(1, managedTypes.size());
140   -
141   - deployer.undeploy("default");
142 111  
  112 + Beans.getBeanManager().fireEvent(new BeforeShutdown() {});
  113 +
143 114 //Após o "undeploy", o ciclo de vida precisa ter removido a classe gerenciada da lista.
144 115 Assert.assertEquals(0, managedTypes.size());
145 116 }
146 117  
147   - @Test
148   - public void testWrongAnnotation(){
149   -
150   - try{
151   - deployer.deploy("wrong_annotation");
152   -
153   - //O processo de deploy precisa falhar, pois temos uma classe anotada com falhas.
154   - Assert.fail();
155   - }
156   - catch(Exception e){
157   - deployer.undeploy("wrong_annotation");
158   - }
159   - }
160   -
161 118 }
... ...
impl/core/src/test/java/management/ValidationTestCase.java
... ... @@ -4,6 +4,8 @@ import java.io.File;
4 4  
5 5 import management.testclasses.DummyManagedClass;
6 6 import management.testclasses.DummyManagementExtension;
  7 +import management.testclasses.DummyValidator;
  8 +import management.testclasses.DummyValidatorAnnotation;
7 9 import management.testclasses.ManagedClassStore;
8 10  
9 11 import org.jboss.arquillian.container.test.api.Deployment;
... ... @@ -21,7 +23,7 @@ import br.gov.frameworkdemoiselle.util.Beans;
21 23  
22 24 @RunWith(Arquillian.class)
23 25 public class ValidationTestCase {
24   -
  26 +
25 27 @Deployment
26 28 public static JavaArchive createDeployment() {
27 29 return ShrinkWrap
... ... @@ -33,30 +35,61 @@ public class ValidationTestCase {
33 35 new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
34 36 "services/javax.enterprise.inject.spi.Extension")
35 37 .addPackages(false, NotificationTestCase.class.getPackage())
36   - .addClasses(DummyManagementExtension.class,ManagedClassStore.class,DummyManagedClass.class);
  38 + .addClasses(DummyManagementExtension.class
  39 + , ManagedClassStore.class
  40 + , DummyManagedClass.class
  41 + , DummyValidator.class
  42 + , DummyValidatorAnnotation.class);
37 43 }
38   -
  44 +
39 45 /**
40   - * Test if changing properties of a management controller passes through
41   - * validation phase.
  46 + * Test if a management controller accepts a valid value annotated with a core validation (from javax.validation)
  47 + * when a property is being set by a management client
42 48 */
43 49 @Test
44   - public void testManagedClassValidation(){
45   -
46   - //Testa se é possível definir um valor válido para uma propriedade.
  50 + public void testSetValidValue() {
  51 + // Testa se é possível definir um valor válido para uma propriedade.
47 52 ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
48 53 store.setProperty(DummyManagedClass.class, "id", new Integer(1));
49 54 Assert.assertEquals(new Integer(1), store.getProperty(DummyManagedClass.class, "id"));
50   -
51   - //Testa se definir um valor inválido dispara o erro adequado
52   - try{
53   - store.setProperty(DummyManagedClass.class, "id", new Integer(5));
  55 + }
  56 +
  57 + /**
  58 + * Test if a management controller refuses a valid value annotated with a core validation (from javax.validation)
  59 + * when a property is being set by a management client
  60 + */
  61 + @Test
  62 + public void testSetInvalidValue() {
  63 + // Testa se é possível definir um valor válido para uma propriedade.
  64 + try {
  65 + ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
  66 + store.setProperty(DummyManagedClass.class, "id", (Integer) null);
  67 +
54 68 Assert.fail();
  69 + } catch (DemoiselleException de) {
  70 + // Classes de gerenciamento disparam Demoiselle Exception quando uma validação falha
55 71 }
56   - catch(DemoiselleException e){
57   - //SUCCESS
  72 + }
  73 +
  74 + /**
  75 + * Tests if custom validators (outside the javax.validation package) run as normal
  76 + */
  77 + @Test
  78 + public void testCustomValidation() {
  79 +
  80 + try {
  81 + ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
  82 +
  83 + // Atributo "gender" deve aceitar apenas "M" ou "F", tanto maiúsculo quanto minúsculo. A anotação
  84 + // customizada DummyValidatorAnnotation é uma simples validação que testa se uma string passada está
  85 + // na lista de strings aceitas.
  86 + store.setProperty(DummyManagedClass.class, "gender", "J");
  87 +
  88 + Assert.fail();
  89 + } catch (DemoiselleException e) {
  90 + Assert.assertTrue( e.getMessage().contains("Test Message") );
58 91 }
59   -
  92 +
60 93 }
61 94  
62 95 }
... ...
impl/core/src/test/java/management/testclasses/DummyManagedClass.java
... ... @@ -38,11 +38,11 @@ package management.testclasses;
38 38  
39 39 import java.util.UUID;
40 40  
  41 +import javax.validation.constraints.NotNull;
  42 +
41 43 import br.gov.frameworkdemoiselle.annotation.ManagedOperation;
42 44 import br.gov.frameworkdemoiselle.annotation.ManagedProperty;
43 45 import br.gov.frameworkdemoiselle.stereotype.ManagementController;
44   -import br.gov.frameworkdemoiselle.validation.annotation.AllowedValues;
45   -import br.gov.frameworkdemoiselle.validation.annotation.AllowedValues.ValueType;
46 46  
47 47 @ManagementController
48 48 public class DummyManagedClass {
... ... @@ -51,10 +51,14 @@ public class DummyManagedClass {
51 51 private String name;
52 52  
53 53 @ManagedProperty
54   - @AllowedValues(allows={"1","2","3","4"},valueType=ValueType.INTEGER)
  54 + @NotNull
55 55 private Integer id;
56 56  
57 57 @ManagedProperty
  58 + @DummyValidatorAnnotation(allows={"f","m","F","M"})
  59 + private String gender;
  60 +
  61 + @ManagedProperty
58 62 private Integer firstFactor , secondFactor;
59 63  
60 64 @ManagedProperty
... ... @@ -153,24 +157,8 @@ public class DummyManagedClass {
153 157 }
154 158  
155 159 @ManagedOperation
156   - public Integer calculateFactorsNonSynchronized(Integer firstFactor , Integer secondFactor){
157   - setFirstFactor(firstFactor);
158   - setSecondFactor(secondFactor);
159   -
160   - try {
161   - int temp = firstFactor + secondFactor;
162   - Thread.sleep( (long)(Math.random() * 100));
163   -
164   - temp = temp + firstFactor;
165   - Thread.sleep( (long)(Math.random() * 100));
166   -
167   - temp = temp + secondFactor;
168   - Thread.sleep( (long)(Math.random() * 100));
169   -
170   - return temp;
171   - } catch (InterruptedException e) {
172   - throw new RuntimeException(e);
173   - }
  160 + public Integer sumFactors(){
  161 + return (firstFactor!=null ? firstFactor.intValue() : 0) + (secondFactor!=null ? secondFactor.intValue() : 0);
174 162 }
175 163  
176 164 @ManagedOperation
... ... @@ -197,6 +185,18 @@ public class DummyManagedClass {
197 185 public void nonOperationAnnotatedMethod(){
198 186 System.out.println("Test");
199 187 }
  188 +
  189 +
  190 + public String getGender() {
  191 + return gender;
  192 + }
  193 +
  194 +
  195 + public void setGender(String gender) {
  196 + this.gender = gender;
  197 + }
  198 +
  199 +
200 200  
201 201  
202 202 }
... ...
impl/core/src/test/java/management/testclasses/DummyValidator.java 0 → 100644
... ... @@ -0,0 +1,64 @@
  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 management.testclasses;
  38 +
  39 +import javax.validation.ConstraintValidator;
  40 +import javax.validation.ConstraintValidatorContext;
  41 +
  42 +
  43 +public class DummyValidator implements ConstraintValidator<DummyValidatorAnnotation, String> {
  44 +
  45 + String[] allows;
  46 +
  47 + @Override
  48 + public void initialize(DummyValidatorAnnotation constraintAnnotation) {
  49 + allows = constraintAnnotation.allows();
  50 + }
  51 +
  52 + @Override
  53 + public boolean isValid(String value, ConstraintValidatorContext context) {
  54 +
  55 + for (String allow : allows){
  56 + if (allow.equals(value)){
  57 + return true;
  58 + }
  59 + }
  60 +
  61 + return false;
  62 + }
  63 +
  64 +}
... ...
impl/core/src/test/java/management/testclasses/DummyValidatorAnnotation.java 0 → 100644
... ... @@ -0,0 +1,61 @@
  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 management.testclasses;
  38 +
  39 +import static java.lang.annotation.ElementType.FIELD;
  40 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  41 +
  42 +import java.lang.annotation.Retention;
  43 +import java.lang.annotation.Target;
  44 +
  45 +import javax.validation.Constraint;
  46 +import javax.validation.Payload;
  47 +
  48 +@Target({ FIELD})
  49 +@Retention(RUNTIME)
  50 +@Constraint(validatedBy = DummyValidator.class)
  51 +public @interface DummyValidatorAnnotation {
  52 +
  53 + String[] allows();
  54 +
  55 + String message() default "Test Message";
  56 +
  57 + Class<?>[] groups() default {};
  58 +
  59 + Class<? extends Payload>[] payload() default {};
  60 +
  61 +}
... ...