ConfigurationOverrides { public List<String> loadTextFileAndUpdate(String configFilePath, ServletContext context, Path appPath, BufferedReader reader) throws IOException { ServletResourceLoader loader = new ServletResourceLoader(context, appPath); try { String resource = lookupOverrideParameter(context, appPath); return loadFileAndUpdate(loader, resource, configFilePath, reader); } catch (JDOMException e) { return loadFileAndUpdate(loader, null, configFilePath, reader); } } ConfigurationOverrides(final String overrides); void updateLoggingAsAccordingToOverrides(ServletContext context, Path appPath); void updateWithOverrides(String configFile, ServletContext context, Path appPath, Element configElement); Element loadXmlFileAndUpdate(String servletRelativePath, ServletContext context); List<String> loadTextFileAndUpdate(String configFilePath, ServletContext context, Path appPath, BufferedReader reader); @SuppressWarnings("unchecked") void importSpringConfigurations(XmlBeanDefinitionReader reader, ConfigurableBeanFactory beanFactory, ServletContext servletContext, Path appPath); void postProcessSpringBeanFactory(ConfigurableListableBeanFactory beanFactory, ServletContext servletContext,
                                             Path appPath); void onSpringApplicationContextFinishedRefresh(ConfigurableListableBeanFactory beanFactory, ServletContext servletContext,
                                                          Path appPath); static final String OVERRIDES_KEY; static final ConfigurationOverrides DEFAULT; }
@Test public void loadFile() throws JDOMException, IOException { URL resourceAsStream = classLoader.getResource("test-sql.sql"); BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream.openStream(), Constants.ENCODING)); try { List<String> lines = new ConfigurationOverrides("/WEB-INF/overrides-config.xml,/WEB-INF/overrides-config-overlay.xml").loadTextFileAndUpdate("test-sql.sql", null, appPath, reader); assertEquals("CREATE TABLE NewRelations", lines.get(0).trim()); assertEquals("(", lines.get(1).trim()); assertEquals("primary key(id,overridden)", lines.get(2).trim()); assertEquals(");", lines.get(3).trim()); assertEquals("INSERT INTO Settings VALUES (21,20,'host','localhost');", lines.get(4).trim()); assertEquals("INSERT INTO Settings VALUES (22,20,'port','8080');", lines.get(5).trim()); } finally { reader.close(); } }