Skip to content

Commit

Permalink
Test are good
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed Apr 8, 2014
1 parent 9e2d236 commit 8a67302
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/src/test/resources/classes1/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Manifest-Version: 1.0
Implementation-Vendor: fake-spark-class
Implementation-Title: fake spark class
Implementation-Version: 0.0.1
Implementation-Vendor-Id: fake-spark-class
Specification-Vendor: fake-spark-class
Specification-Title: fake spark class
Specification-Version: 0.0.1

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.repl

import java.io.File
import java.net.URLClassLoader

import org.scalatest.FunSuite

class ExecutorClassLoaderSuite extends FunSuite {

val spark_home = sys.env.get("SPARK_HOME").orElse(sys.props.get("spark.home")).get
val url1 = "file://" + spark_home + "/core/src/test/resources/classes1/"
val urls2 = List(new File(spark_home + "/core/src/test/resources/classes2/").toURI.toURL).toArray
test("child first") {
println("url1 "+url1)
val parentLoader = new URLClassLoader(urls2, null)
val classLoader = new ExecutorClassLoader(url1, parentLoader, true)
val fakeClass = classLoader.loadClass("org.apache.spark.test.FakeClass2").newInstance()
val fakeClassVersion = fakeClass.toString
assert(fakeClassVersion === "1")
}

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

0 comments on commit 8a67302

Please sign in to comment.