yichen
2 years ago
1 changed files with 52 additions and 0 deletions
@ -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); |
||||
} |
||||
} |
Loading…
Reference in new issue