List of usage examples for org.springframework.mock.web MockHttpServletRequest setCharacterEncoding
@Override public void setCharacterEncoding(@Nullable String characterEncoding)
From source file:org.pentaho.test.platform.web.ui.servlet.MondrianCatalogPublisherTests.java
protected MockHttpServletResponse simulateRequest(Map<String, String> map) throws Exception { // prepare request MockHttpServletRequest request = new MockHttpServletRequest(); request.setContentType("multipart/form-data; boundary=---1234"); //$NON-NLS-1$ request.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ String mondrianSchemaFile = map.get("mondrianSchemaFile"); if (logger.isDebugEnabled()) { logger.debug("uploading mondrian schema file named \"" + mondrianSchemaFile + "\""); }/*w w w. jav a 2s . com*/ String content = MessageFormat.format(DEFAULT_CONTENT_TEMPLATE, mondrianSchemaFile, DEFAULT_FILE_CONTENT); if (logger.isDebugEnabled()) { logger.debug("content=" + content); //$NON-NLS-1$ } request.setContent(content.getBytes("UTF-8")); //$NON-NLS-1$ request.addParameter("publishPath", map.get("publishPath")); //$NON-NLS-1$ //$NON-NLS-2$ request.addParameter("publishKey", map.get("publishKey")); //$NON-NLS-1$ //$NON-NLS-2$ request.addParameter("overwrite", map.get("overwrite")); //$NON-NLS-1$ //$NON-NLS-2$ request.addParameter("jndiName", map.get("jndiName")); //$NON-NLS-1$ //$NON-NLS-2$ MockHttpSession httpSession = new MockHttpSession(); httpSession.setAttribute("pentaho-session", pentahoSession); //$NON-NLS-1$ request.setSession(httpSession); // prepare response MockHttpServletResponse response = new MockHttpServletResponse(); // prepare mondrian catalog service MondrianCatalogHelper catService = new MondrianCatalogHelper(); catService.setDataSourcesConfig("file:" + destFile.getAbsolutePath()); //$NON-NLS-1$ // catService.afterPropertiesSet(); // prepare mondrian catalog publisher MondrianCatalogPublisher pub = new MondrianCatalogPublisher(); pub.setMondrianCatalogService(catService); pub.setFullyQualifiedServerURL("http://localhost:8080/pentaho"); //$NON-NLS-1$ // pub.afterPropertiesSet(); // process request // TODO We need to figure out how to test this . doGet is a protected method now //pub.doGet(request, response); // assertions response.getWriter().flush(); String responseContent = response.getContentAsString(); if (logger.isDebugEnabled()) { logger.debug("response=" + responseContent); //$NON-NLS-1$ } return response; }