當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。