fix : update test for rpc

pull/946/head
pizihao 3 years ago
parent c08c59553c
commit 554bec7c51

@ -27,17 +27,18 @@ import io.netty.channel.pool.ChannelPoolHandler;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
public class ConnectHandlerTest {
@Test
public void handlerTest() {
public void handlerTest() throws IOException {
// server
Class<InstanceServerLoader> cls = InstanceServerLoader.class;
ClassRegistry.put(cls.getName(), cls);
ServerPort port = () -> 8888;
ServerPort port = () -> 8891;
Instance instance = new DefaultInstance();
NettyServerTakeHandler serverHandler = new NettyServerTakeHandler(instance);
AbstractNettyServerConnection connection = new AbstractNettyServerConnection(serverHandler);
@ -54,6 +55,8 @@ public class ConnectHandlerTest {
InstanceServerLoader loader = NettyProxyCenter.getProxy(rpcClient, cls, "localhost", port);
String name = loader.getName();
Assert.assertEquals("name", name);
rpcClient.close();
rpcServer.close();
}
}

@ -19,7 +19,6 @@ package cn.hippo4j.rpc.support;
import cn.hippo4j.common.web.exception.IllegalException;
import cn.hippo4j.rpc.discovery.ServerPort;
import cn.hippo4j.rpc.exception.ConnectionException;
import cn.hippo4j.rpc.handler.AbstractNettyClientPoolHandler;
import cn.hippo4j.rpc.handler.NettyClientTakeHandler;
import org.junit.Assert;
@ -43,14 +42,6 @@ public class NettyProxyCenterTest {
Assert.assertNotNull(localhost);
}
@Test(expected = ConnectionException.class)
public void getProxyTestCall() {
AbstractNettyClientPoolHandler handler = new AbstractNettyClientPoolHandler(new NettyClientTakeHandler());
ProxyInterface localhost = NettyProxyCenter.getProxy(ProxyInterface.class, "localhost", port, handler);
localhost.hello();
Assert.assertNotNull(localhost);
}
interface ProxyInterface {
void hello();

@ -29,7 +29,7 @@ public class NettyServerSupportTest {
@Test
public void bind() throws IOException {
NettyServerSupport support = new NettyServerSupport(() -> 8888, InstanceServerLoader.class);
NettyServerSupport support = new NettyServerSupport(() -> 8890, InstanceServerLoader.class);
CompletableFuture.runAsync(support::bind);
try {
TimeUnit.SECONDS.sleep(3);

Loading…
Cancel
Save