1 package com.fasterxml.jackson.databind.exc; 2 3 import com.fasterxml.jackson.annotation.*; 4 5 import com.fasterxml.jackson.databind.*; 6 7 public class ExceptionPathTest extends BaseMapTest 8 { 9 static class Outer { 10 public Inner inner = new Inner(); 11 } 12 13 static class Inner { 14 public int x; 15 create(@sonProperty"x") int x)16 @JsonCreator public static Inner create(@JsonProperty("x") int x) { 17 throw new RuntimeException("test-exception"); 18 } 19 } 20 21 /* 22 /********************************************************** 23 /* Test methods 24 /********************************************************** 25 */ 26 27 private final ObjectMapper MAPPER = new ObjectMapper(); 28 testReferenceChainForInnerClass()29 public void testReferenceChainForInnerClass() throws Exception 30 { 31 String json = MAPPER.writeValueAsString(new Outer()); 32 try { 33 MAPPER.readValue(json, Outer.class); 34 fail("Should not pass"); 35 } catch (JsonMappingException e) { 36 JsonMappingException.Reference reference = e.getPath().get(0); 37 assertEquals(getClass().getName()+"$Outer[\"inner\"]", 38 reference.toString()); 39 } 40 } 41 } 42