Update to Jackson 2.8.1
This commit updates Jackson to the 2.8.1 version, which is more strict when it comes to build objects. Original commit: elastic/x-pack-elasticsearch@fb23208e7d
This commit is contained in:
parent
a2cca18c49
commit
ec950a2ca7
|
@ -31,9 +31,11 @@ public class LicensesMetaDataSerializationTests extends ESTestCase {
|
|||
License license = TestUtils.generateSignedLicense(TimeValue.timeValueHours(2));
|
||||
LicensesMetaData licensesMetaData = new LicensesMetaData(license);
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.startObject("licenses");
|
||||
licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
builder.endObject();
|
||||
LicensesMetaData licensesMetaDataFromXContent = getLicensesMetaDataFromXContent(builder.bytes());
|
||||
assertThat(licensesMetaDataFromXContent.getLicense(), equalTo(license));
|
||||
}
|
||||
|
@ -77,18 +79,22 @@ public class LicensesMetaDataSerializationTests extends ESTestCase {
|
|||
final License trialLicense = TrialLicense.create(specBuilder);
|
||||
LicensesMetaData licensesMetaData = new LicensesMetaData(trialLicense);
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.startObject("licenses");
|
||||
licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
builder.endObject();
|
||||
LicensesMetaData licensesMetaDataFromXContent = getLicensesMetaDataFromXContent(builder.bytes());
|
||||
assertThat(licensesMetaDataFromXContent.getLicense(), equalTo(trialLicense));
|
||||
}
|
||||
|
||||
public void testLicenseTombstoneFromXContext() throws Exception {
|
||||
final XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.startObject("licenses");
|
||||
builder.nullField("license");
|
||||
builder.endObject();
|
||||
builder.endObject();
|
||||
LicensesMetaData metaDataFromXContent = getLicensesMetaDataFromXContent(builder.bytes());
|
||||
assertThat(metaDataFromXContent.getLicense(), equalTo(LicensesMetaData.LICENSE_TOMBSTONE));
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ public class FileRolesStore extends AbstractLifecycleComponent implements RolesS
|
|||
} else {
|
||||
logger.error(e.getMessage() + ". skipping role...");
|
||||
}
|
||||
} catch (YAMLException | IOException e) {
|
||||
} catch (IOException e) {
|
||||
if (roleName != null) {
|
||||
logger.error("invalid role definition [{}] in roles file [{}]. skipping role...", e, roleName, path);
|
||||
} else {
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Map;
|
|||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
|
@ -99,7 +100,9 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
|||
attachments.add(httpRequestAttachment);
|
||||
EmailAttachments emailAttachments = new EmailAttachments(attachments);
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject();
|
||||
emailAttachments.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
logger.info("JSON is: {}", builder.string());
|
||||
assertThat(builder.string(), containsString("my-name.json"));
|
||||
assertThat(builder.string(), containsString("json"));
|
||||
|
@ -122,11 +125,22 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
|||
|
||||
EmailAttachments emailAttachments = new EmailAttachments(attachments);
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject();
|
||||
emailAttachments.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
logger.info("JSON is: " + builder.string());
|
||||
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
try {
|
||||
XContentParser.Token token = xContentParser.currentToken();
|
||||
assertNull(token);
|
||||
|
||||
token = xContentParser.nextToken();
|
||||
assertThat(token, equalTo(XContentParser.Token.START_OBJECT));
|
||||
|
||||
token = xContentParser.nextToken();
|
||||
assertThat(token, equalTo(XContentParser.Token.FIELD_NAME));
|
||||
|
||||
parser.parse(xContentParser);
|
||||
fail("Expected parser to fail but did not happen");
|
||||
} catch (ElasticsearchParseException e) {
|
||||
|
|
|
@ -180,7 +180,9 @@ public class EmailAttachmentTests extends AbstractWatcherIntegrationTestCase {
|
|||
attachments.add(httpRequestAttachment);
|
||||
EmailAttachments emailAttachments = new EmailAttachments(attachments);
|
||||
XContentBuilder tmpBuilder = jsonBuilder();
|
||||
tmpBuilder.startObject();
|
||||
emailAttachments.toXContent(tmpBuilder, ToXContent.EMPTY_PARAMS);
|
||||
tmpBuilder.endObject();
|
||||
logger.info("TMP BUILDER {}", tmpBuilder.string());
|
||||
|
||||
EmailTemplate.Builder emailBuilder = EmailTemplate.builder().from("_from").to("_to").subject("Subject");
|
||||
|
|
Loading…
Reference in New Issue