diff --git a/integrationtest/java17/pom.xml b/integrationtest/java17/pom.xml new file mode 100644 index 00000000..8dac5b51 --- /dev/null +++ b/integrationtest/java17/pom.xml @@ -0,0 +1,94 @@ + + 4.0.0 + + aptk-tools-java17 + jar + + + io.toolisticon.aptk + integrationtest-parent + 0.24.1-148_records-SNAPSHOT + + + aptk-tools-java17 + + + + + + io.toolisticon.aptk + aptk-tools + + + + + + + + + + + maven-enforcer-plugin + + + enforce + + enforce + + + + + [3.0.4,) + + + 9 + + + false + + * + + + io.toolisticon.aptk:aptk-tools:* + *:*:*:*:test:* + *:*:*:*:provided:* + + + + + + + + + + maven-compiler-plugin + + 16 + 16 + + + + + org.codehaus.mojo + animal-sniffer-maven-plugin + + true + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + + + + diff --git a/integrationtest/java17/src/test/java/io/toolisticon/aptk/tools/wrapper/Java17Tests.java b/integrationtest/java17/src/test/java/io/toolisticon/aptk/tools/wrapper/Java17Tests.java new file mode 100644 index 00000000..c97fe934 --- /dev/null +++ b/integrationtest/java17/src/test/java/io/toolisticon/aptk/tools/wrapper/Java17Tests.java @@ -0,0 +1,68 @@ +package io.toolisticon.aptk.tools.wrapper; + +import io.toolisticon.aptk.common.ToolingProvider; +import io.toolisticon.cute.Cute; +import io.toolisticon.cute.PassIn; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.Test; + +import javax.lang.model.element.TypeElement; +import java.util.stream.Collectors; + +public class Java17Tests { + + + @Test + public void test_sealedClassesFeature_unsealed() { + Cute.unitTest().when().passInElement().fromClass(Java17Tests.class).intoUnitTest((processingEnvironment, element) -> { + try { + ToolingProvider.setTooling(processingEnvironment); + + TypeElementWrapper elementWrapper = TypeElementWrapper.wrap(element); + + MatcherAssert.assertThat(elementWrapper.getPermittedSubclasses(), Matchers.empty()); + MatcherAssert.assertThat(element.getPermittedSubclasses(), Matchers.empty()); + + } finally { + ToolingProvider.clearTooling(); + } + + }).thenExpectThat().compilationSucceeds().executeTest(); + + } + + + + static final class AllowedClass extends SealedClass { + + } + + @PassIn + static sealed class SealedClass permits AllowedClass{ + + } + + + + @Test + public void test_sealedClassesFeature_sealed() { + Cute.unitTest().when().passInElement().fromClass(SealedClass.class).intoUnitTest((processingEnvironment, element) -> { + try { + ToolingProvider.setTooling(processingEnvironment); + + TypeElementWrapper elementWrapper = TypeElementWrapper.wrap(element); + + MatcherAssert.assertThat(elementWrapper.getPermittedSubclasses().stream().map(e -> e.getQualifiedName()).collect(Collectors.toSet()), Matchers.contains(SealedClass.class.getCanonicalName())); + MatcherAssert.assertThat(element.getPermittedSubclasses().stream().map(e -> e.toString()).collect(Collectors.toSet()), , Matchers.contains(SealedClass.class.getCanonicalName())); + + } finally { + ToolingProvider.clearTooling(); + } + + }).thenExpectThat().compilationSucceeds().executeTest(); + + } + + +} diff --git a/integrationtest/pom.xml b/integrationtest/pom.xml index 2a587340..a168efd2 100644 --- a/integrationtest/pom.xml +++ b/integrationtest/pom.xml @@ -38,6 +38,19 @@ + + java-17 + + [17,) + + + + java9 + java16 + java17 + + +