Search in sources :

Example 1 with StringOrder

use of org.apache.webbeans.test.component.literals.InstanceTypeLiteralBean.StringOrder in project openwebbeans by apache.

the class TypeLiteralTest method testTypeLiteralInInstance.

@Test
public void testTypeLiteralInInstance() {
    startContainer(StringOrder.class, IntegerOrder.class, InstanceTypeLiteralBean.class);
    InstanceTypeLiteralBean beaninstance = getInstance(InstanceTypeLiteralBean.class);
    Object produce = beaninstance.produce(0);
    Assert.assertTrue(produce instanceof Instance);
    Instance<IntegerOrder> order = (Instance<IntegerOrder>) produce;
    Assert.assertTrue(order.get() instanceof IntegerOrder);
    produce = beaninstance.produce(1);
    Assert.assertTrue(produce instanceof Instance);
    Instance<StringOrder> order2 = (Instance<StringOrder>) produce;
    Assert.assertTrue(order2.get() instanceof StringOrder);
}
Also used : Instance(javax.enterprise.inject.Instance) InstanceTypeLiteralBean(org.apache.webbeans.test.component.literals.InstanceTypeLiteralBean) IntegerOrder(org.apache.webbeans.test.component.literals.InstanceTypeLiteralBean.IntegerOrder) StringOrder(org.apache.webbeans.test.component.literals.InstanceTypeLiteralBean.StringOrder) AbstractUnitTest(org.apache.webbeans.test.AbstractUnitTest) Test(org.junit.Test)

Aggregations

Instance (javax.enterprise.inject.Instance)1 AbstractUnitTest (org.apache.webbeans.test.AbstractUnitTest)1 InstanceTypeLiteralBean (org.apache.webbeans.test.component.literals.InstanceTypeLiteralBean)1 IntegerOrder (org.apache.webbeans.test.component.literals.InstanceTypeLiteralBean.IntegerOrder)1 StringOrder (org.apache.webbeans.test.component.literals.InstanceTypeLiteralBean.StringOrder)1 Test (org.junit.Test)1