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/03 05:29:34 UTC
svn commit: r1226634 - in
/lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji:
./ dict/ trie/
Author: rmuir
Date: Tue Jan 3 04:29:34 2012
New Revision: 1226634
URL: http://svn.apache.org/viewvc?rev=1226634&view=rev
Log:
LUCENE-3305: some test cleanups
Modified:
lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TokenizerTest.java
lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UnknownDictionaryTest.java
lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UserDictionaryTest.java
lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/DoubleArrayTrieTest.java
lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/NodeTest.java
lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/TrieTest.java
Modified: lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TokenizerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TokenizerTest.java?rev=1226634&r1=1226633&r2=1226634&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TokenizerTest.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TokenizerTest.java Tue Jan 3 04:29:34 2012
@@ -77,28 +77,42 @@ public class TokenizerTest extends Lucen
assertEquals(tokens.get(5).getReading(), "ã");
}
+ public void testBocchan() throws Exception {
+ doTestBocchan(1);
+ }
+
@Test @Nightly
- public void testBocchan() throws IOException, InterruptedException {
- LineNumberReader reader = new LineNumberReader(new InputStreamReader(
- this.getClass().getResourceAsStream("bocchan.utf-8")));
-
- String line = reader.readLine();
- reader.close();
+ public void testBocchanBig() throws Exception {
+ doTestBocchan(100);
+ }
+
+ private void doTestBocchan(int numIterations) throws Exception {
+ LineNumberReader reader = new LineNumberReader(new InputStreamReader(
+ this.getClass().getResourceAsStream("bocchan.utf-8")));
+
+ String line = reader.readLine();
+ reader.close();
- System.out.println("Test for Bocchan without pre-splitting sentences");
- long totalStart = System.currentTimeMillis();
- for (int i = 0; i < 100; i++){
- tokenizer.tokenize(line);
- }
- System.out.println("Total time : " + (System.currentTimeMillis() - totalStart));
- System.out.println("Test for Bocchan with pre-splitting sentences");
- String[] sentences = line.split("ã|ã");
- totalStart = System.currentTimeMillis();
- for (int i = 0; i < 100; i++) {
- for (String sentence: sentences) {
- tokenizer.tokenize(sentence);
- }
- }
- System.out.println("Total time : " + (System.currentTimeMillis() - totalStart));
+ if (VERBOSE) {
+ System.out.println("Test for Bocchan without pre-splitting sentences");
+ }
+ long totalStart = System.currentTimeMillis();
+ for (int i = 0; i < numIterations; i++){
+ tokenizer.tokenize(line);
+ }
+ if (VERBOSE) {
+ System.out.println("Total time : " + (System.currentTimeMillis() - totalStart));
+ System.out.println("Test for Bocchan with pre-splitting sentences");
+ }
+ String[] sentences = line.split("ã|ã");
+ totalStart = System.currentTimeMillis();
+ for (int i = 0; i < numIterations; i++) {
+ for (String sentence: sentences) {
+ tokenizer.tokenize(sentence);
+ }
+ }
+ if (VERBOSE) {
+ System.out.println("Total time : " + (System.currentTimeMillis() - totalStart));
+ }
}
}
Modified: lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UnknownDictionaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UnknownDictionaryTest.java?rev=1226634&r1=1226633&r2=1226634&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UnknownDictionaryTest.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UnknownDictionaryTest.java Tue Jan 3 04:29:34 2012
@@ -25,16 +25,11 @@ import java.io.InputStreamReader;
import org.apache.lucene.analysis.kuromoji.dict.UnknownDictionary;
import org.apache.lucene.analysis.kuromoji.util.CSVUtil;
import org.apache.lucene.util.LuceneTestCase;
-import org.junit.BeforeClass;
import org.junit.Test;
public class UnknownDictionaryTest extends LuceneTestCase {
public static final String FILENAME = "unk-tokeninfo-dict.obj";
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
@Test
public void testPutCharacterCategory() {
UnknownDictionary unkDic = new UnknownDictionary(10 * 1024 * 1024);
Modified: lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UserDictionaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UserDictionaryTest.java?rev=1226634&r1=1226633&r2=1226634&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UserDictionaryTest.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/dict/UserDictionaryTest.java Tue Jan 3 04:29:34 2012
@@ -21,11 +21,10 @@ import java.io.IOException;
import org.apache.lucene.analysis.kuromoji.TokenizerTest;
import org.apache.lucene.analysis.kuromoji.dict.UserDictionary;
-import org.junit.BeforeClass;
+import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;
-import static org.junit.Assert.*;
-public class UserDictionaryTest {
+public class UserDictionaryTest extends LuceneTestCase {
@Test
public void testLookup() throws IOException {
Modified: lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/DoubleArrayTrieTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/DoubleArrayTrieTest.java?rev=1226634&r1=1226633&r2=1226634&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/DoubleArrayTrieTest.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/DoubleArrayTrieTest.java Tue Jan 3 04:29:34 2012
@@ -17,29 +17,26 @@ package org.apache.lucene.analysis.kurom
* limitations under the License.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.lucene.analysis.kuromoji.trie.DoubleArrayTrie;
import org.apache.lucene.analysis.kuromoji.trie.Trie;
+import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;
-public class DoubleArrayTrieTest {
+public class DoubleArrayTrieTest extends LuceneTestCase {
@Test
- public void buildTest() {
+ public void testBuild() {
Trie trie = getTrie();
DoubleArrayTrie doubleArrayTrie = new DoubleArrayTrie();
doubleArrayTrie.build(trie);
}
@Test
- public void writeTest() throws IOException {
+ public void testWrite() throws IOException {
Trie trie = getTrie();
DoubleArrayTrie doubleArrayTrie = new DoubleArrayTrie();
@@ -52,6 +49,7 @@ public class DoubleArrayTrieTest {
}
+ // nocommit: lets use TEMPDIR here
String tmpDir = System.getProperty("java.io.tmpdir");
File dir = new File(tmpDir + File.separator + "datmp");
dir.mkdir();
@@ -64,16 +62,15 @@ public class DoubleArrayTrieTest {
assertTrue(dir.length() > 0);
}
-
-
@Test
- public void lookupTest() throws IOException {
+ public void testLookup() throws IOException {
Trie trie = getTrie();
DoubleArrayTrie doubleArrayTrie = new DoubleArrayTrie();
doubleArrayTrie.build(trie);
+ // nocommit: lets use TEMPDIR here
String tmpDir = System.getProperty("java.io.tmpdir");
File dir = new File(tmpDir + File.separator + "datmp");
dir.mkdir();
Modified: lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/NodeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/NodeTest.java?rev=1226634&r1=1226633&r2=1226634&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/NodeTest.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/NodeTest.java Tue Jan 3 04:29:34 2012
@@ -17,18 +17,12 @@ package org.apache.lucene.analysis.kurom
* limitations under the License.
*/
-import static org.junit.Assert.assertEquals;
-
import org.apache.lucene.analysis.kuromoji.trie.Trie;
import org.apache.lucene.analysis.kuromoji.trie.Trie.Node;
-import org.junit.BeforeClass;
+import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;
-public class NodeTest {
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
+public class NodeTest extends LuceneTestCase {
@Test
public void testNode() {
Modified: lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/TrieTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/TrieTest.java?rev=1226634&r1=1226633&r2=1226634&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/TrieTest.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/trie/TrieTest.java Tue Jan 3 04:29:34 2012
@@ -17,15 +17,12 @@ package org.apache.lucene.analysis.kurom
* limitations under the License.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import org.apache.lucene.analysis.kuromoji.trie.Trie;
import org.apache.lucene.analysis.kuromoji.trie.Trie.Node;
+import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;
-public class TrieTest {
+public class TrieTest extends LuceneTestCase {
@Test
public void testGetRoot() {