Skip to content

Commit ea9e1bf

Browse files
committed
Fix test case
1 parent 177e122 commit ea9e1bf

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

core/java8/proxy/src/main/java/org/apache/openwhisk/runtime/java/action/JarLoader.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,25 @@ public static Path saveBase64EncodedFile(InputStream encoded) throws Exception {
5555
}
5656

5757
public JarLoader(Path jarPath, String entrypoint)
58-
throws MalformedURLException, ClassNotFoundException, SecurityException {
58+
throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, SecurityException {
5959
super(new URL[] { jarPath.toUri().toURL() });
6060

6161
final String[] splittedEntrypoint = entrypoint.split("#");
6262
final String entrypointClassName = splittedEntrypoint[0];
6363

64-
this.entrypointMethodName = splittedEntrypoint.length > 1 ? splittedEntrypoint[1] : "main";
6564
this.mainClass = loadClass(entrypointClassName);
65+
this.entrypointMethodName = splittedEntrypoint.length > 1 ? splittedEntrypoint[1] : "main";
66+
Method[] methods = mainClass.getDeclaredMethods();
67+
Boolean existMain = false;
68+
for(Method method: methods) {
69+
if (method.getName().equals(this.entrypointMethodName)) {
70+
existMain = true;
71+
break;
72+
}
73+
}
74+
if (!existMain) {
75+
throw new NoSuchMethodException(this.entrypointMethodName);
76+
}
6677
}
6778

6879
@SuppressWarnings({ "unchecked", "rawtypes" })

tests/src/test/scala/actionContainers/JavaActionContainerTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class JavaActionContainerTests extends BasicActionRunnerTests with WskActorSyste
320320
val (initCode, _) = c.init(initPayload(jar, "HelloArrayWhisk"))
321321
initCode should be(200)
322322

323-
val (runCode, runRes) = c.runForJsArray(JsObject())
323+
val (runCode, runRes) = c.runForJsArray(runPayload(JsObject()))
324324
runCode should be(200)
325325
runRes shouldBe Some(JsArray(JsString("a"), JsString("b")))
326326
}

0 commit comments

Comments
 (0)