Search in sources :

Example 56 with JavaFileObject

use of javax.tools.JavaFileObject in project neo4j by neo4j.

the class ProcedureProcessorTest method fails_if_record_type_has_nonpublic_fields.

@Test
public void fails_if_record_type_has_nonpublic_fields() {
    JavaFileObject record = JavaFileObjectUtils.INSTANCE.procedureSource("invalid/bad_record_type/BadRecord.java");
    UnsuccessfulCompilationClause compilation = assert_().about(javaSources()).that(asList(JavaFileObjectUtils.INSTANCE.procedureSource("invalid/bad_record_type/BadRecordTypeSproc.java"), record)).processedWith(processor).failsToCompile().withErrorCount(2);
    compilation.withErrorContaining("Record definition error: field BadRecord#label must be public").in(record).onLine(26);
    compilation.withErrorContaining("Record definition error: field BadRecord#age must be public").in(record).onLine(27);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) UnsuccessfulCompilationClause(com.google.testing.compile.CompileTester.UnsuccessfulCompilationClause) Test(org.junit.Test)

Example 57 with JavaFileObject

use of javax.tools.JavaFileObject in project neo4j by neo4j.

the class ProcedureProcessorTest method fails_if_procedure_generic_record_field_type_is_not_supported.

@Test
public void fails_if_procedure_generic_record_field_type_is_not_supported() {
    JavaFileObject record = JavaFileObjectUtils.INSTANCE.procedureSource("invalid/bad_record_field_type/BadRecordGenericFieldType.java");
    UnsuccessfulCompilationClause compilation = assert_().about(javaSources()).that(asList(JavaFileObjectUtils.INSTANCE.procedureSource("invalid/bad_record_field_type/BadRecordGenericFieldTypeSproc.java"), record)).processedWith(processor).failsToCompile().withErrorCount(3);
    compilation.withErrorContaining("Record definition error: type of field BadRecordGenericFieldType#wrongType1 is not supported").in(record).onLine(34);
    compilation.withErrorContaining("Record definition error: type of field BadRecordGenericFieldType#wrongType2 is not supported").in(record).onLine(35);
    compilation.withErrorContaining("Record definition error: type of field BadRecordGenericFieldType#wrongType3 is not supported").in(record).onLine(36);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) UnsuccessfulCompilationClause(com.google.testing.compile.CompileTester.UnsuccessfulCompilationClause) Test(org.junit.Test)

Example 58 with JavaFileObject

use of javax.tools.JavaFileObject in project neo4j by neo4j.

the class ProcedureProcessorTest method fails_if_parameters_are_not_properly_annotated.

@Test
public void fails_if_parameters_are_not_properly_annotated() {
    JavaFileObject sproc = JavaFileObjectUtils.INSTANCE.procedureSource("invalid/missing_name/MissingNameSproc.java");
    UnsuccessfulCompilationClause compilation = assert_().about(javaSource()).that(sproc).processedWith(processor).failsToCompile().withErrorCount(2);
    compilation.withErrorContaining("@org.neo4j.procedure.Name usage error: missing on parameter <parameter>").in(sproc).onLine(35);
    compilation.withErrorContaining("@org.neo4j.procedure.Name usage error: missing on parameter <otherParam>").in(sproc).onLine(35);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) UnsuccessfulCompilationClause(com.google.testing.compile.CompileTester.UnsuccessfulCompilationClause) Test(org.junit.Test)

Example 59 with JavaFileObject

use of javax.tools.JavaFileObject in project neo4j by neo4j.

the class ProcedureProcessorTest method fails_if_procedure_generic_input_type_is_not_supported.

@Test
public void fails_if_procedure_generic_input_type_is_not_supported() {
    JavaFileObject sproc = JavaFileObjectUtils.INSTANCE.procedureSource("invalid/bad_proc_input_type/BadGenericInputSproc.java");
    UnsuccessfulCompilationClause compilation = assert_().about(javaSource()).that(sproc).processedWith(processor).failsToCompile().withErrorCount(3);
    compilation.withErrorContaining("Unsupported parameter type " + "<java.util.List<java.util.List<java.util.Map<java.lang.String,java.lang.Thread>>>>" + " of procedure|function BadGenericInputSproc#doSomething").in(sproc).onLine(36);
    compilation.withErrorContaining("Unsupported parameter type " + "<java.util.Map<java.lang.String,java.util.List<java.util.concurrent.ExecutorService>>>" + " of procedure|function BadGenericInputSproc#doSomething2").in(sproc).onLine(42);
    compilation.withErrorContaining("Unsupported parameter type <java.util.Map> of procedure|function BadGenericInputSproc#doSomething3").in(sproc).onLine(48);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) UnsuccessfulCompilationClause(com.google.testing.compile.CompileTester.UnsuccessfulCompilationClause) Test(org.junit.Test)

Example 60 with JavaFileObject

use of javax.tools.JavaFileObject in project neo4j by neo4j.

the class ProcedureProcessorTest method fails_if_duplicate_procedures_are_declared.

@Test
public void fails_if_duplicate_procedures_are_declared() {
    JavaFileObject firstDuplicate = JavaFileObjectUtils.INSTANCE.procedureSource("invalid/duplicated/Sproc1.java");
    JavaFileObject secondDuplicate = JavaFileObjectUtils.INSTANCE.procedureSource("invalid/duplicated/Sproc2.java");
    assert_().about(javaSources()).that(asList(firstDuplicate, secondDuplicate)).processedWith(processor).failsToCompile().withErrorCount(2).withErrorContaining("Procedure|function name <org.neo4j.tooling.procedure.procedures.invalid.duplicated.foobar> is " + "already defined 2 times. It should be defined only once!");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Test(org.junit.Test)

Aggregations

JavaFileObject (javax.tools.JavaFileObject)663 Test (org.junit.Test)473 ButterKnifeProcessor (butterknife.compiler.ButterKnifeProcessor)121 IOException (java.io.IOException)52 JavaCompiler (javax.tools.JavaCompiler)40 StorIOContentResolverProcessor (com.pushtorefresh.storio.contentresolver.annotations.processor.StorIOContentResolverProcessor)38 StorIOSQLiteProcessor (com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor)35 File (java.io.File)32 Diagnostic (javax.tools.Diagnostic)30 DiagnosticCollector (javax.tools.DiagnosticCollector)28 SimpleJavaFileObject (javax.tools.SimpleJavaFileObject)25 StandardJavaFileManager (javax.tools.StandardJavaFileManager)25 ArrayList (java.util.ArrayList)24 TypeElement (javax.lang.model.element.TypeElement)21 Result (com.sun.tools.javac.main.Main.Result)20 Writer (java.io.Writer)17 PrintWriter (java.io.PrintWriter)16 CompilationTask (javax.tools.JavaCompiler.CompilationTask)14 JCTree (com.sun.tools.javac.tree.JCTree)10 StringWriter (java.io.StringWriter)10