mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r1088489 - in /mahout/trunk: core/src/test/java/org/apache/mahout/fpm/pfpgrowth/ utils/src/test/java/org/apache/mahout/text/
Date Mon, 04 Apr 2011 07:12:14 GMT
Author: srowen
Date: Mon Apr  4 07:12:14 2011
New Revision: 1088489

URL: http://svn.apache.org/viewvc?rev=1088489&view=rev
Log:
MAHOUT-649 fix small platform-specific file path problem in test

Modified:
    mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthRetailDataTest.java
    mahout/trunk/utils/src/test/java/org/apache/mahout/text/MailArchivesClusteringAnalyzerTest.java
    mahout/trunk/utils/src/test/java/org/apache/mahout/text/SequenceFilesFromMailArchivesTest.java

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthRetailDataTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthRetailDataTest.java?rev=1088489&r1=1088488&r2=1088489&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthRetailDataTest.java
(original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthRetailDataTest.java
Mon Apr  4 07:12:14 2011
@@ -17,8 +17,6 @@
 
 package org.apache.mahout.fpm.pfpgrowth;
 
-import static org.junit.Assert.assertEquals;
-
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -27,6 +25,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.hadoop.mapred.OutputCollector;
+import org.apache.mahout.common.MahoutTestCase;
 import org.apache.mahout.common.Pair;
 import org.apache.mahout.common.iterator.FileLineIterable;
 import org.apache.mahout.common.iterator.StringRecordIterator;
@@ -36,7 +35,8 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
-public class FPGrowthRetailDataTest {
+public final class FPGrowthRetailDataTest extends MahoutTestCase {
+
   @Test
   public void testSpecificCaseFromRetailDataMinSup500() throws IOException {
     FPGrowth<String> fp = new FPGrowth<String>();

Modified: mahout/trunk/utils/src/test/java/org/apache/mahout/text/MailArchivesClusteringAnalyzerTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/utils/src/test/java/org/apache/mahout/text/MailArchivesClusteringAnalyzerTest.java?rev=1088489&r1=1088488&r2=1088489&view=diff
==============================================================================
--- mahout/trunk/utils/src/test/java/org/apache/mahout/text/MailArchivesClusteringAnalyzerTest.java
(original)
+++ mahout/trunk/utils/src/test/java/org/apache/mahout/text/MailArchivesClusteringAnalyzerTest.java
Mon Apr  4 07:12:14 2011
@@ -16,19 +16,17 @@
  */
 package org.apache.mahout.text;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
 import java.io.StringReader;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.TermAttribute;
 
+import org.apache.mahout.utils.MahoutTestCase;
 import org.junit.Test;
 
 /**
  * Unit tests for the MailArchivesClusteringAnalyzer text analyzer.
  */
-public class MailArchivesClusteringAnalyzerTest {
+public class MailArchivesClusteringAnalyzerTest extends MahoutTestCase {
   
   @Test
   public void testAnalysis() throws Exception {

Modified: mahout/trunk/utils/src/test/java/org/apache/mahout/text/SequenceFilesFromMailArchivesTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/utils/src/test/java/org/apache/mahout/text/SequenceFilesFromMailArchivesTest.java?rev=1088489&r1=1088488&r2=1088489&view=diff
==============================================================================
--- mahout/trunk/utils/src/test/java/org/apache/mahout/text/SequenceFilesFromMailArchivesTest.java
(original)
+++ mahout/trunk/utils/src/test/java/org/apache/mahout/text/SequenceFilesFromMailArchivesTest.java
Mon Apr  4 07:12:14 2011
@@ -28,7 +28,7 @@ import org.apache.hadoop.io.Text;
 import org.apache.mahout.common.IOUtils;
 import org.apache.mahout.common.Pair;
 import org.apache.mahout.common.iterator.sequencefile.SequenceFileIterator;
-import org.junit.After;
+import org.apache.mahout.utils.MahoutTestCase;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,7 +36,7 @@ import org.junit.Test;
 /**
  * Test case for the SequenceFilesFromMailArchives command-line application.
  */
-public class SequenceFilesFromMailArchivesTest {
+public final class SequenceFilesFromMailArchivesTest extends MahoutTestCase {
   
   // TODO: Negative tests
 
@@ -48,11 +48,10 @@ public class SequenceFilesFromMailArchiv
    * the SequenceFilesFromMailArchives application.
    */
   @Before
-  public void setupBeforeTesting() throws IOException {
-    // tread-lightly, create folder names using the timestamp
-    long now = System.currentTimeMillis();
-    inputDir = createTempDir("mail-archives-"+now+"-in");
-    outputDir = createTempDir("mail-archives-"+now+"-out");
+  public void setUp() throws Exception {
+    super.setUp();
+    inputDir = getTestTempDir("mail-archives-in");
+    outputDir = getTestTempDir("mail-archives-out");
     
     // write test mail messages to a gzipped file in a nested directory
     File subDir = new File(inputDir, "subdir");
@@ -98,54 +97,18 @@ public class SequenceFilesFromMailArchiv
     Assert.assertTrue("First key/value pair not found!", iterator.hasNext());
     Pair<Text,Text> record = iterator.next();
 
-    Assert.assertEquals("TEST/subdir/mail-messages.gz/" + testVars[0][0], record.getFirst().toString());
+    File parentFile = new File(new File(new File("TEST"), "subdir"), "mail-messages.gz");
+    Assert.assertEquals(new File(parentFile, testVars[0][0]).toString(), record.getFirst().toString());
     Assert.assertEquals(testVars[0][1]+testVars[0][2], record.getSecond().toString());
 
     Assert.assertTrue("Second key/value pair not found!", iterator.hasNext());
     record = iterator.next();
-    Assert.assertEquals("TEST/subdir/mail-messages.gz/"+testVars[1][0], record.getFirst().toString());
+    Assert.assertEquals(new File(parentFile, testVars[1][0]).toString(), record.getFirst().toString());
     Assert.assertEquals(testVars[1][1]+testVars[1][2], record.getSecond().toString());
 
     Assert.assertFalse("Only two key/value pairs expected!", iterator.hasNext());
   }
 
-  @After
-  public void cleanupAfterTesting() {
-    if (inputDir != null) {
-      rmdir(inputDir);
-    }
-    if (outputDir != null) {
-      rmdir(outputDir);
-    }
-  }
-
-  // creates a temp directory for storing test input / output
-  // fails if the directory cannot be created
-  private static File createTempDir(String dirName) {
-    File tempDir = new File(System.getProperty("java.io.tmpdir"), dirName);
-    if (!tempDir.isDirectory()) {
-      tempDir.mkdirs();
-      if (!tempDir.isDirectory()) {
-        Assert.fail("Failed to create temp directory "+tempDir.getAbsolutePath());
-      }
-    }
-    return tempDir;
-  }
-
-  // recursively delete the temp directories created by this test
-  private static void rmdir(File dir) {
-    if (dir.isDirectory()) {
-      File[] files = dir.listFiles();
-      for (File file : files) {
-        if (file.isDirectory()) {
-          rmdir(file);
-        } else {
-          file.delete();
-        }
-      }
-    }
-    dir.delete();
-  }
   
   // Messages extracted and anonymized from the ASF mail archives
   private static final String[][] testVars = {



Mime
View raw message