[SQL] Use TestSQLContext in Java tests

Sometimes tests were failing due to the creation of multiple `SparkContext`s in a single JVM.

Author: Michael Armbrust <michael@databricks.com>

Closes #4441 from marmbrus/javaTests and squashes the following commits:

657b1e0 [Michael Armbrust] [SQL] Use TestSQLContext in Java tests
This commit is contained in:
Michael Armbrust 2015-02-06 15:11:02 -08:00
parent 61073f8321
commit 76c4bf59f6
2 changed files with 6 additions and 7 deletions

View file

@ -19,6 +19,7 @@ package org.apache.spark.sql.api.java;
import java.io.Serializable;
import org.apache.spark.sql.test.TestSQLContext$;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -37,14 +38,12 @@ public class JavaAPISuite implements Serializable {
@Before
public void setUp() {
sc = new JavaSparkContext("local", "JavaAPISuite");
sqlContext = new SQLContext(sc);
sqlContext = TestSQLContext$.MODULE$;
sc = new JavaSparkContext(sqlContext.sparkContext());
}
@After
public void tearDown() {
sc.stop();
sc = null;
}
@SuppressWarnings("unchecked")

View file

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.spark.sql.test.TestSQLContext$;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -42,13 +43,12 @@ public class JavaApplySchemaSuite implements Serializable {
@Before
public void setUp() {
javaCtx = new JavaSparkContext("local", "JavaApplySchemaSuite");
javaSqlCtx = new SQLContext(javaCtx);
javaSqlCtx = TestSQLContext$.MODULE$;
javaCtx = new JavaSparkContext(javaSqlCtx.sparkContext());
}
@After
public void tearDown() {
javaCtx.stop();
javaCtx = null;
javaSqlCtx = null;
}