@@ -0,0 +1,2673 @@
+/*%0A * Copyright 2015 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage io.atomix.catalyst.transport;%0A%0Aimport io.atomix.catalyst.serializer.Serializer;%0Aimport io.atomix.catalyst.util.concurrent.SingleThreadContext;%0Aimport io.atomix.catalyst.util.concurrent.ThreadContext;%0Aimport net.jodah.concurrentunit.ConcurrentTestCase;%0Aimport org.testng.annotations.Test;%0A%0Aimport java.net.InetAddress;%0Aimport java.net.InetSocketAddress;%0Aimport java.net.UnknownHostException;%0Aimport java.util.concurrent.CompletableFuture;%0A%0A/**%0A * Netty transport test.%0A *%0A * @author %3Ca href=%22http://github.com/kuujo%22%3EJordan Halterman%3C/a%3E%0A */%0A@Test%0Apublic class NettyTransportTest extends ConcurrentTestCase %7B%0A%0A  /**%0A   * Tests connecting to a server and sending a message.%0A   */%0A  public void testSendReceive() throws Throwable %7B%0A    Transport transport = new NettyTransport();%0A%0A    Server server = transport.server();%0A    Client client = transport.client();%0A%0A    ThreadContext context = new SingleThreadContext(%22test-thread-%25d%22, new Serializer());%0A%0A    context.executor().execute(() -%3E %7B%0A      try %7B%0A        server.listen(new Address(new InetSocketAddress(InetAddress.getByName(%22localhost%22), 5555)), connection -%3E %7B%0A          connection.%3CString, String%3Ehandler(String.class, message -%3E %7B%0A            threadAssertEquals(%22Hello world!%22, message);%0A            return CompletableFuture.completedFuture(%22Hello world back!%22);%0A          %7D);%0A        %7D).thenRun(this::resume);%0A      %7D catch (UnknownHostException e) %7B%0A        threadFail(e);%0A      %7D%0A    %7D);%0A    await();%0A%0A    context.executor().execute(() -%3E %7B%0A      try %7B%0A        client.connect(new Address(new InetSocketAddress(InetAddress.getByName(%22localhost%22), 5555))).thenAccept(connection -%3E %7B%0A          connection.send(%22Hello world!%22).thenAccept(response -%3E %7B%0A            threadAssertEquals(%22Hello world back!%22, response);%0A            resume();%0A          %7D);%0A        %7D);%0A      %7D catch (UnknownHostException e) %7B%0A        threadFail(e);%0A      %7D%0A    %7D);%0A    await();%0A%0A    context.executor().execute(() -%3E %7B%0A      client.close().join();%0A      server.close().join();%0A      resume();%0A    %7D);%0A    await();%0A  %7D%0A%0A%7D%0A

Add Netty tests.