Search in sources :

Example 21 with ActionForm

use of org.apache.struts.action.ActionForm in project sonarqube by SonarSource.

the class TestRequestUtils method testCreateActionForm1b.

// Second module -- No ActionForm should be created
public void testCreateActionForm1b() {
    request.setPathElements("/myapp", "/2/noform.do", null, null);
    ActionMapping mapping = (ActionMapping) moduleConfig2.findActionConfig("/noform");
    assertNotNull("Found /noform mapping", mapping);
    ActionForm form = RequestUtils.createActionForm(request, mapping, moduleConfig2, null);
    assertNull("No ActionForm returned", form);
}
Also used : ActionMapping(org.apache.struts.action.ActionMapping) ActionForm(org.apache.struts.action.ActionForm) DynaActionForm(org.apache.struts.action.DynaActionForm)

Example 22 with ActionForm

use of org.apache.struts.action.ActionForm in project sonarqube by SonarSource.

the class TestRequestUtils method testCreateActionForm3b.

// Second module -- Dynamic ActionForm should be created
public void testCreateActionForm3b() {
    request.setPathElements("/myapp", "/2/dynamic2.do", null, null);
    ActionMapping mapping = (ActionMapping) moduleConfig2.findActionConfig("/dynamic2");
    assertNotNull("Found /dynamic2 mapping", mapping);
    assertNotNull("Mapping has non-null name", mapping.getName());
    assertEquals("Mapping has correct name", "dynamic2", mapping.getName());
    assertNotNull("AppConfig has form bean " + mapping.getName(), moduleConfig2.findFormBeanConfig(mapping.getName()));
    ActionForm form = RequestUtils.createActionForm(request, mapping, moduleConfig2, null);
    assertNotNull("ActionForm returned", form);
    assertTrue("ActionForm of correct type", form instanceof DynaActionForm);
}
Also used : ActionMapping(org.apache.struts.action.ActionMapping) DynaActionForm(org.apache.struts.action.DynaActionForm) ActionForm(org.apache.struts.action.ActionForm) DynaActionForm(org.apache.struts.action.DynaActionForm)

Example 23 with ActionForm

use of org.apache.struts.action.ActionForm in project sonarqube by SonarSource.

the class TestRequestUtils method testCreateActionForm2b.

// Second module -- Standard ActionForm should be created
public void testCreateActionForm2b() {
    request.setPathElements("/myapp", "/2/static.do", null, null);
    ActionMapping mapping = (ActionMapping) moduleConfig2.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, moduleConfig2, null);
    assertNotNull("ActionForm returned", form);
    assertTrue("ActionForm of correct type", form instanceof MockFormBean);
}
Also used : ActionMapping(org.apache.struts.action.ActionMapping) ActionForm(org.apache.struts.action.ActionForm) DynaActionForm(org.apache.struts.action.DynaActionForm) MockFormBean(org.apache.struts.mock.MockFormBean)

Example 24 with ActionForm

use of org.apache.struts.action.ActionForm in project sonarqube by SonarSource.

the class TestRequestUtils method testCreateActionForm3a.

// Default module -- Dynamic ActionForm should be created
public void testCreateActionForm3a() {
    request.setPathElements("/myapp", "/dynamic.do", null, null);
    ActionMapping mapping = (ActionMapping) moduleConfig.findActionConfig("/dynamic");
    assertNotNull("Found /dynamic mapping", mapping);
    assertNotNull("Mapping has non-null name", mapping.getName());
    assertEquals("Mapping has correct name", "dynamic", 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 DynaActionForm);
}
Also used : ActionMapping(org.apache.struts.action.ActionMapping) DynaActionForm(org.apache.struts.action.DynaActionForm) ActionForm(org.apache.struts.action.ActionForm) DynaActionForm(org.apache.struts.action.DynaActionForm)

Example 25 with ActionForm

use of org.apache.struts.action.ActionForm 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);
}
Also used : ActionMapping(org.apache.struts.action.ActionMapping) ActionForm(org.apache.struts.action.ActionForm) DynaActionForm(org.apache.struts.action.DynaActionForm) MockFormBean(org.apache.struts.mock.MockFormBean)

Aggregations

ActionForm (org.apache.struts.action.ActionForm)25 DynaActionForm (org.apache.struts.action.DynaActionForm)12 ActionMapping (org.apache.struts.action.ActionMapping)9 MockFormBean (org.apache.struts.mock.MockFormBean)5 ActionConfig (org.apache.struts.config.ActionConfig)4 Map (java.util.Map)3 FormBeanConfig (org.apache.struts.config.FormBeanConfig)3 ServletActionContext (org.apache.struts.chain.contexts.ServletActionContext)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 ServletException (javax.servlet.ServletException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 HttpSession (javax.servlet.http.HttpSession)1 DynaBean (org.apache.commons.beanutils.DynaBean)1 MutableDynaClass (org.apache.commons.beanutils.MutableDynaClass)1 Action (org.apache.struts.action.Action)1 ActionErrors (org.apache.struts.action.ActionErrors)1