Skip to content

Commit a261066

Browse files
tests
1 parent 4d7dc0b commit a261066

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/main/java/com/microsoft/azure/functions/worker/broker/JavaFunctionBroker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private void addSearchPathsToClassLoader(FunctionMethodDescriptor function) thro
9191
function.getLibDirectory().ifPresent(d -> registerWithClassLoaderProvider(d));
9292
}
9393

94-
private void registerWithClassLoaderProvider(File libDirectory) {
94+
void registerWithClassLoaderProvider(File libDirectory) {
9595
try {
9696
if(SystemUtils.IS_JAVA_1_8) {
9797
String workerLibPath = System.getenv(Constants.FUNCTIONS_WORKER_DIRECTORY) + "/lib";
@@ -116,7 +116,7 @@ private void registerWithClassLoaderProvider(File libDirectory) {
116116
}
117117
}
118118

119-
private boolean checkLibFolder(File workerLib, String workerLibPath, String status) throws Exception {
119+
boolean checkLibFolder(File workerLib, String workerLibPath, String status) throws Exception{
120120
if(!workerLib.exists()) {
121121
throw new Exception("Error loading worker jars, for "+ status +", from path: " + workerLibPath);
122122
} else {

src/test/java/com/microsoft/azure/functions/worker/broker/tests/JavaFunctionBrokerTest.java renamed to src/test/java/com/microsoft/azure/functions/worker/broker/JavaFunctionBrokerTest.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.microsoft.azure.functions.worker.broker.tests;
1+
package com.microsoft.azure.functions.worker.broker;
22

33
import com.microsoft.azure.functions.rpc.messages.InvocationRequest;
44
import com.microsoft.azure.functions.rpc.messages.ParameterBinding;
@@ -7,9 +7,12 @@
77
import com.microsoft.azure.functions.worker.reflect.DefaultClassLoaderProvider;
88
import mockit.*;
99
import org.junit.Test;
10+
11+
import java.io.File;
1012
import java.util.*;
1113

1214
import static org.junit.Assert.assertEquals;
15+
import static org.junit.Assert.assertTrue;
1316

1417
public class JavaFunctionBrokerTest {
1518

@@ -105,4 +108,26 @@ public void getTriggerMetadataMap_ignored(
105108
// In case of non-http request, it will not modify the triggerMetadata
106109
assertEquals(expectedCount, actualTriggerMetadata.size());
107110
}
111+
112+
@Test(expected = Exception.class)
113+
public void checkLibFolderNoWorkerLib() throws Exception {
114+
JavaFunctionBroker broker = new JavaFunctionBroker(null);
115+
broker.checkLibFolder(new File(""), null, null);
116+
}
117+
118+
@Test(expected = Exception.class)
119+
public void checkLibFolderNoJarsInLib() throws Exception {
120+
JavaFunctionBroker broker = new JavaFunctionBroker(null);
121+
String path = "./";
122+
File file = new File(path);
123+
broker.checkLibFolder(file, path, "CLIENT_LIB_FIRST");
124+
}
125+
126+
@Test
127+
public void checkLibFolderNoException() throws Exception {
128+
JavaFunctionBroker broker = new JavaFunctionBroker(null);
129+
String path = "./lib_worker_1.6.2";
130+
File file = new File(path);
131+
assertTrue(broker.checkLibFolder(file, path, "CLIENT_LIB_FIRST"));
132+
}
108133
}

0 commit comments

Comments
 (0)