You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "zhan7236 (via GitHub)" <gi...@apache.org> on 2025/12/23 06:03:58 UTC

[PR] feat(java): add xlang tests for Union types [fory]

zhan7236 opened a new pull request, #3076:
URL: https://github.com/apache/fory/pull/3076

   ## What does this PR do?
   
   This PR adds cross-language (xlang) tests for Union types in XlangTestBase.java as requested in #3062.
   
   ### Changes:
   - Add \`StructWithUnionFields\` class with Union through Union6 fields for testing Union types as struct fields
   - Add \`testStructWithUnionFields()\` test method to verify serialization/deserialization of structs containing Union fields
   - Add \`testTopLevelUnion()\` test method to verify serialization/deserialization of top-level Union objects
   - Skip Union tests in \`GoXlangTest\` and \`RustXlangTest\` with \`SkipException\` (Union types not yet supported in Go/Rust)
   
   ### Test Details:
   1. **testStructWithUnionFields**: Creates a struct with Union1-6 fields containing different value types (Integer, String, Double, Boolean, Long, Float), serializes and deserializes it
   2. **testTopLevelUnion**: Tests serializing Union objects directly (not as struct fields), including both int and string variants
   
   ## Related issues
   
   Follow-up to #3062 (Java Union type support)
   Relates to #3030 (Union type support tracking issue)
   
   ## Does this PR introduce any user-facing change?
   
   No, this PR only adds tests.
   
   ## Benchmark
   
   N/A - test-only changes


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [PR] feat(java): add xlang tests for Union types [fory]

Posted by "zhan7236 (via GitHub)" <gi...@apache.org>.
zhan7236 commented on code in PR #3076:
URL: https://github.com/apache/fory/pull/3076#discussion_r2643479698


##########
java/fory-core/src/test/java/org/apache/fory/XlangTestBase.java:
##########
@@ -1575,6 +1575,109 @@ public void testEnumSchemaEvolutionCompatible() throws java.io.IOException {
     Assert.assertNull(result2.f2);
   }
 
+  // ============================================================================
+  // Union type tests
+  // ============================================================================
+
+  /** Struct containing Union fields of different arities (Union through Union6). */
+  @Data
+  public static class StructWithUnionFields {
+    public org.apache.fory.type.union.Union union;

Review Comment:
   Thanks.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [PR] feat(java): add xlang tests for Union types [fory]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang closed pull request #3076: feat(java): add xlang tests for Union types
URL: https://github.com/apache/fory/pull/3076


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [PR] feat(java): add xlang tests for Union types [fory]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on code in PR #3076:
URL: https://github.com/apache/fory/pull/3076#discussion_r2642110998


##########
java/fory-core/src/test/java/org/apache/fory/XlangTestBase.java:
##########
@@ -1575,6 +1575,109 @@ public void testEnumSchemaEvolutionCompatible() throws java.io.IOException {
     Assert.assertNull(result2.f2);
   }
 
+  // ============================================================================
+  // Union type tests
+  // ============================================================================
+
+  /** Struct containing Union fields of different arities (Union through Union6). */
+  @Data
+  public static class StructWithUnionFields {
+    public org.apache.fory.type.union.Union union;

Review Comment:
   Please add imports for those types instead of using qualified class



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [PR] feat(java): add xlang tests for Union types [fory]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on code in PR #3076:
URL: https://github.com/apache/fory/pull/3076#discussion_r2643691859


##########
java/fory-core/src/test/java/org/apache/fory/CPPXlangTest.java:
##########
@@ -130,4 +130,16 @@ private void runBazelCommand(String... args) throws IOException {
   public void testConsistentNamed() throws java.io.IOException {
     super.testConsistentNamed();
   }
+
+  @Test
+  @Override
+  public void testStructWithUnionFields() throws java.io.IOException {
+    throw new SkipException("Union types not yet supported in C++");

Review Comment:
   Could you add cpp tests in `cpp/fory/serialization/xlang_test_main.cc`?
   
   Only added cpp tests, and make it pass, we can ensure union xlang serialization is OK



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org