@Test public void toStringOnTextWithNewlines() { // Instead of emitting a literal newline in the toString(), these are escaped as "\n". assertEquals("[text=a\\r\\nb\\nc\\rd\\\\e]", factory.encodeUtf8("a\r\nb\nc\rd\\e").toString()); }
@Test public void toStringOnData() { ByteString byteString = factory.decodeHex("" + "60b420bb3851d9d47acb933dbe70399bf6c92da33af01d4fb770e98c0325f41d3ebaf8986da712c82bcd4d55" + "4bf0b54023c29b624de9ef9c2f931efc580f9afb"); assertEquals("[hex=" + "60b420bb3851d9d47acb933dbe70399bf6c92da33af01d4fb770e98c0325f41d3ebaf8986da712c82bcd4d55" + "4bf0b54023c29b624de9ef9c2f931efc580f9afb]", byteString.toString()); }
@Test public void toStringOnLongDataIsTruncated() { ByteString byteString = factory.decodeHex("" + "60b420bb3851d9d47acb933dbe70399bf6c92da33af01d4fb770e98c0325f41d3ebaf8986da712c82bcd4d55" + "4bf0b54023c29b624de9ef9c2f931efc580f9afba1"); assertEquals("[size=65 hex=" + "60b420bb3851d9d47acb933dbe70399bf6c92da33af01d4fb770e98c0325f41d3ebaf8986da712c82bcd4d55" + "4bf0b54023c29b624de9ef9c2f931efc580f9afb…]", byteString.toString()); }
@Test public void toStringOnLongTextIsTruncated() { String raw = "Um, I'll tell you the problem with the scientific power that you're using here, " + "it didn't require any discipline to attain it. You read what others had done and you " + "took the next step. You didn't earn the knowledge for yourselves, so you don't take any " + "responsibility for it. You stood on the shoulders of geniuses to accomplish something " + "as fast as you could, and before you even knew what you had, you patented it, and " + "packaged it, and slapped it on a plastic lunchbox, and now you're selling it, you wanna " + "sell it."; assertEquals("[size=517 text=Um, I'll tell you the problem with the scientific power that " + "you…]", factory.encodeUtf8(raw).toString()); String war = "Սm, I'll 𝓽𝖾ll ᶌօ𝘂 ᴛℎ℮ 𝜚𝕣०bl𝖾m wі𝕥𝒽 𝘵𝘩𝐞 𝓼𝙘𝐢𝔢𝓷𝗍𝜄𝚏𝑖c 𝛠𝝾w𝚎𝑟 𝕥h⍺𝞃 𝛄𝓸𝘂'𝒓𝗲 υ𝖘𝓲𝗇ɡ 𝕙𝚎𝑟e, " + "𝛊𝓽 ⅆ𝕚𝐝𝝿'𝗍 𝔯𝙚𝙦ᴜ𝜾𝒓𝘦 𝔞𝘯𝐲 ԁ𝜄𝑠𝚌ι𝘱lι𝒏e 𝑡𝜎 𝕒𝚝𝖙𝓪і𝞹 𝔦𝚝. 𝒀ο𝗎 𝔯𝑒⍺𝖉 w𝐡𝝰𝔱 𝞂𝞽һ𝓮𝓇ƽ հ𝖺𝖉 ⅾ𝛐𝝅ⅇ 𝝰πԁ 𝔂ᴑᴜ 𝓉ﮨ၀𝚔 " + "т𝒽𝑒 𝗇𝕖ⅹ𝚝 𝔰𝒕е𝓅. 𝘠ⲟ𝖚 𝖉ⅰԁ𝝕'τ 𝙚𝚊r𝞹 𝘵Ꮒ𝖾 𝝒𝐧هwl𝑒𝖉ƍ𝙚 𝓯૦r 𝔂𝞼𝒖𝕣𝑠𝕖l𝙫𝖊𝓼, 𐑈о y𝘰𝒖 ⅆە𝗇't 𝜏α𝒌𝕖 𝛂𝟉ℽ " + "𝐫ⅇ𝗌ⲣ๐ϖ𝖘ꙇᖯ𝓲l𝓲𝒕𝘆 𝐟𝞼𝘳 𝚤𝑡. 𝛶𝛔𝔲 s𝕥σσ𝐝 ﮩ𝕟 𝒕𝗁𝔢 𝘴𝐡𝜎ᴜlⅾ𝓮𝔯𝚜 𝛐𝙛 ᶃ𝚎ᴨᎥս𝚜𝘦𝓈 𝓽𝞸 a𝒄𝚌𝞸mρl𝛊ꜱ𝐡 𝓈𝚘m𝚎𝞃𝔥⍳𝞹𝔤 𝐚𝗌 𝖋a𝐬𝒕 " + "αs γ𝛐𝕦 𝔠ﻫ𝛖lԁ, 𝚊π𝑑 Ь𝑒𝙛૦𝓇𝘦 𝓎٥𝖚 ⅇvℯ𝝅 𝜅ո𝒆w w𝗵𝒂𝘁 ᶌ੦𝗎 h𝐚𝗱, 𝜸ﮨ𝒖 𝓹𝝰𝔱𝖾𝗇𝓽𝔢ⅆ і𝕥, 𝚊𝜛𝓭 𝓹𝖺ⅽϰ𝘢ℊеᏧ 𝑖𝞃, " + "𝐚𝛑ꓒ 𝙨l𝔞р𝘱𝔢𝓭 ɩ𝗍 ہ𝛑 𝕒 pl𝛂ѕᴛ𝗂𝐜 l𝞄ℼ𝔠𝒽𝑏ﮪ⨯, 𝔞ϖ𝒹 n𝛔w 𝛾𝐨𝞄'𝗿𝔢 ꜱ℮ll𝙞nɡ ɩ𝘁, 𝙮𝕠𝛖 w𝑎ℼ𝚗𝛂 𝕤𝓮ll 𝙞𝓉."; assertEquals( "[size=1496 text=Սm, I'll 𝓽𝖾ll ᶌօ𝘂 ᴛℎ℮ 𝜚𝕣०bl𝖾m wі𝕥𝒽 𝘵𝘩𝐞 𝓼𝙘𝐢𝔢𝓷𝗍𝜄𝚏𝑖c 𝛠𝝾w𝚎𝑟 𝕥h⍺𝞃 " + "𝛄𝓸𝘂…]", factory.encodeUtf8(war).toString()); }
@Test public void toStringOnEmpty() { assertEquals("[size=0]", factory.decodeHex("").toString()); }
@Override public String toString() { return "BytesEvent{" + "bytes=" + bytes.toString() + ", metadata=" + map.toMap() + '}'; } }
@Override public void onMessage(WebSocket webSocket, ByteString bytes) { // message bytes callback if (mJkWsStatusListener != null) { if (bytes != null) { Log.e(TAG, "#onMessage#bytes=" + bytes.toString()); }else { Log.e(TAG, "#onMessage#bytes"); } mJkWsStatusListener.onMessage(bytes); } }
@Override public void onMessage(WebSocket webSocket, ByteString bytes) { onMessage(webSocket, bytes.toString()); }
@Override public String toString() { return toByteString().toString(); }