Ejemplo n.º 1
0
 public static StateStore.Factory deserialize(Element store) throws XMLParseException {
   String type = store.getAttribute("type");
   if (type.compareToIgnoreCase("hash") == 0) {
     return HashTableStore.Factory.deserialize(store);
   } else if (type.compareToIgnoreCase("bdb") == 0) {
     try {
       return BerkeleyDBStore.Factory.deserialize(store);
     } catch (DatabaseException e) {
       throw new XMLParseException(e.getMessage(), e.getCause());
     }
   }
   throw new XMLParseException("Unrecognized state store type \'" + type + "\'", store);
 }
  /**
   * Tests that an exception is thrown when a log header is read with a newer version than the
   * current version. The maxversion.jdb log file is loaded as a resource by this test and written
   * as a regular log file. When the environment is opened, we expect a LogException.
   */
  public void testGreaterVersionNotAllowed() throws DatabaseException, IOException {

    TestUtils.loadLog(getClass(), Utils.MAX_VERSION_NAME, envHome);

    EnvironmentConfig envConfig = TestUtils.initEnvConfig();
    envConfig.setAllowCreate(false);
    envConfig.setTransactional(true);

    try {
      Environment env = new Environment(envHome, envConfig);
      try {
        env.close();
      } catch (Exception ignore) {
      }
    } catch (DatabaseException e) {
      if (e.getCause() instanceof LogException) {
        /* Got LogException as expected. */
        return;
      }
    }
    fail("Expected LogException");
  }