编写Servlet的单元测试用例

时间:2019-07-19 10:59:23

标签: servlets junit init

我想编写测试用例以获取此应用程序jar的真实路径,然后进行进一步处理。有人可以帮忙编写测试用例吗?

我是单元测试的新手,所以不确定如何编写servlet的测试用例。

public void init(ServletConfig config) throws ServletException {
        try {
            Properties props = loadProperties();    
            info("Loaded properties: " + jnlpprops);

            String appsStr = checkAppsExists(props);
            supportedApps = Arrays.asList(appsStr.split(","));

            applicationjars = config.getServletContext().getRealPath("application-jars");
            if (applicationjars == null) {
                throw new ServletException("Cannot find path for application jars");
            }

            populateJarFileNames(applicationjars);

        } catch (ServletException e) {
            throw e;
        } finally {

        }
    }

0 个答案:

没有答案