Search in sources :

Example 76 with Executable

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");
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 77 with Executable

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());
    }
}
Also used : EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 78 with Executable

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();
        }
    });
}
Also used : Entry(java.util.Map.Entry) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 79 with Executable

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();
        }
    });
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 80 with Executable

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();
        }
    }
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Aggregations

Executable (org.junit.jupiter.api.function.Executable)476 Test (org.junit.jupiter.api.Test)434 lombok.val (lombok.val)112 ByteBuf (io.netty.buffer.ByteBuf)83 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)42 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)36 CucumberException (io.cucumber.core.exception.CucumberException)20 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)19 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)15 Feature (io.cucumber.core.gherkin.Feature)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 StepDefinition (io.cucumber.core.backend.StepDefinition)14 Step (io.cucumber.core.gherkin.Step)14 Argument (io.cucumber.core.stepexpression.Argument)14 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)13 LocalChannel (io.netty.channel.local.LocalChannel)12 CucumberBackendException (io.cucumber.core.backend.CucumberBackendException)11 StepExpression (io.cucumber.core.stepexpression.StepExpression)11 SSLEngine (javax.net.ssl.SSLEngine)11 Bootstrap (io.netty.bootstrap.Bootstrap)10