Search in sources :

Example 6 with AnnotationLiteral

use of jakarta.enterprise.util.AnnotationLiteral in project cdi-tck by jakartaee.

the class InterceptorDefinitionTest method testNonBindingTypeToResolveInterceptorsFails.

@Test(expectedExceptions = { IllegalArgumentException.class })
@SpecAssertions({ @SpecAssertion(section = BM_INTERCEPTOR_RESOLUTION, id = "d") })
public void testNonBindingTypeToResolveInterceptorsFails() {
    Annotation nonBinding = new AnnotationLiteral<NonBindingType>() {
    };
    getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE, nonBinding);
}
Also used : AnnotationLiteral(jakarta.enterprise.util.AnnotationLiteral) Annotation(java.lang.annotation.Annotation) SpecAssertions(org.jboss.test.audit.annotations.SpecAssertions) Test(org.testng.annotations.Test) AbstractTest(org.jboss.cdi.tck.AbstractTest)

Example 7 with AnnotationLiteral

use of jakarta.enterprise.util.AnnotationLiteral in project cdi-tck by jakartaee.

the class DecoratorDefinitionTest method testEmptyTypeSetOnResolveDecoratorsFails.

@Test(expectedExceptions = IllegalArgumentException.class)
@SpecAssertion(section = BM_DECORATOR_RESOLUTION, id = "e")
public void testEmptyTypeSetOnResolveDecoratorsFails() {
    Annotation binding = new AnnotationLiteral<NonMeta>() {
    };
    getCurrentManager().resolveDecorators(new HashSet<Type>(), binding);
}
Also used : Type(java.lang.reflect.Type) AnnotationLiteral(jakarta.enterprise.util.AnnotationLiteral) Annotation(java.lang.annotation.Annotation) Test(org.testng.annotations.Test) AbstractTest(org.jboss.cdi.tck.AbstractTest) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 8 with AnnotationLiteral

use of jakarta.enterprise.util.AnnotationLiteral in project cdi-tck by jakartaee.

the class DecoratorDefinitionTest method testNonBindingsOnResolveDecoratorsFails.

@Test(expectedExceptions = IllegalArgumentException.class)
@SpecAssertion(section = BM_DECORATOR_RESOLUTION, id = "d")
public void testNonBindingsOnResolveDecoratorsFails() {
    Annotation binding = new AnnotationLiteral<NonMeta>() {
    };
    getCurrentManager().resolveDecorators(FooBar.TYPES, binding);
}
Also used : AnnotationLiteral(jakarta.enterprise.util.AnnotationLiteral) Annotation(java.lang.annotation.Annotation) Test(org.testng.annotations.Test) AbstractTest(org.jboss.cdi.tck.AbstractTest) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 9 with AnnotationLiteral

use of jakarta.enterprise.util.AnnotationLiteral in project cdi-tck by jakartaee.

the class DecoratorDefinitionTest method testDuplicateBindingsOnResolveDecoratorsFails.

@Test(expectedExceptions = IllegalArgumentException.class)
@SpecAssertion(section = BM_DECORATOR_RESOLUTION, id = "c")
public void testDuplicateBindingsOnResolveDecoratorsFails() {
    Annotation binding = new AnnotationLiteral<Meta>() {
    };
    getCurrentManager().resolveDecorators(FooBar.TYPES, binding, binding);
}
Also used : AnnotationLiteral(jakarta.enterprise.util.AnnotationLiteral) Annotation(java.lang.annotation.Annotation) Test(org.testng.annotations.Test) AbstractTest(org.jboss.cdi.tck.AbstractTest) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 10 with AnnotationLiteral

use of jakarta.enterprise.util.AnnotationLiteral in project core by weld.

the class TransitiveResolutionTest method testDecoratorEnabledInWarButPackagedInEjbJar.

/*
    * WELD-507
    */
@Test
public void testDecoratorEnabledInWarButPackagedInEjbJar() {
    // Create the BDA in which we will deploy Foo. This is equivalent to a ejb
    // jar
    final BeanDeploymentArchiveImpl ejbJar = new BeanDeploymentArchiveImpl("ejb-jar", Blah.class, BlahDecorator.class, BlahImpl.class);
    // Create the BDA in which we will deploy Bar. This is equivalent to a war
    BeansXml beansXml = new BeansXmlImpl(null, null, Collections.singletonList(BlahDecorator.class.getName()), null);
    final BeanDeploymentArchiveImpl war = new BeanDeploymentArchiveImpl("war", beansXml, BlahImpl2.class);
    // The war can access the ejb jar
    war.getBeanDeploymentArchives().add(ejbJar);
    // Create a deployment, any other classes are put into the ejb-jar (not
    // relevant to test)
    Deployment deployment = new FlatDeployment(new BeanDeploymentArchive[] { war, ejbJar }) {

        public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass) {
            return ejbJar;
        }
    };
    TestContainer container = new TestContainer(deployment);
    container.startContainer();
    container.ensureRequestActive();
    // Get the bean manager for war and ejb jar
    BeanManager warBeanManager = container.getBeanManager(war);
    BeanManager ejbJarBeanManager = container.getBeanManager(ejbJar);
    BasicInterceptor.reset();
    Blah blah = getReference(ejbJarBeanManager, Blah.class);
    blah.ping(10);
    assertEquals(10, blah.getI());
    BasicInterceptor.reset();
    blah = getReference(warBeanManager, Blah.class, new AnnotationLiteral<Baz>() {
    });
    blah.ping(10);
    assertEquals(11, blah.getI());
    container.stopContainer();
}
Also used : TestContainer(org.jboss.arquillian.container.weld.embedded.mock.TestContainer) BeanDeploymentArchiveImpl(org.jboss.arquillian.container.weld.embedded.mock.BeanDeploymentArchiveImpl) AnnotationLiteral(jakarta.enterprise.util.AnnotationLiteral) FlatDeployment(org.jboss.arquillian.container.weld.embedded.mock.FlatDeployment) BeansXml(org.jboss.weld.bootstrap.spi.BeansXml) Deployment(org.jboss.weld.bootstrap.spi.Deployment) FlatDeployment(org.jboss.arquillian.container.weld.embedded.mock.FlatDeployment) BeanManager(jakarta.enterprise.inject.spi.BeanManager) Test(org.testng.annotations.Test)

Aggregations

AnnotationLiteral (jakarta.enterprise.util.AnnotationLiteral)14 Annotation (java.lang.annotation.Annotation)13 Test (org.testng.annotations.Test)11 AbstractTest (org.jboss.cdi.tck.AbstractTest)10 SpecAssertion (org.jboss.test.audit.annotations.SpecAssertion)8 Type (java.lang.reflect.Type)4 Observes (jakarta.enterprise.event.Observes)2 Disposes (jakarta.enterprise.inject.Disposes)2 Produces (jakarta.enterprise.inject.Produces)2 InjectLiteral (jakarta.enterprise.inject.literal.InjectLiteral)2 AnnotatedMethod (jakarta.enterprise.inject.spi.AnnotatedMethod)2 AnnotatedType (jakarta.enterprise.inject.spi.AnnotatedType)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 AnnotatedMethodWrapper (org.jboss.cdi.tck.util.annotated.AnnotatedMethodWrapper)2 AnnotatedParameterWrapper (org.jboss.cdi.tck.util.annotated.AnnotatedParameterWrapper)2 SpecAssertions (org.jboss.test.audit.annotations.SpecAssertions)2 BeanManager (jakarta.enterprise.inject.spi.BeanManager)1 BeanDeploymentArchiveImpl (org.jboss.arquillian.container.weld.embedded.mock.BeanDeploymentArchiveImpl)1 FlatDeployment (org.jboss.arquillian.container.weld.embedded.mock.FlatDeployment)1