Skip to content

Commit

Permalink
Fix the core/src/test/scala/org/apache/spark/executor/ExecutorURLClas…
Browse files Browse the repository at this point in the history
…sLoaderSuite.scala tests
  • Loading branch information
holdenk committed Apr 8, 2014
1 parent 204b199 commit f0b7114
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ import org.apache.spark.TestUtils

class ExecutorURLClassLoaderSuite extends FunSuite {

val classNames = List("org.apache.spark.test.FakeClass1",
"org.apache.spark.test.FakeClass2")
val urls = List(TestUtils.createJarWithClassesAndValue(classNames, 1)).toArray
val urls2 = List(TestUtils.createJarWithClassesAndValue(classNames, 2)).toArray
val childClassNames = List("FakeClass1", "FakeClass2")
val parentClassNames = List("FakeClass1", "FakeClass2", "FakeClass3")
val urls = List(TestUtils.createJarWithClassesAndValue(childClassNames, 1)).toArray
val urls2 = List(TestUtils.createJarWithClassesAndValue(parentClassNames, 2)).toArray

test("child first") {
val parentLoader = new URLClassLoader(urls2, null)
val classLoader = new ChildExecutorURLClassLoader(urls, parentLoader)
val fakeClass = classLoader.loadClass("org.apache.spark.test.FakeClass2").newInstance()
val fakeClass = classLoader.loadClass("FakeClass2").newInstance()
val fakeClassVersion = fakeClass.toString
assert(fakeClassVersion === "1")
}

test("parent first") {
val parentLoader = new URLClassLoader(urls2, null)
val classLoader = new ExecutorURLClassLoader(urls, parentLoader)
val fakeClass = classLoader.loadClass("org.apache.spark.test.FakeClass1").newInstance()
val fakeClass = classLoader.loadClass("FakeClass1").newInstance()
val fakeClassVersion = fakeClass.toString
assert(fakeClassVersion === "2")
}

test("child first can fall back") {
val parentLoader = new URLClassLoader(urls2, null)
val classLoader = new ChildExecutorURLClassLoader(urls, parentLoader)
val fakeClass = classLoader.loadClass("org.apache.spark.test.FakeClass3").newInstance()
val fakeClass = classLoader.loadClass("FakeClass3").newInstance()
val fakeClassVersion = fakeClass.toString
assert(fakeClassVersion === "2")
}
Expand All @@ -59,7 +59,7 @@ class ExecutorURLClassLoaderSuite extends FunSuite {
val parentLoader = new URLClassLoader(urls2, null)
val classLoader = new ChildExecutorURLClassLoader(urls, parentLoader)
intercept[java.lang.ClassNotFoundException] {
classLoader.loadClass("org.apache.spark.test.FakeClassDoesNotExist").newInstance()
classLoader.loadClass("FakeClassDoesNotExist").newInstance()
}
}

Expand Down

0 comments on commit f0b7114

Please sign in to comment.