geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject [geode] branch feature/GEODE-3239 updated: GEODE-3275: test LuceneSerializer should not cause PDX values to be deserialized
Date Mon, 02 Oct 2017 21:15:41 GMT
This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a commit to branch feature/GEODE-3239
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-3239 by this push:
     new 215d56e  GEODE-3275: test LuceneSerializer should not cause PDX values to be deserialized
215d56e is described below

commit 215d56e4fac3341603bdf45d7402ac7f242c0e29
Author: zhouxh <gzhou@pivotal.io>
AuthorDate: Thu Sep 28 17:55:35 2017 -0700

    GEODE-3275: test LuceneSerializer should not cause PDX values to be deserialized
    
    This closes #843
---
 .../LuceneIndexMaintenanceIntegrationTest.java     | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
index 9ee8e3c..7d9aed2 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
@@ -27,6 +27,8 @@ import java.util.concurrent.TimeUnit;
 import org.apache.geode.internal.cache.CachedDeserializable;
 import org.apache.geode.internal.cache.EntrySnapshot;
 import org.apache.geode.internal.cache.RegionEntry;
+import org.apache.geode.pdx.JSONFormatter;
+import org.apache.geode.pdx.PdxInstance;
 import org.awaitility.Awaitility;
 
 import org.junit.Test;
@@ -44,6 +46,7 @@ import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
 import org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats;
 import org.apache.geode.cache.lucene.internal.repository.serializer.HeterogeneousLuceneSerializer;
 import org.apache.geode.cache.lucene.test.LuceneTestUtilities;
+import org.apache.geode.cache.query.data.PortfolioPdx;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.lucene.document.Document;
 
@@ -155,6 +158,29 @@ public class LuceneIndexMaintenanceIntegrationTest extends LuceneIntegrationTest
   }
 
   @Test
+  public void pdxInstanceShouldNotBeDeserialized() throws Exception {
+    luceneService.createIndexFactory().setFields("status", "description")
+        .setLuceneSerializer(new TestPdxInstanceSerializer()).create(INDEX_NAME, REGION_NAME);
+
+    Region region = createRegion(REGION_NAME, RegionShortcut.PARTITION);
+    for (int i = 0; i < 10; i++) {
+      PortfolioPdx p = new PortfolioPdx(i);
+      region.put(i, p);
+    }
+
+    LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
+    luceneService.waitUntilFlushed(INDEX_NAME, REGION_NAME, WAIT_FOR_FLUSH_TIME,
+        TimeUnit.MILLISECONDS);
+    LuceneQuery query = luceneService.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME,
+        "status:active", "status");
+    PageableLuceneQueryResults<Integer, TestObject> results = query.findPages();
+    assertEquals(5, results.size());
+    LuceneIndexForPartitionedRegion indexForPR = (LuceneIndexForPartitionedRegion) index;
+    LuceneIndexStats indexStats = indexForPR.getIndexStats();
+    assertEquals(10, indexStats.getUpdates());
+  }
+
+  @Test
   public void statsAreUpdatedAfterACommit() throws Exception {
     luceneService.createIndexFactory().setFields("title", "description").create(INDEX_NAME,
         REGION_NAME);
@@ -353,4 +379,13 @@ public class LuceneIndexMaintenanceIntegrationTest extends LuceneIntegrationTest
       }
     }
   }
+
+  private static class TestPdxInstanceSerializer extends HeterogeneousLuceneSerializer {
+
+    @Override
+    public Collection<Document> toDocuments(LuceneIndex index, Object value) {
+      assertTrue(value instanceof PdxInstance);
+      return super.toDocuments(index, value);
+    }
+  }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message