private SecondaryDatabase openSecondaryDb(
      TupleSerialFactory factory,
      String keyName,
      Database primary,
      String file,
      Database foreignStore)
      throws Exception {

    TupleSerialMarshalledKeyCreator keyCreator =
        factory.getKeyCreator(MarshalledObject.class, keyName);

    SecondaryConfig secConfig = new SecondaryConfig();
    DbCompat.setTypeBtree(secConfig);
    secConfig.setTransactional(testEnv.isTxnMode());
    secConfig.setAllowCreate(true);
    secConfig.setKeyCreator(keyCreator);
    if (foreignStore != null) {
      secConfig.setForeignKeyDatabase(foreignStore);
      secConfig.setForeignKeyDeleteAction(onDelete);
      if (onDelete == ForeignKeyDeleteAction.NULLIFY) {
        secConfig.setForeignKeyNullifier(keyCreator);
      }
    }

    return DbCompat.testOpenSecondaryDatabase(env, null, file, null, primary, secConfig);
  }
  private void createDatabase() throws Exception {

    catalog = new StoredClassCatalog(openDb("catalog.db"));
    factory = new TupleSerialFactory(catalog);
    assertSame(catalog, factory.getCatalog());

    store1 = openDb("store1.db");
    store2 = openDb("store2.db");
    index1 = openSecondaryDb(factory, "1", store1, "index1.db", null);
    index2 = openSecondaryDb(factory, "2", store2, "index2.db", store1);
  }
 private void createViews() {
   storeMap1 = factory.newMap(store1, String.class, MarshalledObject.class, true);
   storeMap2 = factory.newMap(store2, String.class, MarshalledObject.class, true);
   indexMap1 = factory.newMap(index1, String.class, MarshalledObject.class, true);
   indexMap2 = factory.newMap(index2, String.class, MarshalledObject.class, true);
 }