/**
   * Returns true if the store was opened successfully. Returns false if the store could not be
   * opened because an exception was expected -- this is not a test failure but no further tests for
   * an EntityStore may be run.
   */
  private boolean openStore(StoreConfig config) throws Exception {

    config.setTransactional(true);
    config.setMutations(caseObj.getMutations());

    EntityModel model = new AnnotationModel();
    config.setModel(model);
    caseObj.configure(model, config);

    String expectException = caseObj.getStoreOpenException();
    try {
      store = new EntityStore(env, EvolveCase.STORE_NAME, config);
      if (expectException != null) {
        fail("Expected: " + expectException);
      }
    } catch (Exception e) {
      if (expectException != null) {
        String actualMsg = e.getMessage();
        if (e instanceof IncompatibleClassException) {
          actualMsg = actualMsg.substring(0, actualMsg.lastIndexOf("\n---\n(Note that"));
        }
        actualMsg = e.getClass().getName() + ": " + actualMsg;
        if (!expectException.equals(actualMsg)) {
          e.printStackTrace();
        }
        EvolveCase.checkEquals(expectException, actualMsg);
        return false;
      } else {
        throw e;
      }
    }
    return true;
  }
  void openNewStore() throws Exception {

    StoreConfig config = new StoreConfig();
    config.setAllowCreate(true);
    config.setTransactional(true);

    EntityModel model = new AnnotationModel();
    config.setModel(model);
    caseObj.configure(model, config);

    newStore = new EntityStore(env, "new", config);
  }
Esempio n. 3
0
  private void open(Class clsToRegister) throws DatabaseException {

    StoreConfig config = new StoreConfig();
    config.setAllowCreate(envConfig.getAllowCreate());
    if (clsToRegister != null) {
      com.sleepycat.persist.model.EntityModel model =
          new com.sleepycat.persist.model.AnnotationModel();
      model.registerClass(clsToRegister);
      config.setModel(model);
    }
    open(config);
  }