diff --git a/src/main/java/com/sunyard/sge/bytes/BytesQueue.java b/src/main/java/com/sunyard/sge/bytes/BytesQueue.java index 17e9f87..725a238 100644 --- a/src/main/java/com/sunyard/sge/bytes/BytesQueue.java +++ b/src/main/java/com/sunyard/sge/bytes/BytesQueue.java @@ -17,6 +17,9 @@ public class BytesQueue { private int index = 0; // 维护实时长度 private int length = 0; + public int getLength() { + return length; + } /** * 尾部添加 diff --git a/src/main/java/com/sunyard/sge/log/LogFactory.java b/src/main/java/com/sunyard/sge/log/LogFactory.java index a7e9170..4f2db66 100644 --- a/src/main/java/com/sunyard/sge/log/LogFactory.java +++ b/src/main/java/com/sunyard/sge/log/LogFactory.java @@ -27,13 +27,13 @@ public class LogFactory { public static final String logName = "sge-hsm-sydapi-log"; // 日志级别 - public static int iLogLevel = Consts.LogLevelOFF; + public static int iLogLevel = Consts.LogLevelOFF; // Levels - public static final Level[] levels = new Level[]{ Level.OFF, Level.ERROR, Level.INFO, Level.DEBUG }; + private static final Level[] levels = new Level[]{ Level.OFF, Level.ERROR, Level.INFO, Level.DEBUG }; // 日志目录 - public static String pcLogPath = "./sydapi-logs/"; + private static String pcLogPath = "./sydapi-logs/"; // // 日期格式 // private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); diff --git a/src/test/java/test/ByteBuffTest.java b/src/test/java/test/ByteBuffTest.java new file mode 100644 index 0000000..b020563 --- /dev/null +++ b/src/test/java/test/ByteBuffTest.java @@ -0,0 +1,19 @@ +package test; + +import java.nio.ByteBuffer; + +public class ByteBuffTest { + public static void main(String[] args) { + + ByteBuffer bb = ByteBuffer.allocate(1024); + bb.put( new byte[16] ); + bb.flip(); + ByteBuffer b2 = ByteBuffer.allocate(1024); + b2.put( bb ); + + + System.out.println( b2.position() ); + + + } +} diff --git a/src/test/java/test/FuncTest.java b/src/test/java/test/FuncTest.java index bb66b5a..7fb6915 100644 --- a/src/test/java/test/FuncTest.java +++ b/src/test/java/test/FuncTest.java @@ -1,9 +1,7 @@ package test; -import com.sunyard.sge.database.Consts; -import com.sunyard.sge.database.SydApi; -import com.sunyard.sge.database.SydApi4Database; -import com.sunyard.sge.database.SydApiBuilder; +import com.sunyard.proto.Util; +import com.sunyard.sge.database.*; import com.sunyard.sge.database.pool.HsmLinkInfo; import com.sunyard.sge.database.pool.SydApiPool; import com.sunyard.sge.log.LogFactory; @@ -11,6 +9,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Before; import org.junit.Test; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.time.Instant; import java.util.concurrent.TimeUnit; @@ -29,7 +28,7 @@ public class FuncTest { @Test public void syd_Short_Connect_Ex(){ - String[] pcipList = {"127.0.0.1", "192.168.0.200" }; + String[] pcipList = {"127.0.0.1", "192.168.0.100" }; int[] iportList ={8080,8889}; SydApi api = new SydApi4Database(); try { @@ -52,6 +51,7 @@ public class FuncTest { ); api = builder.build(); + } @@ -77,14 +77,14 @@ public class FuncTest { public void originShort() throws Exception { SydApi.SYD_SetLogConfig("./logs/",3); Logger log = LogFactory.getLogger(); - String[] pcipList = {"192.168.0.200", "192.168.0.200", "192.168.0.200" }; - int[] iportList ={8080,8889,8889}; + String[] pcipList = {"192.168.0.100", "192.168.0.100", "192.168.0.100","192.168.0.100" }; + int[] iportList ={8080,8889,8889,8889}; for (int i = 0; i < 1000; i++) { int tmp = i; new Thread(() -> { + SydApi api = new SydApi4Database(); try { - SydApi api = new SydApi4Database(); for (int j = 0; j < 20; j++) { api.SYD_Short_Connect_Ex(pcipList,iportList,10,15); byte[] bytes = api.SYD_SM4_ShortData(0, (tmp + "t" + j).getBytes(), Consts.ECB_ENC); diff --git a/sydapi-database.iml b/sydapi-database.iml new file mode 100644 index 0000000..a1226f9 --- /dev/null +++ b/sydapi-database.iml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file