use of org.apache.struts.mock.MockFormBean in project sonarqube by SonarSource.
the class TestRequestUtils method testCreateActionForm2a.
// Default module -- Standard ActionForm should be created
public void testCreateActionForm2a() {
request.setPathElements("/myapp", "/static.do", null, null);
ActionMapping mapping = (ActionMapping) moduleConfig.findActionConfig("/static");
assertNotNull("Found /static mapping", mapping);
assertNotNull("Mapping has non-null name", mapping.getName());
assertEquals("Mapping has correct name", "static", mapping.getName());
assertNotNull("AppConfig has form bean " + mapping.getName(), moduleConfig.findFormBeanConfig(mapping.getName()));
ActionForm form = RequestUtils.createActionForm(request, mapping, moduleConfig, null);
assertNotNull("ActionForm returned", form);
assertTrue("ActionForm of correct type", form instanceof MockFormBean);
}
use of org.apache.struts.mock.MockFormBean in project sonarqube by SonarSource.
the class TestTagUtils method test_Object_lookup_PageContext_String_String_String2.
// try to get the call to throw an IllegalArgumentException
public void test_Object_lookup_PageContext_String_String_String2() {
pageContext.setAttribute("bean", new MockFormBean());
Object val = null;
try {
val = tagutils.lookup(pageContext, "bean", "doesNotExistMethod", "page");
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 testGetActionErrors1d.
// String Array (thrown JspException)
public void testGetActionErrors1d() {
request.setAttribute("foo", new MockFormBean());
ActionMessages errors = null;
try {
errors = tagutils.getActionMessages(pageContext, "foo");
fail("should have thrown JspException");
} catch (JspException e) {
assertNull("errors should be null", errors);
}
}
use of org.apache.struts.mock.MockFormBean in project sonarqube by SonarSource.
the class TestTagUtils method testComputeParameters3a.
// Kitchen sink combination of parameters with a merge
public void testComputeParameters3a() {
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", "mapProperty", "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", 2, values.length);
assertTrue("Parameter foo2 present", map.containsKey("foo2"));
assertEquals("Parameter foo2 value", "bar2", (String) map.get("foo2"));
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 testComputeParameters3b.
// Kitchen sink combination of parameters with a merge
public void testComputeParameters3b() {
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", "mapProperty", "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", 2, values.length);
assertTrue("Parameter foo2 present", map.containsKey("foo2"));
assertEquals("Parameter foo2 value", "bar2", (String) map.get("foo2"));
assertTrue("Transaction token parameter present", map.containsKey(Constants.TOKEN_KEY));
assertEquals("Transaction token parameter value", "token", (String) map.get(Constants.TOKEN_KEY));
}
Aggregations