Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test utf8 encoding

  • Loading branch information...
commit e1a7686cc8b18897b3d80d1a67b9265973917135 1 parent 71a393e
@notnoop authored
View
19 src/test/java/com/notnoop/apns/PayloadBuilderTest.java
@@ -465,4 +465,23 @@ public void trimWorksWithLongFields() {
}
+ @Test
+ public void utf8Encoding() {
+ String str = "esemŽny";
+
+ PayloadBuilder builder = new PayloadBuilder();
+ String s1 = builder.alertBody(str).toString();
+
+ assertThat(s1, containsString(str));
+ }
+
+ @Test
+ public void utf8EncodingEscaped() {
+ String str = "esem\u00E9ny";
+
+ PayloadBuilder builder = new PayloadBuilder();
+ String s1 = builder.alertBody(str).toString();
+
+ assertThat(s1, containsString(str));
+ }
}
View
12 src/test/java/com/notnoop/apns/internal/UtilitiesTest.java
@@ -56,4 +56,16 @@ public void testParsingBytes() {
Assert.assertTrue(Utilities.parseBytes(0x80, 0,0,0) < 0);
Assert.assertTrue(Utilities.parseBytes(0x70, 0,0,0) > 0);
}
+
+ @Test
+ public void testEncodingUTF8() {
+ String m = "esemŽny";
+
+ byte[] expected = {
+ 'e', 's', 'e', 'm', (byte)0x00C3, (byte)0x00A9, 'n', 'y'
+ };
+
+ Assert.assertArrayEquals(expected, Utilities.toUTF8Bytes(m));
+
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.