Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit afe0405

Browse files
authored
Merge pull request javaee-samples#351 from robertpanzer/cdi_tests_tomee
Use the correct instances to destroy CDI beans obtained from Instances.
2 parents 94bbb87 + 8f0ad36 commit afe0405

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

cdi/instance-qualifiers/src/test/java/org/javaee7/cdi/instance/AnyGreetingTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ public void test() throws Exception {
4949
assertTrue(instance.isAmbiguous());
5050

5151
// use Instance<T>#select()
52-
Greeting businessBean = instance.select(new AnnotationLiteral<Business>() {}).get();
52+
Instance<Greeting> businessInstance = instance.select(new AnnotationLiteral<Business>() {});
53+
Greeting businessBean = businessInstance.get();
5354
assertThat(businessBean, instanceOf(FormalGreeting.class));
54-
instance.destroy(businessBean);
55+
businessInstance.destroy(businessBean);
5556

56-
Greeting defaultBean = instance.select(new AnnotationLiteral<Default>() {}).get();
57+
Instance<Greeting> defaultInstance = instance.select(new AnnotationLiteral<Default>() {});
58+
Greeting defaultBean = defaultInstance.get();
5759
assertThat(defaultBean, instanceOf(SimpleGreeting.class));
58-
instance.destroy(defaultBean);
60+
defaultInstance.destroy(defaultBean);
5961
}
6062
}
6163

cdi/instance-qualifiers/src/test/java/org/javaee7/cdi/instance/GreetingTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ public void test() throws Exception {
5454
instance.destroy(bean);
5555

5656
// use Instance<T>#select()
57-
Greeting anotherBean = instance.select(new AnnotationLiteral<Default>() {}).get();
57+
Instance<Greeting> anotherInstance = instance.select(new AnnotationLiteral<Default>() {
58+
});
59+
Greeting anotherBean = anotherInstance.get();
5860
assertThat(anotherBean, instanceOf(SimpleGreeting.class));
59-
instance.destroy(anotherBean);
61+
anotherInstance.destroy(anotherBean);
6062
}
6163
}
6264

0 commit comments

Comments
 (0)