DataServiceDialog { protected DataServiceDialog loadXul( Shell shell, XulLoader xulLoader, XulRunner runner ) throws XulException { xulLoader.setOuterContext( shell ); xulLoader.registerClassLoader( DataServiceDialog.class.getClassLoader() ); XulDomContainer container = xulLoader.loadXul( XUL_DIALOG_PATH, createResourceBundle( PKG ) ); container.addEventHandler( controller ); runner.addContainer( container ); runner.initialize(); return this; } DataServiceDialog( DataServiceDialogController controller, DataServiceModel model ); XulDomContainer getXulDomContainer(); XulDomContainer applyOverlay( OptimizationOverlay overlay, String xulSource ); void open(); void close(); DataServiceDialogController getController(); DataServiceModel getModel();  }
@Test public void testLoadXul() throws Exception { Shell shell = mock( Shell.class ); XulLoader xulLoader = mock( XulLoader.class ); XulRunner xulRunner = mock( XulRunner.class ); XulDomContainer xulDomContainer = mock( XulDomContainer.class ); final ResourceBundle resourceBundle = mock( ResourceBundle.class ); DataServiceDialog dialog = new DataServiceDialog( controller, model ) { @Override protected ResourceBundle createResourceBundle( Class<?> packageClass ) { assertThat( packageClass, equalTo( (Class) DataServiceDialog.class ) ); assertThat( super.createResourceBundle( packageClass ), isA( ResourceBundle.class ) ); return resourceBundle; } }; when( xulLoader.loadXul( anyString(), same( resourceBundle ) ) ).thenReturn( xulDomContainer ); dialog.loadXul( shell, xulLoader, xulRunner ); verify( xulLoader ).setOuterContext( shell ); verify( xulLoader ).registerClassLoader( any( ClassLoader.class ) ); verify( xulDomContainer ).addEventHandler( controller ); verify( xulRunner ).addContainer( xulDomContainer ); verify( xulRunner ).initialize(); }