/** * Instancie un controleur secondaire pour la fenetre de consultation du mot à consulter * * @return */ private Stage loadConsultation() { Stage stageConsultation = null; FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("../dictionnaire_mot.fxml")); VBox rootConsultation = null; try { rootConsultation = (VBox) fxmlLoader.load(); FXMLController_2 subController = (FXMLController_2) fxmlLoader.getController(); subController.setController(this); subController.setMotAConsulter(model.motSelectionne); subController.setImage(); subController.init(); Scene sceneConsultation = new Scene(rootConsultation); stageConsultation = new Stage(); stageConsultation.setScene(sceneConsultation); stageConsultation.setTitle("Consultation"); setConsultWindowCloseHandler(stageConsultation, subController); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return stageConsultation; }
@Test public void testControllerInjection() throws IOException { URL location = getClass().getResource("rt_20471.fxml"); ResourceBundle resources = ResourceBundle.getBundle("javafx.fxml.rt_20471"); FXMLLoader fxmlLoader = new FXMLLoader(location, resources); fxmlLoader.load(); RT_20471Controller controller = fxmlLoader.getController(); assertEquals(controller.getLocation(), location); assertEquals(controller.getResources(), resources); assertTrue(controller.isInitialized()); }