lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r1421050 - /lucene/pylucene/trunk/test/test_PerFieldAnalyzerWrapper.py
Date Thu, 13 Dec 2012 00:11:39 GMT
Author: vajda
Date: Thu Dec 13 00:11:38 2012
New Revision: 1421050

URL: http://svn.apache.org/viewvc?rev=1421050&view=rev
Log:
migrated test_PerFieldAnalyzerWrapper.py

Modified:
    lucene/pylucene/trunk/test/test_PerFieldAnalyzerWrapper.py

Modified: lucene/pylucene/trunk/test/test_PerFieldAnalyzerWrapper.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/test_PerFieldAnalyzerWrapper.py?rev=1421050&r1=1421049&r2=1421050&view=diff
==============================================================================
--- lucene/pylucene/trunk/test/test_PerFieldAnalyzerWrapper.py (original)
+++ lucene/pylucene/trunk/test/test_PerFieldAnalyzerWrapper.py Thu Dec 13 00:11:38 2012
@@ -13,21 +13,30 @@
 # ====================================================================
 
 from unittest import TestCase, main
-from lucene import *
+from PyLuceneTestCase import PyLuceneTestCase
 
+from java.io import StringReader
+from java.util import HashMap
+from org.apache.lucene.analysis.core import SimpleAnalyzer, WhitespaceAnalyzer
+from org.apache.lucene.analysis.miscellaneous import PerFieldAnalyzerWrapper
+from org.apache.lucene.analysis.tokenattributes import CharTermAttribute
+from org.apache.lucene.util import Version
 
-class PerFieldAnalyzerTestCase(TestCase):
+
+class PerFieldAnalyzerTestCase(PyLuceneTestCase):
     """
     Unit tests ported from Java Lucene
     """
 
     def testPerField(self):
 
-        text = "Qwerty"
-        analyzer = PerFieldAnalyzerWrapper(WhitespaceAnalyzer())
-        analyzer.addAnalyzer("special", SimpleAnalyzer())
+        perField = HashMap()
+        perField.put("special", SimpleAnalyzer(Version.LUCENE_CURRENT))
+        analyzer = PerFieldAnalyzerWrapper(WhitespaceAnalyzer(Version.LUCENE_CURRENT), perField)
 
+        text = "Qwerty"
         tokenStream = analyzer.tokenStream("field", StringReader(text))
+        tokenStream.reset()
         termAtt = tokenStream.getAttribute(CharTermAttribute.class_)
 
         self.assert_(tokenStream.incrementToken())
@@ -35,6 +44,7 @@ class PerFieldAnalyzerTestCase(TestCase)
                          "WhitespaceAnalyzer does not lowercase")
 
         tokenStream = analyzer.tokenStream("special", StringReader(text))
+        tokenStream.reset()
         termAtt = tokenStream.getAttribute(CharTermAttribute.class_)
         self.assert_(tokenStream.incrementToken())
         self.assertEqual("qwerty", termAtt.toString(),



Mime
View raw message