logstash-core-event-java 5.0.0.alpha2.snapshot2-java → 5.0.0.alpha3-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc35efdbdd5b5b925626d1e40c15b354303fdc00
4
- data.tar.gz: cbfefdca225a3691554bc6aeba75955d80888cb8
3
+ metadata.gz: 26d37f5eb21593563b589a05bc7601a8079b6ec3
4
+ data.tar.gz: 75e52a1e593eb8cd9088866c335fadb0d5525faa
5
5
  SHA512:
6
- metadata.gz: 0dcc25cb787a792ceabb0f07631e8ddd38981cd1134b09c9d2a7b5227311bbd52fa4959a067499d9ee515b345c77d6c396fd881bf599cfe5b16d88c6a7859bec
7
- data.tar.gz: 93117d0d647f39fcb061d8669dfd78471b05461b8d27973ba7491dd8a94fde425182c97d536e668f0f52950d480052cb641fee3af87a09f6528e74d0ec2406f4
6
+ metadata.gz: ab1ede5872c47938f652dfea356469ad1bf41a220972a7c668ce3af2dae23f6e23e2bb53d120a2afbd4367943761ee9743a96a080b6ae393b4a9aecdd58762d2
7
+ data.tar.gz: 514700d367b3da6bd59caa7eda9950404a32ecf347bca2c729fb895f9c1e82a40fc70df9a85c284fe6b6a520a11d4480b027975c3a29caa6fc43aebded120e89
@@ -5,4 +5,4 @@
5
5
  # Note to authors: this should not include dashes because 'gem' barfs if
6
6
  # you include a dash in the version string.
7
7
 
8
- LOGSTASH_CORE_EVENT_JAVA_VERSION = "5.0.0-alpha2.snapshot2"
8
+ LOGSTASH_CORE_EVENT_JAVA_VERSION = "5.0.0-alpha3"
data/spec/event_spec.rb CHANGED
@@ -4,6 +4,7 @@ require "spec_helper"
4
4
  require "logstash/util"
5
5
  require "logstash/event"
6
6
  require "json"
7
+ require "java"
7
8
 
8
9
  TIMESTAMP = "@timestamp"
9
10
 
@@ -26,10 +27,10 @@ describe LogStash::Event do
26
27
 
27
28
  it "should serialize deep hash from field reference assignments" do
28
29
  e = LogStash::Event.new({TIMESTAMP => "2015-05-28T23:02:05.350Z"})
29
- e["foo"] = "bar"
30
- e["bar"] = 1
31
- e["baz"] = 1.0
32
- e["[fancy][pants][socks]"] = "shoes"
30
+ e.set("foo", "bar")
31
+ e.set("bar", 1)
32
+ e.set("baz", 1.0)
33
+ e.set("[fancy][pants][socks]", "shoes")
33
34
  expect(JSON.parse(e.to_json)).to eq(JSON.parse("{\"@timestamp\":\"2015-05-28T23:02:05.350Z\",\"@version\":\"1\",\"foo\":\"bar\",\"bar\":1,\"baz\":1.0,\"fancy\":{\"pants\":{\"socks\":\"shoes\"}}}"))
34
35
  end
35
36
  end
@@ -37,79 +38,79 @@ describe LogStash::Event do
37
38
  context "[]" do
38
39
  it "should get simple values" do
39
40
  e = LogStash::Event.new({"foo" => "bar", "bar" => 1, "baz" => 1.0, TIMESTAMP => "2015-05-28T23:02:05.350Z"})
40
- expect(e["foo"]).to eq("bar")
41
- expect(e["[foo]"]).to eq("bar")
42
- expect(e["bar"]).to eq(1)
43
- expect(e["[bar]"]).to eq(1)
44
- expect(e["baz"]).to eq(1.0)
45
- expect(e["[baz]"]).to eq(1.0)
46
- expect(e[TIMESTAMP].to_s).to eq("2015-05-28T23:02:05.350Z")
47
- expect(e["[#{TIMESTAMP}]"].to_s).to eq("2015-05-28T23:02:05.350Z")
41
+ expect(e.get("foo")).to eq("bar")
42
+ expect(e.get("[foo]")).to eq("bar")
43
+ expect(e.get("bar")).to eq(1)
44
+ expect(e.get("[bar]")).to eq(1)
45
+ expect(e.get("baz")).to eq(1.0)
46
+ expect(e.get("[baz]")).to eq(1.0)
47
+ expect(e.get(TIMESTAMP).to_s).to eq("2015-05-28T23:02:05.350Z")
48
+ expect(e.get("[#{TIMESTAMP}]").to_s).to eq("2015-05-28T23:02:05.350Z")
48
49
  end
49
50
 
50
51
  it "should get deep hash values" do
51
52
  e = LogStash::Event.new({"foo" => {"bar" => 1, "baz" => 1.0}})
52
- expect(e["[foo][bar]"]).to eq(1)
53
- expect(e["[foo][baz]"]).to eq(1.0)
53
+ expect(e.get("[foo][bar]")).to eq(1)
54
+ expect(e.get("[foo][baz]")).to eq(1.0)
54
55
  end
55
56
 
56
57
  it "should get deep array values" do
57
58
  e = LogStash::Event.new({"foo" => ["bar", 1, 1.0]})
58
- expect(e["[foo][0]"]).to eq("bar")
59
- expect(e["[foo][1]"]).to eq(1)
60
- expect(e["[foo][2]"]).to eq(1.0)
61
- expect(e["[foo][3]"]).to be_nil
59
+ expect(e.get("[foo][0]")).to eq("bar")
60
+ expect(e.get("[foo][1]")).to eq(1)
61
+ expect(e.get("[foo][2]")).to eq(1.0)
62
+ expect(e.get("[foo][3]")).to be_nil
62
63
  end
63
64
  end
64
65
 
65
66
  context "[]=" do
66
67
  it "should set simple values" do
67
68
  e = LogStash::Event.new()
68
- expect(e["foo"] = "bar").to eq("bar")
69
- expect(e["foo"]).to eq("bar")
69
+ expect(e.set("foo", "bar")).to eq("bar")
70
+ expect(e.get("foo")).to eq("bar")
70
71
 
71
72
  e = LogStash::Event.new({"foo" => "test"})
72
- expect(e["foo"] = "bar").to eq("bar")
73
- expect(e["foo"]).to eq("bar")
73
+ expect(e.set("foo", "bar")).to eq("bar")
74
+ expect(e.get("foo")).to eq("bar")
74
75
  end
75
76
 
76
77
  it "should set deep hash values" do
77
78
  e = LogStash::Event.new()
78
- expect(e["[foo][bar]"] = "baz").to eq("baz")
79
- expect(e["[foo][bar]"]).to eq("baz")
80
- expect(e["[foo][baz]"]).to be_nil
79
+ expect(e.set("[foo][bar]", "baz")).to eq("baz")
80
+ expect(e.get("[foo][bar]")).to eq("baz")
81
+ expect(e.get("[foo][baz]")).to be_nil
81
82
  end
82
83
 
83
84
  it "should set deep array values" do
84
85
  e = LogStash::Event.new()
85
- expect(e["[foo][0]"] = "bar").to eq("bar")
86
- expect(e["[foo][0]"]).to eq("bar")
87
- expect(e["[foo][1]"] = 1).to eq(1)
88
- expect(e["[foo][1]"]).to eq(1)
89
- expect(e["[foo][2]"] = 1.0 ).to eq(1.0)
90
- expect(e["[foo][2]"]).to eq(1.0)
91
- expect(e["[foo][3]"]).to be_nil
86
+ expect(e.set("[foo][0]", "bar")).to eq("bar")
87
+ expect(e.get("[foo][0]")).to eq("bar")
88
+ expect(e.set("[foo][1]", 1)).to eq(1)
89
+ expect(e.get("[foo][1]")).to eq(1)
90
+ expect(e.set("[foo][2]", 1.0)).to eq(1.0)
91
+ expect(e.get("[foo][2]")).to eq(1.0)
92
+ expect(e.get("[foo][3]")).to be_nil
92
93
  end
93
94
 
94
95
  it "should add key when setting nil value" do
95
96
  e = LogStash::Event.new()
96
- e["[foo]"] = nil
97
+ e.set("[foo]", nil)
97
98
  expect(e.to_hash).to include("foo" => nil)
98
99
  end
99
100
 
100
101
  # BigDecinal is now natively converted by JRuby, see https://github.com/elastic/logstash/pull/4838
101
102
  it "should set BigDecimal" do
102
103
  e = LogStash::Event.new()
103
- e["[foo]"] = BigDecimal.new(1)
104
- expect(e["foo"]).to be_kind_of(BigDecimal)
105
- expect(e["foo"]).to eq(BigDecimal.new(1))
104
+ e.set("[foo]", BigDecimal.new(1))
105
+ expect(e.get("foo")).to be_kind_of(BigDecimal)
106
+ expect(e.get("foo")).to eq(BigDecimal.new(1))
106
107
  end
107
108
 
108
109
  it "should set RubyBignum" do
109
110
  e = LogStash::Event.new()
110
- e["[foo]"] = -9223372036854776000
111
- expect(e["foo"]).to be_kind_of(Bignum)
112
- expect(e["foo"]).to eq(-9223372036854776000)
111
+ e.set("[foo]", -9223372036854776000)
112
+ expect(e.get("foo")).to be_kind_of(Bignum)
113
+ expect(e.get("foo")).to eq(-9223372036854776000)
113
114
  end
114
115
  end
115
116
 
@@ -117,7 +118,7 @@ describe LogStash::Event do
117
118
  it "getters should present a Ruby LogStash::Timestamp" do
118
119
  e = LogStash::Event.new()
119
120
  expect(e.timestamp.class).to eq(LogStash::Timestamp)
120
- expect(e[TIMESTAMP].class).to eq(LogStash::Timestamp)
121
+ expect(e.get(TIMESTAMP).class).to eq(LogStash::Timestamp)
121
122
  end
122
123
 
123
124
  it "to_hash should inject a Ruby LogStash::Timestamp" do
@@ -134,9 +135,9 @@ describe LogStash::Event do
134
135
  it "should set timestamp" do
135
136
  e = LogStash::Event.new
136
137
  now = Time.now
137
- e["@timestamp"] = LogStash::Timestamp.at(now.to_i)
138
+ e.set("@timestamp", LogStash::Timestamp.at(now.to_i))
138
139
  expect(e.timestamp.to_i).to eq(now.to_i)
139
- expect(e["@timestamp"].to_i).to eq(now.to_i)
140
+ expect(e.get("@timestamp").to_i).to eq(now.to_i)
140
141
  end
141
142
  end
142
143
 
@@ -144,16 +145,16 @@ describe LogStash::Event do
144
145
  it "should append" do
145
146
  event = LogStash::Event.new("message" => "hello world")
146
147
  event.append(LogStash::Event.new("message" => "another thing"))
147
- expect(event["message"]).to eq(["hello world", "another thing"])
148
+ expect(event.get("message")).to eq(["hello world", "another thing"])
148
149
  end
149
150
  end
150
151
 
151
152
  context "tags" do
152
153
  it "should tag" do
153
154
  event = LogStash::Event.new("message" => "hello world")
154
- expect(event["tags"]).to be_nil
155
- event["tags"] = ["foo"]
156
- expect(event["tags"]).to eq(["foo"])
155
+ expect(event.get("tags")).to be_nil
156
+ event.tag("foo")
157
+ expect(event.get("tags")).to eq(["foo"])
157
158
  end
158
159
  end
159
160
 
@@ -258,8 +259,8 @@ describe LogStash::Event do
258
259
  expect(LogStash::Event.from_json(source_json).size).to eq(1)
259
260
 
260
261
  event = LogStash::Event.from_json(source_json)[0]
261
- expect(event["[foo]"]).to eq(1)
262
- expect(event["[bar]"]).to eq("baz")
262
+ expect(event.get("[foo]")).to eq(1)
263
+ expect(event.get("[bar]")).to eq("baz")
263
264
  end
264
265
 
265
266
  it "should ignore blank strings" do
@@ -286,4 +287,24 @@ describe LogStash::Event do
286
287
  end
287
288
  end
288
289
  end
290
+
291
+ context "initialize" do
292
+
293
+ it "should accept Ruby Hash" do
294
+ e = LogStash::Event.new({"foo" => 1, TIMESTAMP => "2015-05-28T23:02:05.350Z"})
295
+ expect(e.get("foo")).to eq(1)
296
+ expect(e.timestamp.to_iso8601).to eq("2015-05-28T23:02:05.350Z")
297
+ end
298
+
299
+ it "should accept Java Map" do
300
+ h = Java::JavaUtil::HashMap.new
301
+ h.put("foo", 2);
302
+ h.put(TIMESTAMP, "2016-05-28T23:02:05.350Z");
303
+ e = LogStash::Event.new(h)
304
+
305
+ expect(e.get("foo")).to eq(2)
306
+ expect(e.timestamp.to_iso8601).to eq("2016-05-28T23:02:05.350Z")
307
+ end
308
+
309
+ end
289
310
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-core-event-java
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.alpha2.snapshot2
4
+ version: 5.0.0.alpha3
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement