Search in sources :

Example 51 with JspException

use of javax.servlet.jsp.JspException 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);
    }
}
Also used : JspException(javax.servlet.jsp.JspException) MockFormBean(org.apache.struts.mock.MockFormBean) HashMap(java.util.HashMap) Map(java.util.Map)

Example 52 with JspException

use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.

the class TestTagUtils method testComputeParameters0a.

// ---------------------------------------------------- computeParameters()
// No parameters and no transaction token
public void testComputeParameters0a() {
    Map map = null;
    try {
        map = tagutils.computeParameters(pageContext, null, null, null, null, null, null, null, false);
    } catch (JspException e) {
        fail("JspException: " + e);
    }
    assertNull("Map is null", map);
}
Also used : JspException(javax.servlet.jsp.JspException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 53 with JspException

use of javax.servlet.jsp.JspException in project sonarqube by SonarSource.

the class TestTagUtils method testComputeParametersBeanNotFound.

// specified bean is not found
public void testComputeParametersBeanNotFound() {
    Map map = null;
    try {
        map = tagutils.computeParameters(pageContext, null, null, null, null, "i-do-not-exist", null, null, false);
        fail("JspException not thrown");
    } catch (JspException e) {
        assertNull("map is null", map);
    }
}
Also used : JspException(javax.servlet.jsp.JspException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 54 with JspException

use of javax.servlet.jsp.JspException 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"));
}
Also used : JspException(javax.servlet.jsp.JspException) MockFormBean(org.apache.struts.mock.MockFormBean) HashMap(java.util.HashMap) Map(java.util.Map)

Example 55 with JspException

use of javax.servlet.jsp.JspException 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"));
}
Also used : JspException(javax.servlet.jsp.JspException) MockFormBean(org.apache.struts.mock.MockFormBean) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

JspException (javax.servlet.jsp.JspException)158 IOException (java.io.IOException)34 Map (java.util.Map)30 HashMap (java.util.HashMap)21 HttpServletRequest (javax.servlet.http.HttpServletRequest)21 JspWriter (javax.servlet.jsp.JspWriter)21 Iterator (java.util.Iterator)20 ActionMessages (org.apache.struts.action.ActionMessages)15 MockFormBean (org.apache.struts.mock.MockFormBean)15 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 ActionMessage (org.apache.struts.action.ActionMessage)11 ArrayList (java.util.ArrayList)7 Collection (java.util.Collection)7 List (java.util.List)7 Locale (java.util.Locale)6 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)6 MalformedURLException (java.net.MalformedURLException)5 ModuleConfig (org.apache.struts.config.ModuleConfig)5 UserContext (org.mifos.security.util.UserContext)5 SimpleDateFormat (java.text.SimpleDateFormat)4