use of org.apache.struts.mock.MockFormBean in project sonarqube by SonarSource.
the class TestTagUtils method testComputeParameters2c.
// Provided map -- scope + name + property
public void testComputeParameters2c() {
request.setAttribute("attr", new MockFormBean());
Map map = null;
try {
map = tagutils.computeParameters(pageContext, null, null, null, null, "attr", "mapProperty", "request", false);
} catch (JspException e) {
fail("JspException: " + e);
}
assertNotNull("Map is not null", map);
assertEquals("Two parameter in the returned map", 2, map.size());
assertTrue("Parameter foo1 present", map.containsKey("foo1"));
assertEquals("Parameter foo1 value", "bar1", (String) map.get("foo1"));
assertTrue("Parameter foo2 present", map.containsKey("foo2"));
assertEquals("Parameter foo2 value", "bar2", (String) map.get("foo2"));
}
use of org.apache.struts.mock.MockFormBean 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 org.apache.struts.mock.MockFormBean 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 org.apache.struts.mock.MockFormBean 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 org.apache.struts.mock.MockFormBean in project sonarqube by SonarSource.
the class TestTagUtils method test_Object_lookup_PageContext_String__String2.
// lookup with page scope
public void test_Object_lookup_PageContext_String__String2() {
pageContext.setAttribute("bean", new MockFormBean());
try {
Object val = tagutils.lookup(pageContext, "bean", "page");
assertNotNull((val));
} catch (JspException e) {
fail("bean not found:" + e.getMessage());
}
}
Aggregations