|
17 | 17 |
|
18 | 18 | package org.apache.spark
|
19 | 19 |
|
| 20 | +import org.mockito.Mockito._ |
20 | 21 | import org.scalatest.{BeforeAndAfter, FunSuite}
|
21 |
| -import org.scalatest.mock.EasyMockSugar |
| 22 | +import org.scalatest.mock.MockitoSugar |
22 | 23 |
|
23 | 24 | import org.apache.spark.executor.{DataReadMethod, TaskMetrics}
|
24 | 25 | import org.apache.spark.rdd.RDD
|
25 | 26 | import org.apache.spark.storage._
|
26 | 27 |
|
27 | 28 | // 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 { |
29 | 30 | var sc : SparkContext = _
|
30 | 31 | var blockManager: BlockManager = _
|
31 | 32 | var cacheManager: CacheManager = _
|
@@ -75,29 +76,21 @@ class CacheManagerSuite extends FunSuite with BeforeAndAfter with EasyMockSugar
|
75 | 76 | }
|
76 | 77 |
|
77 | 78 | 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)) |
82 | 81 |
|
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)) |
88 | 85 | }
|
89 | 86 |
|
90 | 87 | 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) |
95 | 90 |
|
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)) |
101 | 94 | }
|
102 | 95 |
|
103 | 96 | test("verify task metrics updated correctly") {
|
|
0 commit comments