Skip to content

Commit 64e5551

Browse files
mengxryhuai
authored andcommitted
[SPARK-11672][ML] set active SQLContext in JavaDefaultReadWriteSuite
The same as #9694, but for Java test suite. yhuai Author: Xiangrui Meng <[email protected]> Closes #9719 from mengxr/SPARK-11672.4.
1 parent d22fc10 commit 64e5551

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mllib/src/test/java/org/apache/spark/ml/util/JavaDefaultReadWriteSuite.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,23 @@
3232
public class JavaDefaultReadWriteSuite {
3333

3434
JavaSparkContext jsc = null;
35+
SQLContext sqlContext = null;
3536
File tempDir = null;
3637

3738
@Before
3839
public void setUp() {
3940
jsc = new JavaSparkContext("local[2]", "JavaDefaultReadWriteSuite");
41+
SQLContext.clearActive();
42+
sqlContext = new SQLContext(jsc);
43+
SQLContext.setActive(sqlContext);
4044
tempDir = Utils.createTempDir(
4145
System.getProperty("java.io.tmpdir"), "JavaDefaultReadWriteSuite");
4246
}
4347

4448
@After
4549
public void tearDown() {
50+
sqlContext = null;
51+
SQLContext.clearActive();
4652
if (jsc != null) {
4753
jsc.stop();
4854
jsc = null;
@@ -64,7 +70,6 @@ public void testDefaultReadWrite() throws IOException {
6470
} catch (IOException e) {
6571
// expected
6672
}
67-
SQLContext sqlContext = new SQLContext(jsc);
6873
instance.write().context(sqlContext).overwrite().save(outputPath);
6974
MyParams newInstance = MyParams.load(outputPath);
7075
Assert.assertEquals("UID should match.", instance.uid(), newInstance.uid());

0 commit comments

Comments
 (0)