Skip to content

Commit fc5e94d

Browse files
committed
Remove EasyMock in CacheManagerSuite
1 parent dae2161 commit fc5e94d

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

core/src/test/scala/org/apache/spark/CacheManagerSuite.scala

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717

1818
package org.apache.spark
1919

20+
import org.mockito.Mockito._
2021
import org.scalatest.{BeforeAndAfter, FunSuite}
21-
import org.scalatest.mock.EasyMockSugar
22+
import org.scalatest.mock.MockitoSugar
2223

2324
import org.apache.spark.executor.{DataReadMethod, TaskMetrics}
2425
import org.apache.spark.rdd.RDD
2526
import org.apache.spark.storage._
2627

2728
// TODO: Test the CacheManager's thread-safety aspects
28-
class CacheManagerSuite extends FunSuite with BeforeAndAfter with EasyMockSugar {
29+
class CacheManagerSuite extends FunSuite with BeforeAndAfter with MockitoSugar {
2930
var sc : SparkContext = _
3031
var blockManager: BlockManager = _
3132
var cacheManager: CacheManager = _
@@ -75,29 +76,21 @@ class CacheManagerSuite extends FunSuite with BeforeAndAfter with EasyMockSugar
7576
}
7677

7778
test("get cached rdd") {
78-
expecting {
79-
val result = new BlockResult(Array(5, 6, 7).iterator, DataReadMethod.Memory, 12)
80-
blockManager.get(RDDBlockId(0, 0)).andReturn(Some(result))
81-
}
79+
val result = new BlockResult(Array(5, 6, 7).iterator, DataReadMethod.Memory, 12)
80+
when(blockManager.get(RDDBlockId(0, 0))).thenReturn(Some(result))
8281

83-
whenExecuting(blockManager) {
84-
val context = new TaskContextImpl(0, 0, 0, 0)
85-
val value = cacheManager.getOrCompute(rdd, split, context, StorageLevel.MEMORY_ONLY)
86-
assert(value.toList === List(5, 6, 7))
87-
}
82+
val context = new TaskContextImpl(0, 0, 0, 0)
83+
val value = cacheManager.getOrCompute(rdd, split, context, StorageLevel.MEMORY_ONLY)
84+
assert(value.toList === List(5, 6, 7))
8885
}
8986

9087
test("get uncached local rdd") {
91-
expecting {
92-
// Local computation should not persist the resulting value, so don't expect a put().
93-
blockManager.get(RDDBlockId(0, 0)).andReturn(None)
94-
}
88+
// Local computation should not persist the resulting value, so don't expect a put().
89+
when(blockManager.get(RDDBlockId(0, 0))).thenReturn(None)
9590

96-
whenExecuting(blockManager) {
97-
val context = new TaskContextImpl(0, 0, 0, 0, true)
98-
val value = cacheManager.getOrCompute(rdd, split, context, StorageLevel.MEMORY_ONLY)
99-
assert(value.toList === List(1, 2, 3, 4))
100-
}
91+
val context = new TaskContextImpl(0, 0, 0, 0, true)
92+
val value = cacheManager.getOrCompute(rdd, split, context, StorageLevel.MEMORY_ONLY)
93+
assert(value.toList === List(1, 2, 3, 4))
10194
}
10295

10396
test("verify task metrics updated correctly") {

0 commit comments

Comments
 (0)