Return-Path: X-Original-To: apmail-flume-commits-archive@www.apache.org Delivered-To: apmail-flume-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D3CE011A44 for ; Fri, 18 Jul 2014 00:35:16 +0000 (UTC) Received: (qmail 41497 invoked by uid 500); 18 Jul 2014 00:35:16 -0000 Delivered-To: apmail-flume-commits-archive@flume.apache.org Received: (qmail 41467 invoked by uid 500); 18 Jul 2014 00:35:16 -0000 Mailing-List: contact commits-help@flume.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flume.apache.org Delivered-To: mailing list commits@flume.apache.org Received: (qmail 41458 invoked by uid 99); 18 Jul 2014 00:35:16 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2014 00:35:16 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6C6408C1982; Fri, 18 Jul 2014 00:35:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hshreedharan@apache.org To: commits@flume.apache.org Message-Id: <7b56a05cae7a4cc3ab41daa387cdefc0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: FLUME-1793. Unit test TestElasticSearchLogStashEventSerializer fails with IBM JDK Date: Fri, 18 Jul 2014 00:35:16 +0000 (UTC) Repository: flume Updated Branches: refs/heads/trunk 69fd6b3ad -> 8410ad307 FLUME-1793. Unit test TestElasticSearchLogStashEventSerializer fails with IBM JDK (Li Xiang via Hari Shreedharan. Reviewed by Edward Sargisson) Project: http://git-wip-us.apache.org/repos/asf/flume/repo Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/8410ad30 Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/8410ad30 Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/8410ad30 Branch: refs/heads/trunk Commit: 8410ad307187b19ca3a4330859815223d1e6b1e2 Parents: 69fd6b3 Author: Hari Shreedharan Authored: Thu Jul 17 17:33:26 2014 -0700 Committer: Hari Shreedharan Committed: Thu Jul 17 17:33:26 2014 -0700 ---------------------------------------------------------------------- ...estElasticSearchLogStashEventSerializer.java | 89 +++++++++++--------- 1 file changed, 49 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flume/blob/8410ad30/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/java/org/apache/flume/sink/elasticsearch/TestElasticSearchLogStashEventSerializer.java ---------------------------------------------------------------------- diff --git a/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/java/org/apache/flume/sink/elasticsearch/TestElasticSearchLogStashEventSerializer.java b/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/java/org/apache/flume/sink/elasticsearch/TestElasticSearchLogStashEventSerializer.java index d2c9543..ab9587d 100644 --- a/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/java/org/apache/flume/sink/elasticsearch/TestElasticSearchLogStashEventSerializer.java +++ b/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/java/org/apache/flume/sink/elasticsearch/TestElasticSearchLogStashEventSerializer.java @@ -28,6 +28,9 @@ import org.junit.Test; import java.util.Date; import java.util.Map; +import com.google.gson.JsonParser; +import com.google.gson.JsonElement; + import static org.apache.flume.sink.elasticsearch.ElasticSearchEventSerializer.charset; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.junit.Assert.assertEquals; @@ -53,28 +56,31 @@ public class TestElasticSearchLogStashEventSerializer { Event event = EventBuilder.withBody(message.getBytes(charset)); event.setHeaders(headers); - XContentBuilder expected = jsonBuilder().startObject(); - expected.field("@message", new String(message.getBytes(), charset)); - expected.field("@timestamp", new Date(timestamp)); - expected.field("@source", "flume_tail_src"); - expected.field("@type", "sometype"); - expected.field("@source_host", "test@localhost"); - expected.field("@source_path", "/tmp/test"); - expected.startObject("@fields"); - expected.field("timestamp", String.valueOf(timestamp)); - expected.field("src_path", "/tmp/test"); - expected.field("host", "test@localhost"); - expected.field("headerNameTwo", "headerValueTwo"); - expected.field("source", "flume_tail_src"); - expected.field("headerNameOne", "headerValueOne"); - expected.field("type", "sometype"); - expected.endObject(); - - expected.endObject(); + XContentBuilder expected = jsonBuilder() + .startObject(); + expected.field("@message", new String(message.getBytes(), charset)); + expected.field("@timestamp", new Date(timestamp)); + expected.field("@source", "flume_tail_src"); + expected.field("@type", "sometype"); + expected.field("@source_host", "test@localhost"); + expected.field("@source_path", "/tmp/test"); + + expected.startObject("@fields"); + expected.field("timestamp", String.valueOf(timestamp)); + expected.field("src_path", "/tmp/test"); + expected.field("host", "test@localhost"); + expected.field("headerNameTwo", "headerValueTwo"); + expected.field("source", "flume_tail_src"); + expected.field("headerNameOne", "headerValueOne"); + expected.field("type", "sometype"); + expected.endObject(); + + expected.endObject(); XContentBuilder actual = fixture.getContentBuilder(event); - assertEquals(new String(expected.bytes().array()), new String(actual - .bytes().array())); + + JsonParser parser = new JsonParser(); + assertEquals(parser.parse(expected.string()),parser.parse(actual.string())); } @Test @@ -96,27 +102,30 @@ public class TestElasticSearchLogStashEventSerializer { Event event = EventBuilder.withBody(message.getBytes(charset)); event.setHeaders(headers); - XContentBuilder expected = jsonBuilder().startObject(); - expected.field("@message", new String(message.getBytes(), charset)); - expected.field("@timestamp", new Date(timestamp)); - expected.field("@source", "flume_tail_src"); - expected.field("@type", "sometype"); - expected.field("@source_host", "test@localhost"); - expected.field("@source_path", "/tmp/test"); - expected.startObject("@fields"); - expected.field("timestamp", String.valueOf(timestamp)); - expected.field("src_path", "/tmp/test"); - expected.field("host", "test@localhost"); - expected.field("headerNameTwo", "headerValueTwo"); - expected.field("source", "flume_tail_src"); - expected.field("headerNameOne", "headerValueOne"); - expected.field("type", "sometype"); - expected.endObject(); - - expected.endObject(); + XContentBuilder expected = jsonBuilder(). + startObject(); + expected.field("@message", new String(message.getBytes(), charset)); + expected.field("@timestamp", new Date(timestamp)); + expected.field("@source", "flume_tail_src"); + expected.field("@type", "sometype"); + expected.field("@source_host", "test@localhost"); + expected.field("@source_path", "/tmp/test"); + + expected.startObject("@fields"); + expected.field("timestamp", String.valueOf(timestamp)); + expected.field("src_path", "/tmp/test"); + expected.field("host", "test@localhost"); + expected.field("headerNameTwo", "headerValueTwo"); + expected.field("source", "flume_tail_src"); + expected.field("headerNameOne", "headerValueOne"); + expected.field("type", "sometype"); + expected.endObject(); + + expected.endObject(); XContentBuilder actual = fixture.getContentBuilder(event); - assertEquals(new String(expected.bytes().array()), new String(actual - .bytes().array())); + + JsonParser parser = new JsonParser(); + assertEquals(parser.parse(expected.string()),parser.parse(actual.string())); } }