public static final DatabaseMeta findDatabase( List<? extends SharedObjectInterface> databases, String dbname ) {
    if ( databases == null || dbname == null ) {
      return null;
    }

    for ( int i = 0; i < databases.size(); i++ ) {
      DatabaseMeta ci = (DatabaseMeta) databases.get( i );
      if ( ci.getName().trim().equalsIgnoreCase( dbname.trim() ) ) {
        return ci;
      }
    }
    return null;
  }
@Test
  public void testfindDatabase() throws KettleDatabaseException {
    List<DatabaseMeta> databases = new ArrayList<DatabaseMeta>();
    databases.add( new DatabaseMeta( "  1", "Infobright", "JDBC", null, "stub:stub", null, null, null ) );
    databases.add( new DatabaseMeta( "  1  ", "Infobright", "JDBC", null, "stub:stub", null, null, null ) );
    databases.add( new DatabaseMeta( "1  ", "Infobright", "JDBC", null, "stub:stub", null, null, null ) );
    Assert.assertNotNull( DatabaseMeta.findDatabase( databases, "1" ) );
    Assert.assertNotNull( DatabaseMeta.findDatabase( databases, "1 " ) );
    Assert.assertNotNull( DatabaseMeta.findDatabase( databases, " 1" ) );
    Assert.assertNotNull( DatabaseMeta.findDatabase( databases, " 1 " ) );
  }