diff --git a/mvvmfx-cdi/src/main/java/de/saxsys/jfx/mvvm/cdi/internal/WeldStartupHelper.java b/mvvmfx-cdi/src/main/java/de/saxsys/jfx/mvvm/cdi/internal/WeldStartupHelper.java index bc3186c8f..1423c5baa 100644 --- a/mvvmfx-cdi/src/main/java/de/saxsys/jfx/mvvm/cdi/internal/WeldStartupHelper.java +++ b/mvvmfx-cdi/src/main/java/de/saxsys/jfx/mvvm/cdi/internal/WeldStartupHelper.java @@ -16,6 +16,7 @@ package de.saxsys.jfx.mvvm.cdi.internal; import javafx.application.Application; +import javafx.application.HostServices; import javafx.stage.Stage; import org.jboss.weld.environment.se.Weld; @@ -23,6 +24,8 @@ import de.saxsys.jfx.mvvm.api.MvvmFX; +import javax.enterprise.inject.Produces; + /** * The class is instantiated by the javafx framework. The purpose of this class is to startup the weld container and * setup the {@link de.saxsys.jfx.mvvm.cdi.internal.CdiInjector} for the mvvmFX framework. @@ -62,4 +65,9 @@ public void start(Stage stage) throws Exception { weldContainer.event().fire(new StartupEvent(stage, this.getParameters())); } + + @Produces + HostServices produceHostServices(){ + return getHostServices(); + } } diff --git a/mvvmfx-cdi/src/test/java/de/saxsys/jfx/mvvm/cdi/internal/CdiInjectorTest.java b/mvvmfx-cdi/src/test/java/de/saxsys/jfx/mvvm/cdi/internal/CdiInjectorTest.java index 27d155915..ebb7163b0 100644 --- a/mvvmfx-cdi/src/test/java/de/saxsys/jfx/mvvm/cdi/internal/CdiInjectorTest.java +++ b/mvvmfx-cdi/src/test/java/de/saxsys/jfx/mvvm/cdi/internal/CdiInjectorTest.java @@ -17,6 +17,7 @@ import javax.inject.Inject; +import javafx.application.HostServices; import org.jboss.weld.environment.se.Weld; import org.jboss.weld.environment.se.WeldContainer; import org.junit.Assert; @@ -25,6 +26,8 @@ import de.saxsys.jfx.mvvm.notifications.NotificationCenter; import de.saxsys.jfx.mvvm.viewloader.ViewLoader; +import static org.assertj.core.api.Assertions.assertThat; + /** * This test verifies that a simple application can be started with the CDI/Weld extension. When there is a problem with * the cdi configuration, f.e. ambiguous dependencies for an internal class of mvvmfx, this kind of bug should be found @@ -38,6 +41,9 @@ static class Example { @Inject ViewLoader viewLoader; + + @Inject + HostServices hostServices; } /** @@ -52,14 +58,12 @@ public void testCdiInjector() { CdiInjector cdiInjector = weldContainer.instance().select(CdiInjector.class).get(); Object exampleObject = cdiInjector.call(Example.class); - Assert.assertNotNull(exampleObject); - - Assert.assertTrue(exampleObject instanceof Example); + assertThat(exampleObject).isNotNull().isInstanceOf(Example.class); Example example = (Example) exampleObject; - - Assert.assertNotNull(example.notificationCenter); - Assert.assertNotNull(example.viewLoader); - + + assertThat(example.notificationCenter).isNotNull(); + assertThat(example.viewLoader).isNotNull(); + assertThat(example.hostServices).isNotNull(); } }