use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method testGetActionErrors1b.
// String
public void testGetActionErrors1b() {
request.setAttribute("foo", "bar");
try {
ActionMessages errors = tagutils.getActionMessages(pageContext, "foo");
assertNotNull("errors should not be null", errors);
assertNotNull("errors prop should not be null", errors.get("prop"));
String key = null;
int i = 0;
for (Iterator iter = errors.get(ActionMessages.GLOBAL_MESSAGE); iter.hasNext(); ) {
ActionMessage error = (ActionMessage) iter.next();
key = error.getKey();
Object[] values = error.getValues();
assertNull(values);
i++;
}
assertEquals("only 1 error", i, 1);
assertEquals("key should match", key, "bar");
} catch (JspException e) {
fail(e.getMessage());
}
}
use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method testActionMessages_getActionMessages_PageContext_String5.
// String Array (thrown JspException)
public void testActionMessages_getActionMessages_PageContext_String5() {
request.setAttribute("foo", new MockFormBean());
ActionMessages messages = null;
try {
messages = tagutils.getActionMessages(pageContext, "foo");
fail("should have thrown JspException");
} catch (JspException e) {
assertNull("messages should be null", messages);
}
}
use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method testComputeParameters3aa.
// Kitchen sink combination of parameters with a merge
// with array values in map
public void testComputeParameters3aa() {
request.setAttribute("attr", new MockFormBean("bar3"));
request.getSession().setAttribute(Globals.TRANSACTION_TOKEN_KEY, "token");
Map map = null;
try {
map = tagutils.computeParameters(pageContext, "foo1", "attr", "stringProperty", "request", "attr", "mapPropertyArrayValues", "request", true);
} catch (JspException e) {
fail("JspException: " + e);
}
assertNotNull("Map is not null", map);
assertEquals("Three parameter in the returned map", 3, map.size());
assertTrue("Parameter foo1 present", map.containsKey("foo1"));
assertTrue("Parameter foo1 value type", map.get("foo1") instanceof String[]);
String[] values = (String[]) map.get("foo1");
assertEquals("Values count", 3, values.length);
assertTrue("Parameter foo2 present", map.containsKey("foo2"));
String[] arrayValues = (String[]) map.get("foo2");
String val = arrayValues[0];
assertEquals("Parameter foo2 value", "bar2", val);
assertTrue("Transaction token parameter present", map.containsKey(Constants.TOKEN_KEY));
assertEquals("Transaction token parameter value", "token", (String) map.get(Constants.TOKEN_KEY));
}
use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method test_Object_lookup_PageContext_String_String_String3.
// try to get the call to throw an NoSuchMethodException
public void test_Object_lookup_PageContext_String_String_String3() {
pageContext.setAttribute("bean", new MockFormBean());
Object val = null;
try {
val = tagutils.lookup(pageContext, "bean", "doesNotExistMethod");
fail("should have thrown exception");
} catch (JspException e) {
assertNull(val);
}
}
use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.
the class TestTagUtils method testComputeParameters1a.
// Single parameter -- name
public void testComputeParameters1a() {
request.getSession().setAttribute("attr", "bar");
Map map = null;
try {
map = tagutils.computeParameters(pageContext, "foo", "attr", null, null, 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"));
}
Aggregations