X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fengine%2FDictionaryTest.java;h=0a9c6733d7d31c969e862e59c9e28c94f93aa3e9;hb=2fc669d88306d563fc9c899d8d91b25d591692ea;hp=16db7237a3e7b762dfdd30fddda1cd30d7fd8825;hpb=e479ba38bbcb261951399326623c20ffacc147d4;p=DictionaryPC.git diff --git a/src/com/hughes/android/dictionary/engine/DictionaryTest.java b/src/com/hughes/android/dictionary/engine/DictionaryTest.java index 16db723..0a9c673 100644 --- a/src/com/hughes/android/dictionary/engine/DictionaryTest.java +++ b/src/com/hughes/android/dictionary/engine/DictionaryTest.java @@ -21,11 +21,11 @@ import java.util.List; import java.util.Random; import java.util.concurrent.atomic.AtomicBoolean; -import junit.framework.TestCase; - import com.hughes.android.dictionary.engine.Index.IndexEntry; import com.hughes.util.CollectionUtil; +import junit.framework.TestCase; + public class DictionaryTest extends TestCase { @@ -34,7 +34,7 @@ public class DictionaryTest extends TestCase { @Override protected void setUp() { - while (!TransliteratorManager.init(null)) { + while (!TransliteratorManager.init(null, null)) { try { Thread.sleep(10); } catch (InterruptedException e) { @@ -48,7 +48,7 @@ public class DictionaryTest extends TestCase { public void testEnItWiktionary() throws IOException { final RandomAccessFile raf = new RandomAccessFile(OUTPUTS + "EN-IT.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index enIndex = dict.indices.get(0); final RowBase row = enIndex.rows.get(4); @@ -61,7 +61,7 @@ public class DictionaryTest extends TestCase { assertTrue(rows.toString(), rows.size() > 0); assertTrue(rows.get(0).toString().startsWith("come mai@")); assertTrue(rows.get(0) instanceof TokenRow); - assertTrue(!((TokenRow)rows.get(0)).getIndexEntry().htmlEntries.isEmpty()); + assertFalse(((TokenRow) rows.get(0)).getIndexEntry().htmlEntries.isEmpty()); } { @@ -70,7 +70,7 @@ public class DictionaryTest extends TestCase { assertTrue(rows.toString(), rows.size() > 0); assertTrue(rows.get(0).toString().startsWith("buon giorno@")); assertTrue(rows.get(0) instanceof TokenRow); - assertTrue(!((TokenRow)rows.get(0)).getIndexEntry().htmlEntries.isEmpty()); + assertFalse(((TokenRow) rows.get(0)).getIndexEntry().htmlEntries.isEmpty()); } { @@ -99,7 +99,7 @@ public class DictionaryTest extends TestCase { public void testDeEnWiktionary() throws IOException { final RandomAccessFile raf = new RandomAccessFile(OUTPUTS + "DE-EN.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index deIndex = dict.indices.get(0); @@ -115,7 +115,7 @@ public class DictionaryTest extends TestCase { public void testGermanMetadata() throws IOException { final RandomAccessFile raf = new RandomAccessFile(TEST_OUTPUTS + "de-en.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index deIndex = dict.indices.get(0); assertEquals("DE", deIndex.shortName); @@ -133,7 +133,7 @@ public class DictionaryTest extends TestCase { public void testGermanIndex() throws IOException { final RandomAccessFile raf = new RandomAccessFile(TEST_OUTPUTS + "de-en.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index deIndex = dict.indices.get(0); for (final Index.IndexEntry indexEntry : deIndex.sortedIndexEntries) { @@ -171,7 +171,7 @@ public class DictionaryTest extends TestCase { // Check that search in lowercase works. assertSearchResult("Alibi", "Alibi", deIndex.findInsertionPoint("alib", new AtomicBoolean(false))); - System.out.println(deIndex.findInsertionPoint("alib", new AtomicBoolean(false)).toString()); + System.out.println(deIndex.findInsertionPoint("alib", new AtomicBoolean(false))); raf.close(); } @@ -183,7 +183,7 @@ public class DictionaryTest extends TestCase { public void testGermanTokenRows() throws IOException { final RandomAccessFile raf = new RandomAccessFile(TEST_OUTPUTS + "de-en.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index deIndex = dict.indices.get(0); // Pre-cache a few of these, just to make sure that's working. @@ -214,7 +214,7 @@ public class DictionaryTest extends TestCase { public void testChemnitz() throws IOException { final RandomAccessFile raf = new RandomAccessFile(TEST_OUTPUTS + "de-en.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index deIndex = dict.indices.get(0); assertSearchResult("Höschen", "Hos", deIndex.findInsertionPoint("Hos", new AtomicBoolean(false))); @@ -225,7 +225,7 @@ public class DictionaryTest extends TestCase { public void testMultiSearch() throws IOException { final RandomAccessFile raf = new RandomAccessFile(TEST_OUTPUTS + "de-en.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index deIndex = dict.indices.get(0); { @@ -239,7 +239,7 @@ public class DictionaryTest extends TestCase { public void testMultiSearchIt() throws IOException { final RandomAccessFile raf = new RandomAccessFile(OUTPUTS + "IT.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index index = dict.indices.get(0); { @@ -253,7 +253,7 @@ public class DictionaryTest extends TestCase { public void testMultiSearchDeBig() throws IOException { final RandomAccessFile raf = new RandomAccessFile(OUTPUTS + "DE-EN.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index enIndex = dict.indices.get(1); { @@ -314,7 +314,7 @@ public class DictionaryTest extends TestCase { public void testMultiSearchBigAF() throws IOException { final RandomAccessFile raf = new RandomAccessFile(OUTPUTS + "AF-EN.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index enIndex = dict.indices.get(1); { @@ -352,7 +352,7 @@ public class DictionaryTest extends TestCase { public void testExactSearch() throws IOException { final RandomAccessFile raf = new RandomAccessFile(OUTPUTS + "EN-cmn.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index cmnIndex = dict.indices.get(1); final Random random = new Random(10); @@ -371,7 +371,7 @@ public class DictionaryTest extends TestCase { public void testThai() throws IOException { final RandomAccessFile raf = new RandomAccessFile(OUTPUTS + "EN-TH.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index thIndex = dict.indices.get(1); final IndexEntry entry = thIndex.findInsertionPoint("ดี", new AtomicBoolean(false)); @@ -382,7 +382,7 @@ public class DictionaryTest extends TestCase { public void testNorwegian() throws IOException { final RandomAccessFile raf = new RandomAccessFile(OUTPUTS + "EN-NL.quickdic", "r"); - final Dictionary dict = new Dictionary(raf); + final Dictionary dict = new Dictionary(raf.getChannel()); final Index nlIndex = dict.indices.get(1); IndexEntry entry = nlIndex.findInsertionPoint("Xhosa", new AtomicBoolean(false));