-
1. Re: Using BYTEMAN in JUnit test with Arquillian
adinn Mar 16, 2018 5:02 AM (in response to tommaso-borgato)Hi Tommaso,
I think it is only possible to do what you want by linking into hooks provided by the Arquilian test runner (Arquilian.class). I don't know enough about how Arquilian works to explain how you would do that (well, actually, I know nothing about how Arquilian works). However, the good news is: I do know that someone else has already done this step for you.
The Arquilian project integrated Byteman into its test model with a byteman extension quite a few years ago. You probably ought to ask about this on the Arquilian forum where there are lots of people who have used it. You might also find the info you need in the Arquilian docs or by googling Arquilian Byteman extension.
regards,
Andrew Dinn
-
2. Re: Using BYTEMAN in JUnit test with Arquillian
tommaso-borgato Mar 16, 2018 5:24 AM (in response to adinn)Thank you Andrew!
In the meantime I found that manually replicating the Byteman call performed in class BMUnitRunner inside my JUnit Test class, does work:
@BeforeClass public static void beforeClass() throws Exception { BMUnitConfigState.pushConfigurationState( MyTestCase.class.getAnnotation(BMUnitConfig.class) , MyTestCase.class); BMUnit.loadScriptFile( MyTestCase.class , BMRunnerUtil.computeBMScriptName(MyTestCase.class.getAnnotation(BMScript.class).value()) , BMRunnerUtil.normaliseLoadDirectory(MyTestCase.class.getAnnotation(BMScript.class))); } @AfterClass public static void afterClass() throws Exception { BMUnit.unloadScriptFile( MyTestCase.class , BMRunnerUtil.computeBMScriptName(MyTestCase.class.getAnnotation(BMScript.class).value())); BMUnitConfigState.popConfigurationState(MyTestCase.class); }
Basically those calls just do the annotation parsing on the JUnit Test class....
-
3. Re: Using BYTEMAN in JUnit test with Arquillian
adinn Mar 16, 2018 5:33 AM (in response to tommaso-borgato)tommaso-borgato wrote:
Thank you Andrew!
In the meantime I found that manually replicating the Byteman call performed in class BMUnitRunner inside my JUnit Test class, does work:
. . .
Basically those calls just do the annotation parsing on the JUnit Test class....
Well, that's good to know. Do make sure that the unload happens inside a finally block so you guarantee to remove the loaded rules!
regards,
Andrew Dinn
-
4. Re: Using BYTEMAN in JUnit test with Arquillian
ochaloup Mar 16, 2018 8:07 AM (in response to tommaso-borgato)Even I haven't tried it personally, have you tried the arquillian extension? GitHub - arquillian/arquillian-extension-byteman: Byteman integration for Arquillian
-
5. Re: Using BYTEMAN in JUnit test with Arquillian
tommaso-borgato Mar 16, 2018 11:01 AM (in response to ochaloup)Thank you Ondra, I tried following the README but it did not work for client side code .... I wrote to Aslak Knutsen (he is part of the arquillian-extension-byteman team) ..... hope he can help me ....
-
6. Re: Using BYTEMAN in JUnit test with Arquillian
ochaloup Mar 16, 2018 12:16 PM (in response to tommaso-borgato)Sure, yeap agree
I've just quickly checked the extension. I wonder the rule run in the container correctly? I could be missing here something just it seems to me there is not installed both extensions - for client and for the container
what about to try to add one more line to the org.jboss.arquillian.core.spi.LoadableExtension file to contain and then compile the extension on your own?
org.jboss.arquillian.extension.byteman.impl.BytemanExtension org.jboss.arquillian.extension.byteman.impl.BytemanRemoteExtension
Either way there could be some other issue easily.
-
7. Re: Using BYTEMAN in JUnit test with Arquillian
rachmato Apr 16, 2019 7:20 PM (in response to tommaso-borgato)I've got the same problem. I believe if you annotate the method with @RunAsClient it should cause the agent to be installed on the client side, but so far it hasn't worked for me. This method is used in one testcase in the testsuite for the extension and works. Still trying to get it working.
Posted my version of "constructive feedback" as an issue on the project: Byteman extension is incomplete · Issue #24 · arquillian/arquillian-extension-byteman · GitHub
UPDATE: Adding the annotation @RunAsClient *will* cause the Byteman agent to be installed in the test process; rules seem to execute fine as long as you are prepared to live with @BMRules and @BMRule.