8000 Merge pull request #85 from rabbitmq/rabbitmq-java-client-84 · panchenko/rabbitmq-java-client@9d4af42 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d4af42

Browse files
Merge pull request rabbitmq#85 from rabbitmq/rabbitmq-java-client-84
Introduce LongString#toString
2 parents 20dc6af + 3576480 commit 9d4af42

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/com/rabbitmq/client/LongString.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,10 @@ public interface LongString
5353
* @return the array of bytes containing the content of the {@link LongString}
5454
*/
5555
public byte [] getBytes();
56+
57+
/**
58+
* Get the content as a String. Uses UTF-8 as encoding.
59+
* @return he content of the {@link LongString} as a string
60+
*/
61+
public String toString();
5662
}

test/src/com/rabbitmq/client/test/ClientTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 8000 line change
@@ -24,6 +24,7 @@ public class ClientTests extends TestCase {
2424
public static TestSuite suite() {
2525
TestSuite suite = new TestSuite("client");
2626
suite.addTest(TableTest.suite());
27+
suite.addTest(LongStringTest.suite());
2728
suite.addTest(BlockingCellTest.suite());
2829
suite.addTest(TruncatedInputStreamTest.suite());
2930
suite.addTest(AMQConnectionTest.suite());
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.rabbitmq.client.test;
2+
3+
import com.rabbitmq.client.LongString;
4+
import com.rabbitmq.client.impl.LongStringHelper;
5+
import junit.framework.TestCase;
6+
import junit.framework.TestSuite;
7+
8+
import java.io.UnsupportedEncodingException;
9+
10+
public class LongStringTest extends TestCase {
11+
public static TestSuite suite()
12+
{
13+
TestSuite suite = new TestSuite("longString");
14+
suite.addTestSuite(LongStringTest.class);
15+
return suite;
16+
}
17+
18+
public void testToString() throws UnsupportedEncodingException {
19+
String s = "abcdef";
20+
LongString ls = LongStringHelper.asLongString(s);
21+
22+
assertTrue(ls.toString().equals(s));
23+
assertTrue(ls.toString().equals(new String(ls.getBytes(), "UTF-8")));
24+
}
25+
}

0 commit comments

Comments
 (0)
0