1 package com.fasterxml.jackson.failing; 2 3 import com.fasterxml.jackson.annotation.JsonUnwrapped; 4 import com.fasterxml.jackson.databind.*; 5 6 public class TestUnwrappedWithUnknown650 extends BaseMapTest 7 { 8 static class A { 9 @JsonUnwrapped 10 public B b; 11 } 12 13 static class B { 14 public String field; 15 } 16 17 private final ObjectMapper MAPPER = new ObjectMapper(); 18 testFailOnUnknownPropertyUnwrapped()19 public void testFailOnUnknownPropertyUnwrapped() throws Exception 20 { 21 assertTrue(MAPPER.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)); 22 23 final String JSON = "{'field': 'value', 'bad':'bad value'}"; 24 try { 25 MAPPER.readValue(aposToQuotes(JSON), A.class); 26 fail("Exception was not thrown on unkown property"); 27 } catch (JsonMappingException e) { 28 verifyException(e, "Unrecognized field"); 29 } 30 } 31 } 32