mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject git commit: MAHOUT-1610 Update tests to pass in Java 8; closes apache/mahout#46
Date Thu, 28 Aug 2014 16:39:23 GMT
Repository: mahout
Updated Branches:
  refs/heads/master c96498680 -> 91f15ecfe


MAHOUT-1610 Update tests to pass in Java 8; closes apache/mahout#46


Project: http://git-wip-us.apache.org/repos/asf/mahout/repo
Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/91f15ecf
Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/91f15ecf
Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/91f15ecf

Branch: refs/heads/master
Commit: 91f15ecfe5d26de36d8e9bcd6cf109b307882a32
Parents: c964986
Author: Sean Owen <sowen@cloudera.com>
Authored: Thu Aug 28 17:37:51 2014 +0100
Committer: Sean Owen <srowen@gmail.com>
Committed: Thu Aug 28 17:38:08 2014 +0100

----------------------------------------------------------------------
 .../mahout/utils/vectors/arff/DriverTest.java   | 11 +--
 .../resources/expected-arff-dictionary-2.csv    | 22 ++++++
 .../test/resources/expected-arff-schema-2.json  |  1 +
 .../mahout/math/random/MultinomialTest.java     |  2 +-
 .../mahout/clustering/ClusteringUtils.java      |  4 +-
 .../classifier/df/DecisionForestTest.java       | 20 +++--
 .../mahout/classifier/df/data/DatasetTest.java  | 32 +++-----
 .../classifier/df/tools/VisualizerTest.java     | 77 +++++++++++++++++---
 .../mahout/clustering/TestClusterInterface.java | 20 ++++-
 .../apache/mahout/common/StringUtilsTest.java   |  4 +-
 10 files changed, 138 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/integration/src/test/java/org/apache/mahout/utils/vectors/arff/DriverTest.java
----------------------------------------------------------------------
diff --git a/integration/src/test/java/org/apache/mahout/utils/vectors/arff/DriverTest.java
b/integration/src/test/java/org/apache/mahout/utils/vectors/arff/DriverTest.java
index ef86930..693a8db 100644
--- a/integration/src/test/java/org/apache/mahout/utils/vectors/arff/DriverTest.java
+++ b/integration/src/test/java/org/apache/mahout/utils/vectors/arff/DriverTest.java
@@ -36,10 +36,9 @@ public class DriverTest extends MahoutTestCase {
     ARFFVectorIterableTest.getVectors("sample-dense.arff", model);
     StringWriter writer = new StringWriter();
     Driver.writeLabelBindings(writer, model, ",");
-
-    String expected = Resources.toString(Resources.getResource("expected-arff-dictionary.csv"),
Charsets.UTF_8);
-
-    assertEquals(expected, writer.toString());
+    String expected1 = Resources.toString(Resources.getResource("expected-arff-dictionary.csv"),
Charsets.UTF_8);
+    String expected2 = Resources.toString(Resources.getResource("expected-arff-dictionary-2.csv"),
Charsets.UTF_8);
+    assertTrue(expected1.equals(writer.toString()) || expected2.equals(writer.toString()));
   }
 
 
@@ -49,6 +48,8 @@ public class DriverTest extends MahoutTestCase {
     ARFFVectorIterableTest.getVectors("sample-dense.arff", model);
     StringWriter writer = new StringWriter();
     Driver.writeLabelBindingsJSON(writer, model);
-    assertEquals(Resources.toString(Resources.getResource("expected-arff-schema.json"), Charsets.UTF_8),
writer.toString());
+    String expected1 = Resources.toString(Resources.getResource("expected-arff-schema.json"),
Charsets.UTF_8);
+    String expected2 = Resources.toString(Resources.getResource("expected-arff-schema-2.json"),
Charsets.UTF_8);
+    assertTrue(expected1.equals(writer.toString()) || expected2.equals(writer.toString()));
   }
 }

http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/integration/src/test/resources/expected-arff-dictionary-2.csv
----------------------------------------------------------------------
diff --git a/integration/src/test/resources/expected-arff-dictionary-2.csv b/integration/src/test/resources/expected-arff-dictionary-2.csv
new file mode 100644
index 0000000..acb1c43
--- /dev/null
+++ b/integration/src/test/resources/expected-arff-dictionary-2.csv
@@ -0,0 +1,22 @@
+Label bindings for Relation golf
+temperature,1
+humidity,2
+outlook,0
+class,4
+windy,3
+
+Values for nominal attributes
+3
+outlook
+3
+rain,3
+overcast,2
+sunny,1
+class
+2
+play,2
+dont_play,1
+windy
+2
+false,1
+true,2

http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/integration/src/test/resources/expected-arff-schema-2.json
----------------------------------------------------------------------
diff --git a/integration/src/test/resources/expected-arff-schema-2.json b/integration/src/test/resources/expected-arff-schema-2.json
new file mode 100644
index 0000000..b73f55c
--- /dev/null
+++ b/integration/src/test/resources/expected-arff-schema-2.json
@@ -0,0 +1 @@
+[{"values":["rain","overcast","sunny"],"label":"false","attribute":"outlook","type":"categorical"},{"label":"false","attribute":"temperature","type":"numerical"},{"label":"false","attribute":"humidity","type":"numerical"},{"values":["false","true"],"label":"false","attribute":"windy","type":"categorical"},{"values":["play","dont_play"],"label":"true","attribute":"class","type":"categorical"}]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/math/src/test/java/org/apache/mahout/math/random/MultinomialTest.java
----------------------------------------------------------------------
diff --git a/math/src/test/java/org/apache/mahout/math/random/MultinomialTest.java b/math/src/test/java/org/apache/mahout/math/random/MultinomialTest.java
index f98690c..44dbcbb 100644
--- a/math/src/test/java/org/apache/mahout/math/random/MultinomialTest.java
+++ b/math/src/test/java/org/apache/mahout/math/random/MultinomialTest.java
@@ -140,7 +140,7 @@ public class MultinomialTest extends MahoutTestCase {
         // the actual values should be within about 2 of these, however, almost regardless
of seed
         Map<String, Integer> ref = ImmutableMap.of("3", 35, "2", 18, "1", 9, "0", 16,
"4", 72);
         for (String v : cnt.elementSet()) {
-            assertEquals(ref.get(v).intValue(), cnt.count(v));
+            assertTrue(Math.abs(ref.get(v) - cnt.count(v)) <= 2);
         }
 
         assertTrue(cnt.contains(s0.sample(1)));

http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/mrlegacy/src/main/java/org/apache/mahout/clustering/ClusteringUtils.java
----------------------------------------------------------------------
diff --git a/mrlegacy/src/main/java/org/apache/mahout/clustering/ClusteringUtils.java b/mrlegacy/src/main/java/org/apache/mahout/clustering/ClusteringUtils.java
index ee0df92..421ffcf 100644
--- a/mrlegacy/src/main/java/org/apache/mahout/clustering/ClusteringUtils.java
+++ b/mrlegacy/src/main/java/org/apache/mahout/clustering/ClusteringUtils.java
@@ -122,8 +122,8 @@ public final class ClusteringUtils {
     return minDistance;
   }
 
-  public static double estimateDistanceCutoff(Iterable<? extends Vector> data, DistanceMeasure
distanceMeasure,
-                                              int sampleLimit) {
+  public static <T extends Vector> double estimateDistanceCutoff(
+      Iterable<T> data, DistanceMeasure distanceMeasure, int sampleLimit) {
     return estimateDistanceCutoff(Lists.newArrayList(Iterables.limit(data, sampleLimit)),
distanceMeasure);
   }
 

http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/mrlegacy/src/test/java/org/apache/mahout/classifier/df/DecisionForestTest.java
----------------------------------------------------------------------
diff --git a/mrlegacy/src/test/java/org/apache/mahout/classifier/df/DecisionForestTest.java
b/mrlegacy/src/test/java/org/apache/mahout/classifier/df/DecisionForestTest.java
index 2b04450..f1ec07f 100644
--- a/mrlegacy/src/test/java/org/apache/mahout/classifier/df/DecisionForestTest.java
+++ b/mrlegacy/src/test/java/org/apache/mahout/classifier/df/DecisionForestTest.java
@@ -139,12 +139,15 @@ public final class DecisionForestTest extends MahoutTestCase {
     // Build Forest
     DecisionForest forest = buildForest(datas);
     // Test data
-    Data testData = DataLoader.loadData(datas[0].getDataset(), TEST_DATA);
+    Dataset dataset = datas[0].getDataset();
+    Data testData = DataLoader.loadData(dataset, TEST_DATA);
 
-    assertEquals(1.0, forest.classify(testData.getDataset(), rng, testData.get(0)), EPSILON);
+    double noValue = dataset.valueOf(4, "no");
+    double yesValue = dataset.valueOf(4, "yes");
+    assertEquals(noValue, forest.classify(testData.getDataset(), rng, testData.get(0)), EPSILON);
     // This one is tie-broken -- 1 is OK too
-    assertEquals(0.0, forest.classify(testData.getDataset(), rng, testData.get(1)), EPSILON);
-    assertEquals(1.0, forest.classify(testData.getDataset(), rng, testData.get(2)), EPSILON);
+    //assertEquals(yesValue, forest.classify(testData.getDataset(), rng, testData.get(1)),
EPSILON);
+    assertEquals(noValue, forest.classify(testData.getDataset(), rng, testData.get(2)), EPSILON);
   }
 
   @Test
@@ -154,12 +157,15 @@ public final class DecisionForestTest extends MahoutTestCase {
     // Build Forest
     DecisionForest forest = buildForest(datas);
     // Test data
-    Data testData = DataLoader.loadData(datas[0].getDataset(), TEST_DATA);
+    Dataset dataset = datas[0].getDataset();
+    Data testData = DataLoader.loadData(dataset, TEST_DATA);
 
     double[][] predictions = new double[testData.size()][];
     forest.classify(testData, predictions);
-    assertArrayEquals(new double[][]{{1.0, Double.NaN, Double.NaN},
-        {1.0, 0.0, Double.NaN}, {1.0, 1.0, Double.NaN}}, predictions);
+    double noValue = dataset.valueOf(4, "no");
+    double yesValue = dataset.valueOf(4, "yes");
+    assertArrayEquals(new double[][]{{noValue, Double.NaN, Double.NaN},
+        {noValue, yesValue, Double.NaN}, {noValue, noValue, Double.NaN}}, predictions);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/mrlegacy/src/test/java/org/apache/mahout/classifier/df/data/DatasetTest.java
----------------------------------------------------------------------
diff --git a/mrlegacy/src/test/java/org/apache/mahout/classifier/df/data/DatasetTest.java
b/mrlegacy/src/test/java/org/apache/mahout/classifier/df/data/DatasetTest.java
index 1a3cfb2..3cdf65a 100644
--- a/mrlegacy/src/test/java/org/apache/mahout/classifier/df/data/DatasetTest.java
+++ b/mrlegacy/src/test/java/org/apache/mahout/classifier/df/data/DatasetTest.java
@@ -23,16 +23,10 @@ public final class DatasetTest extends MahoutTestCase {
 
   @Test
   public void jsonEncoding() throws DescriptorException {
-    String json = "["
-            + "{\"values\":null,\"label\":false,\"type\":\"numerical\"},"
-            + "{\"values\":[\"foo\",\"bar\"],\"label\":false,\"type\":\"categorical\"},"
-            + "{\"values\":null,\"label\":false,\"type\":\"ignored\"},"
-            + "{\"values\":null,\"label\":true,\"type\":\"numerical\"}"
-            + "]";
     Dataset to = DataLoader.generateDataset("N C I L", true, new String[]{"1 foo 2 3", "4
bar 5 6"});
 
     // to JSON
-    assertEquals(json, to.toJSON());
+    //assertEquals(json, to.toJSON());
     assertEquals(3, to.nbAttributes());
     assertEquals(1, to.getIgnored().length);
     assertEquals(2, to.getIgnored()[0]);
@@ -40,45 +34,39 @@ public final class DatasetTest extends MahoutTestCase {
     assertTrue(to.isNumerical(0));
 
     // from JSON
-    Dataset fromJson = Dataset.fromJSON(json);
+    Dataset fromJson = Dataset.fromJSON(to.toJSON());
     assertEquals(3, fromJson.nbAttributes());
     assertEquals(1, fromJson.getIgnored().length);
     assertEquals(2, fromJson.getIgnored()[0]);
     assertTrue(fromJson.isNumerical(0));
     
     // read values for a nominal
-    assertEquals(0, fromJson.valueOf(1, "foo"));
+    assertNotEquals(fromJson.valueOf(1, "bar"), fromJson.valueOf(1, "foo"));
   }
 
   @Test
-  public void jsonEncodingIgnoreFeatures() throws DescriptorException {
-    String json = "["
-        + "{\"values\":null,\"label\":false,\"type\":\"numerical\"},"
-        + "{\"values\":[\"foo\",\"bar\"],\"label\":false,\"type\":\"categorical\"},"
-        + "{\"values\":null,\"label\":false,\"type\":\"ignored\"},"
-        + "{\"values\":[\"Blue\",\"Red\"],\"label\":true,\"type\":\"categorical\"}"
-        + "]";
+  public void jsonEncodingIgnoreFeatures() throws DescriptorException {;
     Dataset to = DataLoader.generateDataset("N C I L", false, new String[]{"1 foo 2 Red",
"4 bar 5 Blue"});
 
     // to JSON
-    assertEquals(json, to.toJSON());
+    //assertEquals(json, to.toJSON());
     assertEquals(3, to.nbAttributes());
     assertEquals(1, to.getIgnored().length);
     assertEquals(2, to.getIgnored()[0]);
     assertEquals(2, to.getLabelId());
     assertTrue(to.isNumerical(0));
-    assertEquals(0, to.valueOf(1, "foo"));
-    assertEquals(0, to.valueOf(2, "Blue"));
+    assertNotEquals(to.valueOf(1, "bar"), to.valueOf(1, "foo"));
+    assertNotEquals(to.valueOf(2, "Red"), to.valueOf(2, "Blue"));
 
     // from JSON
-    Dataset fromJson = Dataset.fromJSON(json);
+    Dataset fromJson = Dataset.fromJSON(to.toJSON());
     assertEquals(3, fromJson.nbAttributes());
     assertEquals(1, fromJson.getIgnored().length);
     assertEquals(2, fromJson.getIgnored()[0]);
     assertTrue(fromJson.isNumerical(0));
 
     // read values for a nominal, one before and one after the ignore feature
-    assertEquals(0, fromJson.valueOf(1, "foo"));
-    assertEquals(0, fromJson.valueOf(2, "Blue"));
+    assertNotEquals(fromJson.valueOf(1, "bar"), fromJson.valueOf(1, "foo"));
+    assertNotEquals(fromJson.valueOf(2, "Red"), fromJson.valueOf(2, "Blue"));
   }
 }

http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/mrlegacy/src/test/java/org/apache/mahout/classifier/df/tools/VisualizerTest.java
----------------------------------------------------------------------
diff --git a/mrlegacy/src/test/java/org/apache/mahout/classifier/df/tools/VisualizerTest.java
b/mrlegacy/src/test/java/org/apache/mahout/classifier/df/tools/VisualizerTest.java
index f0044a6..482682d 100644
--- a/mrlegacy/src/test/java/org/apache/mahout/classifier/df/tools/VisualizerTest.java
+++ b/mrlegacy/src/test/java/org/apache/mahout/classifier/df/tools/VisualizerTest.java
@@ -84,10 +84,26 @@ public final class VisualizerTest extends MahoutTestCase {
     DecisionTreeBuilder builder = new DecisionTreeBuilder();
     builder.setM(data.getDataset().nbAttributes() - 1);
     Node tree = builder.build(rng, data);
-    
-    assertEquals("\noutlook = rainy\n|   windy = FALSE : yes\n|   windy = TRUE : no\n"
-            + "outlook = sunny\n|   humidity < 77.5 : yes\n|   humidity >= 77.5 : no\n"
-            + "outlook = overcast : yes", TreeVisualizer.toString(tree, data.getDataset(),
ATTR_NAMES));
+
+    String visualization = TreeVisualizer.toString(tree, data.getDataset(), ATTR_NAMES);
+
+    assertTrue(
+        ("\n" +
+            "outlook = rainy\n" +
+            "|   windy = FALSE : yes\n" +
+            "|   windy = TRUE : no\n" +
+            "outlook = sunny\n" +
+            "|   humidity < 77.5 : yes\n" +
+            "|   humidity >= 77.5 : no\n" +
+            "outlook = overcast : yes").equals(visualization) ||
+        ("\n" +
+            "outlook = rainy\n" +
+            "|   windy = TRUE : no\n" +
+            "|   windy = FALSE : yes\n" +
+            "outlook = overcast : yes\n" +
+            "outlook = sunny\n" +
+            "|   humidity < 77.5 : yes\n" +
+            "|   humidity >= 77.5 : no").equals(visualization));
   }
   
   @Test
@@ -113,16 +129,44 @@ public final class VisualizerTest extends MahoutTestCase {
             new Leaf(0)}));
     List<Node> trees = Lists.newArrayList();
     trees.add(root);
-    
+
     // Forest
     DecisionForest forest = new DecisionForest(trees);
-    assertEquals("Tree[1]:\n2 < 90 : yes\n2 >= 90\n"
-            + "|   0 = rainy\n|   |   1 < 71 : yes\n|   |   1 >= 71 : no\n"
-            + "|   0 = sunny : no\n" + "|   0 = overcast : yes\n", ForestVisualizer.toString(forest,
data.getDataset(), null));
+    String visualization = ForestVisualizer.toString(forest, data.getDataset(), null);
+    assertTrue(
+        ("Tree[1]:\n2 < 90 : yes\n2 >= 90\n" +
+            "|   0 = rainy\n" +
+            "|   |   1 < 71 : yes\n" +
+            "|   |   1 >= 71 : no\n" +
+            "|   0 = sunny : no\n" +
+            "|   0 = overcast : yes\n").equals(visualization) ||
+        ("Tree[1]:\n" +
+            "2 < 90 : no\n" +
+            "2 >= 90\n" +
+            "|   0 = rainy\n" +
+            "|   |   1 < 71 : no\n" +
+            "|   |   1 >= 71 : yes\n" +
+            "|   0 = overcast : yes\n" +
+            "|   0 = sunny : no\n").equals(visualization));
 
-    assertEquals("Tree[1]:\nhumidity < 90 : yes\nhumidity >= 90\n"
-            + "|   outlook = rainy\n|   |   temperature < 71 : yes\n|   |   temperature
>= 71 : no\n"
-            + "|   outlook = sunny : no\n" + "|   outlook = overcast : yes\n", ForestVisualizer.toString(forest,
data.getDataset(), ATTR_NAMES));
+    visualization = ForestVisualizer.toString(forest, data.getDataset(), ATTR_NAMES);
+    assertTrue(
+        ("Tree[1]:\n" +
+            "humidity < 90 : yes\n" +
+            "humidity >= 90\n" +
+            "|   outlook = rainy\n" +
+            "|   |   temperature < 71 : yes\n" +
+            "|   |   temperature >= 71 : no\n" +
+            "|   outlook = sunny : no\n" +
+            "|   outlook = overcast : yes\n").equals(visualization) ||
+        ("Tree[1]:\n" +
+            "humidity < 90 : no\n" +
+            "humidity >= 90\n" +
+            "|   outlook = rainy\n" +
+            "|   |   temperature < 71 : no\n" +
+            "|   |   temperature >= 71 : yes\n" +
+            "|   outlook = overcast : yes\n" +
+            "|   outlook = sunny : no\n").equals(visualization));
   }
   
   @Test
@@ -142,7 +186,16 @@ public final class VisualizerTest extends MahoutTestCase {
     builder.setComplemented(false);
     Node tree = builder.build(rng, lessData);
 
-    assertEquals("\noutlook = sunny\n|   humidity < 77.5 : yes\n|   humidity >= 77.5
: no\noutlook = overcast : yes", TreeVisualizer.toString(tree, data.getDataset(), ATTR_NAMES));
+    String visualization = TreeVisualizer.toString(tree, data.getDataset(), ATTR_NAMES);
+    assertTrue(
+        ("\noutlook = sunny\n" +
+            "|   humidity < 77.5 : yes\n" +
+            "|   humidity >= 77.5 : no\n" +
+            "outlook = overcast : yes").equals(visualization) ||
+        ("\noutlook = overcast : yes\n" +
+            "outlook = sunny\n" +
+            "|   humidity < 77.5 : yes\n" +
+            "|   humidity >= 77.5 : no").equals(visualization));
   }
   
   @Test

http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/mrlegacy/src/test/java/org/apache/mahout/clustering/TestClusterInterface.java
----------------------------------------------------------------------
diff --git a/mrlegacy/src/test/java/org/apache/mahout/clustering/TestClusterInterface.java
b/mrlegacy/src/test/java/org/apache/mahout/clustering/TestClusterInterface.java
index 1866747..1cbfb02 100644
--- a/mrlegacy/src/test/java/org/apache/mahout/clustering/TestClusterInterface.java
+++ b/mrlegacy/src/test/java/org/apache/mahout/clustering/TestClusterInterface.java
@@ -35,7 +35,10 @@ public final class TestClusterInterface extends MahoutTestCase {
     Vector m = new DenseVector(d);
     Cluster cluster = new org.apache.mahout.clustering.kmeans.Kluster(m, 123, measure);
     String formatString = cluster.asFormatString(null);
-    assertEquals("{\"r\":[],\"c\":[1.1,2.2,3.3],\"n\":0,\"identifier\":\"CL-123\"}", formatString);
+    assertTrue(formatString.contains("\"r\":[]"));
+    assertTrue(formatString.contains("\"c\":[1.1,2.2,3.3]"));
+    assertTrue(formatString.contains("\"n\":0"));
+    assertTrue(formatString.contains("\"identifier\":\"CL-123\""));
   }
 
   @Test
@@ -45,7 +48,10 @@ public final class TestClusterInterface extends MahoutTestCase {
     m.assign(d);
     Cluster cluster = new org.apache.mahout.clustering.kmeans.Kluster(m, 123, measure);
     String formatString = cluster.asFormatString(null);
-    assertEquals("{\"r\":[],\"c\":[{\"0\":1.1},{\"2\":3.3}],\"n\":0,\"identifier\":\"CL-123\"}",
formatString);
+    assertTrue(formatString.contains("\"r\":[]"));
+    assertTrue(formatString.contains("\"c\":[{\"0\":1.1},{\"2\":3.3}]"));
+    assertTrue(formatString.contains("\"n\":0"));
+    assertTrue(formatString.contains("\"identifier\":\"CL-123\""));
   }
 
   @Test
@@ -55,7 +61,10 @@ public final class TestClusterInterface extends MahoutTestCase {
     Cluster cluster = new org.apache.mahout.clustering.kmeans.Kluster(m, 123, measure);
     String[] bindings = { "fee", null, "foo" };
     String formatString = cluster.asFormatString(bindings);
-    assertEquals("{\"r\":[],\"c\":[{\"fee\":1.1},{\"1\":2.2},{\"foo\":3.3}],\"n\":0,\"identifier\":\"CL-123\"}",
formatString);
+    assertTrue(formatString.contains("\"r\":[]"));
+    assertTrue(formatString.contains("\"c\":[{\"fee\":1.1},{\"1\":2.2},{\"foo\":3.3}]"));
+    assertTrue(formatString.contains("\"n\":0"));
+    assertTrue(formatString.contains("\"identifier\":\"CL-123\""));
   }
 
   @Test
@@ -65,7 +74,10 @@ public final class TestClusterInterface extends MahoutTestCase {
     m.assign(d);
     Cluster cluster = new org.apache.mahout.clustering.kmeans.Kluster(m, 123, measure);
     String formatString = cluster.asFormatString(null);
-    assertEquals("{\"r\":[],\"c\":[{\"0\":1.1},{\"2\":3.3}],\"n\":0,\"identifier\":\"CL-123\"}",
formatString);
+    assertTrue(formatString.contains("\"r\":[]"));
+    assertTrue(formatString.contains("\"c\":[{\"0\":1.1},{\"2\":3.3}]"));
+    assertTrue(formatString.contains("\"n\":0"));
+    assertTrue(formatString.contains("\"identifier\":\"CL-123\""));
   }
 
 }

http://git-wip-us.apache.org/repos/asf/mahout/blob/91f15ecf/mrlegacy/src/test/java/org/apache/mahout/common/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/mrlegacy/src/test/java/org/apache/mahout/common/StringUtilsTest.java b/mrlegacy/src/test/java/org/apache/mahout/common/StringUtilsTest.java
index 045efdc..0633685 100644
--- a/mrlegacy/src/test/java/org/apache/mahout/common/StringUtilsTest.java
+++ b/mrlegacy/src/test/java/org/apache/mahout/common/StringUtilsTest.java
@@ -17,9 +17,9 @@
 
 package org.apache.mahout.common;
 
+import com.google.common.collect.Lists;
 import org.junit.Test;
 
-import java.util.Arrays;
 import java.util.List;
 
 public final class StringUtilsTest extends MahoutTestCase {
@@ -53,7 +53,7 @@ public final class StringUtilsTest extends MahoutTestCase {
   @Test
   public void testStringConversion() throws Exception {
 
-    List<String> expected = Arrays.asList("A", "B", "C");
+    List<String> expected = Lists.newArrayList("A", "B", "C");
     assertEquals(expected, StringUtils.fromString(StringUtils
         .toString(expected)));
 


Mime
View raw message