use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method testComputeParameters1b.
// Single parameter -- scope + name
public void testComputeParameters1b() {
request.setAttribute("attr", "bar");
Map map = null;
try {
map = tagutils.computeParameters(pageContext, "foo", "attr", null, "request", null, null, null, false);
} catch (JspException e) {
fail("JspException: " + e);
}
assertNotNull("Map is not null", map);
assertEquals("One parameter in the returned map", 1, map.size());
assertTrue("Parameter present", map.containsKey("foo"));
assertEquals("Parameter value", "bar", (String) map.get("foo"));
}
use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method testGetActionErrors1a.
// ------------------------------------------ getActionErrors()
// ActionErrors
public void testGetActionErrors1a() {
ActionMessages actionErrors = new ActionMessages();
actionErrors.add("prop", new ActionMessage("key.key"));
request.setAttribute("errors", actionErrors);
try {
ActionMessages errors = tagutils.getActionMessages(pageContext, "errors");
assertNotNull("errors should not be null", errors);
assertNotNull("errors prop should not be null", errors.get("prop"));
String val = null;
int i = 0;
for (Iterator iter = errors.get("prop"); iter.hasNext(); ) {
ActionMessage error = (ActionMessage) iter.next();
val = error.getKey();
i++;
}
assertEquals("only 1 error", i, 1);
assertEquals("errors prop should match", val, "key.key");
} catch (JspException e) {
fail(e.getMessage());
}
}
use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method testActionMessages_getActionMessages_PageContext_String4.
// -- using String Array
public void testActionMessages_getActionMessages_PageContext_String4() {
String[] vals = new String[] { "bar", "baz" };
request.setAttribute("foo", vals);
try {
ActionMessages messages = tagutils.getActionMessages(pageContext, "foo");
assertNotNull("messages should not be null", messages);
assertNotNull("messages prop should not be null", messages.get("prop"));
String key = null;
int i = 0;
for (Iterator iter = messages.get(ActionMessages.GLOBAL_MESSAGE); iter.hasNext(); ) {
ActionMessage message = (ActionMessage) iter.next();
key = message.getKey();
Object[] values = message.getValues();
assertNull((values));
assertEquals("1st key should match", key, vals[i]);
i++;
}
assertEquals("only 1 message", i, 2);
} catch (JspException e) {
fail(e.getMessage());
}
}
use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method test_Object_lookup_PageContext_String__String3.
// lookup with invalid scope
// -- (where an exception is thrown)
public void test_Object_lookup_PageContext_String__String3() {
pageContext.setAttribute("bean", new MockFormBean());
Object val = null;
try {
val = tagutils.lookup(pageContext, "bean", "invalid");
fail("invalid scope :");
} catch (JspException e) {
assertNull((val));
}
}
use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method testComputeParametersParamValueToString.
public void testComputeParametersParamValueToString() {
request.getSession().setAttribute("SomeBean", new MockFormBean(false, false, new Double(1)));
Map map = null;
try {
map = tagutils.computeParameters(pageContext, "paramId", "SomeBean", "doubleValue", null, null, null, null, false);
assertNotNull("map is null", map);
String val = (String) map.get("paramId");
assertTrue("paramId should be 1.0", "1.0".equals(val));
} catch (JspException e) {
fail("JspException not thrown");
}
}
Aggregations