Fixed tests to make the generator and the parser have the same scope.
This commit is contained in:
parent
4c2a3dfbe6
commit
6d1e5c9a07
|
@ -1,2 +1,2 @@
|
|||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
org.eclipse.jetty.http2.LEVEL=DEBUG
|
||||
org.eclipse.jetty.http2.LEVEL=INFO
|
||||
|
|
|
@ -89,23 +89,23 @@ public class DataGenerateParseTest
|
|||
{
|
||||
DataGenerator generator = new DataGenerator(new HeaderGenerator());
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
final List<DataFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onData(DataFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateData(lease, 13, data.slice(), true, data.remaining());
|
||||
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onData(DataFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
frames.clear();
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
|
@ -121,10 +121,6 @@ public class DataGenerateParseTest
|
|||
{
|
||||
DataGenerator generator = new DataGenerator(new HeaderGenerator());
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
ByteBuffer data = ByteBuffer.wrap(largeContent);
|
||||
generator.generateData(lease, 13, data.slice(), true, data.remaining());
|
||||
|
||||
final List<DataFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
|
@ -136,6 +132,10 @@ public class DataGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
ByteBuffer data = ByteBuffer.wrap(largeContent);
|
||||
generator.generateData(lease, 13, data.slice(), true, data.remaining());
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
|
|
@ -40,24 +40,25 @@ public class GoAwayGenerateParseTest
|
|||
{
|
||||
GoAwayGenerator generator = new GoAwayGenerator(new HeaderGenerator());
|
||||
|
||||
final List<GoAwayFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onGoAway(GoAwayFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int lastStreamId = 13;
|
||||
int error = 17;
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
final List<GoAwayFrame> frames = new ArrayList<>();
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateGoAway(lease, lastStreamId, error, null);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onGoAway(GoAwayFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
frames.clear();
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
|
@ -81,14 +82,7 @@ public class GoAwayGenerateParseTest
|
|||
{
|
||||
GoAwayGenerator generator = new GoAwayGenerator(new HeaderGenerator());
|
||||
|
||||
int lastStreamId = 13;
|
||||
int error = 17;
|
||||
byte[] payload = new byte[16];
|
||||
new Random().nextBytes(payload);
|
||||
|
||||
final List<GoAwayFrame> frames = new ArrayList<>();
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateGoAway(lease, lastStreamId, error, payload);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
|
@ -99,6 +93,14 @@ public class GoAwayGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
int lastStreamId = 13;
|
||||
int error = 17;
|
||||
byte[] payload = new byte[16];
|
||||
new Random().nextBytes(payload);
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateGoAway(lease, lastStreamId, error, payload);
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
|
|
@ -26,22 +26,20 @@ import org.eclipse.jetty.http.HttpField;
|
|||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.http2.generator.HeaderGenerator;
|
||||
import org.eclipse.jetty.http2.generator.HeadersGenerator;
|
||||
import org.eclipse.jetty.http2.hpack.HpackEncoder;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.http2.parser.Parser;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HeadersGenerateParseTest
|
||||
{
|
||||
private final ByteBufferPool byteBufferPool = new MappedByteBufferPool();
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGenerateParse() throws Exception
|
||||
{
|
||||
|
@ -53,21 +51,22 @@ public class HeadersGenerateParseTest
|
|||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields);
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
final List<HeadersFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onHeaders(HeadersFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateHeaders(lease, streamId, metaData, false);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onHeaders(HeadersFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
frames.clear();
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
|
@ -101,15 +100,7 @@ public class HeadersGenerateParseTest
|
|||
{
|
||||
HeadersGenerator generator = new HeadersGenerator(new HeaderGenerator(), new HpackEncoder());
|
||||
|
||||
int streamId = 13;
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields);
|
||||
|
||||
final List<HeadersFrame> frames = new ArrayList<>();
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateHeaders(lease, streamId, metaData, false);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
|
@ -120,6 +111,15 @@ public class HeadersGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
int streamId = 13;
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields);
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateHeaders(lease, streamId, metaData, false);
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
|
|
@ -40,24 +40,25 @@ public class PingGenerateParseTest
|
|||
{
|
||||
PingGenerator generator = new PingGenerator(new HeaderGenerator());
|
||||
|
||||
final List<PingFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onPing(PingFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
byte[] payload = new byte[8];
|
||||
new Random().nextBytes(payload);
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
final List<PingFrame> frames = new ArrayList<>();
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePing(lease, payload, true);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onPing(PingFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
frames.clear();
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
|
@ -80,12 +81,7 @@ public class PingGenerateParseTest
|
|||
{
|
||||
PingGenerator generator = new PingGenerator(new HeaderGenerator());
|
||||
|
||||
byte[] payload = new byte[8];
|
||||
new Random().nextBytes(payload);
|
||||
|
||||
final List<PingFrame> frames = new ArrayList<>();
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePing(lease, payload, true);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
|
@ -96,6 +92,12 @@ public class PingGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
byte[] payload = new byte[8];
|
||||
new Random().nextBytes(payload);
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePing(lease, payload, true);
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
|
|
@ -39,26 +39,27 @@ public class PriorityGenerateParseTest
|
|||
{
|
||||
PriorityGenerator generator = new PriorityGenerator(new HeaderGenerator());
|
||||
|
||||
final List<PriorityFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onPriority(PriorityFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int streamId = 13;
|
||||
int dependentStreamId = 17;
|
||||
int weight = 3;
|
||||
boolean exclusive = true;
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
final List<PriorityFrame> frames = new ArrayList<>();
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePriority(lease, streamId, dependentStreamId, weight, exclusive);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onPriority(PriorityFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
frames.clear();
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
|
@ -83,14 +84,7 @@ public class PriorityGenerateParseTest
|
|||
{
|
||||
PriorityGenerator generator = new PriorityGenerator(new HeaderGenerator());
|
||||
|
||||
int streamId = 13;
|
||||
int dependentStreamId = 17;
|
||||
int weight = 3;
|
||||
boolean exclusive = true;
|
||||
|
||||
final List<PriorityFrame> frames = new ArrayList<>();
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePriority(lease, streamId, dependentStreamId, weight, exclusive);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
|
@ -101,6 +95,14 @@ public class PriorityGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
int streamId = 13;
|
||||
int dependentStreamId = 17;
|
||||
int weight = 3;
|
||||
boolean exclusive = true;
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePriority(lease, streamId, dependentStreamId, weight, exclusive);
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
|
|
@ -26,27 +26,36 @@ import org.eclipse.jetty.http.HttpField;
|
|||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.http2.generator.HeaderGenerator;
|
||||
import org.eclipse.jetty.http2.generator.PushPromiseGenerator;
|
||||
import org.eclipse.jetty.http2.hpack.HpackEncoder;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.http2.parser.Parser;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PushPromiseGenerateParseTest
|
||||
{
|
||||
private final ByteBufferPool byteBufferPool = new MappedByteBufferPool();
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGenerateParse() throws Exception
|
||||
{
|
||||
PushPromiseGenerator generator = new PushPromiseGenerator(new HeaderGenerator(), new HpackEncoder());
|
||||
|
||||
final List<PushPromiseFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onPushPromise(PushPromiseFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int streamId = 13;
|
||||
int promisedStreamId = 17;
|
||||
HttpFields fields = new HttpFields();
|
||||
|
@ -55,20 +64,10 @@ public class PushPromiseGenerateParseTest
|
|||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields);
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
final List<PushPromiseFrame> frames = new ArrayList<>();
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePushPromise(lease, streamId, promisedStreamId, metaData);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onPushPromise(PushPromiseFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
frames.clear();
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
|
@ -102,16 +101,7 @@ public class PushPromiseGenerateParseTest
|
|||
{
|
||||
PushPromiseGenerator generator = new PushPromiseGenerator(new HeaderGenerator(), new HpackEncoder());
|
||||
|
||||
int streamId = 13;
|
||||
int promisedStreamId = 17;
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields);
|
||||
|
||||
final List<PushPromiseFrame> frames = new ArrayList<>();
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePushPromise(lease, streamId, promisedStreamId, metaData);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
|
@ -122,6 +112,16 @@ public class PushPromiseGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
int streamId = 13;
|
||||
int promisedStreamId = 17;
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", "localhost:8080", "localhost", 8080, "/path", fields);
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePushPromise(lease, streamId, promisedStreamId, metaData);
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
|
|
@ -39,24 +39,25 @@ public class ResetGenerateParseTest
|
|||
{
|
||||
ResetGenerator generator = new ResetGenerator(new HeaderGenerator());
|
||||
|
||||
final List<ResetFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onReset(ResetFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int streamId = 13;
|
||||
int error = 17;
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
final List<ResetFrame> frames = new ArrayList<>();
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateReset(lease, streamId, error);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onReset(ResetFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
frames.clear();
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
|
@ -79,12 +80,7 @@ public class ResetGenerateParseTest
|
|||
{
|
||||
ResetGenerator generator = new ResetGenerator(new HeaderGenerator());
|
||||
|
||||
int streamId = 13;
|
||||
int error = 17;
|
||||
|
||||
final List<ResetFrame> frames = new ArrayList<>();
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateReset(lease, streamId, error);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
|
@ -95,6 +91,12 @@ public class ResetGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
int streamId = 13;
|
||||
int error = 17;
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateReset(lease, streamId, error);
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
|
|
@ -72,21 +72,22 @@ public class SettingsGenerateParseTest
|
|||
{
|
||||
SettingsGenerator generator = new SettingsGenerator(new HeaderGenerator());
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
final List<SettingsFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onSettings(SettingsFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateSettings(lease, settings, true);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onSettings(SettingsFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
frames.clear();
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
|
@ -105,13 +106,6 @@ public class SettingsGenerateParseTest
|
|||
public void testGenerateParseInvalidSettings() throws Exception
|
||||
{
|
||||
SettingsGenerator generator = new SettingsGenerator(new HeaderGenerator());
|
||||
Map<Integer, Integer> settings1 = new HashMap<>();
|
||||
settings1.put(13, 17);
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateSettings(lease, settings1, true);
|
||||
// Modify the length of the frame to make it invalid
|
||||
ByteBuffer bytes = lease.getByteBuffers().get(0);
|
||||
bytes.putShort(0, (short)(bytes.getShort(0) - 1));
|
||||
|
||||
final AtomicInteger errorRef = new AtomicInteger();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
|
@ -123,6 +117,14 @@ public class SettingsGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
Map<Integer, Integer> settings1 = new HashMap<>();
|
||||
settings1.put(13, 17);
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateSettings(lease, settings1, true);
|
||||
// Modify the length of the frame to make it invalid
|
||||
ByteBuffer bytes = lease.getByteBuffers().get(0);
|
||||
bytes.putShort(0, (short)(bytes.getShort(0) - 1));
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
@ -139,14 +141,7 @@ public class SettingsGenerateParseTest
|
|||
{
|
||||
SettingsGenerator generator = new SettingsGenerator(new HeaderGenerator());
|
||||
|
||||
Map<Integer, Integer> settings1 = new HashMap<>();
|
||||
int key = 13;
|
||||
Integer value = 17;
|
||||
settings1.put(key, value);
|
||||
|
||||
final List<SettingsFrame> frames = new ArrayList<>();
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateSettings(lease, settings1, true);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
|
@ -157,6 +152,14 @@ public class SettingsGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
Map<Integer, Integer> settings1 = new HashMap<>();
|
||||
int key = 13;
|
||||
Integer value = 17;
|
||||
settings1.put(key, value);
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateSettings(lease, settings1, true);
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
|
|
@ -39,24 +39,25 @@ public class WindowUpdateGenerateParseTest
|
|||
{
|
||||
WindowUpdateGenerator generator = new WindowUpdateGenerator(new HeaderGenerator());
|
||||
|
||||
final List<WindowUpdateFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onWindowUpdate(WindowUpdateFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int streamId = 13;
|
||||
int windowUpdate = 17;
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
final List<WindowUpdateFrame> frames = new ArrayList<>();
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateWindowUpdate(lease, streamId, windowUpdate);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public boolean onWindowUpdate(WindowUpdateFrame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
frames.clear();
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
|
@ -79,12 +80,7 @@ public class WindowUpdateGenerateParseTest
|
|||
{
|
||||
WindowUpdateGenerator generator = new WindowUpdateGenerator(new HeaderGenerator());
|
||||
|
||||
int streamId = 13;
|
||||
int windowUpdate = 17;
|
||||
|
||||
final List<WindowUpdateFrame> frames = new ArrayList<>();
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateWindowUpdate(lease, streamId, windowUpdate);
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
|
@ -95,6 +91,12 @@ public class WindowUpdateGenerateParseTest
|
|||
}
|
||||
});
|
||||
|
||||
int streamId = 13;
|
||||
int windowUpdate = 17;
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateWindowUpdate(lease, streamId, windowUpdate);
|
||||
|
||||
for (ByteBuffer buffer : lease.getByteBuffers())
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
org.eclipse.jetty.http2.LEVEL=DEBUG
|
||||
org.eclipse.jetty.spdy.server.LEVEL=DEBUG
|
||||
org.eclipse.jetty.http2.LEVEL=INFO
|
||||
|
|
Loading…
Reference in New Issue