@Test public void testInit() throws Exception { MockServletConfig config = new MockServletConfig(); servlet.init(config); Assert.assertTrue(MonetaEnvironment.getConfiguration().getIgnoredContextPathNodes()==null); config.getInitParmMap().put(MonetaServlet.CONFIG_IGNORED_CONTEXT_PATH_NODES, ""); servlet.init(config); Assert.assertTrue(MonetaEnvironment.getConfiguration().getIgnoredContextPathNodes()==null); config.getInitParmMap().put(MonetaServlet.CONFIG_IGNORED_CONTEXT_PATH_NODES, "fart,,,"); servlet.init(config); Assert.assertTrue(MonetaEnvironment.getConfiguration().getIgnoredContextPathNodes().length==1); config.getInitParmMap().put(MonetaServlet.CONFIG_IGNORED_CONTEXT_PATH_NODES, "first , second, third "); servlet.init(config); Assert.assertTrue(MonetaEnvironment.getConfiguration().getIgnoredContextPathNodes().length==3); Assert.assertTrue("third".equals(MonetaEnvironment.getConfiguration().getIgnoredContextPathNodes()[2])); }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); MonetaEnvironment.setConfiguration(new MonetaConfiguration()); if (config == null) return; String IgnoredContextPathNodesStr = config.getInitParameter(CONFIG_IGNORED_CONTEXT_PATH_NODES); if ( !StringUtils.isEmpty(IgnoredContextPathNodesStr)) { String[] nodeArray = StringUtils.split(IgnoredContextPathNodesStr, ","); for (int offset=0; offset < nodeArray.length; offset++) { nodeArray[offset] = nodeArray[offset].trim(); } MonetaEnvironment.getConfiguration().setIgnoredContextPathNodes(nodeArray); } }
MonetaServlet extends HttpServlet { @Override public void init(ServletConfig config) throws ServletException { super.init(config); MonetaEnvironment.setConfiguration(new MonetaConfiguration()); if (config == null) return; String IgnoredContextPathNodesStr = config.getInitParameter(CONFIG_IGNORED_CONTEXT_PATH_NODES); if ( !StringUtils.isEmpty(IgnoredContextPathNodesStr)) { String[] nodeArray = StringUtils.split(IgnoredContextPathNodesStr, ","); for (int offset=0; offset < nodeArray.length; offset++) { nodeArray[offset] = nodeArray[offset].trim(); } MonetaEnvironment.getConfiguration().setIgnoredContextPathNodes(nodeArray); } } }
MonetaServlet extends HttpServlet { @Override public void init(ServletConfig config) throws ServletException { super.init(config); MonetaEnvironment.setConfiguration(new MonetaConfiguration()); if (config == null) return; String IgnoredContextPathNodesStr = config.getInitParameter(CONFIG_IGNORED_CONTEXT_PATH_NODES); if ( !StringUtils.isEmpty(IgnoredContextPathNodesStr)) { String[] nodeArray = StringUtils.split(IgnoredContextPathNodesStr, ","); for (int offset=0; offset < nodeArray.length; offset++) { nodeArray[offset] = nodeArray[offset].trim(); } MonetaEnvironment.getConfiguration().setIgnoredContextPathNodes(nodeArray); } }  }
MonetaServlet extends HttpServlet { @Override public void init(ServletConfig config) throws ServletException { super.init(config); MonetaEnvironment.setConfiguration(new MonetaConfiguration()); if (config == null) return; String IgnoredContextPathNodesStr = config.getInitParameter(CONFIG_IGNORED_CONTEXT_PATH_NODES); if ( !StringUtils.isEmpty(IgnoredContextPathNodesStr)) { String[] nodeArray = StringUtils.split(IgnoredContextPathNodesStr, ","); for (int offset=0; offset < nodeArray.length; offset++) { nodeArray[offset] = nodeArray[offset].trim(); } MonetaEnvironment.getConfiguration().setIgnoredContextPathNodes(nodeArray); } }  @Override void doGet(HttpServletRequest request, HttpServletResponse response); @Override void init(ServletConfig config); }
MonetaServlet extends HttpServlet { @Override public void init(ServletConfig config) throws ServletException { super.init(config); MonetaEnvironment.setConfiguration(new MonetaConfiguration()); if (config == null) return; String IgnoredContextPathNodesStr = config.getInitParameter(CONFIG_IGNORED_CONTEXT_PATH_NODES); if ( !StringUtils.isEmpty(IgnoredContextPathNodesStr)) { String[] nodeArray = StringUtils.split(IgnoredContextPathNodesStr, ","); for (int offset=0; offset < nodeArray.length; offset++) { nodeArray[offset] = nodeArray[offset].trim(); } MonetaEnvironment.getConfiguration().setIgnoredContextPathNodes(nodeArray); } }  @Override void doGet(HttpServletRequest request, HttpServletResponse response); @Override void init(ServletConfig config); static final String CONFIG_IGNORED_CONTEXT_PATH_NODES; }