mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-11 16:26:40 +00:00
perf[net]: 增加了一大波关于网络的测试用例
This commit is contained in:
@@ -10,8 +10,18 @@ import java.net.InetSocketAddress;
|
||||
import java.nio.channels.AsynchronousSocketChannel;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
@Ignore
|
||||
public class AioClientTest implements Runnable {
|
||||
|
||||
@Test
|
||||
public void clientTest() {
|
||||
AioClientTest aioClient = new AioClientTest("127.0.0.1", 9999, 1);
|
||||
aioClient.init();
|
||||
new Thread(aioClient, "client").start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
private AsynchronousSocketChannel client;
|
||||
private String host;
|
||||
private int port;
|
||||
@@ -45,13 +55,5 @@ public class AioClientTest implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
AioClientTest aioClient = new AioClientTest("127.0.0.1", 9999, 1);
|
||||
aioClient.init();
|
||||
new Thread(aioClient, "client").start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,18 @@ import java.net.InetSocketAddress;
|
||||
import java.nio.channels.AsynchronousServerSocketChannel;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
@Ignore
|
||||
public class AioServerTest implements Runnable {
|
||||
|
||||
@Test
|
||||
public void serverTest() {
|
||||
AioServerTest aioServer = new AioServerTest(9999, 1);
|
||||
aioServer.init();
|
||||
new Thread(aioServer, "server").start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
private int port;
|
||||
|
||||
private CountDownLatch latch;
|
||||
@@ -60,13 +70,4 @@ public class AioServerTest implements Runnable {
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void serverTest() {
|
||||
AioServerTest aioServer = new AioServerTest(9999, 1);
|
||||
aioServer.init();
|
||||
new Thread(aioServer, "server").start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,130 +10,130 @@ import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Scanner;
|
||||
|
||||
@Ignore
|
||||
public class BioClientTest {
|
||||
private String name;
|
||||
|
||||
private class SendThread implements Runnable {
|
||||
// 控制台输入流
|
||||
private BufferedReader console;
|
||||
// 管道输出流
|
||||
private DataOutputStream dataOut;
|
||||
// 控制线程
|
||||
private boolean isRunning;
|
||||
@Test
|
||||
public void clientTest() {
|
||||
System.out.println("请输入名称:");
|
||||
String name = new Scanner(System.in).nextLine();
|
||||
|
||||
private SendThread() {
|
||||
console = new BufferedReader(new InputStreamReader(System.in));
|
||||
isRunning = true;
|
||||
}
|
||||
|
||||
public SendThread(Socket client) {
|
||||
this();
|
||||
try {
|
||||
dataOut = new DataOutputStream(client.getOutputStream());
|
||||
send(name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
isRunning = false;
|
||||
IOUtils.closeIO(console, dataOut);
|
||||
}
|
||||
}
|
||||
|
||||
private String getMessageFromConsole() {
|
||||
try {
|
||||
System.out.println("please input message:");
|
||||
return console.readLine();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void send(String message) {
|
||||
if (null != message) {
|
||||
try {
|
||||
dataOut.writeUTF(message);
|
||||
dataOut.flush();
|
||||
} catch (IOException e) {
|
||||
isRunning = false;
|
||||
IOUtils.closeIO(dataOut, console);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isRunning) {
|
||||
send(getMessageFromConsole());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ReceiveThread implements Runnable {
|
||||
// 输入流
|
||||
private DataInputStream dataIn;
|
||||
// 线程标识
|
||||
private boolean isRunning = true;
|
||||
new BioClientTest().launchClient(name);
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
public ReceiveThread(Socket client) {
|
||||
try {
|
||||
dataIn = new DataInputStream(client.getInputStream());
|
||||
} catch (IOException e) {
|
||||
isRunning = false;
|
||||
IOUtils.closeIO(dataIn);
|
||||
}
|
||||
}
|
||||
private String name;
|
||||
|
||||
private String receive() {
|
||||
try {
|
||||
return dataIn.readUTF();
|
||||
} catch (IOException e) {
|
||||
isRunning = false;
|
||||
IOUtils.closeIO(dataIn);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private class SendThread implements Runnable {
|
||||
// 控制台输入流
|
||||
private BufferedReader console;
|
||||
// 管道输出流
|
||||
private DataOutputStream dataOut;
|
||||
// 控制线程
|
||||
private boolean isRunning;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isRunning) {
|
||||
System.out.println(receive());
|
||||
}
|
||||
}
|
||||
}
|
||||
private SendThread() {
|
||||
console = new BufferedReader(new InputStreamReader(System.in));
|
||||
isRunning = true;
|
||||
}
|
||||
|
||||
public void launchClient(String name) {
|
||||
// 1.创建客户端,必须指定服务器+端口,此时就在连接
|
||||
Socket client = null;
|
||||
Thread sendThread = null;
|
||||
Thread receiveThread = null;
|
||||
this.name = name;
|
||||
try {
|
||||
public SendThread(Socket client) {
|
||||
this();
|
||||
try {
|
||||
dataOut = new DataOutputStream(client.getOutputStream());
|
||||
send(name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
isRunning = false;
|
||||
IOUtils.closeIO(console, dataOut);
|
||||
}
|
||||
}
|
||||
|
||||
client = new Socket("localhost", 9999);// 系统自动分配客户端的端口号
|
||||
// 2.发送数据+接受数据
|
||||
sendThread = new Thread(new SendThread(client));
|
||||
receiveThread = new Thread(new ReceiveThread(client));
|
||||
sendThread.start();
|
||||
receiveThread.start();
|
||||
private String getMessageFromConsole() {
|
||||
try {
|
||||
System.out.println("please input message:");
|
||||
return console.readLine();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void send(String message) {
|
||||
if (null != message) {
|
||||
try {
|
||||
dataOut.writeUTF(message);
|
||||
dataOut.flush();
|
||||
} catch (IOException e) {
|
||||
isRunning = false;
|
||||
IOUtils.closeIO(dataOut, console);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isRunning) {
|
||||
send(getMessageFromConsole());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ReceiveThread implements Runnable {
|
||||
// 输入流
|
||||
private DataInputStream dataIn;
|
||||
// 线程标识
|
||||
private boolean isRunning = true;
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
System.out.println("请输入名称:");
|
||||
String name = new Scanner(System.in).nextLine();
|
||||
public ReceiveThread(Socket client) {
|
||||
try {
|
||||
dataIn = new DataInputStream(client.getInputStream());
|
||||
} catch (IOException e) {
|
||||
isRunning = false;
|
||||
IOUtils.closeIO(dataIn);
|
||||
}
|
||||
}
|
||||
|
||||
new BioClientTest().launchClient(name);
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
private String receive() {
|
||||
try {
|
||||
return dataIn.readUTF();
|
||||
} catch (IOException e) {
|
||||
isRunning = false;
|
||||
IOUtils.closeIO(dataIn);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isRunning) {
|
||||
System.out.println(receive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void launchClient(String name) {
|
||||
// 1.创建客户端,必须指定服务器+端口,此时就在连接
|
||||
Socket client = null;
|
||||
Thread sendThread = null;
|
||||
Thread receiveThread = null;
|
||||
this.name = name;
|
||||
try {
|
||||
|
||||
client = new Socket("localhost", 9999);// 系统自动分配客户端的端口号
|
||||
// 2.发送数据+接受数据
|
||||
sendThread = new Thread(new SendThread(client));
|
||||
receiveThread = new Thread(new ReceiveThread(client));
|
||||
sendThread.start();
|
||||
receiveThread.start();
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,8 +13,15 @@ import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Ignore
|
||||
public class BioServerTest {
|
||||
|
||||
@Test
|
||||
public void bioTest() {
|
||||
new BioServerTest().launchServer();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private List<ServerChannel> listClient = new ArrayList<ServerChannel>();
|
||||
|
||||
private class ServerChannel implements Runnable {
|
||||
@@ -121,11 +128,4 @@ public class BioServerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void bioTest() {
|
||||
new BioServerTest().launchServer();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,15 @@ import io.netty.handler.codec.string.StringDecoder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@Ignore
|
||||
public class EchoClientTest {
|
||||
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new EchoClientTest().connect(9999, "127.0.0.1");
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void connect(int port, String host) {
|
||||
EventLoopGroup group = new NioEventLoopGroup();
|
||||
@@ -47,13 +54,4 @@ public class EchoClientTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new EchoClientTest().connect(9999, "127.0.0.1");
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,18 @@ import org.junit.Test;
|
||||
* @version 1.0
|
||||
* @since 2017 05.22 18:23
|
||||
*/
|
||||
@Ignore
|
||||
public class EchoServerTest {
|
||||
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
EchoServerTest server = new EchoServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private int port;
|
||||
|
||||
public EchoServerTest(int port) {
|
||||
@@ -69,15 +79,4 @@ public class EchoServerTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
EchoServerTest server = new EchoServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,15 @@ import io.netty.handler.codec.string.StringDecoder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@Ignore
|
||||
public class EchoClientTest {
|
||||
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new EchoClientTest().connect(9999, "127.0.0.1");
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void connect(int port, String host) {
|
||||
EventLoopGroup group = new NioEventLoopGroup();
|
||||
@@ -43,12 +50,4 @@ public class EchoClientTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new EchoClientTest().connect(9999, "127.0.0.1");
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,18 @@ import org.junit.Test;
|
||||
* @version 1.0
|
||||
* @since 2017 05.22 18:23
|
||||
*/
|
||||
@Ignore
|
||||
public class EchoServerTest {
|
||||
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
EchoServerTest server = new EchoServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private int port;
|
||||
|
||||
public EchoServerTest(int port) {
|
||||
@@ -63,14 +73,4 @@ public class EchoServerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
EchoServerTest server = new EchoServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,18 @@ import org.junit.Test;
|
||||
* @version 1.0
|
||||
* @since 2017 05.31 10:22
|
||||
*/
|
||||
@Ignore
|
||||
public class FileClientTest {
|
||||
|
||||
@Test
|
||||
public void clientTest() {
|
||||
FileClientTest client = new FileClientTest(9999, "127.0.0.1", "rainbow.txt");
|
||||
client.connect();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
private int port;
|
||||
private String host;
|
||||
private String filePath;
|
||||
@@ -60,14 +70,5 @@ public class FileClientTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
FileClientTest client = new FileClientTest(9999, "127.0.0.1", "rainbow.txt");
|
||||
client.connect();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,18 @@ import org.junit.Test;
|
||||
* @version 1.0
|
||||
* @since 2017 05.31 09:49
|
||||
*/
|
||||
@Ignore
|
||||
public class FileServerTest {
|
||||
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
FileServerTest server = new FileServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private int port;
|
||||
|
||||
public FileServerTest(int port) {
|
||||
@@ -66,14 +76,4 @@ public class FileServerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
FileServerTest server = new FileServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,16 @@ import org.junit.Test;
|
||||
* @version 1.0
|
||||
* @since 2017 05.23 18:02
|
||||
*/
|
||||
@Ignore
|
||||
public class SubscribeClientTest {
|
||||
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new SubscribeClientTest().connect(9999, "127.0.0.1");
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
public void connect(int port, String host) {
|
||||
EventLoopGroup group = new NioEventLoopGroup();
|
||||
@@ -50,12 +58,4 @@ public class SubscribeClientTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new SubscribeClientTest().connect(9999, "127.0.0.1");
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,18 @@ import org.junit.Test;
|
||||
* @version 1.0
|
||||
* @since 2017 05.23 16:51
|
||||
*/
|
||||
@Ignore
|
||||
public class SubscribeServerTest {
|
||||
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
SubscribeServerTest server = new SubscribeServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private int port;
|
||||
|
||||
public SubscribeServerTest(int port) {
|
||||
@@ -66,15 +76,4 @@ public class SubscribeServerTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
SubscribeServerTest server = new SubscribeServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,15 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@Ignore
|
||||
public class TimeClientTest {
|
||||
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new TimeClientTest().connect(9999, "127.0.0.1");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void connect(int port, String host) {
|
||||
EventLoopGroup group = new NioEventLoopGroup();
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
@@ -38,12 +45,4 @@ public class TimeClientTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new TimeClientTest().connect(9999, "127.0.0.1");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,16 @@ import org.junit.Test;
|
||||
* @version 1.0
|
||||
* @since 2017 05.22 18:23
|
||||
*/
|
||||
@Ignore
|
||||
public class TimeServerTest {
|
||||
|
||||
@Test
|
||||
public void serverTest() {
|
||||
TimeServerTest server = new TimeServerTest(9999);
|
||||
server.init();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private int port;
|
||||
|
||||
public TimeServerTest(int port) {
|
||||
@@ -55,12 +63,4 @@ public class TimeServerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void serverTest() {
|
||||
TimeServerTest server = new TimeServerTest(9999);
|
||||
server.init();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,16 @@ import io.netty.handler.codec.string.StringDecoder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@Ignore
|
||||
public class TimeClientTest {
|
||||
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new TimeClientTest().connect(9999, "127.0.0.1");
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void connect(int port, String host) {
|
||||
EventLoopGroup group = new NioEventLoopGroup();
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
@@ -42,13 +50,4 @@ public class TimeClientTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
new TimeClientTest().connect(9999, "127.0.0.1");
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,18 @@ import org.junit.Test;
|
||||
* @version 1.0
|
||||
* @since 2017 05.22 18:23
|
||||
*/
|
||||
@Ignore
|
||||
public class TimeServerTest {
|
||||
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
TimeServerTest server = new TimeServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private int port;
|
||||
|
||||
public TimeServerTest(int port) {
|
||||
@@ -59,14 +69,4 @@ public class TimeServerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
TimeServerTest server = new TimeServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,18 @@ import java.net.InetSocketAddress;
|
||||
* @version 1.0
|
||||
* @since 2017 05.27 17:48
|
||||
*/
|
||||
@Ignore
|
||||
public class UDPClientTest {
|
||||
|
||||
@Test
|
||||
public void clientTest() {
|
||||
System.out.println("hello");
|
||||
UDPClientTest server = new UDPClientTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
private int port;
|
||||
|
||||
@@ -57,15 +67,4 @@ public class UDPClientTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
System.out.println("hello");
|
||||
UDPClientTest server = new UDPClientTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,18 @@ import org.junit.Test;
|
||||
* @version 1.0
|
||||
* @since 2017 05.27 17:24
|
||||
*/
|
||||
@Ignore
|
||||
public class UDPServerTest {
|
||||
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
UDPServerTest server = new UDPServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private int port;
|
||||
|
||||
public UDPServerTest(int port) {
|
||||
@@ -44,15 +54,4 @@ public class UDPServerTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void serverTest() {
|
||||
System.out.println("hello");
|
||||
UDPServerTest server = new UDPServerTest(9999);
|
||||
server.init();
|
||||
System.out.println("hello");
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,17 @@ import java.nio.channels.Selector;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Iterator;
|
||||
|
||||
@Ignore
|
||||
public class NioClientTest implements Runnable {
|
||||
|
||||
@Test
|
||||
public void clientTest() {
|
||||
NioClientTest nioClient = new NioClientTest("localhost", 9999);
|
||||
nioClient.init();
|
||||
new Thread(nioClient, "clinetThread").start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private String ip;
|
||||
private int port;
|
||||
|
||||
@@ -123,13 +132,4 @@ public class NioClientTest implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void clientTest() {
|
||||
NioClientTest nioClient = new NioClientTest("localhost", 9999);
|
||||
nioClient.init();
|
||||
new Thread(nioClient, "clinetThread").start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,17 @@ import java.nio.channels.SocketChannel;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
@Ignore
|
||||
public class NioServerTest implements Runnable {
|
||||
|
||||
@Test
|
||||
public void serverTest() {
|
||||
NioServerTest nioServer = new NioServerTest();
|
||||
nioServer.init(9999);
|
||||
new Thread(nioServer, "serverThread").start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
//多路复用器,一对多
|
||||
private Selector selector;
|
||||
|
||||
@@ -129,13 +138,4 @@ public class NioServerTest implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void serverTest() {
|
||||
NioServerTest nioServer = new NioServerTest();
|
||||
nioServer.init(9999);
|
||||
new Thread(nioServer, "serverThread").start();
|
||||
ThreadUtils.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user