[arquillian-issues] [JBoss JIRA] Commented: (ARQ-254) Allow the use of @Deployment on non-static method
Aslak Knutsen (JIRA)
jira-events at lists.jboss.org
Thu Aug 12 13:49:49 EDT 2010
[ https://jira.jboss.org/browse/ARQ-254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12544679#action_12544679 ]
Aslak Knutsen commented on ARQ-254:
-----------------------------------
Arquillian has a client side SPI you could use to implement similar behavior if you want.
org.jboss.arquillian.spi.ApplicationArchiveProcessor
pseudo impl:
public class MyApplicationArchiveProcessor {
void process(Archive<?> applicationArchive, TestClass testClass)
{
if(testClass.isAnnotationPresent(MyClassesAnnotation.class))
{
MyClassesAnnotation anno = testClass.getAnnotation(MyClassesAnnotation.class);
ClassContainer classContainer = (ClasContainer)applicationArchive;
classContainer.addClasses(anno.value());
}
}
}
Register your SPI impl by adding a file somewhere on classpath in /META-INF/services/org.jboss.arquillian.spi.ApplicationArchiveProcessor that contains the fully qualified impl class name.
You test could then look like, e.g.:
@MyClassesAnnotation({FooEJB.class, BarEJB.class})
@RunWith(Arquillian.class)
public class MyTest extends DeploymentTest
{
@Test
....
}
> Allow the use of @Deployment on non-static method
> -------------------------------------------------
>
> Key: ARQ-254
> URL: https://jira.jboss.org/browse/ARQ-254
> Project: Arquillian
> Issue Type: Feature Request
> Reporter: Elias Ross
>
> Some tests I have test the deployment as is, some tests add in additional EJBs. (I exclude certain EJBs and MDBs to speed up testing.)
> This is currently what I do:
> @RunWith(org.jboss.arquillian.junit.Arquillian.class)
> public class DeploymentTest {
> private static List<Class> ejb = new ArrayList<Class>();
>
> protected static void addClass(Class c) {
> ejb.add(c);
> }
> @Deployment
> public static Archive createTestArchive() throws Exception { ... }
> }
> public class XXXTest extends DeploymentTest {
> static {
> addClass(FooEJB.class);
> addClass(BarEJB.class);
> }
> @Deployment
> public static Archive createTestArchive() throws Exception { return DeploymentTest.createTestArchive(); }
> }
> It'd be nice if, in the case of @Deployment on a non-static class, Arquillian could just created a new instance of the class and obtain the deployment that way. So, it'd look like this:
> @RunWith(org.jboss.arquillian.junit.Arquillian.class)
> public class DeploymentTest {
> private List<Class> ejb = new ArrayList<Class>();
>
> protected void addClass(Class c) {
> ejb.add(c);
> }
> @Deployment
> public Archive createTestArchive() throws Exception { ... }
> }
> public class XXXTest extends DeploymentTest {
> {
> addClass(FooEJB.class);
> addClass(BarEJB.class);
> }
> }
> Arquillian should be able to simply do:
> new XXXTest().createTestArchive()
> in this case.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the arquillian-issues
mailing list