|
14 | 14 | * See the License for the specific language governing permissions and |
15 | 15 | * limitations under the License. |
16 | 16 | */ |
| 17 | + |
17 | 18 | package org.apache.spark.deploy.history |
18 | 19 |
|
| 20 | +import javax.servlet.http.HttpServletRequest |
| 21 | + |
| 22 | +import scala.collection.mutable |
| 23 | + |
| 24 | +import org.apache.hadoop.fs.Path |
| 25 | +import org.mockito.Mockito.{when} |
19 | 26 | import org.scalatest.FunSuite |
20 | 27 | import org.scalatest.Matchers |
21 | 28 | import org.scalatest.mock.MockitoSugar |
22 | | -import javax.servlet.http.HttpServletRequest |
23 | | -import org.mockito.Mockito.{when} |
24 | | -import org.apache.hadoop.fs.Path |
| 29 | + |
25 | 30 | import org.apache.spark.ui.SparkUI |
26 | | -import scala.collection.mutable |
27 | 31 |
|
28 | 32 | class HistoryServerSuite extends FunSuite with Matchers with MockitoSugar { |
29 | | - |
30 | | - val historyServer = mock[HistoryServer] |
31 | | - val request = mock[HttpServletRequest] |
32 | | - |
33 | | - test("generate history page with relative links") { |
| 33 | + |
| 34 | + test("generate history page with relative links") { |
| 35 | + val historyServer = mock[HistoryServer] |
| 36 | + val request = mock[HttpServletRequest] |
34 | 37 | val ui = mock[SparkUI] |
35 | 38 | val link = "/history/app1" |
36 | | - val info = new ApplicationHistoryInfo("app1", "app1", 0, 2, 1, "xxx", true ) |
| 39 | + val info = new ApplicationHistoryInfo("app1", "app1", 0, 2, 1, "xxx", true) |
37 | 40 | when(historyServer.getApplicationList()).thenReturn(Seq(info)) |
38 | 41 | when(ui.basePath).thenReturn(link) |
39 | 42 | when(historyServer.getProviderConfig()).thenReturn(Map[String, String]()) |
40 | 43 | val page = new HistoryPage(historyServer) |
41 | | - |
| 44 | + |
42 | 45 | //when |
43 | 46 | val response = page.render(request) |
44 | | - |
| 47 | + |
45 | 48 | //then |
46 | | - val links = response \\ "a" |
47 | | - val justHrefs = for { |
48 | | - l <- links |
49 | | - attrs <- l.attribute("href") |
50 | | - } yield (attrs.toString) |
51 | | - justHrefs should contain(link) |
| 49 | + val links = response \\ "a" |
| 50 | + val justHrefs = for { |
| 51 | + l <- links |
| 52 | + attrs <- l.attribute("href") |
| 53 | + } yield (attrs.toString) |
| 54 | + justHrefs should contain(link) |
52 | 55 | } |
53 | 56 | } |
0 commit comments