@@ -11,41 +11,70 @@ public void testMemoryLimitMBConfiguration() throws Exception {
1111 try {
1212 // Test that memory limit in MB is properly configured
1313 SpiceClient client = SpiceClient .builder ()
14- . withMemoryLimitMB (128 ) // 128 MB
15- .build ();
16-
14+ . withArrowMemoryLimitMB (128 ) // 128 MB
15+ .build ();
16+
1717 // If we reach here without exception, the configuration worked
1818 assertTrue ("Memory configuration should not throw exception" , true );
19-
19+
2020 client .close ();
2121 } catch (Exception e ) {
22- // We expect some exceptions due to no local Spice instance,
23- // but not IllegalArgumentException from memory configuration
24- assertFalse ("Should not throw IllegalArgumentException for valid memory config" ,
25- e instanceof IllegalArgumentException );
22+ fail ("Should not throw exception: " + e .getMessage ());
2623 }
2724 }
2825
2926 public void testInvalidMemoryLimitMB () throws Exception {
3027 try {
3128 SpiceClient .builder ()
32- . withMemoryLimitMB (0 ) // Invalid: must be positive
33- .build ();
29+ . withArrowMemoryLimitMB (0 ) // Invalid: must be positive
30+ .build ();
3431 fail ("Should throw IllegalArgumentException for zero memory limit" );
3532 } catch (IllegalArgumentException e ) {
3633 // Expected exception
37- assertTrue ("Should throw IllegalArgumentException for zero memory limit" , true );
34+ assertTrue ("Should throw IllegalArgumentException for zero memory limit" , true );
3835 }
3936 }
4037
4138 public void testNegativeMemoryLimitMB () throws Exception {
4239 try {
4340 SpiceClient .builder ()
44- . withMemoryLimitMB (-100 ) // Invalid: negative
45- .build ();
41+ . withArrowMemoryLimitMB (-100 ) // Invalid: negative
42+ .build ();
4643 fail ("Should throw IllegalArgumentException for negative memory limit" );
4744 } catch (IllegalArgumentException e ) {
4845 assertTrue ("Should throw IllegalArgumentException for negative memory limit" , true );
4946 }
5047 }
48+
49+ public void testOverflowProtection () throws Exception {
50+ // Test overflow protection - values that would cause overflow when converted to
51+ // bytes
52+ long maxSafeMB = Long .MAX_VALUE / (1024L * 1024L );
53+ long overflowValue = maxSafeMB + 1 ;
54+
55+ try {
56+ SpiceClient .builder ()
57+ .withArrowMemoryLimitMB (overflowValue ) // Would cause overflow
58+ .build ();
59+ fail ("Should throw IllegalArgumentException for overflow-causing memory limit" );
60+ } catch (IllegalArgumentException e ) {
61+ assertTrue ("Should throw IllegalArgumentException for overflow protection" , true );
62+ }
63+ }
64+
65+ public void testMaxSafeMemoryLimit () throws Exception {
66+ // Test that the maximum safe value works without throwing
67+ long maxSafeMB = Long .MAX_VALUE / (1024L * 1024L );
68+
69+ try {
70+ SpiceClient client = SpiceClient .builder ()
71+ .withArrowMemoryLimitMB (maxSafeMB ) // Maximum safe value
72+ .build ();
73+
74+ assertTrue ("Maximum safe memory limit should work" , true );
75+ client .close ();
76+ } catch (Exception e ) {
77+ fail ("Should not throw exception: " + e .getMessage ());
78+ }
79+ }
5180}
0 commit comments