@Test
  public void testTwoDiskStores() {
    diskProps.setPersistBackup(true);
    diskProps.setRegionName("testTwoDiskStores");
    // create first instance in dir 0
    File[] myDirs = new File[1];
    myDirs[0] = dirs[0];
    diskProps.setDiskDirs(myDirs);

    LocalRegion lr = (LocalRegion) DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache,
        diskProps, Scope.LOCAL);
    lr.put("key1", "value1");
    close(lr);
    assertEquals(true, (new File(dirs[0], "BACKUPtestTwoDiskStores.if")).exists());
    assertEquals(true, (new File(dirs[0], "BACKUPtestTwoDiskStores_1.crf")).exists());
    assertEquals(true, (new File(dirs[0], "BACKUPtestTwoDiskStores_1.drf")).exists());

    // now create another instance in dir 1
    myDirs = new File[1];
    myDirs[0] = dirs[1];
    diskProps.setDiskDirs(myDirs);

    lr = (LocalRegion) DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps,
        Scope.LOCAL);
    lr.put("key2", "value2");
    close(lr);
    assertEquals(true, (new File(dirs[1], "BACKUPtestTwoDiskStores.if")).exists());
    assertEquals(true, (new File(dirs[1], "BACKUPtestTwoDiskStores_1.crf")).exists());
    assertEquals(true, (new File(dirs[1], "BACKUPtestTwoDiskStores_1.drf")).exists());

    // remove the second if file; we want to make sure that duplicate oplogs will
    // cause recovery to fail
    (new File(dirs[1], "BACKUPtestTwoDiskStores.if")).delete();

    // now try to recover from with both dirs added. This should fail
    myDirs = new File[2];
    myDirs[0] = dirs[0];
    myDirs[1] = dirs[1];
    diskProps.setDiskDirs(myDirs);
    try {
      lr = (LocalRegion) DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps,
          Scope.LOCAL);
      fail("expected DiskAccessException");
    } catch (org.apache.geode.cache.DiskAccessException expected) {
      if (!expected.getMessage().contains("two different directories")) {
        fail("did not expect: " + expected
            + ". It should have contained: \"two different directories\"");
      }
    }

    // now try to recover with just the wrong oplog files
    (new File(dirs[0], "BACKUPtestTwoDiskStores_1.crf")).delete();
    (new File(dirs[0], "BACKUPtestTwoDiskStores_1.drf")).delete();
    try {
      lr = (LocalRegion) DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps,
          Scope.LOCAL);
      fail("expected DiskAccessException");
    } catch (org.apache.geode.cache.DiskAccessException expected) {
      if (!expected.getMessage().contains("does not belong")) {
        fail("did not expect: " + expected + ". It should have contained: \"does not belong\"");
      }
    }
  }
Make sure that disk store oplog files from another instance of a disk store are not allowed
when loading the other disk store
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskIFJUnitTest.java