From 6bda5d7e4e80d1aefb4f19203361b7199448e70f Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 5 Mar 2020 10:50:48 +0000 Subject: Use Rhino javascript executor in apex-pdp Integation unit tests resultd in StackOverflowException errors in the Graal Javascript interpreter. Following extensive testing and trouobleshooting, it proved very difficult to fix these issues in Graal as the stck overflow errors were occurring in native class instantiation methods being invoked by Grall on the JVM. The alternative Rhino Javascript engine is developed by mozilla, and was incorporated into the Java 6 JVM and evolved into Nashorn in the Java 8 JVM. Oracle dropped Nashorn in Java 11. However, in parallel, Rhino development has continued. This review brings in the Rhino javascript engine into apex-pdp as the replacement for Nashorn and instead of Graal. Graal seems to be pretty unstable as yet so we may bring it in in future releases but for now Rhino is a more stable and reliable alternative. Issue-ID: POLICY-2106 Change-Id: I0edeff3b0bee404b38e3ebe22001a6e3375a44dc Signed-off-by: liamfallon --- .../org/onap/policy/apex/examples/myfirstpolicy/MfpLogicTest.java | 4 ++-- .../onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'examples/examples-myfirstpolicy/src/test/java') diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpLogicTest.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpLogicTest.java index f19e2c8c3..3ebf8155e 100644 --- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpLogicTest.java +++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpLogicTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,7 +80,6 @@ public class MfpLogicTest { } } - /** * Check logic for MyFirstPolicyAlt#1. */ @@ -118,8 +118,8 @@ public class MfpLogicTest { logics.putAll(getTaskLogics(apexPolicyModel)); for (final Entry logicvalue : logics.entrySet()) { - final String filename = "examples/models/MyFirstPolicy/2/" + logicvalue.getKey(); final String logic = logicvalue.getValue(); + final String filename = "examples/models/MyFirstPolicy/2/" + logicvalue.getKey(); final String expectedlogic = ResourceUtils.getResourceAsString(filename); assertNotNull("File " + filename + " was not found. It should contain logic for PolicyModel " + apexPolicyModel.getKey(), expectedlogic); diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java index 07dc96ba3..af0e44450 100644 --- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java +++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelCliTest.java @@ -94,14 +94,14 @@ public class MfpModelCliTest { + tempModelFile1.getAbsolutePath() + " is not the same as the test Model for " + testApexModel1.getKey(), testApexModel1, generatedmodel); + tempLogFile1.delete(); + tempModelFile1.delete(); + generatedmodel = reader.read(TextFileUtils.getTextFileAsString(tempModelFile2.getAbsolutePath())); assertEquals("Model generated from the CLI (" + testApexModel2CliArgs[1] + ") into file " + tempModelFile2.getAbsolutePath() + " is not the same as the test Model for " + testApexModel2.getKey(), testApexModel2, generatedmodel); - tempLogFile1.delete(); - tempModelFile1.delete(); - tempLogFile2.delete(); tempModelFile2.delete(); -- cgit 1.2.3-korg