Commit aa4ea911450b4a3fc0f512986f4d516b85ad8ab7

Authored by Cleverson Sacramento
1 parent c37abee3
Exists in master

Correção do @Deployment dos teste do management

impl/core/src/test/java/management/AnnotationTestCase.java
@@ -53,7 +53,7 @@ import org.junit.Ignore; @@ -53,7 +53,7 @@ import org.junit.Ignore;
53 import org.junit.Test; 53 import org.junit.Test;
54 import org.junit.runner.RunWith; 54 import org.junit.runner.RunWith;
55 55
56 -import test.LocaleProducer; 56 +import test.Tests;
57 57
58 //TODO O arquillian está com um problema onde, embora os testes rodem todos individualmente, 58 //TODO O arquillian está com um problema onde, embora os testes rodem todos individualmente,
59 //ao pedir para rodar todos este teste individual causa todos os testes executados após esse 59 //ao pedir para rodar todos este teste individual causa todos os testes executados após esse
@@ -70,7 +70,7 @@ public class AnnotationTestCase { @@ -70,7 +70,7 @@ public class AnnotationTestCase {
70 public static JavaArchive createWrongAnnotationDeployment() { 70 public static JavaArchive createWrongAnnotationDeployment() {
71 return ShrinkWrap 71 return ShrinkWrap
72 .create(JavaArchive.class) 72 .create(JavaArchive.class)
73 - .addClass(LocaleProducer.class) 73 + .addClass(Tests.class)
74 .addPackages(true, "br") 74 .addPackages(true, "br")
75 .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml") 75 .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml")
76 .addAsManifestResource( 76 .addAsManifestResource(
impl/core/src/test/java/management/ManagementBootstrapTestCase.java
@@ -55,7 +55,7 @@ import org.junit.Ignore; @@ -55,7 +55,7 @@ import org.junit.Ignore;
55 import org.junit.Test; 55 import org.junit.Test;
56 import org.junit.runner.RunWith; 56 import org.junit.runner.RunWith;
57 57
58 -import test.LocaleProducer; 58 +import test.Tests;
59 import br.gov.frameworkdemoiselle.internal.management.ManagedType; 59 import br.gov.frameworkdemoiselle.internal.management.ManagedType;
60 import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; 60 import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension;
61 import br.gov.frameworkdemoiselle.util.Beans; 61 import br.gov.frameworkdemoiselle.util.Beans;
@@ -72,7 +72,7 @@ public class ManagementBootstrapTestCase { @@ -72,7 +72,7 @@ public class ManagementBootstrapTestCase {
72 public static JavaArchive createDeployment() { 72 public static JavaArchive createDeployment() {
73 return ShrinkWrap 73 return ShrinkWrap
74 .create(JavaArchive.class) 74 .create(JavaArchive.class)
75 - .addClass(LocaleProducer.class) 75 + .addClass(Tests.class)
76 .addPackages(true, "br") 76 .addPackages(true, "br")
77 .addAsResource( 77 .addAsResource(
78 new FileAsset(new File( 78 new FileAsset(new File(
impl/core/src/test/java/management/ManagementTestCase.java
@@ -53,7 +53,7 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; @@ -53,7 +53,7 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive;
53 import org.junit.Test; 53 import org.junit.Test;
54 import org.junit.runner.RunWith; 54 import org.junit.runner.RunWith;
55 55
56 -import test.LocaleProducer; 56 +import test.Tests;
57 import br.gov.frameworkdemoiselle.DemoiselleException; 57 import br.gov.frameworkdemoiselle.DemoiselleException;
58 import br.gov.frameworkdemoiselle.util.Beans; 58 import br.gov.frameworkdemoiselle.util.Beans;
59 59
@@ -70,18 +70,15 @@ public class ManagementTestCase { @@ -70,18 +70,15 @@ public class ManagementTestCase {
70 public static JavaArchive createMultithreadedDeployment() { 70 public static JavaArchive createMultithreadedDeployment() {
71 return ShrinkWrap 71 return ShrinkWrap
72 .create(JavaArchive.class) 72 .create(JavaArchive.class)
73 - .addClass(LocaleProducer.class) 73 + .addClass(Tests.class)
74 .addPackages(true, "br") 74 .addPackages(true, "br")
75 .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml") 75 .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml")
76 .addAsManifestResource( 76 .addAsManifestResource(
77 new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), 77 new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
78 "services/javax.enterprise.inject.spi.Extension") 78 "services/javax.enterprise.inject.spi.Extension")
79 .addPackages(false, ManagementTestCase.class.getPackage()) 79 .addPackages(false, ManagementTestCase.class.getPackage())
80 - .addClasses(DummyManagementExtension.class  
81 - , DummyManagedClass.class  
82 - , ManagedClassStore.class  
83 - , RequestScopeBeanClient.class  
84 - , RequestScopedClass.class); 80 + .addClasses(DummyManagementExtension.class, DummyManagedClass.class, ManagedClassStore.class,
  81 + RequestScopeBeanClient.class, RequestScopedClass.class);
85 } 82 }
86 83
87 @Test 84 @Test
@@ -167,32 +164,31 @@ public class ManagementTestCase { @@ -167,32 +164,31 @@ public class ManagementTestCase {
167 } 164 }
168 165
169 } 166 }
170 - 167 +
171 @Test 168 @Test
172 - public void testAccessLevelControl(){  
173 - //tentamos escrever em uma propriedade que, apesar de ter método setter, está marcada como read-only. 169 + public void testAccessLevelControl() {
  170 + // tentamos escrever em uma propriedade que, apesar de ter método setter, está marcada como read-only.
174 ManagedClassStore store = Beans.getReference(ManagedClassStore.class); 171 ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
175 -  
176 - try{  
177 - store.setProperty(DummyManagedClass.class, "readOnlyPropertyWithSetMethod","A Value"); 172 +
  173 + try {
  174 + store.setProperty(DummyManagedClass.class, "readOnlyPropertyWithSetMethod", "A Value");
178 Assert.fail(); 175 Assert.fail();
179 - }  
180 - catch(DemoiselleException de){ 176 + } catch (DemoiselleException de) {
181 System.out.println(de.getMessage()); 177 System.out.println(de.getMessage());
182 - //success 178 + // success
183 } 179 }
184 } 180 }
185 - 181 +
186 @Test 182 @Test
187 public void testRequestScopedOperation() { 183 public void testRequestScopedOperation() {
188 ManagedClassStore store = Beans.getReference(ManagedClassStore.class); 184 ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
189 -  
190 - //Esta operação faz multiplos acessos a um bean RequestScoped. Durante a operação todos os acessos devem  
191 - //operar sob a mesma instância, mas uma segunda invocação deve operar em uma instância nova 185 +
  186 + // Esta operação faz multiplos acessos a um bean RequestScoped. Durante a operação todos os acessos devem
  187 + // operar sob a mesma instância, mas uma segunda invocação deve operar em uma instância nova
192 Object info = store.invoke(DummyManagedClass.class, "requestScopedOperation"); 188 Object info = store.invoke(DummyManagedClass.class, "requestScopedOperation");
193 Assert.assertEquals("-OPERATION ONE CALLED--OPERATION TWO CALLED-", info); 189 Assert.assertEquals("-OPERATION ONE CALLED--OPERATION TWO CALLED-", info);
194 -  
195 - //Segunda invocação para testar se uma nova instância é criada, já que esse é um novo request. 190 +
  191 + // Segunda invocação para testar se uma nova instância é criada, já que esse é um novo request.
196 info = store.invoke(DummyManagedClass.class, "requestScopedOperation"); 192 info = store.invoke(DummyManagedClass.class, "requestScopedOperation");
197 Assert.assertEquals("-OPERATION ONE CALLED--OPERATION TWO CALLED-", info); 193 Assert.assertEquals("-OPERATION ONE CALLED--OPERATION TWO CALLED-", info);
198 } 194 }
impl/core/src/test/java/management/NotificationTestCase.java
@@ -52,7 +52,7 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; @@ -52,7 +52,7 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive;
52 import org.junit.Test; 52 import org.junit.Test;
53 import org.junit.runner.RunWith; 53 import org.junit.runner.RunWith;
54 54
55 -import test.LocaleProducer; 55 +import test.Tests;
56 import br.gov.frameworkdemoiselle.annotation.Name; 56 import br.gov.frameworkdemoiselle.annotation.Name;
57 import br.gov.frameworkdemoiselle.internal.management.ManagedType; 57 import br.gov.frameworkdemoiselle.internal.management.ManagedType;
58 import br.gov.frameworkdemoiselle.internal.management.Management; 58 import br.gov.frameworkdemoiselle.internal.management.Management;
@@ -63,74 +63,74 @@ import br.gov.frameworkdemoiselle.util.Beans; @@ -63,74 +63,74 @@ import br.gov.frameworkdemoiselle.util.Beans;
63 import br.gov.frameworkdemoiselle.util.ResourceBundle; 63 import br.gov.frameworkdemoiselle.util.ResourceBundle;
64 64
65 /** 65 /**
66 - * Test the {@link NotificationManager} with a dummy extension  
67 - * to check if notifications are correctly propagated 66 + * Test the {@link NotificationManager} with a dummy extension to check if notifications are correctly propagated
68 * 67 *
69 * @author serpro 68 * @author serpro
70 - *  
71 */ 69 */
72 @RunWith(Arquillian.class) 70 @RunWith(Arquillian.class)
73 public class NotificationTestCase { 71 public class NotificationTestCase {
74 - 72 +
75 @Inject 73 @Inject
76 private NotificationManager manager; 74 private NotificationManager manager;
77 - 75 +
78 @Inject 76 @Inject
79 @Name("demoiselle-core-bundle") 77 @Name("demoiselle-core-bundle")
80 private ResourceBundle bundle; 78 private ResourceBundle bundle;
81 - 79 +
82 @Deployment 80 @Deployment
83 public static JavaArchive createDeployment() { 81 public static JavaArchive createDeployment() {
84 return ShrinkWrap 82 return ShrinkWrap
85 .create(JavaArchive.class) 83 .create(JavaArchive.class)
86 - .addClass(LocaleProducer.class) 84 + .addClass(Tests.class)
87 .addPackages(true, "br") 85 .addPackages(true, "br")
88 .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml") 86 .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml")
89 .addAsManifestResource( 87 .addAsManifestResource(
90 new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), 88 new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
91 "services/javax.enterprise.inject.spi.Extension") 89 "services/javax.enterprise.inject.spi.Extension")
92 .addPackages(false, NotificationTestCase.class.getPackage()) 90 .addPackages(false, NotificationTestCase.class.getPackage())
93 - .addClasses(DummyNotificationListener.class,DummyManagedClass.class); 91 + .addClasses(DummyNotificationListener.class, DummyManagedClass.class);
94 } 92 }
95 - 93 +
96 /** 94 /**
97 * Test sending a normal notification 95 * Test sending a normal notification
98 */ 96 */
99 @Test 97 @Test
100 - public void testSendGenericNotification(){ 98 + public void testSendGenericNotification() {
101 manager.sendNotification(new GenericNotification("Test Message")); 99 manager.sendNotification(new GenericNotification("Test Message"));
102 DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class); 100 DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class);
103 Assert.assertEquals("Test Message", listener.getMessage()); 101 Assert.assertEquals("Test Message", listener.getMessage());
104 } 102 }
105 - 103 +
106 /** 104 /**
107 * Test sending a notification of change in attribute 105 * Test sending a notification of change in attribute
108 */ 106 */
109 @Test 107 @Test
110 - public void testSendAttributeChangeNotification(){  
111 - manager.sendNotification(new AttributeChangeNotification("Test Message", "attribute", String.class, "old", "new")); 108 + public void testSendAttributeChangeNotification() {
  109 + manager.sendNotification(new AttributeChangeNotification("Test Message", "attribute", String.class, "old",
  110 + "new"));
112 DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class); 111 DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class);
113 Assert.assertEquals("Test Message - attribute", listener.getMessage()); 112 Assert.assertEquals("Test Message - attribute", listener.getMessage());
114 } 113 }
115 - 114 +
116 /** 115 /**
117 - * Test if notifications are automatically sent when an attribute from a managed  
118 - * class change values 116 + * Test if notifications are automatically sent when an attribute from a managed class change values
119 */ 117 */
120 @Test 118 @Test
121 - public void testNotifyChangeManagedClass(){ 119 + public void testNotifyChangeManagedClass() {
122 Management manager = Beans.getReference(Management.class); 120 Management manager = Beans.getReference(Management.class);
123 -  
124 - for (ManagedType type : manager.getManagedTypes()){  
125 - if (type.getType().equals(DummyManagedClass.class)){ 121 +
  122 + for (ManagedType type : manager.getManagedTypes()) {
  123 + if (type.getType().equals(DummyManagedClass.class)) {
126 manager.setProperty(type, "id", new Integer(10)); 124 manager.setProperty(type, "id", new Integer(10));
127 break; 125 break;
128 } 126 }
129 } 127 }
130 - 128 +
131 DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class); 129 DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class);
132 - Assert.assertEquals( bundle.getString("management-notification-attribute-changed","id",DummyManagedClass.class.getCanonicalName()) + " - id"  
133 - , listener.getMessage()); 130 + Assert.assertEquals(
  131 + bundle.getString("management-notification-attribute-changed", "id",
  132 + DummyManagedClass.class.getCanonicalName())
  133 + + " - id", listener.getMessage());
134 } 134 }
135 135
136 } 136 }
impl/core/src/test/java/management/ValidationTestCase.java
@@ -17,7 +17,7 @@ import org.junit.Assert; @@ -17,7 +17,7 @@ import org.junit.Assert;
17 import org.junit.Test; 17 import org.junit.Test;
18 import org.junit.runner.RunWith; 18 import org.junit.runner.RunWith;
19 19
20 -import test.LocaleProducer; 20 +import test.Tests;
21 import br.gov.frameworkdemoiselle.DemoiselleException; 21 import br.gov.frameworkdemoiselle.DemoiselleException;
22 import br.gov.frameworkdemoiselle.util.Beans; 22 import br.gov.frameworkdemoiselle.util.Beans;
23 23
@@ -28,18 +28,15 @@ public class ValidationTestCase { @@ -28,18 +28,15 @@ public class ValidationTestCase {
28 public static JavaArchive createDeployment() { 28 public static JavaArchive createDeployment() {
29 return ShrinkWrap 29 return ShrinkWrap
30 .create(JavaArchive.class) 30 .create(JavaArchive.class)
31 - .addClass(LocaleProducer.class) 31 + .addClass(Tests.class)
32 .addPackages(true, "br") 32 .addPackages(true, "br")
33 .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml") 33 .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml")
34 .addAsManifestResource( 34 .addAsManifestResource(
35 new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), 35 new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"),
36 "services/javax.enterprise.inject.spi.Extension") 36 "services/javax.enterprise.inject.spi.Extension")
37 .addPackages(false, NotificationTestCase.class.getPackage()) 37 .addPackages(false, NotificationTestCase.class.getPackage())
38 - .addClasses(DummyManagementExtension.class  
39 - , ManagedClassStore.class  
40 - , DummyManagedClass.class  
41 - , DummyValidator.class  
42 - , DummyValidatorAnnotation.class); 38 + .addClasses(DummyManagementExtension.class, ManagedClassStore.class, DummyManagedClass.class,
  39 + DummyValidator.class, DummyValidatorAnnotation.class);
43 } 40 }
44 41
45 /** 42 /**
@@ -87,7 +84,7 @@ public class ValidationTestCase { @@ -87,7 +84,7 @@ public class ValidationTestCase {
87 84
88 Assert.fail(); 85 Assert.fail();
89 } catch (DemoiselleException e) { 86 } catch (DemoiselleException e) {
90 - Assert.assertTrue( e.getMessage().contains("Test Message") ); 87 + Assert.assertTrue(e.getMessage().contains("Test Message"));
91 } 88 }
92 89
93 } 90 }