Hi Yann this is fixed and here is the test: https://git1-us-west.apache.org/repos/asf?p=tomee.git;a=blob;f=container/openejb-core/src/test/java/org/apache/openejb/junit/ContainerAndApplicationRulesTest.java;h=1f0ce567efa60ba4c6b7200c1d6fb04e1527bd75;hb=c63f2ec304a174ccefd88dda48bbe440c2036a5f
Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com> 2015-12-02 18:14 GMT+01:00 Yann BLAZART <[email protected] >: > Hello, it seems there is a bug in ApplicationRule with ApplicationComposer. > > With the following code : > > > public class AppRuleBugTest { > > private static final ContainerRule instanceContainer = new > ContainerRule(new Container()); > private static final ApplicationRule instanceServer = new > ApplicationRule(new App1()); > > @Rule > public final TestRule rule = RuleChain > .outerRule(instanceContainer) > .around(instanceServer); > > @Test > public void test() { > > } > > @EnableServices("jaxrs") > @Classes( > value = { > TxRunner.class, > FeedsFlowRepository.class, > } > ) > public static class Container extends > AbstractApplicationComposerHelper { > > } > > @Classes( > context = "App1", > cdi = true, innerClassesAsBean = true > ) > public static class App1 { > > @Module > public PersistenceUnit unit() { > return new PersistenceUnit("jpa"); > } > } > > @Module > public PersistenceUnit unit() { > return new PersistenceUnit("jpa"); > } > } > > I precise I have in my real case to use Rule because I want to test > communications between two 'Application', and I have to use @Module and > @Configuration because I doing some special configurations. > > I have this stacktrace when AppComposer try to call the method Annotated > with @Module in the inner class. This is the same if I externalize the App1 > class : > > java.lang.IllegalArgumentException: object is not an instance of declaring > class > > at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:483) > at > org.apache.openejb.testing.ApplicationComposers.deployApp(ApplicationComposers.java:432) > at > org.apache.openejb.junit.ApplicationRule$1.evaluate(ApplicationRule.java:45) > at > org.apache.openejb.junit.ContainerRule$1.evaluate(ContainerRule.java:45) > at > org.junit.rules.RunRules.evaluate(RunRules.java:20) > at > org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) > at > org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) > at > org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) > > > Thanks in advance. Regards. > > > > This message and any attachments (the "message") is > intended solely for the intended addressees and is confidential. > If you receive this message in error,or are not the intended recipient(s), > please delete it and any copies from your systems and immediately notify > the sender. Any unauthorized view, use that does not comply with its > purpose, > dissemination or disclosure, either whole or partial, is prohibited. Since > the internet > cannot guarantee the integrity of this message which may not be reliable, > BNP PARIBAS > (and its subsidiaries) shall not be liable for the message if modified, > changed or falsified. > Do not print this message unless it is necessary,consider the environment. > > > ---------------------------------------------------------------------------------------------------------------------------------- > > Ce message et toutes les pieces jointes (ci-apres le "message") > sont etablis a l'intention exclusive de ses destinataires et sont > confidentiels. > Si vous recevez ce message par erreur ou s'il ne vous est pas destine, > merci de le detruire ainsi que toute copie de votre systeme et d'en avertir > immediatement l'expediteur. Toute lecture non autorisee, toute utilisation > de > ce message qui n'est pas conforme a sa destination, toute diffusion ou > toute > publication, totale ou partielle, est interdite. L'Internet ne permettant > pas d'assurer > l'integrite de ce message electronique susceptible d'alteration, BNP > Paribas > (et ses filiales) decline(nt) toute responsabilite au titre de ce message > dans l'hypothese > ou il aurait ete modifie, deforme ou falsifie. > N'imprimez ce message que si necessaire, pensez a l'environnement. >
