@Test public void testGetProviderThrowable() throws Exception { MockApplication<File> app = application("plugin.binding.provider.factory.throwable"); File root = app.getClasses().getRoot(); File services = new File(root, "META-INF/services"); assertTrue(services.mkdirs()); File providers = new File(services, ProviderFactory.class.getName()); FileWriter writer = new FileWriter(providers); writer.append("plugin.binding.provider.factory.throwable.ServiceProviderFactory"); writer.close(); // try { app.init(); fail(); } catch (SecurityException e) { } } }
@Test public void testGetProviderThrowable() throws Exception { MockApplication<File> app = application("plugin.binding.provider.factory.throwable"); File root = app.getClasses().getRoot(); File services = new File(root, "META-INF/services"); assertTrue(services.mkdirs()); File providers = new File(services, ProviderFactory.class.getName()); FileWriter writer = new FileWriter(providers); writer.append("plugin.binding.provider.factory.throwable.ServiceProviderFactory"); writer.close(); // try { app.init(); fail(); } catch (SecurityException e) { } } }
@Test public void testCreate() throws Exception { MockApplication<File> app = application("plugin.binding.provider.factory.create"); File root = app.getClasses().getRoot(); File services = new File(root, "META-INF/services"); assertTrue(services.mkdirs()); File providers = new File(services, ProviderFactory.class.getName()); FileWriter writer = new FileWriter(providers); writer.append("plugin.binding.provider.factory.create.ProviderFactoryImpl"); writer.close(); app.init(); // MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("pass", render.assertStringResponse()); }
@Test public void testCreate() throws Exception { MockApplication<File> app = application("plugin.binding.provider.factory.create"); File root = app.getClasses().getRoot(); File services = new File(root, "META-INF/services"); assertTrue(services.mkdirs()); File providers = new File(services, ProviderFactory.class.getName()); FileWriter writer = new FileWriter(providers); writer.append("plugin.binding.provider.factory.create.ProviderFactoryImpl"); writer.close(); app.init(); // MockClient client = app.client(); MockViewBridge render = client.render(); assertEquals("pass", render.assertStringResponse()); }
@Test public void testRuntime() throws Exception { MockApplication<?> app = application("plugin.asset.notfound.runtime"); File root = (File)app.getSourcePath().getPath("plugin", "asset", "notfound", "runtime"); File js = new File(root, "assets/notfound.js"); assertTrue(js.getParentFile().mkdirs()); assertTrue(js.createNewFile()); app.assertCompile(); root = (File)app.getClasses().getPath("plugin", "asset", "notfound", "runtime"); js = new File(root, "assets/notfound.js"); assertTrue(js.delete()); try { app.init(); fail(); } catch (Exception ignore) { } } }
@Test public void testRuntime() throws Exception { MockApplication<?> app = application("plugin.asset.notfound.runtime"); File root = (File)app.getSourcePath().getPath("plugin", "asset", "notfound", "runtime"); File js = new File(root, "assets/notfound.js"); assertTrue(js.getParentFile().mkdirs()); assertTrue(js.createNewFile()); app.assertCompile(); root = (File)app.getClasses().getPath("plugin", "asset", "notfound", "runtime"); js = new File(root, "assets/notfound.js"); assertTrue(js.delete()); try { app.init(); fail(); } catch (Exception ignore) { } } }
@Test public void testPrecompileGroovy() throws Exception { MockApplication<File> app = application("plugin.template.simple").init(); ReadFileSystem<File> fs = app.getClasses(); File groovy = fs.getPath("plugin", "template", "simple", "templates", "index_.groovy"); assertNotNull(groovy); CompilerConfiguration config = new CompilerConfiguration(); config.setTargetDirectory(fs.getRoot()); CompilationUnit cu = new CompilationUnit(config); cu.addSource(groovy); cu.compile(); assertTrue(groovy.delete()); MockClient client = app.client(); assertEquals("hello", client.render().assertStringResponse()); } }
@Test public void testPrecompileGroovy() throws Exception { MockApplication<File> app = application("plugin.template.simple").init(); ReadFileSystem<File> fs = app.getClasses(); File groovy = fs.getPath("plugin", "template", "simple", "templates", "index_.groovy"); assertNotNull(groovy); CompilerConfiguration config = new CompilerConfiguration(); config.setTargetDirectory(fs.getRoot()); CompilationUnit cu = new CompilationUnit(config); cu.addSource(groovy); cu.compile(); assertTrue(groovy.delete()); MockClient client = app.client(); assertEquals("hello", client.render().assertStringResponse()); } }