use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class Bzip2DecoderTest method testIncorrectHuffmanGroupsNumber.
@Test
public void testIncorrectHuffmanGroupsNumber() {
final byte[] data = Arrays.copyOf(DATA, DATA.length);
data[25] = 0x70;
final ByteBuf in = Unpooled.wrappedBuffer(data);
assertThrows(DecompressionException.class, new Executable() {
@Override
public void execute() {
channel.writeInbound(in);
}
}, "incorrect huffman groups number");
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class JsonObjectDecoderTest method testNonJsonContent2.
@Test
public void testNonJsonContent2() {
final EmbeddedChannel ch = new EmbeddedChannel(new JsonObjectDecoder());
ch.writeInbound(Unpooled.copiedBuffer(" [1,2,3] ", CharsetUtil.UTF_8));
ByteBuf res = ch.readInbound();
assertEquals("[1,2,3]", res.toString(CharsetUtil.UTF_8));
res.release();
try {
assertThrows(CorruptedFrameException.class, new Executable() {
@Override
public void execute() {
ch.writeInbound(Unpooled.copiedBuffer(" a {\"key\" : 10}", CharsetUtil.UTF_8));
}
});
} finally {
assertFalse(ch.finish());
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class DefaultHeadersTest method iterateEmptyHeadersShouldThrow.
@Test
public void iterateEmptyHeadersShouldThrow() {
final Iterator<Map.Entry<CharSequence, CharSequence>> iterator = newInstance().iterator();
assertFalse(iterator.hasNext());
assertThrows(NoSuchElementException.class, new Executable() {
@Override
public void execute() {
iterator.next();
}
});
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class DefaultHeadersTest method valuesItrRemoveThrowsWhenEmpty.
@Test
public void valuesItrRemoveThrowsWhenEmpty() {
TestDefaultHeaders headers = newInstance();
assertEquals(0, headers.size());
assertTrue(headers.isEmpty());
final Iterator<CharSequence> itr = headers.valueIterator(of("name"));
assertThrows(IllegalStateException.class, new Executable() {
@Override
public void execute() {
itr.remove();
}
});
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class DnsNameResolverTest method testCNAMELoopInCache.
@Test
public void testCNAMELoopInCache() throws Throwable {
DnsNameResolver resolver = null;
try {
DnsNameResolverBuilder builder = newResolver().recursionDesired(false).resolvedAddressTypes(ResolvedAddressTypes.IPV4_ONLY).maxQueriesPerResolve(16).nameServerProvider(new SingletonDnsServerAddressStreamProvider(dnsServer.localAddress()));
resolver = builder.build();
// Add a CNAME loop into the cache
final String name = "somehost.netty.io.";
String name2 = "cname.netty.io.";
resolver.cnameCache().cache(name, name2, Long.MAX_VALUE, resolver.executor());
resolver.cnameCache().cache(name2, name, Long.MAX_VALUE, resolver.executor());
final DnsNameResolver finalResolver = resolver;
assertThrows(UnknownHostException.class, new Executable() {
@Override
public void execute() throws Throwable {
finalResolver.resolve(name).syncUninterruptibly().getNow();
}
});
} finally {
if (resolver != null) {
resolver.close();
}
}
}
Aggregations