Search in sources :

Example 21 with Encoder

use of java.util.Base64.Encoder in project j2objc by google.

the class Base64Test method testEncoder_nonPrintableBytes.

public void testEncoder_nonPrintableBytes() throws Exception {
    Encoder encoder = Base64.getUrlEncoder();
    assertEquals("", encoder.encodeToString(copyOfRange(SAMPLE_NON_ASCII_BYTES, 0, 0)));
    assertEquals("_w==", encoder.encodeToString(copyOfRange(SAMPLE_NON_ASCII_BYTES, 0, 1)));
    assertEquals("_-4=", encoder.encodeToString(copyOfRange(SAMPLE_NON_ASCII_BYTES, 0, 2)));
    assertEquals("_-7d", encoder.encodeToString(copyOfRange(SAMPLE_NON_ASCII_BYTES, 0, 3)));
    assertEquals("_-7dzA==", encoder.encodeToString(copyOfRange(SAMPLE_NON_ASCII_BYTES, 0, 4)));
    assertEquals("_-7dzLs=", encoder.encodeToString(copyOfRange(SAMPLE_NON_ASCII_BYTES, 0, 5)));
    assertEquals("_-7dzLuq", encoder.encodeToString(copyOfRange(SAMPLE_NON_ASCII_BYTES, 0, 6)));
    assertEquals("_-7dzLuqmQ==", encoder.encodeToString(copyOfRange(SAMPLE_NON_ASCII_BYTES, 0, 7)));
    assertEquals("_-7dzLuqmYg=", encoder.encodeToString(copyOfRange(SAMPLE_NON_ASCII_BYTES, 0, 8)));
}
Also used : Encoder(java.util.Base64.Encoder)

Example 22 with Encoder

use of java.util.Base64.Encoder in project jdk8u_jdk by JetBrains.

the class TestBase64Golden method test1.

private static void test1() throws Exception {
    byte[] src = new byte[] { 46, -97, -35, -44, 127, -60, -39, -4, -112, 34, -57, 47, -14, 67, 40, 18, 90, -59, 68, 112, 23, 121, -91, 94, 35, 49, 104, 17, 30, -80, -104, -3, -53, 27, 38, -72, -47, 113, -52, 18, 5, -126 };
    Encoder encoder = Base64.getMimeEncoder(49, new byte[] { 0x7e });
    byte[] encoded = encoder.encode(src);
    Decoder decoder = Base64.getMimeDecoder();
    byte[] decoded = decoder.decode(encoded);
    if (!Objects.deepEquals(src, decoded)) {
        throw new RuntimeException();
    }
}
Also used : Encoder(java.util.Base64.Encoder) BASE64Encoder(sun.misc.BASE64Encoder) Decoder(java.util.Base64.Decoder) BASE64Decoder(sun.misc.BASE64Decoder)

Aggregations

Bootstrap (io.netty.bootstrap.Bootstrap)11 ByteBuf (io.netty.buffer.ByteBuf)11 Unpooled (io.netty.buffer.Unpooled)11 Channel (io.netty.channel.Channel)11 ChannelDuplexHandler (io.netty.channel.ChannelDuplexHandler)11 ChannelFuture (io.netty.channel.ChannelFuture)11 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)11 ChannelInitializer (io.netty.channel.ChannelInitializer)11 ChannelPipeline (io.netty.channel.ChannelPipeline)11 EventLoopGroup (io.netty.channel.EventLoopGroup)11 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)11 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)11 HttpHeaderNames (io.netty.handler.codec.http.HttpHeaderNames)11 AbstractHttp2ConnectionHandlerBuilder (io.netty.handler.codec.http2.AbstractHttp2ConnectionHandlerBuilder)11 DefaultHttp2Connection (io.netty.handler.codec.http2.DefaultHttp2Connection)11 DefaultHttp2Headers (io.netty.handler.codec.http2.DefaultHttp2Headers)11 Http2Connection (io.netty.handler.codec.http2.Http2Connection)11 Http2ConnectionDecoder (io.netty.handler.codec.http2.Http2ConnectionDecoder)11 Http2ConnectionEncoder (io.netty.handler.codec.http2.Http2ConnectionEncoder)11 Http2ConnectionHandler (io.netty.handler.codec.http2.Http2ConnectionHandler)11