sashapolo commented on a change in pull request #130: URL: https://github.com/apache/ignite-3/pull/130#discussion_r638660550
########## File path: modules/network-annotation-processor/src/integrationTest/java/org/apache/ignite/network/messages/internal/processor/ITAutoSerializableProcessorTest.java ########## @@ -0,0 +1,133 @@ +/* + * 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. + */ + +package org.apache.ignite.network.processor.internal; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import javax.tools.JavaFileObject; +import com.google.testing.compile.Compilation; +import com.google.testing.compile.Compiler; +import com.google.testing.compile.JavaFileObjects; +import org.apache.ignite.network.NetworkMessage; +import org.junit.jupiter.api.Test; + +import static com.google.testing.compile.CompilationSubject.assertThat; + +/** + * Integration tests for {@link AutoSerializableProcessor}. + */ +public class ITAutoSerializableProcessorTest { + /** Package name of the test sources. */ + private static final String RESOURCE_PACKAGE_NAME = "org.apache.ignite.network.processor.internal."; + + /** Compiler instance configured with the annotation processor being tested. */ + private final Compiler compiler = Compiler.javac().withProcessors(new AutoSerializableProcessor()); + + /** + * Compiles the network message with all supported directly marshallable types and checks that the compilation + * completed successfully. + */ + @Test + void testCompileAllTypesMessage() { + Compilation compilation = compiler.compile( + getSources("AllTypesMessage", "AllTypesMessageImpl", "AllTypesMessageFactory") + ); + + assertThat(compilation).succeededWithoutWarnings(); + + assertThat(compilation).generatedSourceFile(RESOURCE_PACKAGE_NAME + "AllTypesMessageSerializer"); + assertThat(compilation).generatedSourceFile(RESOURCE_PACKAGE_NAME + "AllTypesMessageDeserializer"); + assertThat(compilation).generatedSourceFile(RESOURCE_PACKAGE_NAME + "AllTypesMessageSerializationFactory"); + } + + /** + * Compiles a test message that doesn't extend {@link NetworkMessage}. + */ + @Test + void testInvalidAnnotatedTypeMessage() { + Compilation compilation = compiler.compile( + getSources("InvalidAnnotatedTypeMessage", "AllTypesMessageImpl", "AllTypesMessageFactory") + ); + + assertThat(compilation).hadErrorContaining("annotation must only be present on interfaces that extend"); + } + + /** + * Compiles a test message that contains an unsupported content type. + */ + @Test + void testUnsupportedTypeMessage() { + Compilation compilation = compiler.compile( + getSources("UnsupportedTypeMessage", "AllTypesMessageImpl", "AllTypesMessageFactory") + ); + + assertThat(compilation).hadErrorContaining("Unsupported reference type for message (de-)serialization: java.util.ArrayList"); + } + + /** + * Compiles a test message that violates the message contract by not declaring a {@code Builder} interface. + */ + @Test + void testMissingBuilderMessage() { + Compilation compilation = compiler.compile( + getSources("MissingBuilderMessage", "AllTypesMessageImpl", "AllTypesMessageFactory") + ); + + assertThat(compilation).hadErrorContaining("No nested Builder interface found"); Review comment: Yes, this is exactly what I'm going to do in the following ticket: https://issues.apache.org/jira/browse/IGNITE-14715 ########## File path: modules/network-annotation-processor/src/integrationTest/resources/org/apache/ignite/network/processor/internal/AllTypesMessage.java ########## @@ -0,0 +1,138 @@ +/* + * 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. + */ + +package org.apache.ignite.network.processor.internal; + +import java.util.BitSet; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; +import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.network.NetworkMessage; +import org.apache.ignite.network.processor.annotations.AutoSerializable; + +@AutoSerializable(messageFactory = AllTypesMessageFactory.class) Review comment: Please see my answer above -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
