From 1e64fad0a91088b3ed0ef2f77ee5c9e21b7c4523 Mon Sep 17 00:00:00 2001 From: Reguel Wermelinger Date: Thu, 29 Aug 2024 15:17:39 +0200 Subject: [PATCH] XIVY-10310 setup test.engine.url and other props provided by ivyTestRuntime - with this test will always run against the correct base URI, even if multiple Designers are running --- .../ivy/webtest/IvyTestRuntimeProps.java | 31 +++++++++++++++++++ .../ivy/webtest/IvyWebTestExtension.java | 1 + 2 files changed, 32 insertions(+) create mode 100644 web-tester/src/main/java/com/axonivy/ivy/webtest/IvyTestRuntimeProps.java diff --git a/web-tester/src/main/java/com/axonivy/ivy/webtest/IvyTestRuntimeProps.java b/web-tester/src/main/java/com/axonivy/ivy/webtest/IvyTestRuntimeProps.java new file mode 100644 index 0000000..df36504 --- /dev/null +++ b/web-tester/src/main/java/com/axonivy/ivy/webtest/IvyTestRuntimeProps.java @@ -0,0 +1,31 @@ +package com.axonivy.ivy.webtest; + +import java.util.Properties; + +class IvyTestRuntimeProps { + + /** keep sync with ivy.core resource + * ch.ivyteam.ivy.bpm.exec.client.restricted.IvyTestRuntime.IvyTestRuntimeIO#RESOURCE_NAME */ + private static final String RT_PROPS = "ivyTestRuntime.properties"; + + public static void loadToSystem() { + var rtProps = loadProps(); + rtProps.propertyNames().asIterator().forEachRemaining(it -> { + var key = (String)it; + System.setProperty(key, rtProps.getProperty(key)); + }); + } + + public static Properties loadProps() { + var props = new Properties(); + ClassLoader loader = IvyWebTestExtension.class.getClassLoader(); + try(var in = loader.getResourceAsStream(RT_PROPS)) { + props.load(in); + } catch (Exception ex) { + System.err.println("Failed to read properties " + RT_PROPS); + ex.printStackTrace(); + } + return props; + } + +} diff --git a/web-tester/src/main/java/com/axonivy/ivy/webtest/IvyWebTestExtension.java b/web-tester/src/main/java/com/axonivy/ivy/webtest/IvyWebTestExtension.java index 961b63e..0b7026a 100644 --- a/web-tester/src/main/java/com/axonivy/ivy/webtest/IvyWebTestExtension.java +++ b/web-tester/src/main/java/com/axonivy/ivy/webtest/IvyWebTestExtension.java @@ -37,6 +37,7 @@ class IvyWebTestExtension implements BeforeEachCallback, BeforeAllCallback, Para @Override public void beforeAll(ExtensionContext context) throws Exception { + IvyTestRuntimeProps.loadToSystem(); Configuration.browser = browser(context); Configuration.headless = headless(context); }