Fix unclosed objects & arrays

Original commit: elastic/x-pack-elasticsearch@d4b317a9c6
This commit is contained in:
Tanguy Leroux 2016-05-25 14:09:53 +02:00
parent 47d83d37d8
commit eec4ed90d2
10 changed files with 13 additions and 9 deletions

View File

@ -185,6 +185,7 @@ public abstract class AbstractExporterTemplateTestCase extends MarvelIntegTestCa
.endObject()
.endObject()
.endObject()
.endObject().bytes();
.endObject()
.endObject().bytes();
}
}

View File

@ -77,7 +77,7 @@ public class EmailAttachmentParsersTests extends ESTestCase {
XContentBuilder builder = jsonBuilder();
String type = randomAsciiOfLength(8);
builder.startObject().startObject("some-id").startObject(type);
builder.startObject().startObject("some-id").startObject(type).endObject().endObject().endObject();
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
try {

View File

@ -206,7 +206,7 @@ public class HipChatMessageTests extends ESTestCase {
jsonBuilder.field("notify", notify);
}
BytesReference bytes = jsonBuilder.bytes();
BytesReference bytes = jsonBuilder.endObject().bytes();
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
parser.nextToken();

View File

@ -294,6 +294,8 @@ public class EmailActionTests extends ESTestCase {
}
builder.endObject();
}
builder.endObject();
BytesReference bytes = builder.bytes();
logger.info("email action json [{}]", bytes.toUtf8());
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
@ -421,7 +423,7 @@ public class EmailActionTests extends ESTestCase {
HtmlSanitizer htmlSanitizer = mock(HtmlSanitizer.class);
EmailAttachmentsParser emailAttachmentsParser = mock(EmailAttachmentsParser.class);
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value");
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
parser.nextToken();
try {

View File

@ -197,7 +197,7 @@ public class HipChatActionFactoryTests extends ESTestCase {
}
public void testParserInvalid() throws Exception {
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value");
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
parser.nextToken();
try {

View File

@ -247,7 +247,7 @@ public class HipChatActionTests extends ESTestCase {
}
public void testParserInvalid() throws Exception {
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value");
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
parser.nextToken();
try {

View File

@ -236,7 +236,7 @@ public class PagerDutyActionTests extends ESTestCase {
public void testParserInvalid() throws Exception {
try {
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value");
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
parser.nextToken();
PagerDutyAction.parse("_watch", "_action", parser);

View File

@ -188,7 +188,7 @@ public class SlackActionTests extends ESTestCase {
}
public void testParserInvalid() throws Exception {
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value");
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
parser.nextToken();
try {

View File

@ -220,6 +220,7 @@ public class WatcherUtilsTests extends ESTestCase {
templateSource = new Template(template.getTemplate(), template.getType(), null, template.getContentType(),
template.getParams());
}
builder.endObject();
XContentParser parser = XContentHelper.createParser(builder.bytes());
assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT));

View File

@ -153,7 +153,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
watchSource.startObject("condition").startObject("script").field("script", "return true").field("request");
WatcherUtils.writeSearchRequest(newInputSearchRequest(), watchSource, ToXContent.EMPTY_PARAMS);
watchSource.endObject();
watchSource.endObject().endObject();
watchSource.endObject();
try {