@Test public void testWhenUsingCompiledScriptCacheItReturnsModuleFromCache() throws Exception { final CompiledScriptCache cache = new CompiledScriptCache(); subject = new ScribuntoLuaEngine(model, cache); final String pageCode = "return { " + " test_function = function() return 'result' end " + "}"; when(model.getRawWikiContent(any(ParsedPageName.class), anyMap())) .thenReturn(pageCode) .thenThrow(new RuntimeException("should only be called once")); ScribuntoModule module = subject.fetchModuleFromParser("testModule"); assertThat(module.invoke("test_function", new Frame(null, null, null, false))).isEqualTo("result"); ScribuntoModule cachedModule = subject.fetchModuleFromParser("testModule"); assertThat(cachedModule.invoke("test_function", new Frame(null, null, null, false))).isEqualTo("result"); assertThat(cachedModule).isNotSameAs(module); }
@Override public ScribuntoModule fetchModuleFromParser(String moduleName) throws ScribuntoException { ParsedPageName pageName = pageNameForModule(moduleName); Prototype prototype = compiledScriptCache.getPrototypeForChunkname(pageName); if (prototype == null) { try (Reader reader = new StringReader(getRawWikiContent(pageName))) { prototype = loadAndCache(reader, pageName); } catch (IOException e) { throw new ScribuntoException(e); } } return new ScribuntoLuaModule(this, prototype, pageName); }
ScribuntoLuaEngine extends ScribuntoEngineBase implements MwInterface { @Override public ScribuntoModule fetchModuleFromParser(String moduleName) throws ScribuntoException { ParsedPageName pageName = pageNameForModule(moduleName); Prototype prototype = compiledScriptCache.getPrototypeForChunkname(pageName); if (prototype == null) { try (Reader reader = new StringReader(getRawWikiContent(pageName))) { prototype = loadAndCache(reader, pageName); } catch (IOException e) { throw new ScribuntoException(e); } } return new ScribuntoLuaModule(this, prototype, pageName); } }
ScribuntoLuaEngine extends ScribuntoEngineBase implements MwInterface { @Override public ScribuntoModule fetchModuleFromParser(String moduleName) throws ScribuntoException { ParsedPageName pageName = pageNameForModule(moduleName); Prototype prototype = compiledScriptCache.getPrototypeForChunkname(pageName); if (prototype == null) { try (Reader reader = new StringReader(getRawWikiContent(pageName))) { prototype = loadAndCache(reader, pageName); } catch (IOException e) { throw new ScribuntoException(e); } } return new ScribuntoLuaModule(this, prototype, pageName); } ScribuntoLuaEngine(IWikiModel model, CompiledScriptCache cache); private  ScribuntoLuaEngine(IWikiModel model, CompiledScriptCache compiledScriptCache, Globals globals); }
ScribuntoLuaEngine extends ScribuntoEngineBase implements MwInterface { @Override public ScribuntoModule fetchModuleFromParser(String moduleName) throws ScribuntoException { ParsedPageName pageName = pageNameForModule(moduleName); Prototype prototype = compiledScriptCache.getPrototypeForChunkname(pageName); if (prototype == null) { try (Reader reader = new StringReader(getRawWikiContent(pageName))) { prototype = loadAndCache(reader, pageName); } catch (IOException e) { throw new ScribuntoException(e); } } return new ScribuntoLuaModule(this, prototype, pageName); } ScribuntoLuaEngine(IWikiModel model, CompiledScriptCache cache); private  ScribuntoLuaEngine(IWikiModel model, CompiledScriptCache compiledScriptCache, Globals globals); @Override ScribuntoModule fetchModuleFromParser(String moduleName); @Override String name(); @Override LuaTable getInterface(); @Override LuaValue getSetupOptions(); }
ScribuntoLuaEngine extends ScribuntoEngineBase implements MwInterface { @Override public ScribuntoModule fetchModuleFromParser(String moduleName) throws ScribuntoException { ParsedPageName pageName = pageNameForModule(moduleName); Prototype prototype = compiledScriptCache.getPrototypeForChunkname(pageName); if (prototype == null) { try (Reader reader = new StringReader(getRawWikiContent(pageName))) { prototype = loadAndCache(reader, pageName); } catch (IOException e) { throw new ScribuntoException(e); } } return new ScribuntoLuaModule(this, prototype, pageName); } ScribuntoLuaEngine(IWikiModel model, CompiledScriptCache cache); private  ScribuntoLuaEngine(IWikiModel model, CompiledScriptCache compiledScriptCache, Globals globals); @Override ScribuntoModule fetchModuleFromParser(String moduleName); @Override String name(); @Override LuaTable getInterface(); @Override LuaValue getSetupOptions();  }