Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
tests-arquillian/src/test/java/org/jboss/weld/tests/assignability/AssignabilityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package org.jboss.weld.tests.assignability; | ||
|
||
import junit.framework.Assert; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.BeanArchive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import javax.enterprise.inject.spi.Bean; | ||
import javax.enterprise.inject.spi.BeanManager; | ||
import javax.enterprise.util.TypeLiteral; | ||
import javax.inject.Inject; | ||
import java.util.Set; | ||
|
||
/** | ||
* | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class AssignabilityTest { | ||
|
||
@Inject | ||
private BeanManager beanManager; | ||
|
||
@Deployment | ||
public static Archive<?> deploy() { | ||
return ShrinkWrap.create(BeanArchive.class) | ||
.addPackage(AssignabilityTest.class.getPackage()); | ||
} | ||
|
||
|
||
@Test | ||
public void testAssignability1() { | ||
Set<Bean<?>> beans = beanManager.getBeans(new TypeLiteral<Dao<Order>>() { | ||
}.getType()); | ||
|
||
Assert.assertEquals(1, beans.size()); | ||
} | ||
|
||
@Test | ||
public void testAssignability2() { | ||
Set<Bean<?>> beans = beanManager.getBeans(new TypeLiteral<Dao<User>>() { | ||
}.getType()); | ||
Assert.assertEquals(2, beans.size()); | ||
} | ||
|
||
@Test | ||
public void testAssignability3() { | ||
Set<Bean<?>> beans = beanManager.getBeans(new TypeLiteral<Dao<?>>() { | ||
}.getType()); | ||
System.err.println("beans = " + beans); | ||
Assert.assertEquals(2, beans.size()); | ||
} | ||
|
||
@Test | ||
public void testAssignability4() { | ||
Set<Bean<?>> beans = beanManager.getBeans(new TypeLiteral<Dao<? extends Persistent>>() { | ||
}.getType()); | ||
Assert.assertEquals(2, beans.size()); | ||
} | ||
|
||
@Test | ||
public <X extends Persistent> void testAssignability5() { | ||
Set<Bean<?>> beans = beanManager.getBeans(new TypeLiteral<Dao<X>>() { | ||
}.getType()); | ||
Assert.assertEquals(2, beans.size()); | ||
} | ||
|
||
@Test | ||
public void testAssignability6() { | ||
Set<Bean<?>> beans = beanManager.getBeans(new TypeLiteral<Dao<? extends User>>() { | ||
}.getType()); | ||
Assert.assertEquals(2, beans.size()); | ||
} | ||
|
||
@Ignore("WELD-1054") | ||
@Test | ||
public void testAssignability7() { | ||
Set<Bean<?>> beans = beanManager.getBeans(Dao.class); | ||
Assert.assertEquals(0, beans.size()); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
tests-arquillian/src/test/java/org/jboss/weld/tests/assignability/Dao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.jboss.weld.tests.assignability; | ||
|
||
/** | ||
* | ||
*/ | ||
public class Dao<T extends Persistent> { | ||
|
||
public String getType() { | ||
return "Dao"; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
tests-arquillian/src/test/java/org/jboss/weld/tests/assignability/Order.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.jboss.weld.tests.assignability; | ||
|
||
/** | ||
* | ||
*/ | ||
public class Order implements Persistent { | ||
} |
7 changes: 7 additions & 0 deletions
7
tests-arquillian/src/test/java/org/jboss/weld/tests/assignability/Persistent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.jboss.weld.tests.assignability; | ||
|
||
/** | ||
* | ||
*/ | ||
public interface Persistent { | ||
} |
7 changes: 7 additions & 0 deletions
7
tests-arquillian/src/test/java/org/jboss/weld/tests/assignability/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.jboss.weld.tests.assignability; | ||
|
||
/** | ||
* | ||
*/ | ||
public class User implements Persistent { | ||
} |
12 changes: 12 additions & 0 deletions
12
tests-arquillian/src/test/java/org/jboss/weld/tests/assignability/UserDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.jboss.weld.tests.assignability; | ||
|
||
/** | ||
* | ||
*/ | ||
public class UserDao extends Dao<User> { | ||
|
||
@Override | ||
public String getType() { | ||
return "UserDao"; | ||
} | ||
} |