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


Java JavaFileObjects类代码示例

本文整理汇总了Java中com.google.testing.compile.JavaFileObjects的典型用法代码示例。如果您正苦于以下问题:Java JavaFileObjects类的具体用法?Java JavaFileObjects怎么用?Java JavaFileObjects使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JavaFileObjects类属于com.google.testing.compile包,在下文中一共展示了JavaFileObjects类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void test() throws URISyntaxException, MalformedURLException {
    Compilation compilation = Compiler.javac()
        .withProcessors(new SyndesisExtensionActionProcessor())
        .compile(JavaFileObjects.forSourceString(
            "test.AnnotatedClassTest",
            "package test;\n" +
            "\n" +
            "@io.syndesis.integration.runtime.api.SyndesisExtensionAction(\n" +
            "    id = \"action-id\",\n" +
            "    name = \"action-name\",\n" +
            "    description = \"action-description\"\n" +
            ")\n" +
            "public class AnnotatedClassTest {\n" +
            "}"
        )
    );

    assertTrue(compilation.generatedFile(StandardLocation.SOURCE_OUTPUT, "test/AnnotatedClassTest-action-id.properties").isPresent());
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:21,代码来源:SyndesisExtensionActionProcessorTest.java

示例2: testAnnotatedMembers_instanceField

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void testAnnotatedMembers_instanceField() {
  List<Diagnostic<? extends JavaFileObject>> diagnostics = compiler.compile(
      BETA, ANNOTATED_MEMBERS,
      JavaFileObjects.forSourceLines("example.Test",
          "package example;",
          "",
          "import com.google.common.foo.AnnotatedMembers;",
          "",
          "public class Test {",
          "  public static void foo(AnnotatedMembers instance) {",
          "    System.out.println(instance.annotatedInstanceField);", // error
          "  }",
          "}")
  );

  compiler.assertErrorsOnLines("example/Test.java", diagnostics, 7);
}
 
开发者ID:google,项目名称:guava-beta-checker,代码行数:19,代码来源:BetaCheckerTest.java

示例3: methodVisibility

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test public void methodVisibility() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
      + "package test;\n"
      + "import android.view.View;\n"
      + "import butterknife.OnClick;\n"
      + "public class Test {\n"
      + "  @OnClick(1) public void thing1() {}\n"
      + "  @OnClick(2) void thing2() {}\n"
      + "  @OnClick(3) protected void thing3() {}\n"
      + "}"
  );

  assertAbout(javaSource()).that(source)
      .withCompilerOptions("-Xlint:-processing")
      .processedWith(new ButterKnifeProcessor())
      .compilesWithoutWarnings();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:OnClickTest.java

示例4: compilation_withExtension_fails

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void compilation_withExtension_fails() {
  expectedException.expect(RuntimeException.class);
  javac()
      .withProcessors(new GlideAnnotationProcessor())
      .compile(
          emptyAppModule(),
          JavaFileObjects.forSourceLines(
              "Extension",
              "package com.bumptech.glide.test;",
              "import com.bumptech.glide.annotation.GlideExtension;",
              "@GlideExtension",
              "class Extension {",
              "  private Extension() {}",
              "}"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:InvalidGlideExtensionTest.java

示例5: testAnnotatedClass_extending

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void testAnnotatedClass_extending() {
  List<Diagnostic<? extends JavaFileObject>> diagnostics = compiler.compile(
      BETA, ANNOTATED_CLASS,
      JavaFileObjects.forSourceLines(
          "example.Test",
          "package example;",
          "",
          "import com.google.common.foo.AnnotatedClass;",
          "",
          "public class Test extends AnnotatedClass {", // error
          "}")
  );

  compiler.assertErrorsOnLines("example/Test.java", diagnostics, 5);
}
 
开发者ID:google,项目名称:guava-beta-checker,代码行数:17,代码来源:BetaCheckerTest.java

示例6: failsIfPrivateMethod

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test public void failsIfPrivateMethod() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
      + "package test;\n"
      + "import butterknife.OnClick;\n"
      + "public class Test {\n"
      + "  @OnClick(1)\n"
      + "  private void doStuff() {\n"
      + "  }\n"
      + "}"
  );

  assertAbout(javaSource()).that(source)
      .processedWith(new ButterKnifeProcessor())
      .failsToCompile()
      .withErrorContaining("@OnClick methods must not be private or static. (test.Test.doStuff)")
      .in(source).onLine(5);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:OnClickTest.java

示例7: testAnnotatedClass_asTypeArgument

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void testAnnotatedClass_asTypeArgument() {
  List<Diagnostic<? extends JavaFileObject>> diagnostics = compiler.compile(
      BETA, ANNOTATED_CLASS,
      JavaFileObjects.forSourceLines(
          "example.Test",
          "package example;",
          "",
          "import com.google.common.foo.AnnotatedClass;",
          "",
          "import java.util.List;",
          "",
          "public class Test {",
          "  public static void foo(List<AnnotatedClass> stuff) {", // error
          "  }",
          "}")
  );

  compiler.assertErrorsOnLines("example/Test.java", diagnostics, 8);
}
 
开发者ID:google,项目名称:guava-beta-checker,代码行数:21,代码来源:BetaCheckerTest.java

示例8: testAnnotatedClass_asParameter

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void testAnnotatedClass_asParameter() {
  List<Diagnostic<? extends JavaFileObject>> diagnostics = compiler.compile(
      BETA, ANNOTATED_CLASS,
      JavaFileObjects.forSourceLines(
          "example.Test",
          "package example;",
          "",
          "import com.google.common.foo.AnnotatedClass;",
          "",
          "public class Test {",
          "  public static void foo(AnnotatedClass annotated) {", // error
          "  }",
          "}")
  );

  compiler.assertErrorsOnLines("example/Test.java", diagnostics, 6);
}
 
开发者ID:google,项目名称:guava-beta-checker,代码行数:19,代码来源:BetaCheckerTest.java

示例9: testCleanClass

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void testCleanClass() {
  List<Diagnostic<? extends JavaFileObject>> diagnostics = compiler.compile(BETA,
      JavaFileObjects.forSourceLines(
          "example.Test",
          "package example;",
          "",
          "import java.util.Arrays;",
          "",
          "public class Test {",
          "  public static void main(String[] args) {",
          "    System.out.println(Arrays.asList(args));",
          "  }",
          "}")
  );

  assertThat(diagnostics).isEmpty();
}
 
开发者ID:google,项目名称:guava-beta-checker,代码行数:19,代码来源:BetaCheckerTest.java

示例10: compilation_withAnnotatedStaticMethod_withoutRequestOptionsArg_fails

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void compilation_withAnnotatedStaticMethod_withoutRequestOptionsArg_fails() {
  expectedException.expect(RuntimeException.class);
  javac()
      .withProcessors(new GlideAnnotationProcessor())
      .compile(
          emptyAppModule(),
          JavaFileObjects.forSourceLines(
              "Extension",
              "package com.bumptech.glide.test;",
              "import com.bumptech.glide.annotation.GlideExtension;",
              "import com.bumptech.glide.annotation.GlideOption;",
              "@GlideExtension",
              "public class Extension {",
              "  private Extension() {}",
              "  @GlideOption",
              "  public static void doSomething() {}",
              "}"));

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:InvalidGlideOptionsExtensionTest.java

示例11: testFindNodeClasses

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void testFindNodeClasses() throws FileNotFoundException {
    JavaFileObject wand = JavaFileObjects.forResource("input/Wand.java");
    JavaFileObject owner = JavaFileObjects.forResource("input/Owner.java");
    JavaFileObject school = JavaFileObjects.forResource("input/School.java");

    JavaFileObject autoValueWand = JavaFileObjects.forResource("expected/AutoValue_Wand.java");
    JavaFileObject autoValueOwner = JavaFileObjects.forResource("expected/AutoValue_Owner.java");
    JavaFileObject autoValueSchool = JavaFileObjects.forResource("expected/AutoValue_School.java");

    JavaFileObject nodeWand = JavaFileObjects.forResource("expected/Node_Wand.java");
    JavaFileObject nodeOwner = JavaFileObjects.forResource("expected/Node_Owner.java");
    JavaFileObject nodeSchool = JavaFileObjects.forResource("expected/Node_School.java");
    assertAbout(javaSources())
            .that(Arrays.asList(school, owner, wand))
            .processedWith(autoValueNodeProcessor, autoValueProcessor)
            .compilesWithoutError()
            .and()
            .generatesSources(autoValueWand, autoValueOwner, autoValueSchool, nodeOwner, nodeSchool, nodeWand);
}
 
开发者ID:ccheptea,项目名称:auto-value-node,代码行数:21,代码来源:AutoValueNodeExtensionTest.java

示例12: compilation_withAnnotatedStaticMethod_withNonRequestBuilderArg_fails

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void compilation_withAnnotatedStaticMethod_withNonRequestBuilderArg_fails() {
  expectedException
      .expectMessage(
          "@GlideType methods must take a RequestBuilder object as their first and only"
              + " parameter, but given: java.lang.Object");
  javac()
      .withProcessors(new GlideAnnotationProcessor())
      .compile(
          emptyAppModule(),
          JavaFileObjects.forSourceLines("Extension",
              "package com.bumptech.glide.test;",
              "import com.bumptech.glide.RequestBuilder;",
              "import com.bumptech.glide.annotation.GlideExtension;",
              "import com.bumptech.glide.annotation.GlideType;",
              "@GlideExtension",
              "public class Extension {",
              "  private Extension() {}",
              "  @GlideType(Number.class)",
              "  public static void type(Object arg) {}",
              "}"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:InvalidGlideTypeExtensionTest.java

示例13: compilationShoulNotFailIfDuplicateFoundAndSupressed

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void compilationShoulNotFailIfDuplicateFoundAndSupressed() {
  final JavaFileObject source =
          JavaFileObjects.forSourceString(
                  "com.groupon.android.dichecks.dummy.A",
                  Joiner.on('\n')
                          .join(
                                  "package com.groupon.android.dichecks.dummy;",
                                  "import javax.inject.Inject;",
                                  "import javax.inject.Named;",
                                  "public class A {",
                                  "    @Inject @Named(\"someNamedString\") String something;",
                                  "    @Inject InjectedClass aClass;",
                                  "}",
                                  "class B extends A {",
                                  "    @SuppressWarnings(\"" + CompilerOptions.OPTIONS_PREFIX + CompilerOptions.DUPLICATE_CHECK + "\")",
                                  "    @Inject InjectedClass aClass;",
                                  "}",
                                  "class D extends B {}",
                                  "class C extends A {}",
                                  "class InjectedClass {}"));

  assertAbout(javaSource()).that(source).processedWith(new DiChecksProcessor()).compilesWithoutError();
}
 
开发者ID:groupon,项目名称:dependency-injection-checks,代码行数:25,代码来源:ProcessorTest.java

示例14: compilation_withOverrideExtend_andOverridingMethod_succeeds

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void compilation_withOverrideExtend_andOverridingMethod_succeeds() {
  Compilation compilation = javac()
      .withProcessors(new GlideAnnotationProcessor())
      .compile(
          emptyAppModule(),
          JavaFileObjects.forSourceLines(
              "Extension",
              "package com.bumptech.glide.test;",
              "import com.bumptech.glide.annotation.GlideExtension;",
              "import com.bumptech.glide.annotation.GlideOption;",
              "import com.bumptech.glide.request.RequestOptions;",
              "@GlideExtension",
              "public class Extension {",
              "  private Extension() {}",
              "  @GlideOption(override = GlideOption.OVERRIDE_EXTEND)",
              "  public static void centerCrop(RequestOptions options) {}",
              "}"));
  assertThat(compilation).succeeded();
  assertThat(compilation).hadWarningContaining("is using a legacy format.");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:InvalidGlideOptionsExtensionTest.java

示例15: compilation_withAnnotatedStaticMethod_withRequestOptionsArg_succeeds

import com.google.testing.compile.JavaFileObjects; //导入依赖的package包/类
@Test
public void compilation_withAnnotatedStaticMethod_withRequestOptionsArg_succeeds() {
  Compilation compilation = javac()
      .withProcessors(new GlideAnnotationProcessor())
      .compile(
          emptyAppModule(),
          JavaFileObjects.forSourceLines(
              "Extension",
              "package com.bumptech.glide.test;",
              "import com.bumptech.glide.annotation.GlideExtension;",
              "import com.bumptech.glide.annotation.GlideOption;",
              "import com.bumptech.glide.request.RequestOptions;",
              "@GlideExtension",
              "public class Extension {",
              "  private Extension() {}",
              "  @GlideOption",
              "  public static void doSomething(RequestOptions options) {}",
              "}"));
  assertThat(compilation).succeeded();
  assertThat(compilation).hadWarningContaining("is using a legacy format.");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:InvalidGlideOptionsExtensionTest.java


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