[
https://issues.jboss.org/browse/WELD-974?page=com.atlassian.jira.plugin.s...
]
Jens Augustsson commented on WELD-974:
--------------------------------------
Geoffrey,
First, I assume you'd like to resolve your SpecializesNamedFoo, not NamedFoo?
{code}
@Test
public void testSpecializationWithAlternative() {
Assert.assertEquals(SpecializesNamedFoo.class, beanManager.resolve(beanManager.getBeans(NamedFoo.class)).getBeanClass());
}
{code}
Second, I believe the behavior is expected, because according to the spec, alternatives
should be by default disabled unless you enable them in beans.xml. So if I modify your
test case to reflect this, it passes the test:
{code}
@Deployment
public static Archive<?> deploy() {
return ShrinkWrap.create(BeanArchive.class)
.alternate(SpecializesNamedFoo.class)
.addPackage(SpecializationTest.class.getPackage());
}
{code}
Or?
br,
Jens
@Alternative @Specializes does not work
---------------------------------------
Key: WELD-974
URL:
https://issues.jboss.org/browse/WELD-974
Project: Weld
Issue Type: Bug
Affects Versions: 1.1.2.Final
Reporter: Geoffrey De Smet
Priority: Critical
See pull request with testcase.
{code}
@ApplicationScoped
@Named("namedFoo") // doesn't matter if it's @Named or not
public class NamedFoo
{
}
@Alternative @Specializes
public class SpecializesNamedFoo extends NamedFoo
{
}
@Test
public void testSpecializationWithAlternative()
{
Assert.assertEquals(NamedFoo.class,
beanManager.resolve(beanManager.getBeans(NamedFoo.class)).getBeanClass()); // FAILS WITH
NPE!
}
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira