lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r1408167 - in /lucene/pylucene/trunk/test: PyLuceneTestCase.py test_Analyzers.py test_Binary.py test_BinaryDocument.py
Date Mon, 12 Nov 2012 01:39:03 GMT
Author: vajda
Date: Mon Nov 12 01:39:03 2012
New Revision: 1408167

URL: http://svn.apache.org/viewvc?rev=1408167&view=rev
Log:
fixed/ported a few tests

Modified:
    lucene/pylucene/trunk/test/PyLuceneTestCase.py
    lucene/pylucene/trunk/test/test_Analyzers.py
    lucene/pylucene/trunk/test/test_Binary.py
    lucene/pylucene/trunk/test/test_BinaryDocument.py

Modified: lucene/pylucene/trunk/test/PyLuceneTestCase.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/PyLuceneTestCase.py?rev=1408167&r1=1408166&r2=1408167&view=diff
==============================================================================
--- lucene/pylucene/trunk/test/PyLuceneTestCase.py (original)
+++ lucene/pylucene/trunk/test/PyLuceneTestCase.py Mon Nov 12 01:39:03 2012
@@ -14,9 +14,16 @@
 
 
 from unittest import TestCase
-from lucene import RAMDirectory, File, IndexWriter, IndexWriterConfig, \
-    LimitTokenCountAnalyzer, WhitespaceAnalyzer, Version, IndexSearcher, \
-    DirectoryReader
+
+from java.io import File
+from org.apache.lucene.analysis.core import WhitespaceAnalyzer
+from org.apache.lucene.analysis.miscellaneous import LimitTokenCountAnalyzer
+from org.apache.lucene.index import \
+    IndexWriter, IndexWriterConfig, DirectoryReader
+from org.apache.lucene.search import IndexSearcher
+from org.apache.lucene.store import RAMDirectory
+from org.apache.lucene.util import Version
+
 
 class PyLuceneTestCase(TestCase):
 

Modified: lucene/pylucene/trunk/test/test_Analyzers.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/test_Analyzers.py?rev=1408167&r1=1408166&r2=1408167&view=diff
==============================================================================
--- lucene/pylucene/trunk/test/test_Analyzers.py (original)
+++ lucene/pylucene/trunk/test/test_Analyzers.py Mon Nov 12 01:39:03 2012
@@ -80,6 +80,7 @@ class AnalyzersTestCase(BaseTokenStreamT
 
     def _verifyPayload(self, ts):
 
+        ts.reset()
         payloadAtt = ts.getAttribute(PayloadAttribute.class_)
         b = 0
         while True:

Modified: lucene/pylucene/trunk/test/test_Binary.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/test_Binary.py?rev=1408167&r1=1408166&r2=1408167&view=diff
==============================================================================
--- lucene/pylucene/trunk/test/test_Binary.py (original)
+++ lucene/pylucene/trunk/test/test_Binary.py Mon Nov 12 01:39:03 2012
@@ -15,7 +15,10 @@
 # test PyLucene binary field
 
 from unittest import TestCase, main
-from lucene import StoredField, JArray
+from lucene import JArray
+
+from org.apache.lucene.document import StoredField
+
 
 class BinaryTestCase(TestCase):
 

Modified: lucene/pylucene/trunk/test/test_BinaryDocument.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/test_BinaryDocument.py?rev=1408167&r1=1408166&r2=1408167&view=diff
==============================================================================
--- lucene/pylucene/trunk/test/test_BinaryDocument.py (original)
+++ lucene/pylucene/trunk/test/test_BinaryDocument.py Mon Nov 12 01:39:03 2012
@@ -13,9 +13,16 @@
 # ====================================================================
 
 from unittest import TestCase, main
-from lucene import *
+from lucene import JArray
 from PyLuceneTestCase import PyLuceneTestCase
 
+from org.apache.lucene.document import \
+    Document, StoredField, CompressionTools, Field, FieldType
+from org.apache.lucene.analysis.standard import StandardAnalyzer
+from org.apache.lucene.index import IndexWriter
+from org.apache.lucene.store import RAMDirectory
+from org.apache.lucene.util import Version
+
 
 class TestBinaryDocument(PyLuceneTestCase):
 
@@ -24,24 +31,13 @@ class TestBinaryDocument(PyLuceneTestCas
   
     def testBinaryFieldInIndex(self):
 
-        bytes = JArray('byte')(self.binaryValStored)
-        binaryFldStored = StoredField("binaryStored", bytes)
         ft = FieldType()
         ft.setStored(True)
-        ft.setIndexed(False)
-        ft.setStoreTermVectors(False)
+
+        bytes = JArray('byte')(self.binaryValStored)
+        binaryFldStored = StoredField("binaryStored", bytes)
         stringFldStored = Field("stringStored", self.binaryValStored, ft)
         
-        # couldn't find any combination with lucene4.0 where it would raise errors
-        #try:
-        #    # binary fields with store off are not allowed
-        #    Field("fail", bytes, Field.Store.NO)
-        #    self.fail()
-        #except JavaError, e:
-        #    self.assertEqual(e.getJavaException().getClass().getName(),
-        #                     'java.lang.IllegalArgumentException')
-        
-    
         doc = Document()
         doc.add(binaryFldStored)
         doc.add(stringFldStored)
@@ -56,7 +52,7 @@ class TestBinaryDocument(PyLuceneTestCas
     
         # open a reader and fetch the document
         reader = self.getReader()
-        docFromReader = reader.document(0) #segfault
+        docFromReader = reader.document(0)
         self.assert_(docFromReader is not None)
     
         # fetch the binary stored field and compare it's content with the
@@ -70,32 +66,25 @@ class TestBinaryDocument(PyLuceneTestCas
         stringFldStoredTest = docFromReader.get("stringStored")
         self.assertEqual(stringFldStoredTest, self.binaryValStored)
     
-        # delete the document from index
-        reader.deleteDocument(0)
-        self.assertEqual(0, reader.numDocs())
-    
         reader.close()
-        dir.close()
   
     def testCompressionTools(self):
 
         bytes = JArray('byte')(self.binaryValCompressed)
-        binaryFldCompressed = Field("binaryCompressed", CompressionTools.compress(bytes))
-        stringFldCompressed = Field("stringCompressed", CompressionTools.compressString(self.binaryValCompressed))
+        binaryFldCompressed = StoredField("binaryCompressed", CompressionTools.compress(bytes))
+        stringFldCompressed = StoredField("stringCompressed", CompressionTools.compressString(self.binaryValCompressed))
     
         doc = Document()
         doc.add(binaryFldCompressed)
         doc.add(stringFldCompressed)
     
         # add the doc to a ram index
-        dir = RAMDirectory()
-        writer = IndexWriter(dir, StandardAnalyzer(Version.LUCENE_CURRENT),
-                             True, IndexWriter.MaxFieldLength.LIMITED)
+        writer = self.getWriter(analyzer=StandardAnalyzer(Version.LUCENE_CURRENT))
         writer.addDocument(doc)
         writer.close()
     
         # open a reader and fetch the document
-        reader = IndexReader.open(dir, False)
+        reader = self.getReader()
         docFromReader = reader.document(0)
         self.assert_(docFromReader is not None)
     
@@ -107,7 +96,6 @@ class TestBinaryDocument(PyLuceneTestCas
         self.assertEqual(CompressionTools.decompressString(docFromReader.getBinaryValue("stringCompressed")),
self.binaryValCompressed)
 
         reader.close()
-        dir.close()
 
 
 if __name__ == '__main__':



Mime
View raw message