package org.apache.lucene.spatial.test.strategy;

import org.apache.lucene.spatial.base.context.SpatialContext;
import org.apache.lucene.spatial.base.prefix.GeohashSpatialPrefixGrid;
import org.apache.lucene.spatial.strategy.SimpleSpatialFieldInfo;
import org.apache.lucene.spatial.strategy.prefix.DynamicPrefixStrategy;
import org.apache.lucene.spatial.test.SpatialMatchConcern;
import org.apache.lucene.spatial.test.StrategyTestCase;
import org.junit.Test;

import java.io.IOException;


public abstract class BaseGeohashStrategyTestCase extends StrategyTestCase<SimpleSpatialFieldInfo> {

  protected abstract SpatialContext getSpatialContext();

  @Override
  public void setUp() throws Exception {
    super.setUp();
    int maxLength = GeohashSpatialPrefixGrid.getMaxLevelsPossible();
    // SimpleIO
    this.shapeIO = getSpatialContext();
    this.strategy = new DynamicPrefixStrategy(new GeohashSpatialPrefixGrid(
        shapeIO, maxLength ));
    this.fieldInfo = new SimpleSpatialFieldInfo( "geohash" );
  }

  @Test
  public void testGeohashStrategy() throws IOException {
    getAddAndVerifyIndexedDocuments(DATA_WORLD_CITIES_POINTS);
    executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_IsWithin_BBox);
  }
}

@@ -585,16 +585,42 @@
 nfo%3E %7B%0A%0A
+  private int maxLength;%0A%0A
   protec
@@ -745,20 +745,16 @@
 ();%0A    
-int 
 maxLengt
@@ -1164,16 +1164,182 @@
 OINTS);%0A
+%0A    //execute queries for each prefix grid scan level%0A    for(int i = 0; i %3C= maxLength; i++) %7B%0A      ((DynamicPrefixStrategy)strategy).setPrefixGridScanLevel(i);%0A  
     exec
@@ -1406,14 +1406,20 @@
 _BBox);%0A
+    %7D%0A
   %7D%0A%7D%0A

Test DynamicPrefixStrategy for each grid scan level (an internal threshold) to tease out possible bugs.