> If you want I can try to make a pull request with this (reusing code from
SingleApplicationComposerRunner) and some tests.

That would be great. I'd love to try it out.

Jon

On Wed, Dec 19, 2018 at 10:14 PM cocorossello <[email protected]>
wrote:

> Hi,
>
> Just in case somebody needs it I wrote Junit-jupiter extensions for
> ApplicationComposer and SingleApplicationComposer. They are very simple
> since all the work is already done, but they may save somebody's 10
> minutes.
>
> public class ApplicationComposerExtension implements BeforeEachCallback,
> AfterEachCallback {
>
>     private ApplicationComposers delegate;
>
>     @Override
>     public void beforeEach(ExtensionContext context) throws Exception {
>         delegate = new
> ApplicationComposers(context.getRequiredTestInstance());
>         delegate.before(context.getRequiredTestInstance());
>     }
>
>     @Override
>     public void afterEach(ExtensionContext context) throws Exception {
>         delegate.after();
>     }
>
> }
>
>
>
> public class SingleApplicationComposerExtension implements
> BeforeEachCallback {
>
>
>     private static volatile boolean started = false;
>     private static final AtomicReference APP = new AtomicReference<>();
>     private static final AtomicReference<Thread> HOOK = new
> AtomicReference<>();
>
>     @Override
>     public void beforeEach(ExtensionContext context) throws Exception {
>         start(context.getRequiredTestInstance().getClass());
>         composerInject(context.getRequiredTestInstance());
>     }
>
>
>     public static void setApp(final Object o) {
>         APP.set(o);
>     }
>
>
>     public static void close() {
>         //Same as in SingleApplicationComposerRunner
>         ...
>     }
>
>
>     private static void start(final Class<?> marker) throws Exception {
>         //Same as in SingleApplicationComposerRunner
>         ...
>     }
>
>     private static void composerInject(final Object target) throws
> IllegalAccessException {
>         //Same as in SingleApplicationComposerRunner
>         ...
>     }
>
>
> }
>
> Of course, I may not have taken into account all possibilities (it does
> work
> in my project, that's all), so feel free to criticize or implement it some
> other way.
>
> If you want I can try to make a pull request with this (reusing code from
> SingleApplicationComposerRunner) and some tests.
>
>
> Best regards,
> Vicente.
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>

Reply via email to