You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/01/18 18:57:41 UTC
svn commit: r1232975 -
/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
Author: rmuir
Date: Wed Jan 18 17:57:41 2012
New Revision: 1232975
URL: http://svn.apache.org/viewvc?rev=1232975&view=rev
Log:
LUCENE-3576: add method to generate a surrogates index for 4.0s TestBackwardsCompatibility
Modified:
lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=1232975&r1=1232974&r2=1232975&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Wed Jan 18 17:57:41 2012
@@ -71,6 +71,10 @@ public class TestBackwardsCompatibility
public void testCreateNoCFS() throws IOException {
createIndex("index.nocfs", false, false);
}
+
+ public void testCreateSurrogates() throws IOException {
+ createSurrogatesIndex("index.surrogates");
+ }
*/
/*
@@ -537,6 +541,35 @@ public class TestBackwardsCompatibility
return indexDir;
}
+
+ // creates an index to check term order for 4.x's TestBackwardsCompatibility
+ public File createSurrogatesIndex(String dirName) throws IOException {
+ File indexDir = new File(LuceneTestCase.TEMP_DIR, dirName);
+ _TestUtil.rmDir(indexDir);
+ Directory dir = newFSDirectory(indexDir);
+ IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT));
+ IndexWriter writer = new IndexWriter(dir, conf);
+ String alphabet[] = { "A", "a", "ð", "ð", "ð", "ð", "D", "ï½" };
+ int maxLength = 4;
+ int max = (int) Math.pow(8, maxLength);
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < max; i++) {
+ sb.append(' ');
+ String s = Integer.toOctalString(i);
+ for (char c : s.toCharArray()) {
+ sb.append(alphabet[c-'0']);
+ }
+ }
+ Document doc = new Document();
+ // empty string
+ doc.add(new Field("foo", "", Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+ // big string of surrogates
+ doc.add(new Field("foo", sb.toString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+ writer.addDocument(doc);
+ writer.close();
+ dir.close();
+ return indexDir;
+ }
/* Verifies that the expected file names were produced */