[SPARK-11672][ML] set active SQLContext in JavaDefaultReadWriteSuite

The same as #9694, but for Java test suite. yhuai

Author: Xiangrui Meng <meng@databricks.com>

Closes #9719 from mengxr/SPARK-11672.4.
This commit is contained in:
Xiangrui Meng 2015-11-15 13:23:05 -08:00 committed by Yin Huai
parent d22fc10887
commit 64e5551103

View file

@ -32,17 +32,23 @@ import org.apache.spark.util.Utils;
public class JavaDefaultReadWriteSuite {
JavaSparkContext jsc = null;
SQLContext sqlContext = null;
File tempDir = null;
@Before
public void setUp() {
jsc = new JavaSparkContext("local[2]", "JavaDefaultReadWriteSuite");
SQLContext.clearActive();
sqlContext = new SQLContext(jsc);
SQLContext.setActive(sqlContext);
tempDir = Utils.createTempDir(
System.getProperty("java.io.tmpdir"), "JavaDefaultReadWriteSuite");
}
@After
public void tearDown() {
sqlContext = null;
SQLContext.clearActive();
if (jsc != null) {
jsc.stop();
jsc = null;
@ -64,7 +70,6 @@ public class JavaDefaultReadWriteSuite {
} catch (IOException e) {
// expected
}
SQLContext sqlContext = new SQLContext(jsc);
instance.write().context(sqlContext).overwrite().save(outputPath);
MyParams newInstance = MyParams.load(outputPath);
Assert.assertEquals("UID should match.", instance.uid(), newInstance.uid());