geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject geode git commit: Fix test failures
Date Fri, 05 May 2017 23:15:47 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2858 3674f70a7 -> 90200aa98


Fix test failures


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/90200aa9
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/90200aa9
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/90200aa9

Branch: refs/heads/feature/GEODE-2858
Commit: 90200aa984451c5515f3c49f7843f9ae1a4f2233
Parents: 3674f70
Author: Kirk Lund <klund@apache.org>
Authored: Fri May 5 16:15:30 2017 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Fri May 5 16:15:30 2017 -0700

----------------------------------------------------------------------
 .../cache/query/LocalQueryServiceJUnitTest.java | 101 ++++++++-----------
 1 file changed, 43 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/90200aa9/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
index d3df451..2f6505c 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/LocalQueryServiceJUnitTest.java
@@ -14,88 +14,73 @@
  */
 package org.apache.geode.cache.query;
 
-import org.apache.geode.internal.net.SocketCreatorFactory;
-import org.apache.geode.distributed.internal.DistributionConfigImpl;
+import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
+import static org.junit.Assert.assertEquals;
+
 import org.apache.geode.cache.CacheTransactionManager;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.client.ClientCache;
 import org.apache.geode.cache.client.ClientCacheFactory;
 import org.apache.geode.cache.client.ClientRegionFactory;
 import org.apache.geode.cache.client.ClientRegionShortcut;
-import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import java.io.IOException;
-import java.util.Properties;
-
-import static org.junit.Assert.assertEquals;
 
-@Category(UnitTest.class)
+@Category(IntegrationTest.class)
 public class LocalQueryServiceJUnitTest {
 
-  @Test
-  public void testLocalQueryService() throws Exception {
-    ClientCache c = null;
-    try {
-      c = new ClientCacheFactory().create();
-      addExpectedException(c, IOException.class.getName());
-      Region r = createRegion(c);
-      int numEntries = 10;
-      loadRegion(r, numEntries);
-      SelectResults sR = executeLocalQuery(c, "SELECT * from /localRegion");
-      assertEquals(numEntries, sR.size());
-    } finally {
-      if (c != null) {
-        c.close();
-      }
+  private IgnoredException ignoredException;
+  private ClientCache clientCache;
+  private int numEntries;
+
+  @Before
+  public void before() throws Exception {
+    this.ignoredException = addIgnoredException(IOException.class.getName());
+
+    this.clientCache = new ClientCacheFactory().create();
+    ClientRegionFactory factory = this.clientCache.createClientRegionFactory(ClientRegionShortcut.LOCAL);
+    Region region = factory.create("localRegion");
+    this.numEntries = 10;
+    for (int i = 0; i < this.numEntries; i++) {
+      region.put(i, i);
     }
   }
 
-  @Test
-  public void testLocalQueryServiceWithTransaction() throws Exception {
-    ClientCache c = null;
-    try {
-      SocketCreatorFactory.setDistributionConfig(new DistributionConfigImpl(new Properties()));
-      c = new ClientCacheFactory().create();
-      addExpectedException(c, IOException.class.getName());
-      Region r = createRegion(c);
-      int numEntries = 10;
-      loadRegion(r, numEntries);
-      CacheTransactionManager cacheTransactionManager = c.getCacheTransactionManager();
-      cacheTransactionManager.begin();
-      SelectResults sR = executeLocalQuery(c, "SELECT * from /localRegion");
-      assertEquals(numEntries, sR.size());
-      cacheTransactionManager.commit();
-    } finally {
-      if (c != null) {
-        c.close();
-      }
+  @After
+  public void after() throws Exception {
+    if (this.clientCache != null) {
+      this.clientCache.close();
     }
+    this.ignoredException.remove();
   }
 
-  private Region createRegion(ClientCache c) {
-    ClientRegionFactory factory = c.createClientRegionFactory(ClientRegionShortcut.LOCAL);
-    return factory.create("localRegion");
-  }
+  @Test
+  public void testLocalQueryService() throws Exception {
+    SelectResults sR = executeLocalQuery(this.clientCache, "SELECT * from /localRegion");
 
-  private void loadRegion(Region r, int numEntries) {
-    for (int i = 0; i < numEntries; i++) {
-      r.put(i, i);
-    }
+    assertEquals(this.numEntries, sR.size());
   }
 
-  private SelectResults executeLocalQuery(ClientCache c, String qS) throws QueryException
{
-    QueryService qs = c.getLocalQueryService();
-    Query q = qs.newQuery("SELECT * from /localRegion");
-    return (SelectResults) q.execute();
-  }
+  @Test
+  public void testLocalQueryServiceWithTransaction() throws Exception {
+    CacheTransactionManager cacheTransactionManager = clientCache.getCacheTransactionManager();
+    cacheTransactionManager.begin();
+    SelectResults selectResults = executeLocalQuery(this.clientCache, "SELECT * from /localRegion");
+
+    assertEquals(this.numEntries, selectResults.size());
 
-  private void addExpectedException(ClientCache c, String exception) {
-    c.getLogger().info("<ExpectedException action=add>" + exception + "</ExpectedException>");
+    cacheTransactionManager.commit();
   }
 
-  private void removeExpectedException(ClientCache c, String exception) {
-    c.getLogger().info("<ExpectedException action=remove>" + exception + "</ExpectedException>");
+  private SelectResults executeLocalQuery(ClientCache c, String query) throws QueryException
{
+    QueryService qs = c.getLocalQueryService();
+    Query q = qs.newQuery(query);
+    return (SelectResults) q.execute();
   }
 }


Mime
View raw message