Java Code Examples for io.netty.util.internal.StringUtil#toHexString()

The following examples show how to use io.netty.util.internal.StringUtil#toHexString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HpackTestCase.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
void testCompress() throws Exception {
    HpackEncoder hpackEncoder = createEncoder();

    for (HeaderBlock headerBlock : headerBlocks) {

        byte[] actual =
                encode(hpackEncoder, headerBlock.getHeaders(), headerBlock.getMaxHeaderTableSize(),
                        sensitiveHeaders);

        if (!Arrays.equals(actual, headerBlock.encodedBytes)) {
            throw new AssertionError(
                    "\nEXPECTED:\n" + headerBlock.getEncodedStr() +
                            "\nACTUAL:\n" + StringUtil.toHexString(actual));
        }

        List<HpackHeaderField> actualDynamicTable = new ArrayList<HpackHeaderField>();
        for (int index = 0; index < hpackEncoder.length(); index++) {
            actualDynamicTable.add(hpackEncoder.getHeaderField(index));
        }

        List<HpackHeaderField> expectedDynamicTable = headerBlock.getDynamicTable();

        if (!expectedDynamicTable.equals(actualDynamicTable)) {
            throw new AssertionError(
                    "\nEXPECTED DYNAMIC TABLE:\n" + expectedDynamicTable +
                            "\nACTUAL DYNAMIC TABLE:\n" + actualDynamicTable);
        }

        if (headerBlock.getTableSize() != hpackEncoder.size()) {
            throw new AssertionError(
                    "\nEXPECTED TABLE SIZE: " + headerBlock.getTableSize() +
                            "\n ACTUAL TABLE SIZE : " + hpackEncoder.size());
        }
    }
}
 
Example 2
Source File: HpackDecoderTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
private static String hex(String s) {
    return StringUtil.toHexString(s.getBytes());
}
 
Example 3
Source File: SocksCommonUtils.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
private static void appendHextet(StringBuilder sb, byte[] src, int i) {
    StringUtil.toHexString(sb, src, i << 1, 2);
}
 
Example 4
Source File: SocksCommonUtils.java    From shadowsocks-java with MIT License 4 votes vote down vote up
private static void appendHextet(StringBuilder sb, byte[] src, int i) {
    StringUtil.toHexString(sb, src, i << 1, 2);
}
 
Example 5
Source File: SocksCommonUtils.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
private static void appendHextet(StringBuilder sb, byte[] src, int i) {
    StringUtil.toHexString(sb, src, i << 1, 2);
}