本文整理汇总了Java中com.google.testing.compile.CompileTester类的典型用法代码示例。如果您正苦于以下问题:Java CompileTester类的具体用法?Java CompileTester怎么用?Java CompileTester使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompileTester类属于com.google.testing.compile包,在下文中一共展示了CompileTester类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
private void doTest() throws Exception {
LOG.info("Running test '{}' for parser '{}'", caseName, parserName);
List<JavaFileObject> inputs = subFileObjetcs(inputPath);
LOG.debug("Using inputs {}", inputs);
List<String> options = parseOptions();
LOG.debug("Using options {}", options);
CompileTester.SuccessfulCompilationClause clause = Truth.assert_()
.about(JavaSourcesSubjectFactory.javaSources())
.that(subFileObjetcs(inputPath))
.withCompilerOptions(options)
.processedWith(new OpenAPIProcessor())
.compilesWithoutError();
resources(expectedPath)
.stream()
.peek(resource -> LOG.debug("Validating expectation on {}", resource))
.forEach(resource -> clause.and()
.generatesFileNamed(LOCATION, resource.packageName, resource.relativeName)
.withContents(resource.byteSource));
}
示例2: testLibNotOnClass
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testLibNotOnClass() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Lib;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Lib(\"testing\")\n" +
"public interface Testing {\n" + // <----
" long doStaticTest(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Ptr(int.class) long field2,\n" +
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Lib annotation should be placed on class type only.")
.in(fileObject);
}
示例3: testPtrAnnotationNotOnPrimitiveLong
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testPtrAnnotationNotOnPrimitiveLong() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Lib;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Lib(\"testing\")\n" +
"public class Testing {\n" +
" public static native long doStaticTest(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Ptr(int.class) int field2,\n" + // <----
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Ptr annotation can only be placed on primitive type 'long'.")
.in(fileObject);
}
示例4: testUnsignedAnnotationNotOnPrimitiveNonFloat
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testUnsignedAnnotationNotOnPrimitiveNonFloat() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Lib;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Lib(\"testing\")\n" +
"public class Testing {\n" +
" public static native long doStaticTest(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Unsigned float field2,\n" + // <----
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Unsigned annotation can not be placed on primitive type 'float'.")
.in(fileObject);
}
示例5: testUnsignedAnnotationNotOnPrimitiveNonDouble
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testUnsignedAnnotationNotOnPrimitiveNonDouble() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Lib;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Lib(\"testing\")\n" +
"public class Testing {\n" +
" public static native long doStaticTest(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Unsigned double field2,\n" +// <----
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Unsigned annotation can not be placed on primitive type 'double'.")
.in(fileObject);
}
示例6: testUnsignedAnnotationInConjunctionWithPtrAnnotation
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testUnsignedAnnotationInConjunctionWithPtrAnnotation() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Lib;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Lib(\"testing\")\n" +
"public class Testing {\n" +
" public static native long doStaticTest(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Unsigned @Ptr(long.class) long field2,\n" + // <----
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Unsigned annotation can not be placed in conjunction with @Ptr annotation.")
.in(fileObject);
}
示例7: testSymbolAnnotationNotAPtr
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testSymbolAnnotationNotAPtr(){
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Lib;\n" +
"import org.freedesktop.jaccall.Symbol;\n" +
"\n" +
"@Lib(\"testing\")\n" +
"public class Testing {\n" +
" @Symbol\n" +
" public static native long globalVariable();\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("Symbol should be annotated with @Ptr.")
.in(fileObject);
}
示例8: testStructNoFields
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testStructNoFields() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("org.freedesktop.libtest.struct.TestStruct",
"package org.freedesktop.jaccall.compiletime.linker;\n" +
"\n" +
"import org.freedesktop.jaccall.Struct;\n" +
"\n" +
"@Struct(value = {})\n" +
"public final class TestStruct extends TestStruct_Jaccall_StructType {\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Struct annotation must have at least one field.")
.in(fileObject);
}
示例9: testNotAnInterface
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testNotAnInterface() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Functor;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Functor\n" +
"public abstract class Testing {\n" +
" abstract long $(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Ptr(int.class) long field2,\n" +
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("Type must be an interface.")
.in(fileObject);
}
示例10: testNotDollarAsName
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testNotDollarAsName() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Functor;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Functor\n" +
"public interface Testing {\n" +
" long doStaticTest(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Ptr(int.class) long field2,\n" +
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("Method name must be 'invoke'.")
.in(fileObject);
}
示例11: testPtrAnnotationNotOnPrimitiveLong
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testPtrAnnotationNotOnPrimitiveLong() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Functor;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Functor\n" +
"public interface Testing {\n" +
" long $(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Ptr(int.class) int field2,\n" + // <----
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Ptr annotation can only be placed on primitive type 'long'.")
.in(fileObject);
}
示例12: testUnsignedAnnotationNotOnPrimitiveNonFloat
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testUnsignedAnnotationNotOnPrimitiveNonFloat() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Functor;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Functor\n" +
"public interface Testing {\n" +
" long $(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Unsigned float field2,\n" + // <----
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Unsigned annotation can not be placed on primitive type 'float'.")
.in(fileObject);
}
示例13: testUnsignedAnnotationNotOnPrimitiveNonDouble
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testUnsignedAnnotationNotOnPrimitiveNonDouble() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Functor;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Functor\n" +
"public interface Testing {\n" +
" long $(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Unsigned double field2,\n" +// <----
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Unsigned annotation can not be placed on primitive type 'double'.")
.in(fileObject);
}
示例14: testUnsignedAnnotationInConjunctionWithPtrAnnotation
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testUnsignedAnnotationInConjunctionWithPtrAnnotation() {
//given
final JavaFileObject fileObject = JavaFileObjects.forSourceString("Testing",
"package org.freedesktop.libtest;\n" +
"import org.freedesktop.jaccall.Functor;\n" +
"import org.freedesktop.jaccall.Ptr;\n" +
"import org.freedesktop.jaccall.Unsigned;\n" +
"\n" +
"@Functor\n" +
"public interface Testing {\n" +
" long $(long tst,\n" +
" byte field0,\n" +
" @Unsigned short field1,\n" +
" @Unsigned @Ptr(long.class) long field2,\n" + // <----
" @Ptr(int.class) long field3);\n" +
"}");
//when
final CompileTester compileTester = assert_().about(javaSource())
.that(fileObject)
.processedWith(new JaccallGenerator());
//then
compileTester.failsToCompile()
.withErrorContaining("@Unsigned annotation can not be placed in conjunction with @Ptr annotation.")
.in(fileObject);
}
示例15: testM1_NRelatedToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess_UsesPreviouslyCompiledClass
import com.google.testing.compile.CompileTester; //导入依赖的package包/类
@Test
public void testM1_NRelatedToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess_UsesPreviouslyCompiledClass() {
//GIVEN
JavaFileObject source = forSourceString("test.Test", "" //
+ "package test;\n" //
+ "import org.gradle.incap.Annotation1;\n" //
+ "@Annotation1\n" //
+ "public class Test extends org.gradle.incap.util.Untouched{\n" //
+ "}");
JavaFileObject expected0 = forSourceString("M1_NRelatedToOneAP_TestGen0", "" //
+ "\n" //
+ "public class M1_NRelatedToOneAP_TestGen0 {\n" //
+ "}");
//WHEN
//THEN
CompileTester.SuccessfulCompilationClause successfulCompilationClause = Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
.withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.") //
.processedWith(new M1_NRelatedToOneAP()) //
.compilesWithoutError().and().generatesSources(expected0);
try {
successfulCompilationClause //
.and() //
.generatesFileNamed(StandardLocation.SOURCE_OUTPUT, "", "M1_NRelatedToOneAP_UntouchedGen0");
fail();
} catch (AssertionError e) {
}
}