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-3240: add implementation for java api of set serializer chnage createRepositoryManager's mapper to be LuceneSerializer add integration test
Date Tue, 12 Sep 2017 21:27:49 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 6b5289f  GEODE-3240: add implementation for java api of set serializer          
  chnage createRepositoryManager's mapper to be LuceneSerializer             add integration
test
6b5289f is described below

commit 6b5289f86d5d5da6af026fc520271cf96ff745ee
Author: zhouxh <gzhou@pivotal.io>
AuthorDate: Mon Sep 11 16:46:19 2017 -0700

    GEODE-3240: add implementation for java api of set serializer
                chnage createRepositoryManager's mapper to be LuceneSerializer
                add integration test
    
    This closes #770
---
 .../internal/LuceneIndexForPartitionedRegion.java  |  8 ++-
 .../cache/lucene/internal/LuceneIndexImpl.java     |  7 ++-
 .../cache/lucene/internal/LuceneRawIndex.java      |  8 ++-
 .../lucene/internal/LuceneRegionListener.java      |  9 ++-
 .../cache/lucene/internal/LuceneServiceImpl.java   | 12 ++--
 .../lucene/internal/xml/LuceneIndexCreation.java   |  3 +-
 .../LuceneIndexMaintenanceIntegrationTest.java     | 23 ++++++++
 .../LuceneIndexForPartitionedRegionTest.java       | 44 ++++++++++++--
 .../internal/LuceneRegionListenerJUnitTest.java    | 67 ++++++++++++++++++++++
 .../internal/LuceneServiceImplJUnitTest.java       | 16 ++++++
 10 files changed, 177 insertions(+), 20 deletions(-)

diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index 3300ca6..2fc714a 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -28,6 +28,7 @@ import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.internal.directory.DumpDirectoryFiles;
 import org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats;
 import org.apache.geode.cache.lucene.internal.partition.BucketTargetingFixedResolver;
@@ -55,8 +56,11 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     this.fileSystemStats = new FileSystemStats(cache.getDistributedSystem(), statsName);
   }
 
-  protected RepositoryManager createRepositoryManager() {
-    HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer(getFieldNames());
+  protected RepositoryManager createRepositoryManager(LuceneSerializer luceneSerializer)
{
+    LuceneSerializer mapper = luceneSerializer;
+    if (mapper == null) {
+      mapper = new HeterogeneousLuceneSerializer(getFieldNames());
+    }
     PartitionedRepositoryManager partitionedRepositoryManager =
         new PartitionedRepositoryManager(this, mapper);
     return partitionedRepositoryManager;
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
index a8358fa..b32042b 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
@@ -29,6 +29,7 @@ import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
 import org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl;
 import org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl;
+import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
 import org.apache.geode.cache.lucene.internal.xml.LuceneIndexCreation;
 import org.apache.geode.internal.cache.InternalCache;
@@ -145,11 +146,11 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex
{
     }
   }
 
-  protected void setupRepositoryManager() {
-    repositoryManager = createRepositoryManager();
+  protected void setupRepositoryManager(LuceneSerializer luceneSerializer) {
+    repositoryManager = createRepositoryManager(luceneSerializer);
   }
 
-  protected abstract RepositoryManager createRepositoryManager();
+  protected abstract RepositoryManager createRepositoryManager(LuceneSerializer luceneSerializer);
 
   protected abstract void createLuceneListenersAndFileChunkRegions(
       AbstractPartitionedRepositoryManager partitionedRepositoryManager);
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
index ee2930d..7ee0ff5 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
@@ -14,6 +14,7 @@
  */
 package org.apache.geode.cache.lucene.internal;
 
+import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
 import org.apache.geode.cache.lucene.internal.repository.serializer.HeterogeneousLuceneSerializer;
 import org.apache.geode.internal.cache.InternalCache;
@@ -25,8 +26,11 @@ public class LuceneRawIndex extends LuceneIndexImpl {
   }
 
   @Override
-  protected RepositoryManager createRepositoryManager() {
-    HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer(getFieldNames());
+  protected RepositoryManager createRepositoryManager(LuceneSerializer luceneSerializer)
{
+    HeterogeneousLuceneSerializer mapper = (HeterogeneousLuceneSerializer) luceneSerializer;
+    if (mapper == null) {
+      mapper = new HeterogeneousLuceneSerializer(getFieldNames());
+    }
     RawLuceneRepositoryManager rawLuceneRepositoryManager =
         new RawLuceneRepositoryManager(this, mapper);
     return rawLuceneRepositoryManager;
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRegionListener.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRegionListener.java
index 48462a0..8866249 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRegionListener.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRegionListener.java
@@ -24,6 +24,7 @@ import org.apache.geode.cache.EvictionAttributes;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl;
+import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.InternalRegionArguments;
 import org.apache.geode.internal.cache.RegionListener;
@@ -44,10 +45,13 @@ public class LuceneRegionListener implements RegionListener {
 
   private final String[] fields;
 
+  private LuceneSerializer serializer;
+
   private LuceneIndexImpl luceneIndex;
 
   public LuceneRegionListener(LuceneServiceImpl service, InternalCache cache, String indexName,
-      String regionPath, String[] fields, Analyzer analyzer, Map<String, Analyzer>
fieldAnalyzers) {
+      String regionPath, String[] fields, Analyzer analyzer, Map<String, Analyzer>
fieldAnalyzers,
+      LuceneSerializer serializer) {
     this.service = service;
     this.cache = cache;
     this.indexName = indexName;
@@ -55,6 +59,7 @@ public class LuceneRegionListener implements RegionListener {
     this.fields = fields;
     this.analyzer = analyzer;
     this.fieldAnalyzers = fieldAnalyzers;
+    this.serializer = serializer;
   }
 
   public String getRegionPath() {
@@ -101,7 +106,7 @@ public class LuceneRegionListener implements RegionListener {
           this.regionPath, this.fields, this.analyzer, this.fieldAnalyzers));
 
       luceneIndex = this.service.beforeDataRegionCreated(this.indexName, this.regionPath,
attrs,
-          this.analyzer, this.fieldAnalyzers, aeqId, this.fields);
+          this.analyzer, this.fieldAnalyzers, aeqId, serializer, this.fields);
 
       // Add internal async event id
       internalRegionArgs.addInternalAsyncEventQueueId(aeqId);
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
index 935bc64..60e196c 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
@@ -195,11 +195,12 @@ public class LuceneServiceImpl implements InternalLuceneService {
     Set<String> fieldsSet = fieldAnalyzers.keySet();
     String[] fields = (String[]) fieldsSet.toArray(new String[fieldsSet.size()]);
 
-    createIndex(indexName, regionPath, analyzer, fieldAnalyzers, fields);
+    createIndex(indexName, regionPath, analyzer, fieldAnalyzers, serializer, fields);
   }
 
   public void createIndex(final String indexName, String regionPath, final Analyzer analyzer,
-      final Map<String, Analyzer> fieldAnalyzers, final String... fields) {
+      final Map<String, Analyzer> fieldAnalyzers, final LuceneSerializer serializer,
+      final String... fields) {
 
     if (!regionPath.startsWith("/")) {
       regionPath = "/" + regionPath;
@@ -215,7 +216,7 @@ public class LuceneServiceImpl implements InternalLuceneService {
     }
 
     cache.addRegionListener(new LuceneRegionListener(this, cache, indexName, regionPath,
fields,
-        analyzer, fieldAnalyzers));
+        analyzer, fieldAnalyzers, serializer));
   }
 
   /**
@@ -234,12 +235,13 @@ public class LuceneServiceImpl implements InternalLuceneService {
 
   public LuceneIndexImpl beforeDataRegionCreated(final String indexName, final String regionPath,
       RegionAttributes attributes, final Analyzer analyzer,
-      final Map<String, Analyzer> fieldAnalyzers, String aeqId, final String... fields)
{
+      final Map<String, Analyzer> fieldAnalyzers, String aeqId, final LuceneSerializer
serializer,
+      final String... fields) {
     LuceneIndexImpl index = createIndexObject(indexName, regionPath);
     index.setSearchableFields(fields);
     index.setAnalyzer(analyzer);
     index.setFieldAnalyzers(fieldAnalyzers);
-    index.setupRepositoryManager();
+    index.setupRepositoryManager(serializer);
     index.setupAEQ(attributes, aeqId);
     return index;
 
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/xml/LuceneIndexCreation.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/xml/LuceneIndexCreation.java
index e4c1ea0..e98fb41 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/xml/LuceneIndexCreation.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/xml/LuceneIndexCreation.java
@@ -87,7 +87,8 @@ public class LuceneIndexCreation implements LuceneIndex, Extension<Region<?,
?>>
     Analyzer analyzer = this.fieldAnalyzers == null ? new StandardAnalyzer()
         : new PerFieldAnalyzerWrapper(new StandardAnalyzer(), this.fieldAnalyzers);
     try {
-      service.createIndex(getName(), getRegionPath(), analyzer, this.fieldAnalyzers,
+      // TODO: the null should be replaced with real serializer
+      service.createIndex(getName(), getRegionPath(), analyzer, this.fieldAnalyzers, null,
           getFieldNames());
     } catch (LuceneIndexExistsException e) {
       logger
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 ad28164..03921ee 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
@@ -41,6 +41,7 @@ import org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion;
 import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
 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.test.junit.categories.IntegrationTest;
 
@@ -107,6 +108,28 @@ public class LuceneIndexMaintenanceIntegrationTest extends LuceneIntegrationTest
   }
 
   @Test
+  public void useSerializerToIndex() throws Exception {
+    luceneService.createIndexFactory().setFields("title", "name")
+        .setLuceneSerializer(
+            new HeterogeneousLuceneSerializer(new String[] {"title", "description"}))
+        .create(INDEX_NAME, REGION_NAME);
+
+    Region region = createRegion(REGION_NAME, RegionShortcut.PARTITION);
+    region.put("object-1", new TestObject("title 1", "hello world"));
+    region.put("object-2", new TestObject("title 2", "this will not match"));
+    region.put("object-3", new TestObject("title 3", "hello world"));
+    region.put("object-4", new TestObject("hello world", "hello world"));
+
+    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,
+        "description:\"hello world\"", DEFAULT_FIELD);
+    PageableLuceneQueryResults<Integer, TestObject> results = query.findPages();
+    assertEquals(3, results.size());
+  }
+
+  @Test
   public void statsAreUpdatedAfterACommit() throws Exception {
     luceneService.createIndexFactory().setFields("title", "description").create(INDEX_NAME,
         REGION_NAME);
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
index 985fd8a..075a751 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
@@ -17,11 +17,13 @@ package org.apache.geode.cache.lucene.internal;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
+import java.util.Properties;
+
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.ExpectedException;
-
+import org.mockito.ArgumentCaptor;
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheListener;
@@ -37,6 +39,7 @@ import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
 import org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.internal.directory.DumpDirectoryFiles;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalCache;
@@ -118,6 +121,37 @@ public class LuceneIndexForPartitionedRegionTest {
   }
 
   @Test
+  public void createRepositoryManagerWithNotNullSerializer() {
+    String name = "indexName";
+    String regionPath = "regionName";
+    InternalCache cache = Fakes.cache();
+    LuceneSerializer serializer = mock(LuceneSerializer.class);
+    LuceneIndexForPartitionedRegion index =
+        new LuceneIndexForPartitionedRegion(name, regionPath, cache);
+    index = spy(index);
+    index.setupRepositoryManager(serializer);
+    verify(index).createRepositoryManager(eq(serializer));
+  }
+
+  @Test
+  public void createRepositoryManagerWithNullSerializer() {
+    String name = "indexName";
+    String regionPath = "regionName";
+    String fields[] = {"field1", "field2"};
+    InternalCache cache = Fakes.cache();
+    ArgumentCaptor<LuceneSerializer> serializerCaptor =
+        ArgumentCaptor.forClass(LuceneSerializer.class);
+    LuceneIndexForPartitionedRegion index =
+        new LuceneIndexForPartitionedRegion(name, regionPath, cache);
+    index = spy(index);
+    when(index.getFieldNames()).thenReturn(fields);
+    index.setupRepositoryManager(null);
+    verify(index).createRepositoryManager(serializerCaptor.capture());
+    LuceneSerializer serializer = serializerCaptor.getValue();
+    assertNull(serializer);
+  }
+
+  @Test
   public void createAEQCallsCreateOnAEQFactory() {
     String name = "indexName";
     String regionPath = "regionName";
@@ -219,7 +253,7 @@ public class LuceneIndexForPartitionedRegionTest {
     LuceneIndexForPartitionedRegion spy = spy(index);
     doReturn(null).when(spy).createFileRegion(any(), any(), any(), any(), any());
     doReturn(null).when(spy).createAEQ(any(), any());
-    spy.setupRepositoryManager();
+    spy.setupRepositoryManager(null);
     spy.setupAEQ(region.getAttributes(), aeq);
     spy.initialize();
     return spy;
@@ -275,7 +309,7 @@ public class LuceneIndexForPartitionedRegionTest {
     LuceneIndexForPartitionedRegion spy = spy(index);
     doReturn(null).when(spy).createFileRegion(any(), any(), any(), any(), any());
     doReturn(null).when(spy).createAEQ((RegionAttributes) any(), any());
-    spy.setupRepositoryManager();
+    spy.setupRepositoryManager(null);
     spy.setupAEQ(any(), any());
     spy.initialize();
 
@@ -297,7 +331,7 @@ public class LuceneIndexForPartitionedRegionTest {
     LuceneIndexForPartitionedRegion spy = spy(index);
     doReturn(null).when(spy).createFileRegion(any(), any(), any(), any(), any());
     doReturn(null).when(spy).createAEQ(any(), any());
-    spy.setupRepositoryManager();
+    spy.setupRepositoryManager(null);
     spy.setupAEQ(any(), any());
     spy.initialize();
     spy.initialize();
@@ -323,7 +357,7 @@ public class LuceneIndexForPartitionedRegionTest {
     index = spy(index);
     when(index.getFieldNames()).thenReturn(fields);
     doReturn(aeq).when(index).createAEQ(any(), any());
-    index.setupRepositoryManager();
+    index.setupRepositoryManager(null);
     index.setupAEQ(cache.getRegionAttributes(regionPath), aeq.getId());
     index.initialize();
     PartitionedRegion region = (PartitionedRegion) cache.getRegion(regionPath);
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneRegionListenerJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneRegionListenerJUnitTest.java
new file mode 100644
index 0000000..b97eac9
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneRegionListenerJUnitTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version
2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain
a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under
the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+ * or implied. See the License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.geode.cache.lucene.internal;
+
+import static org.mockito.Mockito.*;
+
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.EvictionAlgorithm;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionAttributes;
+import org.apache.geode.cache.lucene.LuceneSerializer;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.InternalRegionArguments;
+import org.apache.geode.test.fake.Fakes;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.lucene.analysis.Analyzer;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class LuceneRegionListenerJUnitTest {
+
+  @Test
+  public void beforeDataRegionCreatedShouldHaveSerializer() {
+    String name = "indexName";
+    String regionPath = "regionName";
+    String[] fields = {"field1", "field2"};
+    String aeqId = LuceneServiceImpl.getUniqueIndexName(name, regionPath);
+    InternalCache cache = Fakes.cache();
+    final Region region = Fakes.region(regionPath, cache);
+    RegionAttributes attributes = region.getAttributes();
+    DataPolicy policy = attributes.getDataPolicy();
+    when(policy.withPartitioning()).thenReturn(true);
+    EvictionAttributes evictionAttributes = mock(EvictionAttributes.class);
+    when(attributes.getEvictionAttributes()).thenReturn(evictionAttributes);
+    CopyOnWriteArraySet set = new CopyOnWriteArraySet();
+    set.add(aeqId);
+    when(attributes.getAsyncEventQueueIds()).thenReturn(set);
+    when(evictionAttributes.getAlgorithm()).thenReturn(EvictionAlgorithm.NONE);
+    LuceneServiceImpl service = mock(LuceneServiceImpl.class);
+    Analyzer analyzer = mock(Analyzer.class);
+    LuceneSerializer serializer = mock(LuceneSerializer.class);
+    InternalRegionArguments internalRegionArgs = mock(InternalRegionArguments.class);
+    when(internalRegionArgs.addCacheServiceProfile(any())).thenReturn(internalRegionArgs);
+
+    LuceneRegionListener listener = new LuceneRegionListener(service, cache, name, "/" +
regionPath,
+        fields, analyzer, null, serializer);
+    listener.beforeCreate(null, regionPath, attributes, internalRegionArgs);
+    verify(service).beforeDataRegionCreated(eq(name), eq("/" + regionPath), eq(attributes),
+        eq(analyzer), any(), eq(aeqId), eq(serializer), any());
+  }
+}
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplJUnitTest.java
index 40e4429..c5ca8f8 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplJUnitTest.java
@@ -15,6 +15,8 @@
 package org.apache.geode.cache.lucene.internal;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 
 import java.lang.reflect.Field;
@@ -22,6 +24,8 @@ import java.util.Collections;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.geode.cache.Region;
+import org.apache.geode.cache.lucene.LuceneIndexFactory;
+import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.test.junit.categories.UnitTest;
 import org.junit.Before;
@@ -29,6 +33,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.ExpectedException;
+import org.mockito.Mockito;
 
 @Category(UnitTest.class)
 public class LuceneServiceImplJUnitTest {
@@ -50,6 +55,17 @@ public class LuceneServiceImplJUnitTest {
   }
 
   @Test
+  public void shouldPassSerializer() {
+    service = Mockito.spy(service);
+    LuceneIndexFactory factory = service.createIndexFactory();
+    LuceneSerializer serializer = mock(LuceneSerializer.class);
+    factory.setLuceneSerializer(serializer);
+    factory.setFields("field1", "field2");
+    factory.create("index", "region");
+    Mockito.verify(service).createIndex(eq("index"), eq("region"), any(), eq(serializer));
+  }
+
+  @Test
   public void shouldThrowIllegalArgumentExceptionIfFieldsAreMissing() {
     thrown.expect(IllegalArgumentException.class);
     service.createIndexFactory().create("index", "region");

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

Mime
View raw message