Skip to content

Commit 7fa36d4

Browse files
committed
feat: refactor storage directory handling and add extended step definitions for BDD tests
1 parent 3e97775 commit 7fa36d4

4 files changed

Lines changed: 614 additions & 12 deletions

File tree

webapp/src/main/java/webapp/Config.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@ public class Config {
2020
public static final IStorage XML_STORAGE;
2121

2222
static {
23-
String webappRoot = System.getenv("WEBAPP_ROOT");
24-
if (webappRoot == null) {
25-
try {
26-
webappRoot = new File("webapp").getCanonicalPath();
27-
} catch (IOException e) {
28-
e.printStackTrace();
29-
}
23+
File currDir = new File(".");
24+
while (currDir != null && !new File(currDir, "webapp").exists()) {
25+
currDir = currDir.getParentFile();
3026
}
31-
if (webappRoot == null) {
32-
throw new IllegalStateException("Define environment variable WEBAPP_ROOT");
27+
if (currDir == null) {
28+
throw new IllegalStateException("Cannot find webapp root directory");
3329
}
34-
File webappRootDir = new File(webappRoot);
30+
31+
File webappRootDir = new File(currDir, "webapp");
3532
Properties props = new Properties();
3633
try (FileInputStream webappProps = new FileInputStream(new File(webappRootDir, "config/webapp.properties"));
3734
FileInputStream logProps = new FileInputStream(new File(webappRootDir, "config/logging.properties"))) {

0 commit comments

Comments
 (0)