My Appium + JUnit tests works perfectly fine locally, but on aws it can not find properties files. My tests are placed under src/test/java
and properties files used in tests under src/test/resources/locale
.
Zip with dependencies content:
├── app-0.1-tests.jar
├── app-0.1.jar
└── dependency-jars
├── ...
app-0.1-tests.jar
content:
├── META-INF
│ ├── MANIFEST.MF
│ ├── maven
│ ├── ....
├── com
│ ├── ....
└── locale
├── en_EN.properties
Unfortunately when I try to load properties files I have an IOException - file is not found in location:
file:/tmp/scratchcC4yMz.scratch/test-packagefQ2euI/app-0.1-tests.jar!/locale/en_EN.properties
I tried to load them in a couple of ways, each time I have the same issue. Locally everything works like a charm. Example of code:
File file = new File(ClassName.class.getResource("/locale/en_EN.properties").getPath());
try (InputStream inputStream = new FileInputStream(file.getPath());
InputStreamReader streamReader = new InputStreamReader(inputStream, Charset.forName("UTF-8"))) {
Properties properties = new Properties();
properties.load(streamReader);
return properties;
} catch (IOException e) {
System.err.println("Properties file not found: " + file.getPath());
}
or by using class loader:
ClassLoader classLoader = getClass().getClassLoader();
URL resource = classLoader.getResource("/locale/en_EN.properties");
Can someone suggest solution how to read properties file located in resources?