本文整理了Java中javax.enterprise.inject.spi.Bean.getTypes()
方法的一些代码示例,展示了Bean.getTypes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bean.getTypes()
方法的具体详情如下:
包路径:javax.enterprise.inject.spi.Bean
类名称:Bean
方法名:getTypes
[英]Returns api types of a bean.
[中]返回bean的api类型。
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertion(section = LEGAL_BEAN_TYPES, id = "c")
public void testAbstractApiType() {
Set<Bean<FriendlyAntelope>> beans = getBeans(FriendlyAntelope.class);
assertEquals(beans.size(), 1);
Bean<FriendlyAntelope> bean = beans.iterator().next();
assertEquals(bean.getTypes().size(), 4);
assertTrue(bean.getTypes().contains(FriendlyAntelope.class));
assertTrue(bean.getTypes().contains(AbstractAntelope.class));
assertTrue(bean.getTypes().contains(Animal.class));
assertTrue(bean.getTypes().contains(Object.class));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(enabled = false)
// disabled due to CDITCK-575 and marked as testable false
// @SpecAssertions({ @SpecAssertion(section = RESOURCE_TYPES, id = "b") })
public void resourceBeanTypesContainsOnlyLegalTypes() {
Bean<Dog> dogBean = getUniqueBean(Dog.class, Produced.ProducedLiteral.INSTANCE);
for (Type type : dogBean.getTypes()) {
if (type instanceof ParameterizedType) {
assertNotEquals(((ParameterizedType) type).getRawType(), AnimalHolder.class);
}
}
assertEquals(dogBean.getTypes().size(), 2);
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
@Test(groups = { "producerField" })
@SpecAssertion(section = "3.4.1", id = "a")
public void testApiTypeForInterfaceReturn()
{
Set<Bean<Animal>> animalBeans = getBeans(Animal.class, new AnnotationLiteral<AsAnimal>() {});
assert animalBeans.size() == 1;
Bean<Animal> animalModel = animalBeans.iterator().next();
assert animalModel.getTypes().size() == 2;
assert animalModel.getTypes().contains(Animal.class);
assert animalModel.getTypes().contains(Object.class);
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
@Test(groups = "producerMethod")
@SpecAssertion(section = "3.3.1", id = "ba")
public void testApiTypeForPrimitiveReturn() throws Exception
{
assert getBeans(Integer.class).size() == 1;
Bean<Integer> integer = getBeans(Integer.class).iterator().next();
assert integer.getTypes().size() == 2;
assert integer.getTypes().contains(int.class);
assert integer.getTypes().contains(Object.class);
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertion(section = SESSION_BEAN_TYPES, id = "ba")
public void testEnterpriseBeanClassLocalView() {
Bean<Retriever> dogBean = getUniqueBean(Retriever.class);
assert dogBean.getTypes().contains(Retriever.class);
assert dogBean.getTypes().contains(Dog.class);
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
@Test(groups = "producerMethod")
@SpecAssertion(section = "3.3.1", id = "a")
public void testApiTypeForInterfaceReturn() throws Exception
{
assert getBeans(Bite.class).size() == 1;
Bean<Bite> animal = getBeans(Bite.class).iterator().next();
assert animal.getTypes().size() == 2;
assert animal.getTypes().contains(Bite.class);
assert animal.getTypes().contains(Object.class);
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertions({ @SpecAssertion(section = RESOURCE_TYPES, id = "aa") })
public void testResourceBeanTypes() {
Bean<BeanManager> beanRemote = getBeans(BeanManager.class, new AnnotationLiteral<Another>() {
}).iterator().next();
assert beanRemote.getTypes().size() == 2;
assert beanRemote.getTypes().contains(BeanManager.class);
assert beanRemote.getTypes().contains(Object.class);
}
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertions({ @SpecAssertion(section = SESSION_BEAN_TYPES, id = "aa"), @SpecAssertion(section = DECLARING_SESSION_BEAN, id = "c") })
public void testBeanTypesAreLocalInterfacesWithoutWildcardTypesOrTypeVariablesWithSuperInterfaces() {
Bean<DogLocal> dogBean = getBeans(DogLocal.class).iterator().next();
assert dogBean.getTypes().contains(DogLocal.class);
assert dogBean.getTypes().contains(PitbullLocal.class);
assert !dogBean.getTypes().contains(Pitbull.class);
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertions({ @SpecAssertion(section = SESSION_BEAN_TYPES, id = "e") })
public void sessionBeanTypesContainsOnlyLegalTypes() {
Bean<Bird> birdBean = getUniqueBean(Bird.class);
for (Type type : birdBean.getTypes()) {
if (type instanceof ParameterizedType) {
assertNotEquals(((ParameterizedType) type).getRawType(), AnimalHolder.class);
}
}
assertEquals(birdBean.getTypes().size(), 2);
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertion(section = PERFORMING_TYPESAFE_RESOLUTION, id = "lb")
public void testDefaultBindingTypeAssumed() throws Exception {
Set<Bean<Tuna>> possibleTargets = getBeans(Tuna.class);
assertEquals(possibleTargets.size(), 1);
assertTrue(possibleTargets.iterator().next().getTypes().contains(Tuna.class));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = INTEGRATION)
@SpecAssertion(section = SESSION_BEAN_TYPES, id = "ba")
public void testSessionBeanWithNoInterfaceView(){
Bean<Cobra> cobraBean = getUniqueBean(Cobra.class);
assertNotNull(cobraBean);
assertEquals(cobraBean.getTypes().size(), 3);
assertTypeSetMatches(cobraBean.getTypes(), Object.class, Cobra.class, Snake.class);
}
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
@Test(groups = "resolution")
@SpecAssertion(section = "5.2", id = "lb")
public void testDefaultBindingTypeAssumed() throws Exception
{
Set<Bean<Tuna>> possibleTargets = getBeans(Tuna.class);
assert possibleTargets.size() == 1;
assert possibleTargets.iterator().next().getTypes().contains(Tuna.class);
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertion(section = ALTERNATIVE_METADATA_SOURCES_EE, id = "kb")
public void testGetTypeClosureUsedToDetermineTypeOfSessionBean() {
Bean<Pasta> pasta = getBeans(Pasta.class).iterator().next();
assertEquals(pasta.getTypes().size(), 2);
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertion(section = ALTERNATIVE_METADATA_SOURCES, id = "kd")
public void testGetTypeClosureUsedToDetermineTypeOfProducerMethod() {
// produced by Grocery.createVegetable()
Bean<Carrot> carrot = getBeans(Carrot.class, new CheapLiteral()).iterator().next();
// should be [Object, Carrot] instead of [Object, Carrot, Vegetables]
assertEquals(carrot.getTypes().size(), 2);
assertFalse(carrot.getTypes().contains(Vegetables.class));
assertTrue(GroceryWrapper.isGetTypeClosureOfProducerMethodUsed());
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
@Test(groups = { "ejb 3.1" })
@SpecAssertion(section = "3.2.2", id = "ba")
public void testEnterpriseBeanClassLocalView()
{
//TODO We need a 3.1 compliant container for this test
Bean<Retriever> dogBean = getBeans(Retriever.class).iterator().next();
assert dogBean.getTypes().contains(Retriever.class);
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
@Test(groups = { "enterpriseBeans", "ejbjarxml" })
@SpecAssertions( {
@SpecAssertion(section = "3.1.1", id = "n"),
@SpecAssertion(section = "3.2.2", id = "ba")
})
public void testEjbDeclaredInXmlNotSimpleBean()
{
Bean<ElephantLocal> elephantBean = getBeans(ElephantLocal.class).iterator().next();
// The interface is a known type but the class should not be
assert elephantBean.getTypes().contains(ElephantLocal.class);
assert !elephantBean.getTypes().contains(Elephant.class);
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertions({ @SpecAssertion(section = PERFORMING_TYPESAFE_RESOLUTION, id = "ka") })
public void testResolveByTypeWithTypeParameter() throws Exception {
Set<Bean<Farmer<ScottishFish>>> beans = getBeans(new TypeLiteral<Farmer<ScottishFish>>() {
});
assertEquals(beans.size(), 1);
assertTrue(beans.iterator().next().getTypes().contains(ScottishFishFarmer.class));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = JAVAEE_FULL)
@SpecAssertions({ @SpecAssertion(section = RESOURCE_TYPES, id = "ad") })
public void testResourceBeanTypes() {
@SuppressWarnings("serial")
Bean<BeanRemote> beanRemote = getBeans(BeanRemote.class, new AnnotationLiteral<Lazy>() {
}).iterator().next();
assert beanRemote.getTypes().size() == 3;
assert typeSetMatches(beanRemote.getTypes(), BeanRemote.class, Object.class, AnotherInterface.class);
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertions({ @SpecAssertion(section = RESOURCE_TYPES, id = "aa") })
public void testResourceBeanTypes() {
@SuppressWarnings("serial")
Bean<String> greeting = getBeans(String.class, new AnnotationLiteral<Greeting>() {
}).iterator().next();
assert greeting.getTypes().size() == 5;
assert rawTypeSetMatches(greeting.getTypes(), String.class, Object.class, Serializable.class, Comparable.class,
CharSequence.class);
}
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertions({ @SpecAssertion(section = RESOURCE_TYPES, id = "ac") })
public void testBeanTypesOfPersistenceUnit() {
Bean<EntityManagerFactory> factory = getBeans(EntityManagerFactory.class, new AnnotationLiteral<Database>() {
}).iterator().next();
assert factory.getTypes().size() == 2;
assert typeSetMatches(factory.getTypes(), EntityManagerFactory.class, Object.class);
}
}
内容来源于网络,如有侵权,请联系作者删除!