Skip to content

Commit

Permalink
[FLINK-33543][core] Moves Java 17-specific test classes into their ow…
Browse files Browse the repository at this point in the history
…n module to make it easier unload these classes in the IDE.
  • Loading branch information
XComp committed Nov 15, 2023
1 parent 3856e41 commit a1aed4f
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 23 deletions.
83 changes: 83 additions & 0 deletions flink-tests-java17/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.flink</groupId>
<artifactId>flink-parent</artifactId>
<version>1.19-SNAPSHOT</version>
</parent>

<artifactId>flink-tests-java17</artifactId>
<name>Flink : Java 17 Tests</name>
<description>Module that collects Java 17-specific test code.</description>

<packaging>jar</packaging>

<dependencies>
<!-- For Java record (de)serialization -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-core</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<!-- SerializerTestBase lives in the test code -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-core</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>

<!-- Testing the record (de)serialization on different versions -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>fink-migration-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<!-- Base testing tools -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils-junit</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<suppressionsLocation>/tools/maven/suppressions-tests-java17.xml</suppressionsLocation>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
import static org.assertj.core.api.Assertions.assertThat;

/** A test for the {@link PojoSerializer} with Java Records. */
class Java17PojoRecordSerializerTest
extends SerializerTestBase<Java17PojoRecordSerializerTest.TestUserClass> {
class PojoRecordSerializerTest extends SerializerTestBase<PojoRecordSerializerTest.TestUserClass> {
private final TypeInformation<TestUserClass> type =
TypeExtractor.getForClass(TestUserClass.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import java.util.List;

/** A {@link TypeSerializerUpgradeTestBase} for the {@link PojoSerializer}. */
class Java17PojoRecordSerializerUpgradeTest
class PojoRecordSerializerUpgradeTest
extends TypeSerializerUpgradeTestBase<
Java17PojoRecordSerializerUpgradeTestSpecifications.RecordMigrationSetup
PojoRecordSerializerUpgradeTestSpecifications.RecordMigrationSetup
.RecordBeforeMigration,
Java17PojoRecordSerializerUpgradeTestSpecifications.RecordMigrationVerifier
PojoRecordSerializerUpgradeTestSpecifications.RecordMigrationVerifier
.RecordAfterSchemaUpgrade> {

@Override
Expand All @@ -47,16 +47,14 @@ public Collection<FlinkVersion> getMigrationVersions() {
new TestSpecification<>(
"pojo-serializer-to-record",
flinkVersion,
Java17PojoRecordSerializerUpgradeTestSpecifications.PojoToRecordSetup.class,
Java17PojoRecordSerializerUpgradeTestSpecifications.PojoToRecordVerifier
.class));
PojoRecordSerializerUpgradeTestSpecifications.PojoToRecordSetup.class,
PojoRecordSerializerUpgradeTestSpecifications.PojoToRecordVerifier.class));
testSpecifications.add(
new TestSpecification<>(
"pojo-serializer-record-migration",
flinkVersion,
Java17PojoRecordSerializerUpgradeTestSpecifications.RecordMigrationSetup
.class,
Java17PojoRecordSerializerUpgradeTestSpecifications.RecordMigrationVerifier
PojoRecordSerializerUpgradeTestSpecifications.RecordMigrationSetup.class,
PojoRecordSerializerUpgradeTestSpecifications.RecordMigrationVerifier
.class));
return testSpecifications;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import static org.junit.Assert.assertSame;

/** A {@link TypeSerializerUpgradeTestBase} for the {@link PojoSerializer}. */
class Java17PojoRecordSerializerUpgradeTestSpecifications {
class PojoRecordSerializerUpgradeTestSpecifications {

public static final class PojoToRecordSetup
implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

/** Tests for the @{@link JavaRecordBuilderFactory}. */
class Java17RecordBuilderFactoryTest {
class RecordBuilderFactoryTest {

Field[] fields;

Expand Down
11 changes: 3 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ under the License.
<!-- Can be set to any value to reproduce a specific build. -->
<test.randomization.seed/>
<test.unit.pattern>**/*Test.*</test.unit.pattern>
<test.exclusion.pattern>**/Java17*.java</test.exclusion.pattern>
</properties>

<dependencies>
Expand Down Expand Up @@ -1106,10 +1105,9 @@ under the License.
<profile>
<id>java17-target</id>

<!-- Include Java 17 specific tests (by not excluding them) -->
<properties>
<test.exclusion.pattern>nothing</test.exclusion.pattern>
</properties>
<modules>
<module>flink-tests-java17</module>
</modules>

<build>
<plugins>
Expand Down Expand Up @@ -2067,9 +2065,6 @@ under the License.
<!-- Prevents recompilation due to missing package-info.class, see MCOMPILER-205 -->
<arg>-Xpkginfo:always</arg>
</compilerArgs>
<testExcludes>
<testExclude>${test.exclusion.pattern}</testExclude>
</testExcludes>
</configuration>
</plugin>

Expand Down
2 changes: 0 additions & 2 deletions tools/maven/suppressions-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,4 @@ under the License.
files="(.*)test[/\\](.*)testutils[/\\](.*)"
checks="RedundantModifier|JavadocParagraph|JavadocType|JavadocStyle|StaticVariableNameCheck|LocalFinalVariableName|EmptyLineSeparator"/>

<!-- Suppress for Java17-specific test classes where Java records are used. -->
<suppress files="(.*)test[/\\].*[/\\]Java17.*.java" checks="MethodNameCheck"/>
</suppressions>
28 changes: 28 additions & 0 deletions tools/maven/suppressions-tests-java17.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<!-- Java records aren't supported by checkstyle 8.14. The corresponding check error needs to be suppressed. -->
<suppress files="(.*)test[/\\].*[/\\].*.java" checks="MethodNameCheck"/>
</suppressions>

0 comments on commit a1aed4f

Please sign in to comment.