Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8537#discussion_r38582751
  
    --- Diff: 
mllib/src/test/java/org/apache/spark/ml/source/JavaLibSVMRelationSuite.java ---
    @@ -0,0 +1,59 @@
    +package org.apache.spark.ml.source;
    +
    +import com.google.common.base.Charsets;
    +import com.google.common.io.Files;
    +import org.apache.spark.api.java.JavaSparkContext;
    +import org.apache.spark.mllib.linalg.Vectors;
    +import org.apache.spark.sql.DataFrame;
    +import org.apache.spark.sql.Row;
    +import org.apache.spark.sql.SQLContext;
    +import org.apache.spark.util.Utils;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import java.io.File;
    +import java.io.IOException;
    +
    +/**
    + * Test LibSVMRelation in Java.
    + */
    +public class JavaLibSVMRelationSuite {
    +  private transient JavaSparkContext jsc;
    +  private transient SQLContext jsql;
    +  private transient DataFrame dataset;
    +
    +  private File path;
    +
    +  @Before
    +  public void setUp() throws IOException {
    +    jsc = new JavaSparkContext("local", "JavaLibSVMRelationSuite");
    +    jsql = new SQLContext(jsc);
    +
    +    path = Utils.createTempDir(System.getProperty("java.io.tmpdir"),
    +      "datasource").getCanonicalFile();
    +    if (path.exists()) {
    +      path.delete();
    +    }
    +
    +    String s = "1 1:1.0 3:2.0 5:3.0\n0\n0 2:4.0 4:5.0 6:6.0";
    +    Files.write(s, path, Charsets.US_ASCII);
    +  }
    +
    +  @After
    +  public void tearDown() {
    +    jsc.stop();
    +    jsc = null;
    +  }
    +
    +  @Test
    +  public void verifyLibSvmDF() {
    +    dataset = jsql.read().format("libsvm").load();
    +    Assert.assertEquals(dataset.columns()[0], "label");
    +    Assert.assertEquals(dataset.columns()[1], "features");
    +    Row r = dataset.first();
    +    Assert.assertTrue(r.getDouble(0) == 1.0);
    --- End diff --
    
    use `assertEquals`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to