8 changed files with 220 additions and 34 deletions
@ -0,0 +1,35 @@
|
||||
package com.fanruan; |
||||
|
||||
import com.fanruan.handler.Dispatcher; |
||||
import com.fanruan.utils.DBProperties; |
||||
import io.socket.client.Socket; |
||||
|
||||
/** |
||||
* @author Yichen Dai |
||||
* @date 2022/9/20 9:34 |
||||
*/ |
||||
public class ChaosTest { |
||||
public static void main(String[] args){ |
||||
try{ |
||||
testStart(); |
||||
}catch(Exception e){ |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
|
||||
static void testStart() throws ClassNotFoundException { |
||||
Class.forName(DBProperties.HSQL[1]); |
||||
String[][] DBs = new String[][]{ |
||||
DBProperties.HSQL, |
||||
}; |
||||
|
||||
new AgentStarter(DBs); |
||||
|
||||
Socket mainSocket = Dispatcher.CACHE.getSocket("/"); |
||||
mainSocket.connect(); |
||||
|
||||
Socket socket = Dispatcher.CACHE.getSocket(DBProperties.HSQL[0]); |
||||
socket.connect(); |
||||
} |
||||
} |
@ -0,0 +1,70 @@
|
||||
package com.fanruan; |
||||
|
||||
|
||||
import com.fanruan.cache.ClientCache; |
||||
import com.fanruan.proxy.ProxyFactory; |
||||
import com.fanruan.service.jdbc.driver.ServiceDriver; |
||||
import com.fanruan.utils.DBProperties; |
||||
import org.hsqldb.jdbc.JDBCBlob; |
||||
|
||||
import java.io.IOException; |
||||
import java.sql.*; |
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* @author Yichen Dai |
||||
* @date 2022/9/20 9:36 |
||||
*/ |
||||
public class ChaosTest { |
||||
static final Properties info = new Properties(); |
||||
|
||||
static final String[][] dbNameAndDriver = new String[][]{ |
||||
DBProperties.HSQL |
||||
}; |
||||
|
||||
static final ServerStater server = new ServerStater(dbNameAndDriver); |
||||
|
||||
static { |
||||
info.setProperty("user", "sa"); |
||||
info.setProperty("password", ""); |
||||
info.setProperty("agentID", "1001"); |
||||
info.setProperty("agentDBName", DBProperties.HSQL[0]); |
||||
} |
||||
|
||||
static void openSocket(){ |
||||
while(ClientCache.getClient( |
||||
info.getProperty("agentID"), |
||||
info.getProperty("agentDBName")) |
||||
== null){ |
||||
} |
||||
} |
||||
|
||||
public static void main(String[] args) throws SQLException, IOException, InterruptedException { |
||||
openSocket(); |
||||
Connection connection = getConnection(); |
||||
Statement statement = connection.createStatement(); |
||||
|
||||
statement.execute("create table TestLargeBlob" + |
||||
" (testBlob BLOB(10240));" |
||||
); |
||||
|
||||
Thread.sleep(60000); |
||||
|
||||
PreparedStatement prepareStatement = connection.prepareStatement("INSERT INTO TestLargeBlob VALUES(?);"); |
||||
byte[] chuck = new byte[10240]; |
||||
|
||||
Blob blob1 = new JDBCBlob(chuck); |
||||
prepareStatement.setBlob(1, blob1); |
||||
prepareStatement.executeUpdate(); |
||||
|
||||
ResultSet resultSet = statement.executeQuery("SELECT * FROM TestLargeBlob"); |
||||
resultSet.next(); |
||||
} |
||||
|
||||
public static Connection getConnection() throws SQLException { |
||||
Driver driver = (ServiceDriver) ProxyFactory.getProxy(ServiceDriver.class, null); |
||||
Connection conn = driver.connect("jdbc:hsqldb:mem:test;sql.syntax_mys=true", info); |
||||
return conn; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue