geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [1/4] geode git commit: Fix test failures
Date Tue, 02 May 2017 23:31:26 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2632-10 4fb63aa28 -> 0362f358a


http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-core/src/test/java/org/apache/geode/cache30/CacheXml80DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/CacheXml80DUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache30/CacheXml80DUnitTest.java
index 1ac64fa..08b4716 100644
--- a/geode-core/src/test/java/org/apache/geode/cache30/CacheXml80DUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache30/CacheXml80DUnitTest.java
@@ -12,28 +12,23 @@
  * or implied. See the License for the specific language governing permissions and limitations
under
  * the License.
  */
-
-/**
- * 
- */
 package org.apache.geode.cache30;
 
 import static org.junit.Assert.*;
 
 import java.io.File;
 import java.io.FileWriter;
-import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheException;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.Scope;
@@ -50,23 +45,19 @@ import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
 import org.apache.geode.internal.cache.xmlcache.DiskStoreAttributesCreation;
 import org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation;
-import org.apache.geode.test.dunit.Assert;
 import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
 
-  public CacheXml80DUnitTest() {
-    super();
-  }
-
+  @Override
   protected String getGemFireVersion() {
     return CacheXml.VERSION_8_0;
   }
 
   @SuppressWarnings("rawtypes")
   @Test
-  public void testCompressor() {
+  public void testCompressor() throws Exception {
     final String regionName = "testCompressor";
 
     final CacheCreation cache = new CacheCreation();
@@ -86,7 +77,7 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
     regionAfter.localDestroyRegion();
   }
 
-  /*
+  /**
    * Tests xml creation for indexes First creates 3 indexes and makes sure the cache creates
all 3
    * Creates a 4th through the api and writes out the xml Restarts the cache with the new
xml Makes
    * sure the new cache has the 4 indexes
@@ -113,23 +104,20 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
     c.getQueryService().createIndex("crIndex2", "r.CR_ID_2", "/replicated r");
     c.getQueryService().createIndex("rIndex", "r.R_ID", "/replicated r, r.positions.values
rv");
 
-    File dir = new File("XML_" + this.getGemFireVersion());
+    File dir = new File(this.temporaryFolder.getRoot(), "XML_" + this.getGemFireVersion());
     dir.mkdirs();
-    File file = new File(dir, "actual-" + this.getUniqueName() + ".xml");
-    try {
-      PrintWriter pw = new PrintWriter(new FileWriter(file), true);
-      CacheXmlGenerator.generate(c, pw, this.getUseSchema(), this.getGemFireVersion());
-      pw.close();
-    } catch (IOException ex) {
-      Assert.fail("IOException during cache.xml generation to " + file, ex);
-    }
+    File file = new File(dir, "actual-" + getUniqueName() + ".xml");
+
+    PrintWriter pw = new PrintWriter(new FileWriter(file), true);
+    CacheXmlGenerator.generate(c, pw, getUseSchema(), getGemFireVersion());
+    pw.close();
 
     // Get index info before closing cache.
     indexes = qs.getIndexes();
 
     c.close();
     GemFireCacheImpl.testCacheXml = file;
-    assert (c.isClosed());
+    assertTrue(c.isClosed());
 
     c = getCache();
     qs = c.getQueryService();
@@ -184,7 +172,7 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
   }
 
   @Test
-  public void testCacheServerDisableTcpNoDelay() throws CacheException {
+  public void testCacheServerDisableTcpNoDelay() throws Exception {
     CacheCreation cache = new CacheCreation();
 
     CacheServer cs = cache.addCacheServer();
@@ -196,9 +184,8 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
     testXml(cache);
   }
 
-
   @Test
-  public void testCacheServerEnableTcpNoDelay() throws CacheException {
+  public void testCacheServerEnableTcpNoDelay() throws Exception {
     CacheCreation cache = new CacheCreation();
 
     CacheServer cs = cache.addCacheServer();
@@ -211,10 +198,9 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
   }
 
   @Test
-  public void testDiskUsage() {
+  public void testDiskUsage() throws Exception {
     CacheCreation cache = new CacheCreation();
 
-
     DiskStoreAttributesCreation disk = new DiskStoreAttributesCreation();
     disk.setDiskUsageWarningPercentage(97);
     disk.setDiskUsageCriticalPercentage(98);
@@ -233,30 +219,28 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
     return observer.isIndexesUsed && observer.indexName.equals(indexName);
   }
 
-  private class QueryObserverImpl extends QueryObserverAdapter {
+  private static class QueryObserverImpl extends QueryObserverAdapter {
 
     boolean isIndexesUsed = false;
 
-    ArrayList<String> indexesUsed = new ArrayList<String>();
+    List<String> indexesUsed = new ArrayList<String>();
 
     String indexName;
 
+    @Override
     public void beforeIndexLookup(Index index, int oper, Object key) {
       indexName = index.getName();
       indexesUsed.add(index.getName());
 
     }
 
+    @Override
     public void afterIndexLookup(Collection results) {
       if (results != null) {
         isIndexesUsed = true;
       }
     }
 
-    public int numIndexesUsed() {
-      return indexesUsed.size();
-    }
-
     public void reset() {
       indexName = null;
       isIndexesUsed = false;
@@ -264,7 +248,7 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
     }
   }
 
-  private class TestObject {
+  private static class TestObject {
     public int CR_ID;
     public int CR_ID_2;
     public int R_ID;
@@ -282,24 +266,8 @@ public class CacheXml80DUnitTest extends CacheXml70DUnitTest {
       positions.put(ID, "TEST_STRING");
     }
 
-    public int getCR_ID() {
-      return CR_ID;
-    }
-
-    public int getCR_ID_2() {
-      return CR_ID_2;
-    }
-
-    public int getR_ID() {
-      return R_ID;
-    }
-
     public int ID() {
       return ID;
     }
-
-    public int getHASH_ID() {
-      return HASH_ID;
-    }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-core/src/test/java/org/apache/geode/cache30/CacheXml81DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/CacheXml81DUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache30/CacheXml81DUnitTest.java
index aee196d..e6026e1 100644
--- a/geode-core/src/test/java/org/apache/geode/cache30/CacheXml81DUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache30/CacheXml81DUnitTest.java
@@ -37,33 +37,29 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 /**
  * Tests 8.1 schema based configuration. From this point all config test cases should extend
this
  * test case where {@link #getUseSchema()} will return true.
- * 
  *
  * @since GemFire 8.1
  */
 @Category(DistributedTest.class)
 public class CacheXml81DUnitTest extends CacheXml80DUnitTest {
-  private static final long serialVersionUID = 1L;
-
-  public CacheXml81DUnitTest() {
-    super();
-  }
 
+  @Override
   protected String getGemFireVersion() {
     return CacheXml.VERSION_8_1;
   }
 
+  @Override
   protected boolean getUseSchema() {
     return true;
   }
 
   /**
-   * Test extensions to <code>cache<code> element.
+   * Test extensions to <code>cache</code> element.
    * 
    * @since GemFire 8.1
    */
   @Test
-  public void testCacheExtension() {
+  public void testCacheExtension() throws Exception {
     final CacheCreation cache = new CacheCreation();
     final MockCacheExtension extension = new MockCacheExtension("testCacheExtension");
     cache.getExtensionPoint().addExtension(extension);
@@ -88,7 +84,6 @@ public class CacheXml81DUnitTest extends CacheXml80DUnitTest {
     assertEquals(1, m.beforeCreateCounter.get());
     assertEquals(1, m.onCreateCounter.get());
     assertEquals(0, m.getXmlGeneratorCounter.get());
-
   }
 
   /**
@@ -97,7 +92,7 @@ public class CacheXml81DUnitTest extends CacheXml80DUnitTest {
    * @since GemFire 8.1
    */
   @Test
-  public void testRegionExtension() {
+  public void testRegionExtension() throws Exception {
     final String regionName = "testRegionExtension";
     final CacheCreation cache = new CacheCreation();
     final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
@@ -128,7 +123,6 @@ public class CacheXml81DUnitTest extends CacheXml80DUnitTest {
     assertEquals(1, m.beforeCreateCounter.get());
     assertEquals(1, m.onCreateCounter.get());
     assertEquals(0, m.getXmlGeneratorCounter.get());
-
   }
 
   /**
@@ -138,7 +132,7 @@ public class CacheXml81DUnitTest extends CacheXml80DUnitTest {
    * @since GemFire 8.2
    */
   @Test
-  public void testLocatorInException() {
+  public void testLocatorInException() throws Exception {
     final String regionName = "testRegionExtension";
     final CacheCreation cache = new CacheCreation();
     final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
@@ -153,8 +147,8 @@ public class CacheXml81DUnitTest extends CacheXml80DUnitTest {
     assertEquals(0, extension.onCreateCounter.get());
     assertEquals(0, extension.getXmlGeneratorCounter.get());
 
-    IgnoredException expectedException =
-        IgnoredException.addIgnoredException("While reading Cache XML file");
+    IgnoredException.addIgnoredException("While reading Cache XML file");
+
     try {
       testXml(cache);
       fail("Excepted CacheXmlException");
@@ -164,8 +158,6 @@ public class CacheXml81DUnitTest extends CacheXml80DUnitTest {
         assertTrue(((SAXParseException) e.getCause()).getColumnNumber() > 0);
         assertEquals("Value is 'exception'.", e.getCause().getMessage());
       }
-    } finally {
-      expectedException.remove();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlGeode10DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlGeode10DUnitTest.java
b/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlGeode10DUnitTest.java
index ca2618b..4fc8ed8 100644
--- a/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlGeode10DUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlGeode10DUnitTest.java
@@ -12,10 +12,6 @@
  * or implied. See the License for the specific language governing permissions and limitations
under
  * the License.
  */
-
-/**
- * 
- */
 package org.apache.geode.cache30;
 
 import static org.apache.geode.distributed.ConfigurationProperties.*;
@@ -36,6 +32,7 @@ import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.internal.cache.RegionEntryContext;
 import org.apache.geode.internal.cache.xmlcache.CacheCreation;
 import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation;
@@ -44,57 +41,45 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.junit.categories.DistributedTest;
 
-
 @Category(DistributedTest.class)
 public class CacheXmlGeode10DUnitTest extends CacheXml81DUnitTest {
-  private static final long serialVersionUID = -6437436147079728413L;
-
-  public CacheXmlGeode10DUnitTest() {
-    super();
-  }
-
-
-  // ////// Helper methods
 
+  @Override
   protected String getGemFireVersion() {
     return CacheXml.VERSION_1_0;
   }
 
   @SuppressWarnings("rawtypes")
   @Test
-  public void testEnableOffHeapMemory() {
-    try {
-      System.setProperty(DistributionConfig.GEMFIRE_PREFIX + OFF_HEAP_MEMORY_SIZE, "1m");
+  public void testEnableOffHeapMemory() throws Exception {
+    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + OFF_HEAP_MEMORY_SIZE, "1m");
 
-      final String regionName = "testEnableOffHeapMemory";
+    final String regionName = "testEnableOffHeapMemory";
 
-      final CacheCreation cache = new CacheCreation();
-      final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
-      attrs.setOffHeap(true);
-      assertEquals(true, attrs.getOffHeap());
+    final CacheCreation cache = new CacheCreation();
+    final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
+    attrs.setOffHeap(true);
+    assertEquals(true, attrs.getOffHeap());
 
-      final Region regionBefore = cache.createRegion(regionName, attrs);
-      assertNotNull(regionBefore);
-      assertEquals(true, regionBefore.getAttributes().getOffHeap());
+    final Region regionBefore = cache.createRegion(regionName, attrs);
+    assertNotNull(regionBefore);
+    assertEquals(true, regionBefore.getAttributes().getOffHeap());
 
-      testXml(cache);
+    testXml(cache);
 
-      final Cache c = getCache();
-      assertNotNull(c);
+    final Cache c = getCache();
+    assertNotNull(c);
 
-      final Region regionAfter = c.getRegion(regionName);
-      assertNotNull(regionAfter);
-      assertEquals(true, regionAfter.getAttributes().getOffHeap());
-      assertEquals(true, ((LocalRegion) regionAfter).getOffHeap());
-      regionAfter.localDestroyRegion();
-    } finally {
-      System.clearProperty(DistributionConfig.GEMFIRE_PREFIX + OFF_HEAP_MEMORY_SIZE);
-    }
+    final Region regionAfter = c.getRegion(regionName);
+    assertNotNull(regionAfter);
+    assertEquals(true, regionAfter.getAttributes().getOffHeap());
+    assertEquals(true, ((RegionEntryContext) regionAfter).getOffHeap());
+    regionAfter.localDestroyRegion();
   }
 
   @SuppressWarnings("rawtypes")
   @Test
-  public void testEnableOffHeapMemoryRootRegionWithoutOffHeapMemoryThrowsException() {
+  public void testEnableOffHeapMemoryRootRegionWithoutOffHeapMemoryThrowsException() throws
Exception {
     final String regionName = getUniqueName();
 
     final CacheCreation cache = new CacheCreation();
@@ -106,25 +91,25 @@ public class CacheXmlGeode10DUnitTest extends CacheXml81DUnitTest {
     assertNotNull(regionBefore);
     assertEquals(true, regionBefore.getAttributes().getOffHeap());
 
-    IgnoredException expectedException = IgnoredException.addIgnoredException(
+    IgnoredException.addIgnoredException(
         LocalizedStrings.LocalRegion_THE_REGION_0_WAS_CONFIGURED_TO_USE_OFF_HEAP_MEMORY_BUT_OFF_HEAP_NOT_CONFIGURED
             .toLocalizedString("/" + regionName));
+
     try {
       testXml(cache);
+      fail("Expected IllegalStateException to be thrown");
     } catch (IllegalStateException e) {
       // expected
       String msg =
           LocalizedStrings.LocalRegion_THE_REGION_0_WAS_CONFIGURED_TO_USE_OFF_HEAP_MEMORY_BUT_OFF_HEAP_NOT_CONFIGURED
               .toLocalizedString("/" + regionName);
       assertEquals(msg, e.getMessage());
-    } finally {
-      expectedException.remove();
     }
   }
 
   @SuppressWarnings({"rawtypes", "deprecation", "unchecked"})
   @Test
-  public void testEnableOffHeapMemorySubRegionWithoutOffHeapMemoryThrowsException() {
+  public void testEnableOffHeapMemorySubRegionWithoutOffHeapMemoryThrowsException() throws
Exception {
     final String rootRegionName = getUniqueName();
     final String subRegionName = "subRegion";
 
@@ -144,27 +129,25 @@ public class CacheXmlGeode10DUnitTest extends CacheXml81DUnitTest {
     assertNotNull(subRegionBefore);
     assertEquals(true, subRegionBefore.getAttributes().getOffHeap());
 
-    IgnoredException expectedException = IgnoredException.addIgnoredException(
+    IgnoredException.addIgnoredException(
         LocalizedStrings.LocalRegion_THE_REGION_0_WAS_CONFIGURED_TO_USE_OFF_HEAP_MEMORY_BUT_OFF_HEAP_NOT_CONFIGURED
             .toLocalizedString("/" + rootRegionName + "/" + subRegionName));
+
     try {
       testXml(cache);
+      fail("Expected IllegalStateException to be thrown");
     } catch (IllegalStateException e) {
       // expected
       final String msg =
           LocalizedStrings.LocalRegion_THE_REGION_0_WAS_CONFIGURED_TO_USE_OFF_HEAP_MEMORY_BUT_OFF_HEAP_NOT_CONFIGURED
               .toLocalizedString("/" + rootRegionName + "/" + subRegionName);
       assertEquals(msg, e.getMessage());
-    } finally {
-      expectedException.remove();
     }
   }
 
   /**
    * Test the ResourceManager element's critical-off-heap-percentage and
    * eviction-off-heap-percentage attributes
-   * 
-   * @throws Exception
    */
   @Test
   public void testResourceManagerThresholds() throws Exception {
@@ -172,102 +155,96 @@ public class CacheXmlGeode10DUnitTest extends CacheXml81DUnitTest {
     final float low = 90.0f;
     final float high = 95.0f;
 
-    try {
-      System.setProperty(DistributionConfig.GEMFIRE_PREFIX + OFF_HEAP_MEMORY_SIZE, "1m");
-
-      Cache c;
-      ResourceManagerCreation rmc = new ResourceManagerCreation();
-      rmc.setEvictionOffHeapPercentage(low);
-      rmc.setCriticalOffHeapPercentage(high);
-      cache.setResourceManagerCreation(rmc);
-      testXml(cache);
-      {
-        c = getCache();
-        assertEquals(low, c.getResourceManager().getEvictionOffHeapPercentage(), 0);
-        assertEquals(high, c.getResourceManager().getCriticalOffHeapPercentage(), 0);
-      }
-      closeCache();
+    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + OFF_HEAP_MEMORY_SIZE, "1m");
 
-      rmc = new ResourceManagerCreation();
-      // Set them to similar values
-      rmc.setEvictionOffHeapPercentage(low);
-      rmc.setCriticalOffHeapPercentage(low + 1);
-      cache.setResourceManagerCreation(rmc);
-      testXml(cache);
-      {
-        c = getCache();
-        assertEquals(low, c.getResourceManager().getEvictionOffHeapPercentage(), 0);
-        assertEquals(low + 1, c.getResourceManager().getCriticalOffHeapPercentage(), 0);
-      }
-      closeCache();
+    Cache c;
+    ResourceManagerCreation rmc = new ResourceManagerCreation();
+    rmc.setEvictionOffHeapPercentage(low);
+    rmc.setCriticalOffHeapPercentage(high);
+    cache.setResourceManagerCreation(rmc);
+    testXml(cache);
+    {
+      c = getCache();
+      assertEquals(low, c.getResourceManager().getEvictionOffHeapPercentage(), 0);
+      assertEquals(high, c.getResourceManager().getCriticalOffHeapPercentage(), 0);
+    }
+    closeCache();
 
-      rmc = new ResourceManagerCreation();
-      rmc.setEvictionOffHeapPercentage(high);
-      rmc.setCriticalOffHeapPercentage(low);
-      cache.setResourceManagerCreation(rmc);
-      IgnoredException expectedException = IgnoredException.addIgnoredException(
-          LocalizedStrings.MemoryMonitor_EVICTION_PERCENTAGE_LTE_CRITICAL_PERCENTAGE
-              .toLocalizedString());
-      try {
-        testXml(cache);
-        assertTrue(false);
-      } catch (IllegalArgumentException expected) {
-      } finally {
-        expectedException.remove();
-        closeCache();
-      }
-
-      // Disable eviction
-      rmc = new ResourceManagerCreation();
-      rmc.setEvictionOffHeapPercentage(0);
-      rmc.setCriticalOffHeapPercentage(low);
-      cache.setResourceManagerCreation(rmc);
-      testXml(cache);
-      {
-        c = getCache();
-        assertEquals(0f, c.getResourceManager().getEvictionOffHeapPercentage(), 0);
-        assertEquals(low, c.getResourceManager().getCriticalOffHeapPercentage(), 0);
-      }
-      closeCache();
+    rmc = new ResourceManagerCreation();
+    // Set them to similar values
+    rmc.setEvictionOffHeapPercentage(low);
+    rmc.setCriticalOffHeapPercentage(low + 1);
+    cache.setResourceManagerCreation(rmc);
+    testXml(cache);
+    {
+      c = getCache();
+      assertEquals(low, c.getResourceManager().getEvictionOffHeapPercentage(), 0);
+      assertEquals(low + 1, c.getResourceManager().getCriticalOffHeapPercentage(), 0);
+    }
+    closeCache();
 
-      // Disable refusing ops in "red zone"
-      rmc = new ResourceManagerCreation();
-      rmc.setEvictionOffHeapPercentage(low);
-      rmc.setCriticalOffHeapPercentage(0);
-      cache.setResourceManagerCreation(rmc);
+    rmc = new ResourceManagerCreation();
+    rmc.setEvictionOffHeapPercentage(high);
+    rmc.setCriticalOffHeapPercentage(low);
+    cache.setResourceManagerCreation(rmc);
+    IgnoredException expectedException = IgnoredException.addIgnoredException(
+        LocalizedStrings.MemoryMonitor_EVICTION_PERCENTAGE_LTE_CRITICAL_PERCENTAGE
+            .toLocalizedString());
+    try {
       testXml(cache);
-      {
-        c = getCache();
-        assertEquals(low, c.getResourceManager().getEvictionOffHeapPercentage(), 0);
-        assertEquals(0f, c.getResourceManager().getCriticalOffHeapPercentage(), 0);
-      }
+      fail("Expected IllegalArgumentException to be thrown");
+    } catch (IllegalArgumentException expected) {
+    } finally {
+      expectedException.remove();
       closeCache();
+    }
 
-      // Disable both
-      rmc = new ResourceManagerCreation();
-      rmc.setEvictionOffHeapPercentage(0);
-      rmc.setCriticalOffHeapPercentage(0);
-      cache.setResourceManagerCreation(rmc);
-      testXml(cache);
+    // Disable eviction
+    rmc = new ResourceManagerCreation();
+    rmc.setEvictionOffHeapPercentage(0);
+    rmc.setCriticalOffHeapPercentage(low);
+    cache.setResourceManagerCreation(rmc);
+    testXml(cache);
+    {
       c = getCache();
       assertEquals(0f, c.getResourceManager().getEvictionOffHeapPercentage(), 0);
+      assertEquals(low, c.getResourceManager().getCriticalOffHeapPercentage(), 0);
+    }
+    closeCache();
+
+    // Disable refusing ops in "red zone"
+    rmc = new ResourceManagerCreation();
+    rmc.setEvictionOffHeapPercentage(low);
+    rmc.setCriticalOffHeapPercentage(0);
+    cache.setResourceManagerCreation(rmc);
+    testXml(cache);
+    {
+      c = getCache();
+      assertEquals(low, c.getResourceManager().getEvictionOffHeapPercentage(), 0);
       assertEquals(0f, c.getResourceManager().getCriticalOffHeapPercentage(), 0);
-    } finally {
-      System.clearProperty(DistributionConfig.GEMFIRE_PREFIX + OFF_HEAP_MEMORY_SIZE);
     }
+    closeCache();
+
+    // Disable both
+    rmc = new ResourceManagerCreation();
+    rmc.setEvictionOffHeapPercentage(0);
+    rmc.setCriticalOffHeapPercentage(0);
+    cache.setResourceManagerCreation(rmc);
+    testXml(cache);
+    c = getCache();
+    assertEquals(0f, c.getResourceManager().getEvictionOffHeapPercentage(), 0);
+    assertEquals(0f, c.getResourceManager().getCriticalOffHeapPercentage(), 0);
   }
 
   @SuppressWarnings("rawtypes")
   @Test
-  public void testAsyncEventQueueIsForwardExpirationDestroyAttribute() {
-
-    final String regionName = "testAsyncEventQueueIsEnableEvictionAndExpirationAttribute";
+  public void testAsyncEventQueueIsForwardExpirationDestroyAttribute() throws Exception {
+    final String regionName = this.testName.getMethodName();
 
     // Create AsyncEventQueue with Listener
     final CacheCreation cache = new CacheCreation();
     AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
 
-
     AsyncEventListener listener = new MyAsyncEventListenerGeode10();
 
     // Test for default forwardExpirationDestroy attribute value (which is false)
@@ -315,12 +292,15 @@ public class CacheXmlGeode10DUnitTest extends CacheXml81DUnitTest {
 
   public static class MyAsyncEventListenerGeode10 implements AsyncEventListener, Declarable
{
 
+    @Override
     public boolean processEvents(List<AsyncEvent> events) {
       return true;
     }
 
+    @Override
     public void close() {}
 
+    @Override
     public void init(Properties properties) {}
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlTestCase.java b/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlTestCase.java
index 938c56d..43fc98f 100644
--- a/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlTestCase.java
@@ -14,23 +14,31 @@
  */
 package org.apache.geode.cache30;
 
+import static org.apache.geode.test.dunit.Assert.*;
 import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.*;
 
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.net.URL;
 import java.util.Properties;
 
+import org.apache.commons.io.FileUtils;
+import org.junit.Rule;
+
 import org.apache.geode.cache.Cache;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.extension.Extension;
 import org.apache.geode.internal.cache.xmlcache.CacheCreation;
 import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
 import org.apache.geode.internal.cache.xmlcache.ClientCacheCreation;
-import org.apache.geode.test.dunit.Assert;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
+import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
+import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
 import org.apache.geode.util.test.TestUtil;
 
 public class CacheXmlTestCase extends JUnit4CacheTestCase {
@@ -41,6 +49,15 @@ public class CacheXmlTestCase extends JUnit4CacheTestCase {
   /** set this to false if a test needs a non-loner distributed system */
   static boolean lonerDistributedSystem = true;
 
+  @Rule
+  public DistributedRestoreSystemProperties restoreSystemProperties = new DistributedRestoreSystemProperties();
+
+  @Rule
+  public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+
+  @Rule
+  public SerializableTestName testName = new SerializableTestName();
+
   @Override
   public final void postSetUp() throws Exception {
     disconnectAllFromDS();
@@ -49,6 +66,7 @@ public class CacheXmlTestCase extends JUnit4CacheTestCase {
   @Override
   public final void preTearDownCacheTestCase() throws Exception {
     this.xmlFile = null;
+    GemFireCacheImpl.testCacheXml = null;
   }
 
   @Override
@@ -79,11 +97,20 @@ public class CacheXmlTestCase extends JUnit4CacheTestCase {
   /**
    * Finds an XML file with the given name. Looks in $JTESTS.
    */
-  protected File findFile(String fileName) {
-    String path = TestUtil.getResourcePath(getClass(), fileName);
-    return new File(path);
+  protected File findFile(String fileName) throws IOException {
+    return copyResourceToDirectory(this.temporaryFolder.getRoot(), fileName);
+//    String path = TestUtil.getResourcePath(getClass(), fileName);
+//    return new File(path);
+  }
+
+  protected File copyResourceToDirectory(File directory, String fileName) throws IOException
{
+    URL url = getClass().getResource(fileName);
+    File file = new File(directory, fileName);
+    FileUtils.copyURLToFile(url, file);
+    return file;
   }
 
+  @Override
   public Properties getDistributedSystemProperties() {
     Properties props = super.getDistributedSystemProperties();
     if (this.xmlFile != null) {
@@ -104,27 +131,22 @@ public class CacheXmlTestCase extends JUnit4CacheTestCase {
    * {@link CacheCreation}. It then creates a {@link Cache} from the XML and asserts that
it is the
    * same as the cache described in the <code>CacheCreation</code>.
    */
-  protected void testXml(CacheCreation creation) {
+  protected void testXml(CacheCreation creation) throws IOException {
     testXml(creation, true);
   }
 
-  protected void testXml(CacheCreation creation, boolean checkSame) {
-
-    File dir = new File("XML_" + this.getGemFireVersion());
+  protected void testXml(CacheCreation creation, boolean checkSame) throws IOException {
+    File root = this.temporaryFolder.getRoot();
+    File dir = new File(root, "XML_" + getGemFireVersion());
     dir.mkdirs();
-    File file = new File(dir, this.getUniqueName() + ".xml");
+    File file = new File(dir, getUniqueName() + ".xml");
 
     final boolean useSchema = getUseSchema();
     final String version = getGemFireVersion();
-    try {
-      PrintWriter pw = new PrintWriter(new FileWriter(file), true);
-      CacheXmlGenerator.generate(creation, pw, useSchema, version);
-      pw.close();
 
-    } catch (IOException ex) {
-      String s = "While generating XML";
-      Assert.fail(s, ex);
-    }
+    PrintWriter pw = new PrintWriter(new FileWriter(file), true);
+    CacheXmlGenerator.generate(creation, pw, useSchema, version);
+    pw.close();
 
     setXmlFile(file);
 
@@ -142,7 +164,7 @@ public class CacheXmlTestCase extends JUnit4CacheTestCase {
       StringWriter sw = new StringWriter();
       CacheXmlGenerator.generate(creation, new PrintWriter(sw, true), useSchema, version);
       CacheXmlGenerator.generate(cache, new PrintWriter(sw, true), useSchema, version);
-      Assert.fail(sw.toString(), re);
+      fail(sw.toString(), re);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-core/src/test/java/org/apache/geode/internal/cache/execute/Bug51193DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/Bug51193DUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/Bug51193DUnitTest.java
index 12b467c..0dfbe6c 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/Bug51193DUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/Bug51193DUnitTest.java
@@ -56,7 +56,6 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 @SuppressWarnings("serial")
 public class Bug51193DUnitTest extends JUnit4DistributedTestCase {
 
-
   private static final String REGION_NAME = "Bug51193DUnitTest_region";
 
   private static GemFireCacheImpl cache;

http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java
index 8748df6..3706e1c 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentColocatedPartitionedRegionDUnitTest.java
@@ -1492,7 +1492,6 @@ public class PersistentColocatedPartitionedRegionDUnitTest
     Set<Integer> vm2PrimaryBuckets = getPrimaryBucketList(vm2, PR_REGION_NAME);
     assertEquals(vm2PrimaryBuckets, getPrimaryBucketList(vm2, "region2"));
 
-
     closeCache(vm2);
     // Make sure the other members notice that vm2 has gone
     // TODO use a callback for this.
@@ -1513,8 +1512,6 @@ public class PersistentColocatedPartitionedRegionDUnitTest
     waitForBucketRecovery(vm0, vm0Buckets);
     waitForBucketRecovery(vm1, vm1Buckets);
 
-
-
     checkData(vm0, 0, NUM_BUCKETS, "a");
 
     // region 2 didn't have persistent data, so it nothing should be recovered

http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java
index 5d74ca4..917361f 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit3CacheTestCase.java
@@ -72,9 +72,9 @@ public abstract class JUnit3CacheTestCase extends JUnit3DistributedTestCase
    * Finish what {@code beginCacheXml} started. It does this be generating a cache.xml file
and then
    * creating a real cache using that cache.xml.
    */
-  public final void finishCacheXml(final String name, final boolean useSchema,
+  public final void finishCacheXml(final File root, final String name, final boolean useSchema,
       final String xmlVersion) {
-    delegate.finishCacheXml(name, useSchema, xmlVersion);
+    delegate.finishCacheXml(root, name, useSchema, xmlVersion);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
index 5b1629b..60f47c4 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
@@ -213,10 +213,10 @@ public abstract class JUnit4CacheTestCase extends JUnit4DistributedTestCase
    * Finish what {@code beginCacheXml} started. It does this be generating a cache.xml file
and then
    * creating a real cache using that cache.xml.
    */
-  public final void finishCacheXml(final String name, final boolean useSchema,
+  public final void finishCacheXml(final File root, final String name, final boolean useSchema,
       final String xmlVersion) {
     synchronized (JUnit4CacheTestCase.class) {
-      File dir = new File("XML_" + xmlVersion);
+      File dir = new File(root, "XML_" + xmlVersion);
       dir.mkdirs();
       File file = new File(dir, name + ".xml");
       try {
@@ -224,8 +224,8 @@ public abstract class JUnit4CacheTestCase extends JUnit4DistributedTestCase
         CacheXmlGenerator.generate(cache, pw, useSchema, xmlVersion);
         pw.close();
       } catch (IOException ex) {
-        Assert.fail("IOException during cache.xml generation to " + file, ex); // TODO: remove
error
-                                                                               // handling
+        // TODO: remove error handling
+        Assert.fail("IOException during cache.xml generation to " + file, ex);
       }
       cache = null;
       GemFireCacheImpl.testCacheXml = file;

http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-wan/src/test/java/org/apache/geode/cache/CacheXml70GatewayDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/cache/CacheXml70GatewayDUnitTest.java
b/geode-wan/src/test/java/org/apache/geode/cache/CacheXml70GatewayDUnitTest.java
index 83b2cf4..25cffb3 100644
--- a/geode-wan/src/test/java/org/apache/geode/cache/CacheXml70GatewayDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/cache/CacheXml70GatewayDUnitTest.java
@@ -14,18 +14,12 @@
  */
 package org.apache.geode.cache;
 
-import org.junit.experimental.categories.Category;
-import org.junit.Test;
-
 import static org.junit.Assert.*;
 
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
 import java.util.Properties;
 import java.util.Set;
 
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.asyncqueue.AsyncEventListener;
@@ -48,14 +42,12 @@ import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.internal.cache.xmlcache.ParallelGatewaySenderCreation;
 import org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation;
 import org.apache.geode.internal.cache.xmlcache.SerialGatewaySenderCreation;
+import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 public class CacheXml70GatewayDUnitTest extends CacheXmlTestCase {
 
-  public CacheXml70GatewayDUnitTest() {
-    super();
-  }
-
+  @Override
   protected String getGemFireVersion() {
     return CacheXml.VERSION_7_0;
   }
@@ -64,7 +56,7 @@ public class CacheXml70GatewayDUnitTest extends CacheXmlTestCase {
    * Added to test the scenario of defect #50600.
    */
   @Test
-  public void testAsyncEventQueueWithGatewayEventFilter() {
+  public void testAsyncEventQueueWithGatewayEventFilter() throws Exception {
     getSystem();
     CacheCreation cache = new CacheCreation();
 
@@ -128,7 +120,7 @@ public class CacheXml70GatewayDUnitTest extends CacheXmlTestCase {
   }
 
   @Test
-  public void testParallelGatewaySender() throws CacheException {
+  public void testParallelGatewaySender() throws Exception {
     getSystem();
     CacheCreation cache = new CacheCreation();
 
@@ -166,7 +158,7 @@ public class CacheXml70GatewayDUnitTest extends CacheXmlTestCase {
   }
 
   @Test
-  public void testSerialGatewaySender() throws CacheException {
+  public void testSerialGatewaySender() throws Exception {
     getSystem();
     CacheCreation cache = new CacheCreation();
     GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
@@ -206,18 +198,23 @@ public class CacheXml70GatewayDUnitTest extends CacheXmlTestCase {
   }
 
   public static class MyGatewayEventFilter implements GatewayEventFilter, Declarable {
+    @Override
     public void afterAcknowledgement(GatewayQueueEvent event) {}
 
+    @Override
     public boolean beforeEnqueue(GatewayQueueEvent event) {
       return true;
     }
 
+    @Override
     public boolean beforeTransmit(GatewayQueueEvent event) {
       return true;
     }
 
+    @Override
     public void close() {}
 
+    @Override
     public void init(Properties properties) {}
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/502e9611/geode-wan/src/test/java/org/apache/geode/cache/CacheXml80GatewayDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/cache/CacheXml80GatewayDUnitTest.java
b/geode-wan/src/test/java/org/apache/geode/cache/CacheXml80GatewayDUnitTest.java
index 3b78217..5c256df 100644
--- a/geode-wan/src/test/java/org/apache/geode/cache/CacheXml80GatewayDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/cache/CacheXml80GatewayDUnitTest.java
@@ -14,39 +14,40 @@
  */
 package org.apache.geode.cache;
 
-import org.junit.experimental.categories.Category;
-import org.junit.Test;
-
 import static org.junit.Assert.*;
 
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-import java.io.IOException;
 import java.util.Properties;
 import java.util.Set;
 
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory;
-import org.apache.geode.cache.wan.*;
-import org.apache.geode.cache30.*;
+import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter;
+import org.apache.geode.cache.wan.GatewayReceiver;
+import org.apache.geode.cache.wan.GatewayReceiverFactory;
+import org.apache.geode.cache.wan.GatewaySender;
+import org.apache.geode.cache.wan.GatewaySenderFactory;
+import org.apache.geode.cache.wan.GatewayTransportFilter;
+import org.apache.geode.cache30.CacheXml70DUnitTest;
+import org.apache.geode.cache30.CacheXmlTestCase;
+import org.apache.geode.cache30.MyGatewayTransportFilter1;
+import org.apache.geode.cache30.MyGatewayTransportFilter2;
 import org.apache.geode.internal.cache.xmlcache.CacheCreation;
 import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 public class CacheXml80GatewayDUnitTest extends CacheXmlTestCase {
 
-  public CacheXml80GatewayDUnitTest() {
-    super();
-  }
-
+  @Override
   protected String getGemFireVersion() {
     return CacheXml.VERSION_8_0;
   }
 
   @Test
-  public void testGatewayReceiverWithManualStartTRUE() throws CacheException {
+  public void testGatewayReceiverWithManualStartTRUE() throws Exception {
     // getSystem();
     CacheCreation cache = new CacheCreation();
 
@@ -62,11 +63,9 @@ public class CacheXml80GatewayDUnitTest extends CacheXmlTestCase {
     GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
     gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter2);
     GatewayReceiver receiver1 = gatewayReceiverFactory.create();
-    try {
-      receiver1.start();
-    } catch (IOException e) {
-      fail("Could not start GatewayReceiver");
-    }
+
+    receiver1.start();
+
     testXml(cache);
     Cache c = getCache();
     assertNotNull(c);
@@ -77,7 +76,7 @@ public class CacheXml80GatewayDUnitTest extends CacheXmlTestCase {
   }
 
   @Test
-  public void testAsyncEventQueueWithSubstitutionFilter() {
+  public void testAsyncEventQueueWithSubstitutionFilter() throws Exception {
     getSystem();
     CacheCreation cache = new CacheCreation();
 
@@ -101,7 +100,7 @@ public class CacheXml80GatewayDUnitTest extends CacheXmlTestCase {
   }
 
   @Test
-  public void testGatewaySenderWithSubstitutionFilter() {
+  public void testGatewaySenderWithSubstitutionFilter() throws Exception {
     getSystem();
     CacheCreation cache = new CacheCreation();
 
@@ -136,12 +135,15 @@ public class CacheXml80GatewayDUnitTest extends CacheXmlTestCase {
   public static class MyGatewayEventSubstitutionFilter
       implements GatewayEventSubstitutionFilter, Declarable {
 
+    @Override
     public Object getSubstituteValue(EntryEvent event) {
       return event.getKey();
     }
 
+    @Override
     public void close() {}
 
+    @Override
     public void init(Properties properties) {}
   }
 }


Mime
View raw message