Search in sources :

Example 1 with Playback

use of org.webpieces.recording.api.Playback 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

InputStream (java.io.InputStream)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 DataWrapper (org.webpieces.data.api.DataWrapper)1 Memento (org.webpieces.httpparser.api.Memento)1 HttpPayload (org.webpieces.httpparser.api.dto.HttpPayload)1 Playback (org.webpieces.recording.api.Playback)1