File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1313import java .time .LocalTime ;
1414import java .time .ZoneId ;
1515import java .time .ZonedDateTime ;
16+ import java .util .HashMap ;
1617import java .util .HashSet ;
1718import java .util .Hashtable ;
1819import java .util .LinkedHashSet ;
20+ import java .util .Map ;
1921import java .util .Set ;
2022import java .util .TreeSet ;
2123import java .util .Vector ;
@@ -326,6 +328,34 @@ public void testTime() throws Exception {
326328 oos .flush ();
327329 }
328330
331+ /**
332+ * Tests th pull request #27 by @qistoph:
333+ * Add support for java.lang.Bool, Integer and Long classes
334+ */
335+ @ Test
336+ public void testBoolIntLong () throws Exception {
337+ Map <String , Object > hm1 = new HashMap <String , Object >();
338+ hm1 .put ("key1" , "value1" );
339+ hm1 .put ("key2" , "value2" );
340+ hm1 .put ("int" , 9 );
341+ hm1 .put ("int2" , new Integer (10 ));
342+ hm1 .put ("bool" , true );
343+ hm1 .put ("bool2" , new Boolean (true ));
344+
345+ oos .writeObject (hm1 );
346+ oos .flush ();
347+
348+ Map <String , Object > hm2 = new HashMap <String , Object >();
349+ hm2 .put ("subMap" , hm1 );
350+
351+ ObjectOutputStream oos2 = new ObjectOutputStream (new FileOutputStream (name .getMethodName () + "-2.ser" ));
352+ try {
353+ oos2 .writeObject (hm2 );
354+ } finally {
355+ oos2 .close ();
356+ }
357+ }
358+
329359 @ Test
330360 public void testSwingObject () throws Exception {
331361
Original file line number Diff line number Diff line change @@ -391,9 +391,35 @@ def test_jceks_issue_5(self):
391391 _logger .info (pobj )
392392 # self._try_marshalling(jobj, pobj)
393393
394+ def test_qistoph_pr_27 (self ):
395+ """
396+ Tests support for Bool, Integer, Long classes (PR #27)
397+ """
398+ # Load the basic map
399+ jobj = self .read_file ("testBoolIntLong.ser" )
400+ pobj = javaobj .loads (jobj )
401+ _logger .debug (pobj )
402+
403+ # Basic checking
404+ self .assertEqual (pobj ["key1" ], "value1" )
405+ self .assertEqual (pobj ["key2" ], "value2" )
406+ self .assertEqual (pobj ["int" ], 9 )
407+ self .assertEqual (pobj ["int2" ], 10 )
408+ self .assertEqual (pobj ["bool" ], True )
409+ self .assertEqual (pobj ["bool2" ], True )
410+
411+ # Load the parent map
412+ jobj2 = self .read_file ("testBoolIntLong-2.ser" )
413+ pobj2 = javaobj .loads (jobj2 )
414+ _logger .debug (pobj2 )
415+
416+ parent_map = pobj2 ["subMap" ]
417+ for key , value in pobj .items ():
418+ self .assertEqual (parent_map [key ], value )
394419
395420# ------------------------------------------------------------------------------
396421
422+
397423if __name__ == "__main__" :
398424 # Setup logging
399425 logging .basicConfig (level = logging .INFO )
You can’t perform that action at this time.
0 commit comments