SHA256
Зафиксировать текущие изменения CORE/CONTENT
This commit is contained in:
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# Isolated test of configuration loading; no real credentials or server needed.
|
||||
set -euo pipefail
|
||||
ROOT=$(cd -- "$(dirname -- "$0")/../.." && pwd)
|
||||
TMP=$(mktemp -d)
|
||||
trap 'rm -rf -- "$TMP"' EXIT
|
||||
mkdir -p "$TMP/classes" "$TMP/work" "$TMP/defaults"
|
||||
cat > "$TMP/Probe.java" <<'JAVA'
|
||||
import utils.config.AppConfig;
|
||||
public class Probe {
|
||||
public static void main(String[] args) {
|
||||
AppConfig config = AppConfig.getInstance();
|
||||
if (!args[0].equals(config.getParam("shine.config.probe"))) throw new AssertionError("Unexpected probe value");
|
||||
if (args.length > 1 && !args[1].equals(config.getParam("shine.config.other"))) throw new AssertionError("Missing default");
|
||||
}
|
||||
}
|
||||
JAVA
|
||||
javac --release 17 -d "$TMP/classes" "$ROOT/SHiNE-server/shine-server-config/src/main/java/utils/config/AppConfig.java" "$TMP/Probe.java"
|
||||
cd "$TMP/work"
|
||||
CP="$TMP/classes"
|
||||
printf 'shine.config.probe=external\n' > application.properties
|
||||
java -cp "$CP" Probe external
|
||||
printf 'shine.config.probe=internal\nshine.config.other=default\n' > "$TMP/defaults/application.properties"
|
||||
java -cp "$CP:$TMP/defaults" Probe external default
|
||||
SHINE_CONFIG_PROBE=environment java -cp "$CP" Probe environment
|
||||
SHINE_CONFIG_PROBE=environment java -Dshine.config.probe=system -cp "$CP" Probe system
|
||||
rm application.properties
|
||||
java -cp "$CP:$TMP/defaults" Probe internal default
|
||||
if java -cp "$CP" Probe missing > "$TMP/error" 2>&1; then
|
||||
echo 'FAIL: missing configuration accepted'; exit 1
|
||||
fi
|
||||
grep -q 'External application.properties missing' "$TMP/error"
|
||||
echo 'PASS: external only, overlay, env, JVM property, internal only, missing config'
|
||||
Reference in New Issue
Block a user