Skip to content

Commit

Permalink
fixed unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianKirmaier committed Dec 15, 2023
1 parent 88eeae9 commit 0541d9f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class TestAppCrawler {
def testCrawlApp(): Unit = {
def app = new RouteNode(null) {
setRoute(Route.empty()
.and(RouteUtils.get("/", r => new Page1))
.and(RouteUtils.get("/page2", r => new Page2)))
.and(RouteUtils.getView("/", r => new Page1))
.and(RouteUtils.getView("/page2", r => new Page2)))
}
val result = AppCrawler.crawlApp("http://localhost", () => app)

Expand All @@ -50,7 +50,7 @@ class TestAppCrawler {
def testEmptyImage(): Unit = {
def app = new RouteNode(null) {
setRoute(Route.empty()
.and(RouteUtils.get("/", r => new View {
.and(RouteUtils.getView("/", r => new View {
override def title: String = ""

override def description: String = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class TestMemoryTester {
def simpleTest(): Unit = {
def app = new RouteNode(null) {
setRoute(Route.empty()
.and(get("/", r => new Page1))
.and(get("/page2", r => new Page2))
.and(get("/page4", r => new Page2)))
.and(getView("/", r => new Page1))
.and(getView("/page2", r => new Page2))
.and(getView("/page4", r => new Page2)))
}
val result = AppCrawler.crawlApp("http://localhost", () => app)
MemoryTester.testForLeaks(result, () => app)
Expand All @@ -27,9 +27,9 @@ class TestMemoryTester {
val page2 = new Page2
def app = new RouteNode(null) {
setRoute(Route.empty()
.and(get("/", r => new Page1))
.and(get("/page2", r => page2))
.and(get("/page4", r => new Page2)))
.and(getView("/", r => new Page1))
.and(getView("/page2", r => page2))
.and(getView("/page4", r => new Page2)))
}
val result = AppCrawler.crawlApp("http://localhost", () => app)
intercept[Throwable](MemoryTester.testForLeaks(result, () => app))
Expand All @@ -41,9 +41,9 @@ class TestMemoryTester {

def app = new RouteNode(null) {
setRoute(Route.empty()
.and(get("/", r => new Page1))
.and(get("/page2", r => viewFromNode(node2)))
.and(get("/page4", r => new Page2)))
.and(getView("/", r => new Page1))
.and(getView("/page2", r => viewFromNode(node2)))
.and(getView("/page4", r => new Page2)))
}

val result = AppCrawler.crawlApp("http://localhost", () => app)
Expand All @@ -54,9 +54,9 @@ class TestMemoryTester {
def simpleFailingTest3(): Unit = {
val app = inFX(new RouteNode(null) {
setRoute(Route.empty()
.and(get("/", r => new Page1))
.and(get("/page2", r => new Page2))
.and(get("/page4", r => new Page2)))
.and(getView("/", r => new Page1))
.and(getView("/page2", r => new Page2))
.and(getView("/page4", r => new Page2)))
})
val result = AppCrawler.crawlApp("http://localhost", () => app)
intercept[Throwable](MemoryTester.testForLeaks(result, () => app)) // fails because the webapp is not collectable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package one.jpro.platform.routing.crawl

import one.jpro.platform.routing.RouteUtils._
import one.jpro.platform.routing.crawl.TestUtils._
import one.jpro.platform.routing.{Redirect, Route, RouteNode}
import one.jpro.platform.routing.{Redirect, Response, Route, RouteNode}
import org.junit.jupiter.api.Test
import simplefx.experimental._

Expand All @@ -11,10 +11,10 @@ class TestSitemapGenerator {
def test(): Unit = {
def app = new RouteNode(null) {
setRoute(Route.empty()
.and(get("/", r => new Page1))
.and(get("/page2", r => new Page2))
.and(get("/page4", r => new Page2))
.and(r => FXFuture.unit(new Page1)))
.and(getView("/", r => new Page1))
.and(getView("/page2", r => new Page2))
.and(getView("/page4", r => new Page2))
.and(r => Response.view(new Page1)))
}
val result = AppCrawler.crawlApp("http://localhost", () => app)
val sm = SitemapGenerator.createSitemap("http://localhost", result)
Expand All @@ -28,8 +28,8 @@ class TestSitemapGenerator {
def testMailToRedirect(): Unit = {
def app = new RouteNode(null) {
setRoute(Route.empty()
.and(get("/", r => pageWithLink(List("/page2", "/page3", "mailto:something"))))
.and(get("/page2", r => new Redirect("mailto:something-2"))))
.and(getView("/", r => pageWithLink(List("/page2", "/page3", "mailto:something"))))
.and(get("/page2", r => Response.redirect("mailto:something-2"))))
}
val result = AppCrawler.crawlApp("http://localhost", () => app)
println("got result: " + result)
Expand Down

0 comments on commit 0541d9f

Please sign in to comment.