This is an automated email from the ASF dual-hosted git repository.

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git


The following commit(s) were added to refs/heads/main by this push:
     new 63999d544 test(java): assert non-ASCII meta encoding failures (#4025)
63999d544 is described below

commit 63999d5445648cfe3dcf7a556bace33c3b41436f
Author: Leo <[email protected]>
AuthorDate: Mon Sep 7 06:58:53 2026 +0800

    test(java): assert non-ASCII meta encoding failures (#4025)
    
    ## What changes
    
    Make the non-ASCII meta string encoding test fail when the expected
    exception is not thrown.
    
    The previous try/catch structure only performed the assertion when an
    exception was raised, so the test could pass silently if the encoder
    unexpectedly accepted the input.
    
    ## Tests
    
    - `mvn -T2 -pl fory-core -am
    "-Dtest=org.apache.fory.meta.MetaStringTest"
    "-Dsurefire.failIfNoSpecifiedTests=false" test`
    - `mvn -pl fory-core spotless:check`
---
 .../src/test/java/org/apache/fory/meta/MetaStringTest.java     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/java/fory-core/src/test/java/org/apache/fory/meta/MetaStringTest.java 
b/java/fory-core/src/test/java/org/apache/fory/meta/MetaStringTest.java
index 1c5f1ae0f..c755ecedd 100644
--- a/java/fory-core/src/test/java/org/apache/fory/meta/MetaStringTest.java
+++ b/java/fory-core/src/test/java/org/apache/fory/meta/MetaStringTest.java
@@ -252,10 +252,10 @@ public class MetaStringTest {
     MetaStringEncoder encoder = new MetaStringEncoder('_', '$');
     String nonAsciiString = "こんにちは"; // Non-ASCII string
 
-    try {
-      encoder.encode(nonAsciiString, MetaString.Encoding.LOWER_SPECIAL);
-    } catch (IllegalArgumentException e) {
-      assertEquals(e.getMessage(), "Non-ASCII characters in meta string are 
not allowed");
-    }
+    IllegalArgumentException exception =
+        expectThrows(
+            IllegalArgumentException.class,
+            () -> encoder.encode(nonAsciiString, 
MetaString.Encoding.LOWER_SPECIAL));
+    assertEquals(exception.getMessage(), "Non-ASCII characters in meta string 
are not allowed");
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to