public static IMetaStore openLocalPentahoMetaStore() throws MetaStoreException {
    return MetaStoreConst.openLocalPentahoMetaStore( true );
  }
@Test
  public void testOpenLocalPentahoMetaStore() throws Exception {
    MetaStoreConst.disableMetaStore = false;
    File tempDir = Files.createTempDir();
    String tempPath = tempDir.getAbsolutePath();
    System.setProperty( Const.PENTAHO_METASTORE_FOLDER, tempPath );
    String metaFolder = tempPath + File.separator + XmlUtil.META_FOLDER_NAME;

    // Create a metastore
    assertNotNull( MetaStoreConst.openLocalPentahoMetaStore() );
    assertTrue( ( new File( metaFolder ) ).exists() );

    // Check existing while disabling the metastore ( used for tests )
    MetaStoreConst.disableMetaStore = true;
    assertNull( MetaStoreConst.openLocalPentahoMetaStore() );

    // Check existing metastore
    MetaStoreConst.disableMetaStore = false;
    assertNotNull( MetaStoreConst.openLocalPentahoMetaStore( false ) );

    // Try to read a metastore that does not exist with allowCreate = false
    FileUtils.deleteDirectory( new File( metaFolder ) );
    assertNull( MetaStoreConst.openLocalPentahoMetaStore( false ) );
    assertFalse( ( new File( metaFolder ) ).exists() );
  }