@@ -19,27 +19,20 @@ package org.apache.spark
1919
2020import org .scalatest .FunSuite
2121import org .apache .spark .serializer .{KryoRegistrator , KryoSerializer }
22+ import org .apache .spark .util .ResetSystemProperties
2223import com .esotericsoftware .kryo .Kryo
2324
24- class SparkConfSuite extends FunSuite with LocalSparkContext {
25+ class SparkConfSuite extends FunSuite with LocalSparkContext with ResetSystemProperties {
2526 test(" loading from system properties" ) {
26- try {
27- System .setProperty(" spark.test.testProperty" , " 2" )
28- val conf = new SparkConf ()
29- assert(conf.get(" spark.test.testProperty" ) === " 2" )
30- } finally {
31- System .clearProperty(" spark.test.testProperty" )
32- }
27+ System .setProperty(" spark.test.testProperty" , " 2" )
28+ val conf = new SparkConf ()
29+ assert(conf.get(" spark.test.testProperty" ) === " 2" )
3330 }
3431
3532 test(" initializing without loading defaults" ) {
36- try {
37- System .setProperty(" spark.test.testProperty" , " 2" )
38- val conf = new SparkConf (false )
39- assert(! conf.contains(" spark.test.testProperty" ))
40- } finally {
41- System .clearProperty(" spark.test.testProperty" )
42- }
33+ System .setProperty(" spark.test.testProperty" , " 2" )
34+ val conf = new SparkConf (false )
35+ assert(! conf.contains(" spark.test.testProperty" ))
4336 }
4437
4538 test(" named set methods" ) {
@@ -117,23 +110,17 @@ class SparkConfSuite extends FunSuite with LocalSparkContext {
117110
118111 test(" nested property names" ) {
119112 // This wasn't supported by some external conf parsing libraries
120- try {
121- System .setProperty(" spark.test.a" , " a" )
122- System .setProperty(" spark.test.a.b" , " a.b" )
123- System .setProperty(" spark.test.a.b.c" , " a.b.c" )
124- val conf = new SparkConf ()
125- assert(conf.get(" spark.test.a" ) === " a" )
126- assert(conf.get(" spark.test.a.b" ) === " a.b" )
127- assert(conf.get(" spark.test.a.b.c" ) === " a.b.c" )
128- conf.set(" spark.test.a.b" , " A.B" )
129- assert(conf.get(" spark.test.a" ) === " a" )
130- assert(conf.get(" spark.test.a.b" ) === " A.B" )
131- assert(conf.get(" spark.test.a.b.c" ) === " a.b.c" )
132- } finally {
133- System .clearProperty(" spark.test.a" )
134- System .clearProperty(" spark.test.a.b" )
135- System .clearProperty(" spark.test.a.b.c" )
136- }
113+ System .setProperty(" spark.test.a" , " a" )
114+ System .setProperty(" spark.test.a.b" , " a.b" )
115+ System .setProperty(" spark.test.a.b.c" , " a.b.c" )
116+ val conf = new SparkConf ()
117+ assert(conf.get(" spark.test.a" ) === " a" )
118+ assert(conf.get(" spark.test.a.b" ) === " a.b" )
119+ assert(conf.get(" spark.test.a.b.c" ) === " a.b.c" )
120+ conf.set(" spark.test.a.b" , " A.B" )
121+ assert(conf.get(" spark.test.a" ) === " a" )
122+ assert(conf.get(" spark.test.a.b" ) === " A.B" )
123+ assert(conf.get(" spark.test.a.b.c" ) === " a.b.c" )
137124 }
138125
139126 test(" register kryo classes through registerKryoClasses" ) {
0 commit comments