@Test public void testGetResourceFromClassPath() throws Exception { File fic = File.createTempFile("test", ".jar"); fic.deleteOnExit(); JavaArchive jar = ShrinkWrap.create(JavaArchive.class); jar.addAsResource(new StringAsset("the_resource"), "resource.txt"); jar.as(ZipExporter.class).exportTo(fic, true); JarFileSystem classpath = new JarFileSystem(new JarFile(fic)); RAMFileSystem output = new RAMFileSystem(); Compiler compiler = Compiler.builder(). javaCompiler(compilerProvider). config(new CompilerConfig().force(true)). addClassPath(classpath). sourcePath(new RAMFileSystem()). output(output).build(); GetResource processor = new GetResource(StandardLocation.CLASS_PATH, FileKey.newResourceName("", "resource.txt")); compiler.addAnnotationProcessor(processor); compiler.compile(); processor.assertResource("the_resource"); }
@Test public void testGetResourceFromClassPath() throws Exception { File fic = File.createTempFile("test", ".jar"); fic.deleteOnExit(); JavaArchive jar = ShrinkWrap.create(JavaArchive.class); jar.addAsResource(new StringAsset("the_resource"), "resource.txt"); jar.as(ZipExporter.class).exportTo(fic, true); JarFileSystem classpath = new JarFileSystem(new JarFile(fic)); RAMFileSystem output = new RAMFileSystem(); Compiler compiler = Compiler.builder(). javaCompiler(compilerProvider). config(new CompilerConfig().force(true)). addClassPath(classpath). sourcePath(new RAMFileSystem()). output(output).build(); GetResource processor = new GetResource(StandardLocation.CLASS_PATH, FileKey.newResourceName("", "resource.txt")); compiler.addAnnotationProcessor(processor); compiler.compile(); processor.assertResource("the_resource"); }
@Test public void testProcessorErrorOnElement() throws Exception { DiskFileSystem fs = diskFS("compiler.annotationexception"); Compiler compiler = Compiler.builder().javaCompiler(compilerProvider).sourcePath(fs).output(new RAMFileSystem()).build(); @javax.annotation.processing.SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_6) @javax.annotation.processing.SupportedAnnotationTypes({"*"})
Compiler compiler = Compiler.builder().javaCompiler(compilerProvider).sourcePath(fs).output(new RAMFileSystem()).build(); @javax.annotation.processing.SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_6) @javax.annotation.processing.SupportedAnnotationTypes({"*"})
@Test public void testProcessorErrorOnElement() throws Exception { DiskFileSystem fs = diskFS("compiler.annotationexception"); Compiler compiler = Compiler.builder().javaCompiler(compilerProvider).sourcePath(fs).output(new RAMFileSystem()).build(); @javax.annotation.processing.SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_6) @javax.annotation.processing.SupportedAnnotationTypes({"*"})
Compiler compiler = Compiler.builder().sourcePath(ramFS).output(output).build(); compiler.compile(); assertEquals(2, output.size(ReadFileSystem.FILE));
config(new CompilerConfig().withProcessorOption("juzu.error_reporting", "formal")). sourcePath(fs). output(new RAMFileSystem()). build(); P processor = new P();
Compiler compiler = Compiler.builder().javaCompiler(compilerProvider).sourcePath(fs).output(new RAMFileSystem()).build(); @javax.annotation.processing.SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_6) @javax.annotation.processing.SupportedAnnotationTypes({"*"})
Compiler compiler = Compiler.builder().sourcePath(ramFS).output(output).build(); compiler.compile(); assertEquals(2, output.size(ReadFileSystem.FILE));
config(new CompilerConfig().withProcessorOption("juzu.error_reporting", "formal")). sourcePath(fs). output(new RAMFileSystem()). build(); P processor = new P();
@Test public void testGetResourceFromSourcePath() throws Exception { DiskFileSystem input = diskFS("compiler.getresource"); RAMFileSystem output = new RAMFileSystem(); Compiler compiler = Compiler.builder().javaCompiler(compilerProvider).sourcePath(input).output(output).build(); GetResource processor = new GetResource(StandardLocation.SOURCE_PATH, FileKey.newResourceName("compiler.getresource", "A.txt")); compiler.addAnnotationProcessor(processor); compiler.compile(); assertEquals(1, output.size(ReadFileSystem.FILE)); processor.assertResource("value"); }
@Test public void testGetResourceFromSourcePath() throws Exception { DiskFileSystem input = diskFS("compiler.getresource"); RAMFileSystem output = new RAMFileSystem(); Compiler compiler = Compiler.builder().javaCompiler(compilerProvider).sourcePath(input).output(output).build(); GetResource processor = new GetResource(StandardLocation.SOURCE_PATH, FileKey.newResourceName("compiler.getresource", "A.txt")); compiler.addAnnotationProcessor(processor); compiler.compile(); assertEquals(1, output.size(ReadFileSystem.FILE)); processor.assertResource("value"); }