Example usage for org.springframework.mock.web MockHttpServletRequest addParameter

List of usage examples for org.springframework.mock.web MockHttpServletRequest addParameter

Introduction

In this page you can find the example usage for org.springframework.mock.web MockHttpServletRequest addParameter.

Prototype

public void addParameter(String name, String... values) 

Source Link

Document

Add an array of values for the specified HTTP parameter.

Usage

From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java

public void testDoModifyPluginPoolNoToken() throws AccessDeniedException {
    assertNull(PluginService.getPlugin(PLUGIN_NAME).getDbPoolName());
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("plugin_name", PLUGIN_NAME);
    request.addParameter(PARAM_DB_POOL_NAME, "junit");

    try {//from   ww  w.  j  a v  a  2 s . co m
        instance.doModifyPluginPool(request);
        fail("Should have thrown");
    } catch (AccessDeniedException e) {
        assertNull(PluginService.getPlugin(PLUGIN_NAME).getDbPoolName());
    }
}

From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java

public void testDoUninstallPluginNoToken() throws AccessDeniedException {
    PluginService.getPlugin(PLUGIN_NAME).install();
    assertTrue(PluginService.isPluginEnable(PLUGIN_NAME));
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("plugin_name", PLUGIN_NAME);

    try {//w w w  .  j  av a  2 s .  co m
        instance.doUninstallPlugin(request, request.getServletContext());
        fail("Should have thrown");
    } catch (AccessDeniedException e) {
        assertTrue(PluginService.isPluginEnable(PLUGIN_NAME));
    }
}

From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java

public void testDoModifyPluginPoolInvalidToken() throws AccessDeniedException {
    assertNull(PluginService.getPlugin(PLUGIN_NAME).getDbPoolName());
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("plugin_name", PLUGIN_NAME);
    request.addParameter(PARAM_DB_POOL_NAME, "junit");
    request.addParameter(SecurityTokenService.PARAMETER_TOKEN,
            SecurityTokenService.getInstance().getToken(request, "admin/system/manage_plugins.html") + "b");
    try {/*  w w  w.  java 2s.co  m*/
        instance.doModifyPluginPool(request);
        fail("Should have thrown");
    } catch (AccessDeniedException e) {
        assertNull(PluginService.getPlugin(PLUGIN_NAME).getDbPoolName());
    }
}

From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java

public void testGetDbTablePk1() throws Exception {
    MockHttpServletRequest req = createRequest("/db1/test_record_v2/1");
    req.addParameter("-column", "record_id,name");

    Response resp = getRespone(req);
    Assert.assertEquals(resp.getStatus(), 200);

    DataMap data = resp.getData();//from  w ww. j  a  va 2 s  .  c om
    Assert.assertEquals(data.getInt("record_id", 0), 1);
    Assert.assertNull(data.getString("name"));
    Assert.assertNotNull(data.getString("title"));
    Assert.assertTrue(data.size() > 2);
}

From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java

public void testDoUninstallPluginInvalidToken() throws AccessDeniedException {
    PluginService.getPlugin(PLUGIN_NAME).install();
    assertTrue(PluginService.isPluginEnable(PLUGIN_NAME));
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("plugin_name", PLUGIN_NAME);
    request.addParameter(SecurityTokenService.PARAMETER_TOKEN,
            SecurityTokenService.getInstance().getToken(request, "jsp/admin/system/DoUninstallPlugin.jsp")
                    + "b");
    try {//from   ww  w.  ja v  a 2s . c o  m
        instance.doUninstallPlugin(request, request.getServletContext());
        fail("Should have thrown");
    } catch (AccessDeniedException e) {
        assertTrue(PluginService.isPluginEnable(PLUGIN_NAME));
    }
}

From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java

public void testGetDbTable2() throws Exception {
    MockHttpServletRequest req = createRequest("/db1/test_record_v2");
    req.addParameter("column", "record_id,name");

    Response resp = getRespone(req);
    Assert.assertEquals(resp.getStatus(), 200);

    DataTable<DataMap> table = resp.getData();

    Assert.assertTrue(table.size() > 1);

    DataMap data = table.get(0);//from   w w w .j  a v a  2 s  .c  o m
    Assert.assertEquals(data.getString("record_id"), "1");
    Assert.assertNotNull(data.getString("name"));
    Assert.assertNull(data.getString("title"));
    Assert.assertTrue(data.size() > 1);
}

From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java

public void testGetDbTableFilter01() throws Exception {
    MockHttpServletRequest req = createRequest("/db1/test_record_v2");
    req.addParameter("column", "record_id,name");
    req.addParameter("record_id>1", "");

    Response resp = getRespone(req);
    Assert.assertEquals(resp.getStatus(), 200);

    DataTable<DataMap> table = resp.getData();

    Assert.assertTrue(table.size() > 0);

    DataMap data = table.get(0);/*from w w w.  j  a va 2 s. c o  m*/
    Assert.assertEquals(data.getString("record_id"), "2");
    Assert.assertNotNull(data.getString("name"));
    Assert.assertNull(data.getString("title"));
}

From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java

public void testGetDbTableFilter02() throws Exception {
    MockHttpServletRequest req = createRequest("/db1/test_record_v2");
    req.addParameter("column", "record_id,name");
    req.addParameter("record_id>", "1");

    Response resp = getRespone(req);
    Assert.assertEquals(resp.getStatus(), 200);

    DataTable<DataMap> table = resp.getData();

    Assert.assertTrue(table.size() > 0);

    DataMap data = table.get(0);/*from  ww  w . j av a2  s  .c  o  m*/
    Assert.assertEquals(data.getString("record_id"), "1");
    Assert.assertNotNull(data.getString("name"));
    Assert.assertNull(data.getString("title"));
}

From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java

public void testGetDbTableFilter03() throws Exception {
    MockHttpServletRequest req = createRequest("/db1/test_record_v2");
    req.addParameter("column", "record_id,name");
    req.addParameter("record_id<>1", "");

    Response resp = getRespone(req);
    Assert.assertEquals(resp.getStatus(), 200);

    DataTable<DataMap> table = resp.getData();

    Assert.assertTrue(table.size() > 0);

    DataMap data = table.get(0);/*from   w w w  .j  a  va 2s  .  co  m*/
    Assert.assertEquals(data.getString("record_id"), "2");
    Assert.assertNotNull(data.getString("name"));
    Assert.assertNull(data.getString("title"));
}

From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java

public void testGetDbTableFilter04() throws Exception {
    MockHttpServletRequest req = createRequest("/db1/test_record_v2");
    req.addParameter("column", "record_id,name");
    req.addParameter("name~ns*", "");

    Response resp = getRespone(req);
    Assert.assertEquals(resp.getStatus(), 200);

    DataTable<DataMap> table = resp.getData();

    Assert.assertTrue(table.size() > 0);

    DataMap data = table.get(0);//from w w  w .ja  va2s.co m
    Assert.assertEquals(data.getString("record_id"), "1");
    Assert.assertNotNull(data.getString("name"));
    Assert.assertNull(data.getString("title"));
}