|
|
|
@ -1,12 +1,11 @@
|
|
|
|
|
import com.corundumstudio.socketio.SocketIOClient; |
|
|
|
|
import com.corundumstudio.socketio.SocketIOServer; |
|
|
|
|
import com.fanruan.cache.ClientCache; |
|
|
|
|
import com.fanruan.utils.DBProperties; |
|
|
|
|
import org.junit.jupiter.api.Assertions; |
|
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
import java.net.Socket; |
|
|
|
|
|
|
|
|
|
import java.sql.*; |
|
|
|
|
import java.util.Properties; |
|
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
@ -34,8 +33,6 @@ public class ServiceTest extends AutoStarter{
|
|
|
|
|
); |
|
|
|
|
ft.run(); |
|
|
|
|
ft.get(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -51,8 +48,14 @@ public class ServiceTest extends AutoStarter{
|
|
|
|
|
PreparedStatement pst = null; |
|
|
|
|
ResultSet rs = null; |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
// 创建 连接
|
|
|
|
|
conn = DriverManager.getConnection("jdbc:hsqldb:mem:test", info); |
|
|
|
|
|
|
|
|
|
// 创建 statement
|
|
|
|
|
st = conn.createStatement(); |
|
|
|
|
|
|
|
|
|
// 创建表
|
|
|
|
|
st.executeUpdate("DROP TABLE student IF EXISTS;"); |
|
|
|
|
|
|
|
|
|
st.executeUpdate("CREATE TABLE student (" + |
|
|
|
@ -63,6 +66,7 @@ public class ServiceTest extends AutoStarter{
|
|
|
|
|
"PRIMARY KEY (student_id)" + |
|
|
|
|
");"); |
|
|
|
|
|
|
|
|
|
// 插入数据
|
|
|
|
|
st.executeUpdate("INSERT INTO student VALUES" + |
|
|
|
|
"(1, '张三', '上海')," + |
|
|
|
|
"(2, '李四', '北京')," + |
|
|
|
@ -70,7 +74,7 @@ public class ServiceTest extends AutoStarter{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 预查询语句 删除指定 ID
|
|
|
|
|
pst = conn.prepareStatement("delete from student where student_id = ?"); |
|
|
|
|
|
|
|
|
|
pst.setInt(1, 1); |
|
|
|
@ -82,6 +86,7 @@ public class ServiceTest extends AutoStarter{
|
|
|
|
|
String[] nameStrings = new String[]{"张三", "李四", "王五"}; |
|
|
|
|
String[] addressStrings = new String[]{"上海", "北京", "成都"}; |
|
|
|
|
|
|
|
|
|
// 结果集断言
|
|
|
|
|
int num = 2; |
|
|
|
|
while(rs.next()) { |
|
|
|
|
Assertions.assertEquals(rs.getInt("student_id"), num); |
|
|
|
|