Skip to content

Commit

Permalink
Merge branch 'master' into step-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
mumoshu committed Dec 30, 2009
2 parents a2f0c49 + 6ae29b0 commit 5d2fa0b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/Step.scala
Expand Up @@ -63,7 +63,7 @@ abstract class Step extends HttpServlet
_request.withValue(request) {
_response.withValue(response) {
_session.withValue(request) {
paramsMap.withValue(args ++ realParams) {
paramsMap.withValue(args ++ realParams withDefaultValue(null)) {
response.getWriter print route.action()
}
}
Expand All @@ -79,7 +79,7 @@ abstract class Step extends HttpServlet
}

def before(fun: => Any) = fun
def params(name: String) = paramsMap value name
def params = paramsMap value
def redirect(uri: String) = (_response value) sendRedirect uri
def request = _request value
def session = _session value
Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/WEB-INF/web.xml
Expand Up @@ -14,5 +14,11 @@
<url-pattern>/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/images/*</url-pattern>
<url-pattern>/css/*</url-pattern>
<url-pattern>/js/*</url-pattern>
</servlet-mapping>

</web-app>
1 change: 1 addition & 0 deletions src/main/webapp/css/put_css_here
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/main/webapp/images/put_images_here
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/main/webapp/js/put_js_here
@@ -0,0 +1 @@

14 changes: 13 additions & 1 deletion src/test/scala/StepTest.scala
Expand Up @@ -24,7 +24,10 @@ class TestServlet extends Step {
}

post("/post/test") {
params("posted_value")
params("posted_value") match {
case null => "posted_value is null"
case s => s
}
}

post("/post/:test/val") {
Expand Down Expand Up @@ -213,4 +216,13 @@ class StepTest extends FunSuite with ShouldMatchers {
response.parse(tester.getResponses(request.generate))
response.getContent should equal ("host:1.2.3.4,port:")
}

test("POST /post/test without params return \"posted_value is null\"") {
request.setMethod("POST")
request.setURI("/post/test")
request.addHeader("Content-Type", "application/x-www-form-urlencoded")
request.setContent("")
response.parse(tester.getResponses(request.generate()))
response.getContent should equal ("posted_value is null")
}
}

0 comments on commit 5d2fa0b

Please sign in to comment.