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);
}
}
Aggregations