Commit aa4ea911450b4a3fc0f512986f4d516b85ad8ab7
1 parent
c37abee3
Exists in
master
Correção do @Deployment dos teste do management
Showing
5 changed files
with
51 additions
and
58 deletions
Show diff stats
impl/core/src/test/java/management/AnnotationTestCase.java
... | ... | @@ -53,7 +53,7 @@ import org.junit.Ignore; |
53 | 53 | import org.junit.Test; |
54 | 54 | import org.junit.runner.RunWith; |
55 | 55 | |
56 | -import test.LocaleProducer; | |
56 | +import test.Tests; | |
57 | 57 | |
58 | 58 | //TODO O arquillian está com um problema onde, embora os testes rodem todos individualmente, |
59 | 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 | 70 | public static JavaArchive createWrongAnnotationDeployment() { |
71 | 71 | return ShrinkWrap |
72 | 72 | .create(JavaArchive.class) |
73 | - .addClass(LocaleProducer.class) | |
73 | + .addClass(Tests.class) | |
74 | 74 | .addPackages(true, "br") |
75 | 75 | .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml") |
76 | 76 | .addAsManifestResource( | ... | ... |
impl/core/src/test/java/management/ManagementBootstrapTestCase.java
... | ... | @@ -55,7 +55,7 @@ import org.junit.Ignore; |
55 | 55 | import org.junit.Test; |
56 | 56 | import org.junit.runner.RunWith; |
57 | 57 | |
58 | -import test.LocaleProducer; | |
58 | +import test.Tests; | |
59 | 59 | import br.gov.frameworkdemoiselle.internal.management.ManagedType; |
60 | 60 | import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; |
61 | 61 | import br.gov.frameworkdemoiselle.util.Beans; |
... | ... | @@ -72,7 +72,7 @@ public class ManagementBootstrapTestCase { |
72 | 72 | public static JavaArchive createDeployment() { |
73 | 73 | return ShrinkWrap |
74 | 74 | .create(JavaArchive.class) |
75 | - .addClass(LocaleProducer.class) | |
75 | + .addClass(Tests.class) | |
76 | 76 | .addPackages(true, "br") |
77 | 77 | .addAsResource( |
78 | 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 | 53 | import org.junit.Test; |
54 | 54 | import org.junit.runner.RunWith; |
55 | 55 | |
56 | -import test.LocaleProducer; | |
56 | +import test.Tests; | |
57 | 57 | import br.gov.frameworkdemoiselle.DemoiselleException; |
58 | 58 | import br.gov.frameworkdemoiselle.util.Beans; |
59 | 59 | |
... | ... | @@ -70,18 +70,15 @@ public class ManagementTestCase { |
70 | 70 | public static JavaArchive createMultithreadedDeployment() { |
71 | 71 | return ShrinkWrap |
72 | 72 | .create(JavaArchive.class) |
73 | - .addClass(LocaleProducer.class) | |
73 | + .addClass(Tests.class) | |
74 | 74 | .addPackages(true, "br") |
75 | 75 | .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml") |
76 | 76 | .addAsManifestResource( |
77 | 77 | new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), |
78 | 78 | "services/javax.enterprise.inject.spi.Extension") |
79 | 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 | 84 | @Test |
... | ... | @@ -167,32 +164,31 @@ public class ManagementTestCase { |
167 | 164 | } |
168 | 165 | |
169 | 166 | } |
170 | - | |
167 | + | |
171 | 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 | 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 | 175 | Assert.fail(); |
179 | - } | |
180 | - catch(DemoiselleException de){ | |
176 | + } catch (DemoiselleException de) { | |
181 | 177 | System.out.println(de.getMessage()); |
182 | - //success | |
178 | + // success | |
183 | 179 | } |
184 | 180 | } |
185 | - | |
181 | + | |
186 | 182 | @Test |
187 | 183 | public void testRequestScopedOperation() { |
188 | 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 | 188 | Object info = store.invoke(DummyManagedClass.class, "requestScopedOperation"); |
193 | 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 | 192 | info = store.invoke(DummyManagedClass.class, "requestScopedOperation"); |
197 | 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 | 52 | import org.junit.Test; |
53 | 53 | import org.junit.runner.RunWith; |
54 | 54 | |
55 | -import test.LocaleProducer; | |
55 | +import test.Tests; | |
56 | 56 | import br.gov.frameworkdemoiselle.annotation.Name; |
57 | 57 | import br.gov.frameworkdemoiselle.internal.management.ManagedType; |
58 | 58 | import br.gov.frameworkdemoiselle.internal.management.Management; |
... | ... | @@ -63,74 +63,74 @@ import br.gov.frameworkdemoiselle.util.Beans; |
63 | 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 | 68 | * @author serpro |
70 | - * | |
71 | 69 | */ |
72 | 70 | @RunWith(Arquillian.class) |
73 | 71 | public class NotificationTestCase { |
74 | - | |
72 | + | |
75 | 73 | @Inject |
76 | 74 | private NotificationManager manager; |
77 | - | |
75 | + | |
78 | 76 | @Inject |
79 | 77 | @Name("demoiselle-core-bundle") |
80 | 78 | private ResourceBundle bundle; |
81 | - | |
79 | + | |
82 | 80 | @Deployment |
83 | 81 | public static JavaArchive createDeployment() { |
84 | 82 | return ShrinkWrap |
85 | 83 | .create(JavaArchive.class) |
86 | - .addClass(LocaleProducer.class) | |
84 | + .addClass(Tests.class) | |
87 | 85 | .addPackages(true, "br") |
88 | 86 | .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml") |
89 | 87 | .addAsManifestResource( |
90 | 88 | new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), |
91 | 89 | "services/javax.enterprise.inject.spi.Extension") |
92 | 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 | 95 | * Test sending a normal notification |
98 | 96 | */ |
99 | 97 | @Test |
100 | - public void testSendGenericNotification(){ | |
98 | + public void testSendGenericNotification() { | |
101 | 99 | manager.sendNotification(new GenericNotification("Test Message")); |
102 | 100 | DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class); |
103 | 101 | Assert.assertEquals("Test Message", listener.getMessage()); |
104 | 102 | } |
105 | - | |
103 | + | |
106 | 104 | /** |
107 | 105 | * Test sending a notification of change in attribute |
108 | 106 | */ |
109 | 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 | 111 | DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class); |
113 | 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 | 118 | @Test |
121 | - public void testNotifyChangeManagedClass(){ | |
119 | + public void testNotifyChangeManagedClass() { | |
122 | 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 | 124 | manager.setProperty(type, "id", new Integer(10)); |
127 | 125 | break; |
128 | 126 | } |
129 | 127 | } |
130 | - | |
128 | + | |
131 | 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 | 17 | import org.junit.Test; |
18 | 18 | import org.junit.runner.RunWith; |
19 | 19 | |
20 | -import test.LocaleProducer; | |
20 | +import test.Tests; | |
21 | 21 | import br.gov.frameworkdemoiselle.DemoiselleException; |
22 | 22 | import br.gov.frameworkdemoiselle.util.Beans; |
23 | 23 | |
... | ... | @@ -28,18 +28,15 @@ public class ValidationTestCase { |
28 | 28 | public static JavaArchive createDeployment() { |
29 | 29 | return ShrinkWrap |
30 | 30 | .create(JavaArchive.class) |
31 | - .addClass(LocaleProducer.class) | |
31 | + .addClass(Tests.class) | |
32 | 32 | .addPackages(true, "br") |
33 | 33 | .addAsResource(new FileAsset(new File("src/test/resources/beans.xml")), "beans.xml") |
34 | 34 | .addAsManifestResource( |
35 | 35 | new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), |
36 | 36 | "services/javax.enterprise.inject.spi.Extension") |
37 | 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 | 84 | |
88 | 85 | Assert.fail(); |
89 | 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 | } | ... | ... |