@@ -458,11 +458,35 @@ public void testEnumWithDefaultAnnotation() throws Exception {
458
458
assertSame (EnumWithDefaultAnno .OTHER , myEnum );
459
459
}
460
460
461
- public void testEnumWithDefaultAnnotationUsingIndexes () throws Exception {
461
+ public void testEnumWithDefaultAnnotationUsingIndexInBound1 () throws Exception {
462
462
final ObjectMapper mapper = new ObjectMapper ();
463
463
mapper .enable (DeserializationFeature .READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE );
464
464
465
- EnumWithDefaultAnno myEnum = mapper .readValue ("9" , EnumWithDefaultAnno .class );
465
+ EnumWithDefaultAnno myEnum = mapper .readValue ("1" , EnumWithDefaultAnno .class );
466
+ assertSame (EnumWithDefaultAnno .B , myEnum );
467
+ }
468
+
469
+ public void testEnumWithDefaultAnnotationUsingIndexInBound2 () throws Exception {
470
+ final ObjectMapper mapper = new ObjectMapper ();
471
+ mapper .enable (DeserializationFeature .READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE );
472
+
473
+ EnumWithDefaultAnno myEnum = mapper .readValue ("2" , EnumWithDefaultAnno .class );
474
+ assertSame (EnumWithDefaultAnno .OTHER , myEnum );
475
+ }
476
+
477
+ public void testEnumWithDefaultAnnotationUsingIndexSameAsLength () throws Exception {
478
+ final ObjectMapper mapper = new ObjectMapper ();
479
+ mapper .enable (DeserializationFeature .READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE );
480
+
481
+ EnumWithDefaultAnno myEnum = mapper .readValue ("3" , EnumWithDefaultAnno .class );
482
+ assertSame (EnumWithDefaultAnno .OTHER , myEnum );
483
+ }
484
+
485
+ public void testEnumWithDefaultAnnotationUsingIndexOutOfBound () throws Exception {
486
+ final ObjectMapper mapper = new ObjectMapper ();
487
+ mapper .enable (DeserializationFeature .READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE );
488
+
489
+ EnumWithDefaultAnno myEnum = mapper .readValue ("4" , EnumWithDefaultAnno .class );
466
490
assertSame (EnumWithDefaultAnno .OTHER , myEnum );
467
491
}
468
492
0 commit comments