Migrate resources from src/main/java to src/main/resources
Description
Making a note of this here, as it was a new one for me:
IntelliJ marks folders as sources, generated sources, test sources, generated test sources, resources, test resources,
We have files such as gs-main src/test/java/org.vfny/geoserver/util/valid.sld that fail to load when running a test in InteliJ … because srs/test/java is a test resources folder and will not be scanned for resources!
this causes testValid() to fail, as null is returned (valid.sld cannot be found)
public void testValid() throws Exception {
SLDValidator validator = new SLDValidator();
List errors = validator.validateSLD(getClass().getResourceAsStream("valid.sld"));
// showErrors(errors);
assertTrue(errors.isEmpty());
}
Wild :)
I think I have usually done a maven build first which copies such files to target/classes …
Making a note of this here, as it was a new one for me:
IntelliJ marks folders as sources, generated sources, test sources, generated test sources, resources, test resources,
We have files such as gs-main src/test/java/org.vfny/geoserver/util/valid.sld that fail to load when running a test in InteliJ … because srs/test/java is a test resources folder and will not be scanned for resources!
this causes testValid() to fail, as null is returned (valid.sld cannot be found)
public void testValid() throws Exception { SLDValidator validator = new SLDValidator(); List errors = validator.validateSLD(getClass().getResourceAsStream("valid.sld")); // showErrors(errors); assertTrue(errors.isEmpty()); }
Wild :)
I think I have usually done a maven build first which copies such files to target/classes …
References:
https://www.jetbrains.com/help/idea/content-roots.html
https://stackoverflow.com/questions/26328040/intellij-idea-getclass-getresource-return-null