Workplace Widget 5.10.8
This commit is contained in:
12
hmi-scripts/test-workplace-cluster.sh
Normal file
12
hmi-scripts/test-workplace-cluster.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
PROJECT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
javac --release 11 --add-modules jdk.httpserver -d "$TMP" \
|
||||
"$PROJECT/backend/src/main/java/com/workbenchclassic/hmi/HmiWorkplaceManifest.java" \
|
||||
"$PROJECT/hmi-scripts/tests/HmiWorkplaceClusterSelfTest.java"
|
||||
java --add-modules jdk.httpserver -cp "$TMP" \
|
||||
com.workbenchclassic.hmi.HmiWorkplaceClusterSelfTest \
|
||||
"$PROJECT/backend/src/main/resources/hmi/Workplace.jnlp"
|
||||
node "$PROJECT/hmi-frontend/tests/cheerpj-runner.mjs"
|
||||
40
hmi-scripts/tests/HmiWorkplaceClusterSelfTest.java
Normal file
40
hmi-scripts/tests/HmiWorkplaceClusterSelfTest.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.workbenchclassic.hmi;
|
||||
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/** Isolated integration test: local JNLP endpoint, no real MES connection. */
|
||||
public final class HmiWorkplaceClusterSelfTest {
|
||||
private HmiWorkplaceClusterSelfTest() {}
|
||||
public static void main(String[] args) throws Exception {
|
||||
Path jnlp=Path.of(args[0]);
|
||||
byte[] original=Files.readAllBytes(jnlp);
|
||||
HttpServer server=HttpServer.create(new InetSocketAddress("127.0.0.1",0),0);
|
||||
server.createContext("/Workplace.jnlp",exchange -> {
|
||||
exchange.getResponseHeaders().add("Content-Type","application/x-java-jnlp-file");
|
||||
exchange.sendResponseHeaders(200,original.length);
|
||||
try(var out=exchange.getResponseBody()){out.write(original);}
|
||||
});
|
||||
server.start();
|
||||
try {
|
||||
URL url=new URL("http://127.0.0.1:"+server.getAddress().getPort()+"/Workplace.jnlp");
|
||||
HmiWorkplaceManifest manifest=HmiWorkplaceManifest.fetch(url,"https://mon-svwin021136.itac.intra:8181/mes");
|
||||
if (!manifest.rewritten.contains("name=\"itac.artes.clusternodes\""))
|
||||
throw new AssertionError("Missing cluster nodes property");
|
||||
if (!manifest.rewritten.contains("value=\"https://mon-svwin021136.itac.intra:8181/mes\""))
|
||||
throw new AssertionError("Missing cluster nodes URL");
|
||||
if (manifest.jars.size()<100)throw new AssertionError("Missing JNLP jar dependencies: "+manifest.jars.size());
|
||||
if (!manifest.rewritten.contains("/backend/api/hmi/v1/cheerpj/workplace/jars"))
|
||||
throw new AssertionError("Unrewritten codebase");
|
||||
try {
|
||||
HmiWorkplaceManifest.fetch(url,"https://evil.example.com/");
|
||||
throw new AssertionError("Wrong MES path accepted");
|
||||
} catch(java.io.IOException correct) { /* expected */ }
|
||||
System.out.println("JNLP cluster property test: OK; jars="+manifest.jars.size());
|
||||
} finally {server.stop(0);}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user