From bfdc34749f82381e8a3a3f7a70b537e2d13e44e9 Mon Sep 17 00:00:00 2001 From: yichen Date: Sun, 18 Sep 2022 11:35:11 +0800 Subject: [PATCH] test agent shutdown --- test/src/test/java/com/fanruan/NetworkIT.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/src/test/java/com/fanruan/NetworkIT.java diff --git a/test/src/test/java/com/fanruan/NetworkIT.java b/test/src/test/java/com/fanruan/NetworkIT.java new file mode 100644 index 0000000..a771220 --- /dev/null +++ b/test/src/test/java/com/fanruan/NetworkIT.java @@ -0,0 +1,52 @@ +package com.fanruan; + +import com.fanruan.utils.DBProperties; +import org.hsqldb.jdbc.JDBCBlob; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; + +import java.io.IOException; +import java.sql.*; +import java.util.Properties; + +/** + * @author Yichen Dai + * @date 2022/9/16 16:03 + */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class NetworkIT extends BaseJDBCTest{ + + + + @BeforeAll + public void setUp(){ + openSocket(); + } + + @Test + public void testAgentShutDown() throws SQLException, IOException { + Connection connection = getConnection(); + + Statement statement = connection.createStatement(); + + statement.execute("create table testAgentShutDown" + + " (testBlob BLOB(10240));" + ); + + PreparedStatement prepareStatement = connection.prepareStatement("INSERT INTO testAgentShutDown VALUES(?);"); + byte[] chuck = new byte[10240]; + + Blob blob1 = new JDBCBlob(chuck); + new Thread(() -> { + try{ + prepareStatement.setBlob(1, blob1); + prepareStatement.executeUpdate(); + ResultSet resultSet = statement.executeQuery("SELECT * FROM testAgentShutDown"); + }catch (Exception e){ + } + }).start(); + shutDownAgent(); + closeSQLObjects(statement, prepareStatement); + } +}