Search in sources :

Example 61 with JspException

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

the class TestTagUtils method testComputeParameters2a.

// Provided map -- name
public void testComputeParameters2a() {
    Map map = new HashMap();
    map.put("foo1", "bar1");
    map.put("foo2", "bar2");
    request.getSession().setAttribute("attr", map);
    try {
        map = tagutils.computeParameters(pageContext, null, null, null, null, "attr", null, null, 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) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 62 with JspException

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

the class TestTagUtils method testComputeParameters2b.

// Provided map -- scope + name
public void testComputeParameters2b() {
    Map map = new HashMap();
    map.put("foo1", "bar1");
    map.put("foo2", "bar2");
    request.setAttribute("attr", map);
    try {
        map = tagutils.computeParameters(pageContext, null, null, null, null, "attr", null, "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) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 63 with JspException

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

Example 64 with JspException

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

the class TestTagUtils method testComputeParametersPropertyThrowsException.

// accessing this property causes an exception
public void testComputeParametersPropertyThrowsException() {
    request.getSession().setAttribute("SomeBean", new MockFormBean(true));
    Map map = null;
    try {
        map = tagutils.computeParameters(pageContext, null, null, null, null, "SomeBean", "justThrowAnException", 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 65 with JspException

use of javax.servlet.jsp.JspException in project jodd by oblac.

the class CaseTag method doTag.

@Override
public void doTag() throws JspException {
    JspTag parent = getParent();
    if (!(parent instanceof SwitchTag)) {
        throw new JspException(SwitchTag.MSG_PARENT_SWITCH_REQUIRED, null);
    }
    SwitchTag switchTag = (SwitchTag) parent;
    if ((switchTag.getValue() != null) && switchTag.getValue().equals(value)) {
        switchTag.valueFounded();
        TagUtil.invokeBody(getJspBody());
    }
}
Also used : JspException(javax.servlet.jsp.JspException) JspTag(javax.servlet.jsp.tagext.JspTag)

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