use of org.apache.struts.mock.MockFormBean in project sonarqube by SonarSource.
the class TestCopyFormToContext method testCopyToDefaultContextKey.
public void testCopyToDefaultContextKey() throws Exception {
CopyFormToContext command = new CopyFormToContext();
String formName = "foo";
command.setFormName(formName);
command.setScope("request");
assertNull(context.getActionForm());
assertNull(context.getRequestScope().get(POST_EXECUTION_CONTEXT_KEY));
assertNull(context.getSessionScope().get(POST_EXECUTION_CONTEXT_KEY));
command.execute(context);
assertNotNull(context.getActionForm());
assertNotNull(context.getRequestScope().get(formName));
assertNull(context.getSessionScope().get(formName));
assertSame(context.getActionForm(), context.getRequestScope().get(formName));
ActionForm theForm = (ActionForm) context.getActionForm();
assertTrue(theForm instanceof MockFormBean);
}
use of org.apache.struts.mock.MockFormBean 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 org.apache.struts.mock.MockFormBean 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");
}
}
use of org.apache.struts.mock.MockFormBean in project sonarqube by SonarSource.
the class TestTagUtils method testComputeParametersParamIdParamPropThrowException.
public void testComputeParametersParamIdParamPropThrowException() {
request.getSession().setAttribute("SomeBean", new MockFormBean(true));
Map map = null;
try {
map = tagutils.computeParameters(pageContext, "paramId", "SomeBean", "justThrowAnException", null, null, null, null, false);
fail("JspException not thrown");
} catch (JspException e) {
assertNull("map is null", map);
}
}
use of org.apache.struts.mock.MockFormBean in project sonarqube by SonarSource.
the class TestTagUtils method testComputeParameters1c.
// Single parameter -- scope + name + property
public void testComputeParameters1c() {
request.setAttribute("attr", new MockFormBean("bar"));
Map map = null;
try {
map = tagutils.computeParameters(pageContext, "foo", "attr", "stringProperty", "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"));
}
Aggregations