Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import java.nio.charset.StandardCharsets
import java.nio.file.{Paths, StandardOpenOption}
import java.util

import scala.concurrent.duration._
import scala.io.Source
import scala.language.implicitConversions

Expand All @@ -34,8 +33,6 @@ import org.mockito.Mockito._
import org.mockito.invocation.InvocationOnMock
import org.mockito.stubbing.Answer
import org.scalatest.BeforeAndAfterAll
import org.scalatest.concurrent.Interruptor
import org.scalatest.concurrent.Timeouts._
import org.scalatest.mock.MockitoSugar

import org.apache.spark._
Expand All @@ -61,7 +58,7 @@ class ExecutorClassLoaderSuite
super.beforeAll()
tempDir1 = Utils.createTempDir()
tempDir2 = Utils.createTempDir()
url1 = "file://" + tempDir1
url1 = tempDir1.toURI.toURL.toString
urls2 = List(tempDir2.toURI.toURL).toArray
childClassNames.foreach(TestUtils.createCompiledClass(_, tempDir1, "1"))
parentResourceNames.foreach { x =>
Expand Down Expand Up @@ -118,8 +115,14 @@ class ExecutorClassLoaderSuite
val resourceName: String = parentResourceNames.head
val is = classLoader.getResourceAsStream(resourceName)
assert(is != null, s"Resource $resourceName not found")
val content = Source.fromInputStream(is, "UTF-8").getLines().next()
assert(content.contains("resource"), "File doesn't contain 'resource'")

val bufferedSource = Source.fromInputStream(is, "UTF-8")
Utils.tryWithSafeFinally {
val content = bufferedSource.getLines().next()
assert(content.contains("resource"), "File doesn't contain 'resource'")
} {
bufferedSource.close()
}
}

test("resources from parent") {
Expand All @@ -128,8 +131,14 @@ class ExecutorClassLoaderSuite
val resourceName: String = parentResourceNames.head
val resources: util.Enumeration[URL] = classLoader.getResources(resourceName)
assert(resources.hasMoreElements, s"Resource $resourceName not found")
val fileReader = Source.fromInputStream(resources.nextElement().openStream()).bufferedReader()
assert(fileReader.readLine().contains("resource"), "File doesn't contain 'resource'")

val bufferedSource = Source.fromInputStream(resources.nextElement().openStream())
Utils.tryWithSafeFinally {
val fileReader = bufferedSource.bufferedReader()
assert(fileReader.readLine().contains("resource"), "File doesn't contain 'resource'")
} {
bufferedSource.close()
}
}

test("fetch classes using Spark's RpcEnv") {
Expand Down