com.google.testing.compile.Compiler Java Examples

The following examples show how to use com.google.testing.compile.Compiler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestProcessor.java    From android-state with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testPrivateClass() {
    JavaFileObject javaFileObject = JavaFileObjects.forSourceString(getName("TestPrivateClass"), ""
            + "package com.evernote.android.state.test;\n"
            + "\n"
            + "import com.evernote.android.state.State;\n"
            + "\n"
            + "public class TestPrivateClass {\n"
            + "    private static class Inner {\n"
            + "        @State\n"
            + "        public int test;\n"
            + "    }\n"
            + "}\n");

    Compilation compilation = Compiler.javac().withProcessors(new StateProcessor()).compile(javaFileObject);
    assertThat(compilation).failed();
    assertThat(compilation)
            .hadErrorContaining("Class must not be private")
            .inFile(javaFileObject)
            .onLine(6)
            .atColumn(20);
}
 
Example #2
Source File: AnalyzeWithDefinedComponentsTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailUponAnalyzeWithPackageMatchedByMultipleComponents() throws Exception {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.MODE, "ANALYZE",
                            Options.COMPONENTS,
                            "foo1:org.moditect.deptective.plugintest.packagecontainedtwiceanalyze.foo;" +
                                    "foo2:org.moditect.deptective.plugintest.packagecontainedtwiceanalyze.foo"
                    )
            )
            .compile(forTestClass(Foo.class));

    assertThat(compilation).failed();
    assertThat(compilation).hadNoteCount(0);
    assertThat(compilation).hadErrorContaining(
            "Multiple components match package org.moditect.deptective.plugintest.packagecontainedtwiceanalyze.foo: foo1, foo2"
    );
}
 
Example #3
Source File: JavacTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldProduceCorrectJavacMessages() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption()
                    )
            )
            .compile(
                    JavaFileObjects.forSourceLines(
                            "com.example.foo.Foo",
                            "package com.example.foo;",
                            "public class Foo {",
                            "    private final String s;",
                            "}"
                    )
            );

    assertThat(compilation).failed();
    assertThat(compilation).hadErrorContaining("variable s not initialized in the default constructor");
}
 
Example #4
Source File: WhitelistTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldApplyWhitelistForJavaLangType() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption()
                    )
            )
            .compile(
                    forTestClass(Bar.class),
                    forTestClass(Foo.class)
            );

    assertThat(compilation).failed();
    assertThat(compilation).hadErrorContaining(
            "package org.moditect.deptective.plugintest.whitelist.foo must not access org.moditect.deptective.plugintest.whitelist.bar"
    );
}
 
Example #5
Source File: BasicPluginTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
private Compilation compile() {
    Compilation compilation = Compiler.javac()
            .withOptions(TestOptions.deptectiveOptions(Options.CONFIG_FILE, getConfigFileOption()))
            .compile(
                    forTestClass(BarCtorCall.class),
                    forTestClass(BarField.class),
                    forTestClass(BarLocalVar.class),
                    forTestClass(BarLoopVar.class),
                    forTestClass(BarParameter.class),
                    forTestClass(BarRetVal.class),
                    forTestClass(BarTypeArg.class),
                    forTestClass(Foo.class)
            );

    return compilation;
}
 
Example #6
Source File: BasicPluginTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldUseWarnReportingPolicy() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption(),
                            Options.REPORTING_POLICY, "WARN"
                            )
                    )
            .compile(forTestClass(BarCtorCall.class), forTestClass(BarField.class), forTestClass(BarLocalVar.class),
                    forTestClass(BarLoopVar.class), forTestClass(BarParameter.class), forTestClass(BarRetVal.class),
                    forTestClass(BarTypeArg.class), forTestClass(Foo.class)
            );

    assertThat(compilation).succeeded();
    assertThat(compilation).hadWarningContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.barfield"));
}
 
Example #7
Source File: CycleTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldDetectCyclesInArchitectureModel() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption()
                    )
            )
            .compile(
                    forTestClass(Foo.class),
                    forTestClass(Bar.class),
                    forTestClass(Baz.class),
                    forTestClass(Qux.class),
                    forTestClass(Abc.class),
                    forTestClass(Def.class)

            );

    assertThat(compilation).failed();
    assertThat(compilation).hadErrorContaining("Architecture model contains cycle(s) between these components:");
    assertThat(compilation).hadErrorContaining("  - bar, baz, foo, qux");
    assertThat(compilation).hadErrorContaining("  - abc, def");
}
 
Example #8
Source File: UnconfiguredPackageTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldWarnWhenEncounteringUnconfiguredPackage() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption()
                    )
            )
            .compile(
                    forTestClass(Foo.class)
            );

    assertThat(compilation).succeeded();
    assertThat(compilation).hadWarningContaining(
            "no Deptective configuration found for package org.moditect.deptective.plugintest.unconfiguredpackage.foo"
    );
}
 
Example #9
Source File: UnconfiguredPackageTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailWhenEncounteringUnconfiguredPackage() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption(),
                            Options.UNCONFIGURED_PACKAGE_REPORTING_POLICY, "ERROR"
                    )
            )
            .compile(
                    forTestClass(Foo.class)
            );

    assertThat(compilation).failed();
    assertThat(compilation).hadErrorContaining(
            "no Deptective configuration found for package org.moditect.deptective.plugintest.unconfiguredpackage.foo"
    );
}
 
Example #10
Source File: TestProcessor.java    From android-state with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testPrivateField() {
    JavaFileObject javaFileObject = JavaFileObjects.forSourceString(getName("TestPrivateField"), ""
            + "package com.evernote.android.state.test;\n"
            + "\n"
            + "import com.evernote.android.state.State;\n"
            + "\n"
            + "public class TestPrivateField {\n"
            + "    @State\n"
            + "    private int test;\n"
            + "}\n");

    Compilation compilation = Compiler.javac().withProcessors(new StateProcessor()).compile(javaFileObject);
    assertThat(compilation).failed();
    assertThat(compilation)
            .hadErrorContaining("Field test must be either non-private or provide a getter and setter method")
            .inFile(javaFileObject)
            .onLine(7)
            .atColumn(17);
}
 
Example #11
Source File: AnalyzeWithDefinedComponentsTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailUponAnalyzeWithPackageMatchedByMultipleComponents() throws Exception {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.MODE, "ANALYZE",
                            Options.COMPONENTS,
                            "foo1:org.moditect.deptective.plugintest.packagecontainedtwiceanalyze.foo;" +
                                    "foo2:org.moditect.deptective.plugintest.packagecontainedtwiceanalyze.foo"
                    )
            )
            .compile(forTestClass(Foo.class));

    assertThat(compilation).failed();
    assertThat(compilation).hadNoteCount(0);
    assertThat(compilation).hadErrorContaining(
            "Multiple components match package org.moditect.deptective.plugintest.packagecontainedtwiceanalyze.foo: foo1, foo2"
    );
}
 
Example #12
Source File: TestProcessor.java    From android-state with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testStatic() {
    JavaFileObject javaFileObject = JavaFileObjects.forSourceString(getName("TestStatic"), ""
            + "package com.evernote.android.state.test;\n"
            + "\n"
            + "import com.evernote.android.state.State;\n"
            + "\n"
            + "public class TestStatic {\n"
            + "    @State\n"
            + "    public static int test;\n"
            + "}\n");

    Compilation compilation = Compiler.javac().withProcessors(new StateProcessor()).compile(javaFileObject);
    assertThat(compilation).failed();
    assertThat(compilation)
            .hadErrorContaining("Field must not be static")
            .inFile(javaFileObject)
            .onLine(7)
            .atColumn(23);
}
 
Example #13
Source File: TestProcessor.java    From android-state with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testFinal() {
    JavaFileObject javaFileObject = JavaFileObjects.forSourceString(getName("TestFinal"), ""
            + "package com.evernote.android.state.test;\n"
            + "\n"
            + "import com.evernote.android.state.State;\n"
            + "\n"
            + "public class TestFinal {\n"
            + "    @State\n"
            + "    public final int test = 5;\n"
            + "}\n");

    Compilation compilation = Compiler.javac().withProcessors(new StateProcessor()).compile(javaFileObject);
    assertThat(compilation).failed();
    assertThat(compilation)
            .hadErrorContaining("Field must not be final")
            .inFile(javaFileObject)
            .onLine(7)
            .atColumn(22);
}
 
Example #14
Source File: TestProcessor.java    From android-state with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testTypeNotSupported() {
    JavaFileObject javaFileObject = JavaFileObjects.forSourceString(getName("TestTypeNotSupported"), ""
            + "package com.evernote.android.state.test;\n"
            + "\n"
            + "import com.evernote.android.state.State;\n"
            + "\n"
            + "public class TestTypeNotSupported {\n"
            + "    @State\n"
            + "    public Other test;\n"
            + "\n"
            + "    public static final class Other {}\n"
            + "}\n");

    Compilation compilation = Compiler.javac().withProcessors(new StateProcessor()).compile(javaFileObject);
    assertThat(compilation).failed();
    assertThat(compilation)
            .hadErrorContaining("Don't know how to put com.evernote.android.state.test.TestTypeNotSupported.Other into a bundle")
            .inFile(javaFileObject)
            .onLine(7)
            .atColumn(18);
}
 
Example #15
Source File: ProcessDescriptionsTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@Test
void skipUncommentedMethodTest() {
    JavaFileObject source = JavaFileObjects.forSourceLines(
            "io.qameta.allure.description.test.DescriptionSample",
            "package io.qameta.allure.description.test;",
            "import io.qameta.allure.Description;",
            "",
            "public class DescriptionSample {",
            "",
            "@Description(useJavaDoc = true)",
            "public void sampleTestWithoutJavadocComment() {",
            "}",
            "}"
    );

    Compiler compiler = javac().withProcessors(new JavaDocDescriptionsProcessor());
    Compilation compilation = compiler.compile(source);
    assertThat(compilation).succeeded();
    assertThat(compilation)
            .hadWarningContaining("Unable to create resource for method "
                    + "sampleTestWithoutJavadocComment[] as it does not have a docs comment");
}
 
Example #16
Source File: ActionProcessorTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws URISyntaxException, MalformedURLException {
    Compilation compilation = Compiler.javac()
        .withProcessors(new ActionProcessor())
        .compile(JavaFileObjects.forSourceString(
            "test.AnnotatedClassTest",
            "package test;\n" +
            "\n" +
            "@io.syndesis.extension.api.annotations.Action(\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.json").isPresent());
}
 
Example #17
Source File: DynamicJar.java    From pippo with Apache License 2.0 6 votes vote down vote up
/**
 * Build the JAR file.
 */
public DynamicJar build() throws IOException {
    try (OutputStream outputStream = new FileOutputStream(path.toFile())) {
        Manifest manifest = createManifest();
        try (JarOutputStream jarOutputStream = new JarOutputStream(outputStream, manifest)) {
            Compilation compilation = Compiler.javac().compile(classes);
            ImmutableList<JavaFileObject> generatedFiles = compilation.generatedFiles();
            for (JavaFileObject generated : generatedFiles) {
                String generatedPath = generated.getName().replaceFirst("/CLASS_OUTPUT/", "");
                JarEntry classEntry = new JarEntry(generatedPath);
                jarOutputStream.putNextEntry(classEntry);
                IoUtils.copy(generated.openInputStream(), jarOutputStream);
                jarOutputStream.closeEntry();
            }
        }
    }

    if (extract) {
        extract(path , path.getParent());
    }

    return new DynamicJar(this);
}
 
Example #18
Source File: ProcessorRule.java    From immutables with Apache License 2.0 6 votes vote down vote up
@Override
public Statement apply(final Statement base, final Description description) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      final LocalProcessor processor = new LocalProcessor(base);
      final Compilation compilation = Compiler.javac().withProcessors(processor).compile(EMPTY);

      if (!compilation.status().equals(Compilation.Status.SUCCESS)) {
        throw new AssertionError(String.format("Compilation failed (status:%s): %s", compilation.status(), compilation.diagnostics()));
      }

      if (!processor.wasEvaluated) {
        throw new AssertionError(String.format("%s was not evaluated. Check that annotation processor %s was triggered " +
                        "(eg. %s annotation is correctly registered)",
                description.getDisplayName(), processor.getClass().getSimpleName(), DEFAULT_ANNOTATION_CLASS.getCanonicalName()));
      }

      processor.rethrowIfError();
    }
  };
}
 
Example #19
Source File: AutoValueJava8Test.java    From auto with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpClass() {
  JavaFileObject javaFileObject =
      JavaFileObjects.forSourceLines(
          "Test",
          "import java.lang.annotation.ElementType;",
          "import java.lang.annotation.Retention;",
          "import java.lang.annotation.RetentionPolicy;",
          "import java.lang.annotation.Target;",
          "public abstract class Test<T> {",
          "  @Retention(RetentionPolicy.RUNTIME)",
          "  @Target(ElementType.TYPE_USE)",
          "  public @interface Nullable {}",
          "",
          "  public abstract @Nullable T t();",
          "}");
  Compilation compilation =
      Compiler.javac().withProcessors(new BugTestProcessor()).compile(javaFileObject);
  if (compilation.errors().isEmpty()) {
    javacHandlesTypeAnnotationsCorrectly = true;
  } else {
    assertThat(compilation).hadErrorCount(1);
    assertThat(compilation).hadErrorContaining(JAVAC_HAS_BUG_ERROR);
  }
}
 
Example #20
Source File: CycleTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldDetectCyclesInArchitectureModel() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption()
                    )
            )
            .compile(
                    forTestClass(Foo.class),
                    forTestClass(Bar.class),
                    forTestClass(Baz.class),
                    forTestClass(Qux.class),
                    forTestClass(Abc.class),
                    forTestClass(Def.class)

            );

    assertThat(compilation).failed();
    assertThat(compilation).hadErrorContaining("Architecture model contains cycle(s) between these components:");
    assertThat(compilation).hadErrorContaining("  - bar, baz, foo, qux");
    assertThat(compilation).hadErrorContaining("  - abc, def");
}
 
Example #21
Source File: TelemetryAnnotationProcessorTest.java    From ScreenshotGo with Mozilla Public License 2.0 6 votes vote down vote up
@Test
public void should_generate_one_document() {
    final ImmutableList<JavaFileObject> telemetryWrapper = Compiler.javac()
            .withProcessors(new TelemetryAnnotationProcessor())
            .compile(
                    JavaFileObjects.forSourceLines(
                            "TelemetryWrapper",
                            "package com.bumptech.glide.test;",
                            "import org.mozilla.telemetry.annotation.TelemetryDoc;\n",
                            "import org.mozilla.telemetry.annotation.TelemetryExtra;\n",
                            "class TelemetryWrapper {" +
                                    "@TelemetryDoc(\n" +
                                    "        name = \"n\",\n" +
                                    "        category = \"a\",\n" +
                                    "        method = \"m\",\n" +
                                    "        object = \"o\",\n" +
                                    "        value = \"v\",\n" +
                                    "        extras = {@TelemetryExtra(name = \"a\", value = \"v\")})",
                            "        public void send(){" +
                                    "}",
                            "}"
                    )).generatedFiles();
    assert (telemetryWrapper.size() > 0);
}
 
Example #22
Source File: TelemetryAnnotationProcessorTest.java    From ScreenshotGo with Mozilla Public License 2.0 6 votes vote down vote up
@Test(expected = IllegalStateException.class)
    public void missing_default_value_for_object() {
        final ImmutableList<JavaFileObject> telemetryWrapper = Compiler.javac()
                .withProcessors(new TelemetryAnnotationProcessor())
                .compile(
                        JavaFileObjects.forSourceLines(
                                "TelemetryWrapper",
                                "package com.bumptech.glide.test;",
                                "import org.mozilla.telemetry.annotation.TelemetryDoc;\n",
                                "import org.mozilla.telemetry.annotation.TelemetryExtra;\n",
                                "class TelemetryWrapper {" +
                                        "@TelemetryDoc(\n" +
                                        "        name = \"n\",\n" +
                                        "        category = \"a\",\n" +
                                        "        method = \"m\",\n" +
//                                        "        object = \"o\",\n" +
                                        "        value = \"v\",\n" +
                                        "        extras = {@TelemetryExtra(name = \"a\", value = \"v\")})",
                                "        public void send(){" +
                                        "}",
                                "}"
                        )).generatedFiles();
        assert (telemetryWrapper.size() > 0);
        assert (new File(TelemetryAnnotationProcessor.FILE_README).exists());
    }
 
Example #23
Source File: UnconfiguredPackageTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailWhenEncounteringUnconfiguredPackage() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption(),
                            Options.UNCONFIGURED_PACKAGE_REPORTING_POLICY, "ERROR"
                    )
            )
            .compile(
                    forTestClass(Foo.class)
            );

    assertThat(compilation).failed();
    assertThat(compilation).hadErrorContaining(
            "no Deptective configuration found for package org.moditect.deptective.plugintest.unconfiguredpackage.foo"
    );
}
 
Example #24
Source File: BasicPluginTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldUseWarnReportingPolicy() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption(),
                            Options.REPORTING_POLICY, "WARN"
                            )
                    )
            .compile(forTestClass(BarCtorCall.class), forTestClass(BarField.class), forTestClass(BarLocalVar.class),
                    forTestClass(BarLoopVar.class), forTestClass(BarParameter.class), forTestClass(BarRetVal.class),
                    forTestClass(BarTypeArg.class), forTestClass(Foo.class)
            );

    assertThat(compilation).succeeded();
    assertThat(compilation).hadWarningContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.barfield"));
}
 
Example #25
Source File: UnconfiguredPackageTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldWarnWhenEncounteringUnconfiguredPackage() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption()
                    )
            )
            .compile(
                    forTestClass(Foo.class)
            );

    assertThat(compilation).succeeded();
    assertThat(compilation).hadWarningContaining(
            "no Deptective configuration found for package org.moditect.deptective.plugintest.unconfiguredpackage.foo"
    );
}
 
Example #26
Source File: JavacTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldProduceCorrectJavacMessages() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption()
                    )
            )
            .compile(
                    JavaFileObjects.forSourceLines(
                            "com.example.foo.Foo",
                            "package com.example.foo;",
                            "public class Foo {",
                            "    private final String s;",
                            "}"
                    )
            );

    assertThat(compilation).failed();
    assertThat(compilation).hadErrorContaining("variable s not initialized in the default constructor");
}
 
Example #27
Source File: WhitelistTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldApplyWhitelistForJavaLangType() {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.CONFIG_FILE, getConfigFileOption()
                    )
            )
            .compile(
                    forTestClass(Bar.class),
                    forTestClass(Foo.class)
            );

    assertThat(compilation).failed();
    assertThat(compilation).hadErrorContaining(
            "package org.moditect.deptective.plugintest.whitelist.foo must not access org.moditect.deptective.plugintest.whitelist.bar"
    );
}
 
Example #28
Source File: BasicPluginTest.java    From deptective with Apache License 2.0 6 votes vote down vote up
private Compilation compile() {
    Compilation compilation = Compiler.javac()
            .withOptions(TestOptions.deptectiveOptions(Options.CONFIG_FILE, getConfigFileOption()))
            .compile(
                    forTestClass(BarCtorCall.class),
                    forTestClass(BarField.class),
                    forTestClass(BarLocalVar.class),
                    forTestClass(BarLoopVar.class),
                    forTestClass(BarParameter.class),
                    forTestClass(BarRetVal.class),
                    forTestClass(BarTypeArg.class),
                    forTestClass(Foo.class)
            );

    return compilation;
}
 
Example #29
Source File: TestProcessor.java    From android-state with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testPrivateProperty() {
    JavaFileObject javaFileObject = JavaFileObjects.forSourceString(getName("TestPrivateProperty"), ""
            + "package com.evernote.android.state.test;\n"
            + "\n"
            + "import com.evernote.android.state.State;\n"
            + "\n"
            + "public class TestPrivateProperty {\n"
            + "    @State\n"
            + "    private int test;\n"
            + "\n"
            + "    private int getTest() {\n"
            + "        return test;\n"
            + "    }\n"
            + "\n"
            + "    public void setTest(int test) {\n"
            + "        this.test = test;\n"
            + "    }\n"
            + "}\n");

    Compilation compilation = Compiler.javac().withProcessors(new StateProcessor()).compile(javaFileObject);
    assertThat(compilation).failed();
    assertThat(compilation)
            .hadErrorContaining("Field test must be either non-private or provide a getter and setter method")
            .inFile(javaFileObject)
            .onLine(7)
            .atColumn(17);
}
 
Example #30
Source File: BasicPluginTest.java    From deptective with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAllowAccessToJavaLangAutomatically() {
    Compilation compilation = Compiler.javac()
            .withOptions(TestOptions.deptectiveOptions(Options.CONFIG_FILE, getConfigFileOption()))
            .compile(forTestClass(FooWithoutErrors.class));
    assertThat(compilation).succeeded();
}