flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject git commit: FLUME-1793. Unit test TestElasticSearchLogStashEventSerializer fails with IBM JDK
Date Fri, 18 Jul 2014 00:35:16 GMT
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 <harishreedharan@gmail.com>
Authored: Thu Jul 17 17:33:26 2014 -0700
Committer: Hari Shreedharan <harishreedharan@gmail.com>
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()));
   }
 }


Mime
View raw message