@Test
  public void testDiskRegRecovery() {
    /**
     * STEP 1
     */
    diskProps.setPersistBackup(true);
    diskProps.setRegionName("RecoveryTestRegion");
    region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
    verifyOplogSizeZeroAfterRecovery(region);
    final byte[] value = new byte[ENTRY_SIZE];
    Arrays.fill(value, (byte) 77);
    for (int i = 0; i < 100; i++) {
      region.put(i, value);
    }
    // for recovery test:
    try {
      region.put("100", new byte[1024]);
      region.put("101", "101");
      region.put("102", 'a');
      region.put("103", new Byte("103"));
      region.put("104", Boolean.TRUE);
      region.put("105", new Short("105"));
      region.put("106", 106);
      region.put("107", 107L);
      region.put("108", 108F);
      region.put("109", 109d);
    } catch (Exception ex) {
      ex.printStackTrace();
      fail("FAILED WHILE PUT:" + ex);
    }
    // Verifying the get operation:
    getByteArrVal("100", region);
    assertEquals("101", region.get("101"));
    assertEquals('a', region.get("102"));
    assertEquals(new Byte("103"), region.get("103"));
    assertEquals(Boolean.TRUE, region.get("104"));
    assertEquals(new Short("105"), region.get("105"));
    assertEquals(106, region.get("106"));
    assertEquals(107L, region.get("107"));
    assertEquals(108F, region.get("108"));
    assertEquals(109d, region.get("109"));
    int origSize = region.size();
    /**
     * close the cache after that create it again and then put few more values
     */
    if (cache != null) {
      cache.close();
    }

    /**
     * STEP 2: create the cache and region with the same name
     */
    try {
      try {
        cache = createCache();
      } catch (Exception e) {
        fail(" failure in creation of cache due to " + e);
      }
      // Create region
      diskProps.setPersistBackup(true);
      diskProps.setRegionName("RecoveryTestRegion");
      region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
      assertEquals(origSize, region.size());
      // Verifying the get operation:
      getByteArrVal("100", region);
      assertEquals("101", region.get("101"));
      assertEquals('a', region.get("102"));
      assertEquals(new Byte("103"), region.get("103"));
      assertEquals(Boolean.TRUE, region.get("104"));
      assertEquals(new Short("105"), region.get("105"));
      assertEquals(106, region.get("106"));
      assertEquals(107L, region.get("107"));
      assertEquals(108F, region.get("108"));
      assertEquals(109d, region.get("109"));
      // put few more entries
      region.put("110", "110");
      region.put("111", 'b');
      region.put("112", new Byte("112"));
      region.put("113", Boolean.FALSE);
      region.put("114", new Short("114"));
      region.put("115", 115);
      region.put("116", 116L);
      region.put("117", 117F);
      region.put("118", 118d);
      region.put("119", new byte[0]);
    } catch (Exception e) {
      logWriter.error("exception not expected", e);
      fail("failed while (in STEP 2) creating the cache and/or region" + e);
    }
    // Verifying the get operation:
    getByteArrVal("100", region);
    assertTrue(region.get("101").equals("101"));
    assertTrue(region.get("102").equals('a'));
    assertTrue(region.get("103").equals(new Byte("103")));
    assertTrue(region.get("104").equals(Boolean.TRUE));
    assertTrue(region.get("105").equals(new Short("105")));
    assertTrue(region.get("106").equals(106));
    assertTrue(region.get("107").equals(107L));
    assertTrue(region.get("108").equals(108F));
    assertTrue(region.get("109").equals(109d));
    assertTrue(region.get("110").equals("110"));
    assertTrue(region.get("111").equals('b'));
    assertTrue(region.get("112").equals(new Byte("112")));
    assertTrue(region.get("113").equals(Boolean.FALSE));
    assertTrue(region.get("114").equals(new Short("114")));
    assertTrue(region.get("115").equals(115));
    assertTrue(region.get("116").equals(116L));
    assertTrue(region.get("117").equals(117F));
    assertTrue(region.get("118").equals(118d));
    getByteArrValZeroLnth("119", region);
    /**
     * close the cache after that create it again
     */
    if (cache != null) {
      cache.close();
      if (logWriter.fineEnabled()) {
        logWriter.fine("Cache closed");
      }
    }

    /**
     * STEP 3: Create the cache and region And close the cache
     */
    try {
      try {
        cache = createCache();
      } catch (Exception e) {
        fail(" failure in creation of cache due to " + e);
      }
      if (logWriter.fineEnabled()) {
        logWriter.fine("Cache created to test the recovery..");
      }
      // Create region
      diskProps.setPersistBackup(true);
      diskProps.setRegionName("RecoveryTestRegion");
      region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
    } catch (Exception e) {
      e.printStackTrace();
      fail("failed while (in STEP 3) creating the cache and/or region" + e);
    }
    // Verifying the get operation:
    getByteArrVal("100", region);
    assertTrue(region.get("101").equals("101"));
    assertTrue(region.get("102").equals('a'));
    assertTrue(region.get("103").equals(new Byte("103")));
    assertTrue(region.get("104").equals(Boolean.TRUE));
    assertTrue(region.get("105").equals(new Short("105")));
    assertTrue(region.get("106").equals(106));
    assertTrue(region.get("107").equals(107L));
    assertTrue(region.get("108").equals(108F));
    assertTrue(region.get("109").equals(109d));
    assertTrue(region.get("110").equals("110"));
    assertTrue(region.get("111").equals('b'));
    assertTrue(region.get("112").equals(new Byte("112")));
    assertTrue(region.get("113").equals(Boolean.FALSE));
    assertTrue(region.get("114").equals(new Short("114")));
    assertTrue(region.get("115").equals(115));
    assertTrue(region.get("116").equals(116L));
    assertTrue(region.get("117").equals(117F));
    assertTrue(region.get("118").equals(118d));
    getByteArrValZeroLnth("119", region);
    /**
     * close the cache after that create it again
     */
    if (cache != null) {
      cache.close();
      if (logWriter.fineEnabled()) {
        logWriter.fine("Cache closed");
      }
    }

    /**
     * STEP 4: Create the cache and region verify disk reg recovery And close the cache
     */
    try {
      try {
        cache = createCache();
      } catch (Exception e) {
        fail(" failure in creation of cache due to " + e);
      }
      if (logWriter.fineEnabled()) {
        logWriter.fine("Cache created to test the recovery..");
      }
      // Create region
      diskProps.setPersistBackup(true);
      diskProps.setRegionName("RecoveryTestRegion");
      region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, diskProps, Scope.LOCAL);
    } catch (Exception e) {
      e.printStackTrace();
      fail("failed while (in STEP 4) creating the cache and/or region" + e);
    }
    // Get all the test values, put in STEP 1 & 2:
    // Verifying the get operation:
    getByteArrVal("100", region);
    assertTrue(region.get("101").equals("101"));
    assertTrue(region.get("102").equals('a'));
    assertTrue(region.get("103").equals(new Byte("103")));
    assertTrue(region.get("104").equals(Boolean.TRUE));
    assertTrue(region.get("105").equals(new Short("105")));
    assertTrue(region.get("106").equals(106));
    assertTrue(region.get("107").equals(107L));
    assertTrue(region.get("108").equals(108F));
    assertTrue(region.get("109").equals(109d));
    assertTrue(region.get("110").equals("110"));
    assertTrue(region.get("111").equals('b'));
    assertTrue(region.get("112").equals(new Byte("112")));
    assertTrue(region.get("113").equals(Boolean.FALSE));
    assertTrue(region.get("114").equals(new Short("114")));
    assertTrue(region.get("115").equals(115));
    assertTrue(region.get("116").equals(116L));
    assertTrue(region.get("117").equals(117F));
    assertTrue(region.get("118").equals(118d));
    getByteArrValZeroLnth("119", region);

    closeDown(); // closes disk file which will flush all buffers
  }
Disk region recovery test for Persist only with sync writes. Test has four steps : STEP 1:
Create cache. Create Region. Put entries. Close cache. STEP 2: Create cache. Create Region with
the same name as that of in STEP 1. Put few more entries. Get and verify the entries put in
STEP 1 and STEP 2 STEP 3: Again Create cache. Create Region with the same name as that of in
STEP 1. Get and verify the entries put in STEP 1 and STEP 2. STEP 4: Create cache. Create
Region with the same name as that of in STEP 1. Get and verify the entries put in STEP 1 and
STEP 2.
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegRecoveryJUnitTest.java