Skip to content

Commit 30b2cc0

Browse files
committed
Verify that @parameter rules work even if parameter is missing (ocpsoft#192)
1 parent a6b3f27 commit 30b2cc0

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎config-annotations/src/test/java/org/ocpsoft/rewrite/annotation/query/QueryParameterTest.java‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public static WebArchive getDeployment()
2828
.addAsLibrary(RewriteAnnotationTest.getRewriteCdiArchive())
2929
.addClass(QueryParameterBean.class)
3030
.addAsWebResource(new StringAsset(
31-
"Log: [${queryParameterBean.value}]"),
31+
"Log: [${queryParameterBean.value}]\n"
32+
+ "IsNull: [${queryParameterBean.value == null}]"),
3233
"query.jsp");
3334
}
3435

@@ -38,6 +39,7 @@ public void testQueryParameter() throws Exception
3839
HttpAction<HttpGet> action = get("/query?q=foo");
3940
assertEquals(200, action.getStatusCode());
4041
assertThat(action.getResponseContent(), Matchers.containsString("Log: [foo]"));
42+
assertThat(action.getResponseContent(), Matchers.containsString("IsNull: [false]"));
4143
}
4244

4345
@Test
@@ -46,6 +48,16 @@ public void shouldFindCorrectQueryParameterIfOthersExist() throws Exception
4648
HttpAction<HttpGet> action = get("/query?a=b&q=foo&c=d");
4749
assertEquals(200, action.getStatusCode());
4850
assertThat(action.getResponseContent(), Matchers.containsString("Log: [foo]"));
51+
assertThat(action.getResponseContent(), Matchers.containsString("IsNull: [false]"));
52+
}
53+
54+
@Test
55+
public void shouldSupportMissingQueryParameter() throws Exception
56+
{
57+
HttpAction<HttpGet> action = get("/query");
58+
assertEquals(200, action.getStatusCode());
59+
assertThat(action.getResponseContent(), Matchers.containsString("Log: []"));
60+
assertThat(action.getResponseContent(), Matchers.containsString("IsNull: [true]"));
4961
}
5062

5163
}

0 commit comments

Comments
 (0)