// Path: serializer-base64/src/test/java/com/vlkan/hrrs/serializer/HttpRequestRecordPipe.java
// public class HttpRequestRecordPipe implements HttpRequestRecordReaderSource<String>, HttpRequestRecordWriterTarget<String> {
// 
//     private final Writer writer;
// 
//     private final BufferedReader reader;
// 
//     public HttpRequestRecordPipe(int pipeSize) {
//         PipedOutputStream outputStream = new PipedOutputStream();
//         this.writer = new OutputStreamWriter(outputStream);
//         try {
//             PipedInputStream inputStream = new PipedInputStream(outputStream, pipeSize);
//             this.reader = new BufferedReader(new InputStreamReader(inputStream));
//         } catch (IOException error) {
//             throw new RuntimeException("failed creating piped input stream", error);
//         }
//     }
// 
//     @Override
//     public void write(String value) {
//         try {
//             writer.write(value);
//         } catch (IOException error) {
//             throw new RuntimeException("write failure", error);
//         }
//     }
// 
//     @Nullable
//     @Override
//     public String read() {
//         try {
//             return reader.readLine();
//         } catch (IOException error) {
//             throw new RuntimeException("read failure", error);
//         }
//     }
// 
//     @Override
//     public void flush() {
//         try {
//             writer.flush();
//         } catch (IOException error) {
//             throw new RuntimeException("flush failure", error);
//         }
//     }
// 
//     @Override
//     public void close() throws IOException {
//         writer.close();
//         reader.close();
//     }
// 
// }
// 
// Path: serializer-base64/src/main/java/com/vlkan/hrrs/serializer/base64/guava/GuavaBase64Decoder.java
// public class GuavaBase64Decoder implements Base64Decoder {
// 
//     private static final GuavaBase64Decoder INSTANCE = new GuavaBase64Decoder();
// 
//     private GuavaBase64Decoder() {
//         // Do nothing.
//     }
// 
//     public static GuavaBase64Decoder getInstance() {
//         return INSTANCE;
//     }
// 
//     @Override
//     public byte[] decode(String encodedBytes) {
//         checkNotNull(encodedBytes, "encodedBytes");
//         return GuavaBase64.BASE_ENCODING.decode(encodedBytes);
//     }
// 
// }
// 
// Path: serializer-base64/src/main/java/com/vlkan/hrrs/serializer/base64/guava/GuavaBase64Encoder.java
// public class GuavaBase64Encoder implements Base64Encoder {
// 
//     private static final GuavaBase64Encoder INSTANCE = new GuavaBase64Encoder();
// 
//     private GuavaBase64Encoder() {
//         // Do nothing.
//     }
// 
//     public static GuavaBase64Encoder getInstance() {
//         return INSTANCE;
//     }
// 
//     @Override
//     public String encode(byte[] bytes) {
//         checkNotNull(bytes, "bytes");
//         return GuavaBase64.BASE_ENCODING.encode(bytes);
//     }
// 
// }


import com.vlkan.hrrs.api.*;
import com.vlkan.hrrs.serializer.HttpRequestRecordPipe;
import com.vlkan.hrrs.serializer.base64.guava.GuavaBase64Decoder;
import com.vlkan.hrrs.serializer.base64.guava.GuavaBase64Encoder;
import org.junit.Test;
import java.util.*;
import static com.google.common.base.Preconditions.checkArgument;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
package com.vlkan.hrrs.serializer.base64;




public class HttpRequestSerializationTest {

    private static final int RANDOM_RECORD_COUNT = 100;

    private static final int MAX_GROUP_COUNT = 10;

    private static final int MAX_HEADER_COUNT = 10;

    private static final int MAX_BYTE_COUNT = 1024 * 128;      // 128 KB

    @Test
    public void should_write_and_read() {
        Random random = new Random(0);
        for (int testIndex = 0; testIndex < RANDOM_RECORD_COUNT; testIndex++) {
            HttpRequestRecord record = generateHttpRequestRecord(random);
            should_write_and_read(record);
        }
    }

    private static void should_write_and_read(HttpRequestRecord record) {
// Path: serializer-base64/src/test/java/com/vlkan/hrrs/serializer/HttpRequestRecordPipe.java
// public class HttpRequestRecordPipe implements HttpRequestRecordReaderSource<String>, HttpRequestRecordWriterTarget<String> {
// 
//     private final Writer writer;
// 
//     private final BufferedReader reader;
// 
//     public HttpRequestRecordPipe(int pipeSize) {
//         PipedOutputStream outputStream = new PipedOutputStream();
//         this.writer = new OutputStreamWriter(outputStream);
//         try {
//             PipedInputStream inputStream = new PipedInputStream(outputStream, pipeSize);
//             this.reader = new BufferedReader(new InputStreamReader(inputStream));
//         } catch (IOException error) {
//             throw new RuntimeException("failed creating piped input stream", error);
//         }
//     }
// 
//     @Override
//     public void write(String value) {
//         try {
//             writer.write(value);
//         } catch (IOException error) {
//             throw new RuntimeException("write failure", error);
//         }
//     }
// 
//     @Nullable
//     @Override
//     public String read() {
//         try {
//             return reader.readLine();
//         } catch (IOException error) {
//             throw new RuntimeException("read failure", error);
//         }
//     }
// 
//     @Override
//     public void flush() {
//         try {
//             writer.flush();
//         } catch (IOException error) {
//             throw new RuntimeException("flush failure", error);
//         }
//     }
// 
//     @Override
//     public void close() throws IOException {
//         writer.close();
//         reader.close();
//     }
// 
// }
// 
// Path: serializer-base64/src/main/java/com/vlkan/hrrs/serializer/base64/guava/GuavaBase64Decoder.java
// public class GuavaBase64Decoder implements Base64Decoder {
// 
//     private static final GuavaBase64Decoder INSTANCE = new GuavaBase64Decoder();
// 
//     private GuavaBase64Decoder() {
//         // Do nothing.
//     }
// 
//     public static GuavaBase64Decoder getInstance() {
//         return INSTANCE;
//     }
// 
//     @Override
//     public byte[] decode(String encodedBytes) {
//         checkNotNull(encodedBytes, "encodedBytes");
//         return GuavaBase64.BASE_ENCODING.decode(encodedBytes);
//     }
// 
// }
// 
// Path: serializer-base64/src/main/java/com/vlkan/hrrs/serializer/base64/guava/GuavaBase64Encoder.java
// public class GuavaBase64Encoder implements Base64Encoder {
// 
//     private static final GuavaBase64Encoder INSTANCE = new GuavaBase64Encoder();
// 
//     private GuavaBase64Encoder() {
//         // Do nothing.
//     }
// 
//     public static GuavaBase64Encoder getInstance() {
//         return INSTANCE;
//     }
// 
//     @Override
//     public String encode(byte[] bytes) {
//         checkNotNull(bytes, "bytes");
//         return GuavaBase64.BASE_ENCODING.encode(bytes);
//     }
// 
// }


// Path: serializer-base64/src/test/java/com/vlkan/hrrs/serializer/base64/HttpRequestSerializationTest.java
import com.vlkan.hrrs.api.*;
import com.vlkan.hrrs.serializer.HttpRequestRecordPipe;
import com.vlkan.hrrs.serializer.base64.guava.GuavaBase64Decoder;
import com.vlkan.hrrs.serializer.base64.guava.GuavaBase64Encoder;
import org.junit.Test;
import java.util.*;
import static com.google.common.base.Preconditions.checkArgument;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

package com.vlkan.hrrs.serializer.base64;




public class HttpRequestSerializationTest {

    private static final int RANDOM_RECORD_COUNT = 100;

    private static final int MAX_GROUP_COUNT = 10;

    private static final int MAX_HEADER_COUNT = 10;

    private static final int MAX_BYTE_COUNT = 1024 * 128;      // 128 KB

    @Test
    public void should_write_and_read() {
        Random random = new Random(0);
        for (int testIndex = 0; testIndex < RANDOM_RECORD_COUNT; testIndex++) {
            HttpRequestRecord record = generateHttpRequestRecord(random);
            should_write_and_read(record);
        }
    }

    private static void should_write_and_read(HttpRequestRecord record) {
        HttpRequestRecordPipe pipe = new HttpRequestRecordPipe(MAX_BYTE_COUNT * 8);