protected void loadDatabaseOptionsFragment( String fragmentUri, DataHandler dataHandler ) throws XulException {

    XulComponent groupElement = document.getElementById( "database-options-box" );
    XulComponent parentElement = groupElement.getParent();

    XulDomContainer fragmentContainer;

    // Get new group box fragment ...
    // This will effectively set up the SWT parent child relationship...

    fragmentContainer = this.xulDomContainer.loadFragment( fragmentUri, Messages.getBundle() );
    XulComponent newGroup = fragmentContainer.getDocumentRoot().getFirstChild();

    parentElement.replaceChild( groupElement, newGroup );

    // merge event handlers so scripts defined in a fragment can be used
    this.xulDomContainer.mergeContainer( fragmentContainer );

    if ( dataHandler != null ) {
      dataHandler.clearExtraHandler();
      // a fragment handler will complement DataHandler with fragment-specific data handler
      Optional.ofNullable( newGroup.getAttributeValue( "handler" ) ).ifPresent( handlerCall -> {
        try {
          DbInfoHandler handler = (DbInfoHandler) this.xulDomContainer.invoke( handlerCall, new Object[0] );
          log.debug( "Using fragment handler {}", handler.getClass() );
          dataHandler.setExtraHandler( handler );
        } catch ( Exception e ) {
          log.error( "Unable to call `handler` attribute", e );
        }
      } );
    }
  }
@Test( expected = XulException.class )
  public void testLoadDatabaseOptionsFragmentWithException() throws Exception {
    XulComponent component = mock( XulComponent.class );
    XulComponent parent = mock( XulComponent.class );
    when( component.getParent() ).thenReturn( parent );
    when( document.getElementById( "database-options-box" ) ).thenReturn( component );
    when( xulDomContainer.loadFragment( anyString(), any( Object.class ) ) ).thenThrow( new XulException() );
    fragmentHandler.loadDatabaseOptionsFragment( "", new DataHandler() );
  }