package org.matrix;


import org.junit.jupiter.api.Test;
import org.junit.platform.commons.util.StringUtils;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.net.Socket;
import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * Unit test for simple App.
 */
public class AppTest 
{
    /**
     * Rigorous Test :-)
     */
    @Test
    public void shouldAnswerWithTrue()
    {
        assertTrue( true );
    }

    @Test
    public void socketTest() throws Exception
    {
        String host = "127.0.0.1";
        int port = 8009;

        //与服务端建立连接
        Socket socket = new Socket(host, port);
        socket.setOOBInline(true);
        //建立连接后获取输出流
        DataOutputStream outputStream = new DataOutputStream(socket.getOutputStream());
        DataInputStream inputStream = new DataInputStream(socket.getInputStream());
        String uuid = UUID.randomUUID().toString();
        outputStream.write(uuid.getBytes());
        while (true){
            String uuid1 = UUID.randomUUID().toString();
            outputStream.write(uuid1.getBytes());
        }
    }
}
