### Question:
FunctionInitializer { public String getMethod(String methodName) { loadFunctionBody(); return methods.get(methodName); } FunctionInitializer(String className, ClassLoader classLoader); ClassLoader getClassLoader(); String getClassName(); List<String> getImports(); String getMethod(String methodName);  }### Answer:
@Test public void testConcurrentFunctionBodyLoad() throws Exception { final FunctionInitializer functionInitializer = new FunctionInitializer(CLASS_NAME, classLoader); final AtomicInteger counter = new AtomicInteger(); new MockUp<FunctionInitializer>() { @Mock Java.CompilationUnit convertToCompilationUnit(Invocation inv, Class<?> clazz) { counter.incrementAndGet(); return inv.proceed(); } }; int threadsNumber = 5; ExecutorService executor = Executors.newFixedThreadPool(threadsNumber); try { List<Future<String>> results = executor.invokeAll(Collections.nCopies(threadsNumber, new Callable<String>() { @Override public String call() throws Exception { return functionInitializer.getMethod("eval"); } })); final Set<String> uniqueResults = new HashSet<>(); for (Future<String> result : results) { uniqueResults.add(result.get()); } assertEquals("All threads should have received the same result", 1, uniqueResults.size()); assertEquals("Number of function body loads should match", 1, counter.intValue()); } finally { executor.shutdownNow(); } }
@Test public void testGetMethod() { FunctionInitializer functionInitializer = new FunctionInitializer(CLASS_NAME, classLoader); String actualMethod = functionInitializer.getMethod("eval"); assertTrue("Method body should match", actualMethod.contains("CustomLowerFunction_eval:")); }