1
1
package com .fasterxml .jackson .dataformat .avro .interop .annotations ;
2
2
3
- import java .io .IOException ;
4
-
5
3
import org .apache .avro .reflect .AvroName ;
6
4
import org .junit .Test ;
7
5
6
+ import com .fasterxml .jackson .annotation .JsonProperty ;
7
+ import com .fasterxml .jackson .databind .DatabindException ;
8
8
import com .fasterxml .jackson .databind .exc .InvalidDefinitionException ;
9
9
import com .fasterxml .jackson .dataformat .avro .AvroTestBase ;
10
10
import com .fasterxml .jackson .dataformat .avro .interop .InteropTestBase ;
@@ -31,6 +31,7 @@ public static class RecordWithNameCollision {
31
31
@ AvroName ("otherField" )
32
32
public String firstField ;
33
33
34
+ @ JsonProperty
34
35
public String otherField ;
35
36
}
36
37
@@ -42,16 +43,26 @@ public void testRecordWithRenamedField() throws Exception{
42
43
assertThat (result ).isEqualTo (original );
43
44
}
44
45
45
- // 02-Nov-2023, tatu: This test has been disabled for some reason, but
46
- // without commentary. Fixed it a bit but ultimately can't enable yet
46
+ // 02-Nov-2023, tatu: This test had been disabled for long time:
47
+ // "Jackson Schema" case did not consider conflict where it was
48
+ // possible to select precedence... so needed to add another
49
+ // annotation to force problem.
47
50
48
- // @Test
51
+ @ Test
49
52
public void testRecordWithNameCollision () throws Exception {
50
53
try {
51
54
schemaFunctor .apply (RecordWithNameCollision .class );
52
55
fail ("Should not pass" );
53
- } catch (InvalidDefinitionException e ) {
54
- AvroTestBase .verifyException (e , "double field entry: otherField" );
56
+ } catch (DatabindException e ) {
57
+ // InvalidDefinitionException with Avro schema
58
+ // JsonMapping with Jackson Schema
59
+
60
+ final String msg = e .toString ();
61
+
62
+ if (!msg .contains ("double field entry: otherField" )
63
+ && !msg .contains ("property \" otherField\" " )) {
64
+ fail ("Got exception but without matching message: " +msg );
65
+ }
55
66
}
56
67
}
57
68
}
0 commit comments