Skip to content

Commit 1d247d2

Browse files
Cleanup and updated unit tests.
1 parent a9d9e9a commit 1d247d2

File tree

6 files changed

+13
-36
lines changed

6 files changed

+13
-36
lines changed

Diff for: servlet_macros/src/main/scala/jaxed/servlet/Model.scala

-8
This file was deleted.

Diff for: servlet_macros/src/main/scala/jaxed/servlet/PathBuilder.scala

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package jaxed.servlet
22

3-
import jaxed.{SinatraPathPatternParser, PathPattern}
43

54
/**
65
* @author Bryce Anderson

Diff for: servlet_macros/src/main/scala/jaxed/servlet/RouteNode.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RouteNode(path: String = "") extends Route with Filter with PathBuilder {
3030

3131
protected val routes = new MutableList[Route]()
3232

33-
protected def runLeaves(context: ServletReqContext): Option[Any] = {
33+
protected def searchLeaves(context: ServletReqContext): Option[Any] = {
3434
pathPattern(context.path).flatMap{ case (params, subPath) =>
3535
val subcontext = context.subPath(subPath, params)
3636
def searchList(it: Iterator[Route]): Option[Any] = {
@@ -47,7 +47,7 @@ class RouteNode(path: String = "") extends Route with Filter with PathBuilder {
4747
}
4848

4949
override def handle(context: ServletReqContext): Option[Any] = {
50-
val result = beforeFilter(context) orElse runLeaves(context)
50+
val result = beforeFilter(context) orElse searchLeaves(context)
5151
afterFilter(context, result)
5252
}
5353

Diff for: base/src/main/scala/jaxed/URLRouting.scala renamed to servlet_macros/src/main/scala/jaxed/servlet/URLRouting.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package jaxed
1+
package jaxed.servlet
22

33
/*
44
This was lifted nearly entirely from the Scalatra project: pathPatternParsers.scala
55
*/
66

77
import scala.util.matching.Regex
88
import scala.util.parsing.combinator.RegexParsers
9+
import jaxed._
910

1011
/**
1112
* A path pattern optionally matches a request path and extracts path

Diff for: servlet_macros/src/test/scala/jaxed/servletmacros/MockRenderer.scala

-14
This file was deleted.

Diff for: servlet_macros/src/test/scala/jaxed/servletmacros/ServletReqContextSpec.scala

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package jaxed
2-
package servletmacros
2+
package servlet
33

44
import org.specs2.mutable.Specification
55
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
66
import javax.ws.rs.GET
7-
import jaxed.servlet.{RouteNode, DoneResult}
87

98
/**
109
* @author Bryce Anderson
@@ -13,19 +12,19 @@ import jaxed.servlet.{RouteNode, DoneResult}
1312

1413
class ServletReqContextSpec extends Specification {
1514

16-
class MockNode extends RouteNode with MockRenderer
15+
class MockNode extends RouteNode
1716

1817
"Servlet Macros" should {
19-
val mocContext = ServletReqContext("/foo/bar", Get, Map("one" -> "two"), null, null)
18+
val mocContext = new ServletReqContext("/foo/bar", Get, Map("one" -> "two"), null, null)
2019
"Run a route" in {
2120
class Test {
2221
@GET
2322
def getHello() = "Hello"
2423
}
2524

2625
val node = new MockNode()
27-
node.mapClass[Test]("foo/bar")
28-
node.handle(mocContext) must_== Some(DoneResult("Hello"))
26+
node.mapClass[Test]("/foo/bar")
27+
node.handle(mocContext) must_== Some("Hello")
2928
}
3029

3130
"Add a request" in {
@@ -35,8 +34,8 @@ class ServletReqContextSpec extends Specification {
3534
}
3635

3736
val node = new MockNode()
38-
node.mapClass[Test]("foo/bar")
39-
node.handle(mocContext) must_== Some(DoneResult("Hello"))
37+
node.mapClass[Test]("/foo/bar")
38+
node.handle(mocContext) must_== Some("Hello")
4039
}
4140

4241
"Add a response" in {
@@ -46,8 +45,8 @@ class ServletReqContextSpec extends Specification {
4645
}
4746

4847
val node = new MockNode()
49-
node.mapClass[Test]("foo/bar")
50-
node.handle(mocContext) must_== Some(DoneResult("Hello"))
48+
node.mapClass[Test]("/foo/bar")
49+
node.handle(mocContext) must_== Some("Hello")
5150
}
5251
}
5352

0 commit comments

Comments
 (0)