protected int doPost(String operationURI, Hashtable params, RAPServlet rapServlet, Writer out) throws ServletException, IOException { FakeServletRequest request = new FakeServletRequest(FakeServletRequest.transform(params)); PrintWriter writer = new PrintWriter(out); FakeServletResponse response = new FakeServletResponse(writer); rapServlet.doPost(request, response, operationURI); return response.getStatus(); }
protected static void setupRAPServlet(RAPServlet rapServlet, String viewURIPrefix) throws ServletException { String base = TestFileUtils.getTestdataOutputDirectory() + testdataDirectory + File.separator; Hashtable initParams = new Hashtable(); initParams.put( "source_config", TestFileUtils.getTestInputFile(testdataDirectory, "WEB-INF/config/tm-sources.xml")); FakeServletContext servletContext = new FakeServletContext(base, new Hashtable(), initParams); Map params = new HashMap(); String viewURI = viewURIPrefix + "get-topic/models/topic_complete.jsp?tm=%tmid%&id=%topicid%"; params.put("view_uri", viewURI); Hashtable paramsTable = TMRAPTestUtils.tabularizeParameters(params); FakeServletConfig servletConfig = new FakeServletConfig(servletContext, paramsTable); rapServlet.init(servletConfig); }
protected int doGet( String operationURI, String parameters, Hashtable params, RAPServlet rapServlet, Writer out, int httpcode) throws ServletException, IOException { Hashtable tempTable = new Hashtable(params); tempTable.putAll( TMRAPTestUtils.tabularizeParameters(TMRAPTestUtils.tokenizeParameters(parameters))); FakeServletRequest request = new FakeServletRequest(FakeServletRequest.transform(tempTable)); PrintWriter writer = new PrintWriter(out); FakeServletResponse response = new FakeServletResponse(writer); rapServlet.doGet(request, response, operationURI); if (httpcode != -1 && response.getStatus() != httpcode) throw new ServletException("Error in HTTP operation: " + response.getMessage()); return response.getStatus(); }
@After public void tearDown() { TopicMapRepositoryIF topicMapRepository = NavigatorUtils.getTopicMapRepository(rapServlet.getServletContext()); TopicMaps.forget(topicMapRepository); }