Skip to content

Commit 3a090a0

Browse files
committed
Fixed test to verify the case of encoding preservation
1 parent 226a0d7 commit 3a090a0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

logstash-core/src/test/java/org/logstash/common/BufferedTokenizerExtTest.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.logstash.common;
2121

2222
import org.jruby.RubyArray;
23+
import org.jruby.RubyEncoding;
2324
import org.jruby.RubyString;
2425
import org.jruby.runtime.ThreadContext;
2526
import org.jruby.runtime.builtin.IRubyObject;
@@ -91,16 +92,16 @@ public void shouldTokenizeEmptyPayloadWithNewline() {
9192

9293
@Test
9394
public void shouldNotChangeEncodingOfTokensAfterPartitioning() {
94-
// RubyString rubyString = RubyString.newString(RUBY, new byte[]{(byte) 0xA3}); // £ character
9595
RubyString rubyString = RubyString.newString(RUBY, new byte[]{(byte) 0xA3, 0x0A, 0x41}); // £ character, newline, A
9696
IRubyObject rubyInput = rubyString.force_encoding(context, RUBY.newString("ISO8859-1"));
9797
RubyArray<RubyString> tokens = (RubyArray<RubyString>)sut.extract(context, rubyInput);
98-
IRubyObject firstToken = tokens.shift(context);
99-
100-
// IRubyObject token = sut.flush(context);
10198

102-
// assertEquals((byte) 0xA3, token.asJavaString().getBytes()[0]);
103-
// assertEquals("£", token.asJavaString());
99+
// read the first token, the £ string
100+
IRubyObject firstToken = tokens.shift(context);
104101
assertEquals("£", firstToken.toString());
102+
103+
// verify encoding "ISO8859-1" is preserved in the Java to Ruby String conversion
104+
RubyEncoding encoding = (RubyEncoding) firstToken.callMethod(context, "encoding");
105+
assertEquals("ISO8859-1", encoding.toString());
105106
}
106107
}

0 commit comments

Comments
 (0)