当前位置: 首页>>代码示例>>Java>>正文


Java CompileTester类代码示例

本文整理汇总了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));
}
 
开发者ID:Cosium,项目名称:openapi-annotation-processor,代码行数:24,代码来源:ParserCaseTester.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedLibTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedLibTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedLibTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedLibTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedLibTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:23,代码来源:CheckWellFormedLibTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:21,代码来源:CheckWellFormedStructTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedFunctorTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedFunctorTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedFunctorTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedFunctorTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedFunctorTest.java

示例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);
}
 
开发者ID:udevbe,项目名称:jaccall,代码行数:27,代码来源:CheckWellFormedFunctorTest.java

示例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) {
  }
}
 
开发者ID:gradle,项目名称:incap,代码行数:30,代码来源:M1_NRelatedToOneAPTest.java


注:本文中的com.google.testing.compile.CompileTester类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。