Skip to content

Commit

Permalink
*Fix Module.js paths
Browse files Browse the repository at this point in the history
*Throw ScriptingException on js exception
  • Loading branch information
tdermendjiev authored and delchev committed Sep 21, 2021
1 parent 2988c00 commit 4011d62
Show file tree
Hide file tree
Showing 5 changed files with 260 additions and 261 deletions.
Expand Up @@ -424,7 +424,10 @@ protected void runTest(IJavascriptEngineExecutor executor, IRepository repositor
}
Object result = null;
long start = System.currentTimeMillis();
executor.executeServiceModule(testModule, null);
Object error = executor.executeServiceModule(testModule, null);
if (error != null && error.toString() != null) {
throw new ScriptingException(error.toString());
}
long time = System.currentTimeMillis() - start;
System.out.println(String.format("API test [%s] on engine [%s] passed for: %d ms", testModule,
executor.getType(), time));
Expand Down
Expand Up @@ -27,8 +27,6 @@ java.lang.Thread.sleep(500);
var resultSet = cassandraSession.getDBResults(cassandraSession,"test", "select*from test_table");
var stringResult = resultSet.getRowAsString();

console.log("EXECUTING ASSERT")
assertTrue(false);
assertTrue(stringResult !== null && stringResult !== undefined && stringResult === "[Row[1, test_user, 18]]");


Expand Up @@ -187,7 +187,7 @@ public Object executeService(String moduleOrCode, Map<Object, Object> executionC

if (isModule) {
bindings.putMember("MODULE_FILENAME", moduleOrCode);
result = context.eval(ENGINE_JAVA_SCRIPT, Require.MODULE_LOAD_CODE).as(Object.class);
context.eval(ENGINE_JAVA_SCRIPT, Require.MODULE_LOAD_CODE);
} else {
bindings.putMember("SCRIPT_STRING", moduleOrCode);
context.eval(ENGINE_JAVA_SCRIPT, Require.LOAD_STRING_CODE).as(Object.class);
Expand All @@ -211,6 +211,8 @@ public Object executeService(String moduleOrCode, Map<Object, Object> executionC
e.printStackTrace();
} catch (PolyglotException e) {
e.printStackTrace();
logger.trace("exiting: executeServiceModule() with js exception");
return e.getMessage(); // TODO: Create JSExecutionResult class and return it instead of Object instance
} catch (URISyntaxException e) {
e.printStackTrace();
}
Expand Down
Expand Up @@ -140,7 +140,7 @@ function findModulePath (id, dirs) {
return findModulePath(id, rest);
}

var resource = org.eclipse.dirigible.api.v3.platform.RepositoryFacade.getResource("/registry/public/" + location)
var resource = org.eclipse.dirigible.api.v3.platform.RepositoryFacade.getResource("/registry/public" + location)
if (resource.exists()) {
return location;
} else {
Expand Down

0 comments on commit 4011d62

Please sign in to comment.