SpringBootUtil { protected static Properties getPropertiesResource(URL resource) { Properties answer = new Properties(); if (resource != null) { try(InputStream stream = resource.openStream()) { answer.load(stream); } catch (IOException e) { throw new IllegalStateException("Error while reading resource from URL " + resource, e); } } return answer; }  static Properties getSpringBootApplicationProperties(URLClassLoader compileClassLoader); static Properties getSpringBootApplicationProperties(String springActiveProfile, URLClassLoader compileClassLoader); static Properties getPropertiesFromApplicationYamlResource(String springActiveProfile, URL ymlResource); static Optional<String> getSpringBootDevToolsVersion(MavenProject mavenProject); static Optional<String> getSpringBootVersion(MavenProject mavenProject); static String getSpringBootActiveProfile(MavenProject mavenProject);  }
@Test public void testPropertiesParsing() { Properties props = SpringBootUtil.getPropertiesResource(SpringBootUtilTest.class.getResource("/util/test-application.properties")); assertNotEquals(0, props.size()); assertEquals("8081", props.getProperty("management.port")); assertEquals("jdbc:mysql: assertEquals("value0", props.getProperty("example.nested.items[0].value")); assertEquals("value1", props.getProperty("example.nested.items[1].value")); }
@Test public void testNonExistentPropertiesParsing() { Properties props = SpringBootUtil.getPropertiesResource(SpringBootUtilTest.class.getResource("/this-file-does-not-exist")); assertNotNull(props); assertEquals(0, props.size()); }