Search in sources :

Example 6 with Memento

use of org.webpieces.httpparser.api.Memento in project webpieces by deanhiller.

the class TestGooglePlayback method runPlayback.

private List<HttpPayload> runPlayback(String name) {
    Memento mem = parser.prepareToParse();
    int counter = 0;
    ClassLoader cl = getClass().getClassLoader();
    InputStream in = cl.getResourceAsStream(name);
    //This loads relative to this test class package(while the above does not).
    //InputStream in = getClass().getResourceAsStream(name);
    Playback playback = RecordingPlaybackFactory.createPlayback(in, 1);
    List<HttpPayload> results = new ArrayList<>();
    while (true) {
        counter++;
        if (counter > 1000)
            throw new IllegalArgumentException("Is your simulation really this long...1000+ buffers?");
        ByteBuffer buffer = playback.getNextPacket();
        if (buffer == null)
            return results;
        DataWrapper data = dataGen.wrapByteBuffer(buffer);
        mem = parser.parse(mem, data);
        List<HttpPayload> parsedMessages = mem.getParsedMessages();
        results.addAll(parsedMessages);
    }
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) Memento(org.webpieces.httpparser.api.Memento) HttpPayload(org.webpieces.httpparser.api.dto.HttpPayload) InputStream(java.io.InputStream) Playback(org.webpieces.recording.api.Playback) ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer)

Aggregations

Memento (org.webpieces.httpparser.api.Memento)6 DataWrapper (org.webpieces.data.api.DataWrapper)3 ByteBuffer (java.nio.ByteBuffer)2 MarshalState (org.webpieces.httpparser.api.MarshalState)2 HttpPayload (org.webpieces.httpparser.api.dto.HttpPayload)2 Http2Request (com.webpieces.hpack.api.dto.Http2Request)1 StreamWriter (com.webpieces.http2engine.api.StreamWriter)1 DataFrame (com.webpieces.http2parser.api.dto.DataFrame)1 Http2HeaderName (com.webpieces.http2parser.api.dto.lib.Http2HeaderName)1 Http2Msg (com.webpieces.http2parser.api.dto.lib.Http2Msg)1 PermitQueue (com.webpieces.util.locking.PermitQueue)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 DataWrapperGenerator (org.webpieces.data.api.DataWrapperGenerator)1 DataWrapperGeneratorFactory (org.webpieces.data.api.DataWrapperGeneratorFactory)1 HttpStream (org.webpieces.frontend2.api.HttpStream)1 StreamListener (org.webpieces.frontend2.api.StreamListener)1