33import com .taosdata .jdbc .utils .SpecifyAddress ;
44import com .taosdata .jdbc .ws .TSWSPreparedStatement ;
55import org .junit .*;
6+ import org .junit .runners .MethodSorters ;
67
78import java .io .InputStream ;
89import java .io .OutputStream ;
1415import java .util .HashSet ;
1516import java .util .Properties ;
1617
17- @ FixMethodOrder
18+ @ FixMethodOrder ( MethodSorters . NAME_ASCENDING )
1819public class WsPstmtTest {
1920 String host = "127.0.0.1" ;
2021 String db_name = "ws_prepare" ;
@@ -25,7 +26,7 @@ public class WsPstmtTest {
2526 PreparedStatement pstmt ;
2627
2728 @ Test
28- public void testExecuteUpdate () throws SQLException {
29+ public void test001_ExecuteUpdate () throws SQLException {
2930 String sql = "insert into " + db_name + "." + tableName + " values(?, ?)" ;
3031 PreparedStatement statement = connection .prepareStatement (sql );
3132 statement .setTimestamp (1 , new Timestamp (System .currentTimeMillis ()));
@@ -37,7 +38,7 @@ public void testExecuteUpdate() throws SQLException {
3738 }
3839
3940 @ Test
40- public void testReuseStmtExecuteUpdate () throws SQLException {
41+ public void test002_ReuseStmtExecuteUpdate () throws SQLException {
4142 String sql = "insert into " + db_name + "." + tableName + " values(?, ?)" ;
4243 PreparedStatement statement = connection .prepareStatement (sql );
4344 statement .setTimestamp (1 , new Timestamp (System .currentTimeMillis ()));
@@ -55,7 +56,7 @@ public void testReuseStmtExecuteUpdate() throws SQLException {
5556 }
5657
5758 @ Test
58- public void testExecuteBatchInsert () throws SQLException {
59+ public void test003_ExecuteBatchInsert () throws SQLException {
5960 String sql = "insert into " + db_name + "." + tableName + " (ts, c1) values(?, ?)" ;
6061 PreparedStatement statement = connection .prepareStatement (sql );
6162 for (int i = 0 ; i < 10 ; i ++) {
@@ -79,7 +80,7 @@ public void testExecuteBatchInsert() throws SQLException {
7980 }
8081
8182 @ Test
82- public void testQuery () throws SQLException {
83+ public void test004_Query () throws SQLException {
8384 String sql = "select * from " + db_name + "." + tableName + " where ts > ? and ts < ?" ;
8485 PreparedStatement statement = connection .prepareStatement (sql );
8586 statement .setTimestamp (1 , new Timestamp (System .currentTimeMillis () - 1000 ));
@@ -90,17 +91,28 @@ public void testQuery() throws SQLException {
9091 }
9192 }
9293
94+ @ Test
95+ public void test005_NormalQuery () throws SQLException {
96+ pstmt .execute ("insert into " + db_name + "." + tableName + " values (now, 1)" );
97+
98+ String sql = "select * from " + db_name + "." + tableName + " limit 1" ;
99+ try (PreparedStatement statement = connection .prepareStatement (sql );
100+ ResultSet resultSet = statement .executeQuery ()){
101+ Assert .assertTrue (resultSet .next ());
102+ }
103+ }
104+
93105 @ Test (expected = SQLException .class )
94- public void testSetNCharacterStream () throws SQLException {
106+ public void test100_SetNCharacterStream () throws SQLException {
95107 pstmt .setNCharacterStream (1 , null );
96108 }
97109
98110 @ Test (expected = SQLException .class )
99- public void testSetNCharacterStream2 () throws SQLException {
111+ public void test101_SetNCharacterStream2 () throws SQLException {
100112 pstmt .setNCharacterStream (1 , null , 0 );
101113 }
102114 @ Test (expected = SQLException .class )
103- public void testSetNClob () throws SQLException {
115+ public void test012_SetNClob () throws SQLException {
104116 pstmt .setNClob (1 , new NClob () {
105117 @ Override
106118 public long length () throws SQLException {
@@ -169,12 +181,12 @@ public Reader getCharacterStream(long pos, long length) throws SQLException {
169181 });
170182 }
171183 @ Test (expected = SQLException .class )
172- public void testSetNClob2 () throws SQLException {
184+ public void test103_SetNClob2 () throws SQLException {
173185 pstmt .setNClob (1 , null , 0 );
174186 }
175187
176188 @ Test (expected = SQLException .class )
177- public void testSetBlob () throws SQLException {
189+ public void test104_SetBlob () throws SQLException {
178190 pstmt .setBlob (1 , new Blob () {
179191 @ Override
180192 public long length () throws SQLException {
@@ -233,38 +245,38 @@ public InputStream getBinaryStream(long pos, long length) throws SQLException {
233245 });
234246 }
235247 @ Test (expected = SQLException .class )
236- public void testSetBlob2 () throws SQLException {
248+ public void test105_SetBlob2 () throws SQLException {
237249 pstmt .setBlob (1 , null , 0 );
238250 }
239251
240252 @ Test (expected = SQLException .class )
241- public void testSetSQLXML () throws SQLException {
253+ public void test106_SetSQLXML () throws SQLException {
242254 pstmt .setSQLXML (1 , null );
243255 }
244256
245257 @ Test (expected = SQLException .class )
246- public void testSetObject () throws SQLException {
258+ public void test107_SetObject () throws SQLException {
247259 pstmt .setObject (1 , null , 0 , 0 );
248260 }
249261
250262 @ Test (expected = SQLException .class )
251- public void testSetAsciiStream () throws SQLException {
263+ public void test108_SetAsciiStream () throws SQLException {
252264 pstmt .setAsciiStream (1 , null , 0 );
253265 }
254266
255267
256268 @ Test (expected = SQLException .class )
257- public void testSetBinaryStream () throws SQLException {
269+ public void test109_SetBinaryStream () throws SQLException {
258270 pstmt .setBinaryStream (1 , null , 0 );
259271 }
260272
261273 @ Test (expected = SQLException .class )
262- public void testSetCharacterStream () throws SQLException {
274+ public void test110_SetCharacterStream () throws SQLException {
263275 pstmt .setCharacterStream (1 , null , 0 );
264276 }
265277
266278 @ Test
267- public void testSetTagNull () throws SQLException {
279+ public void test111_SetTagNull () throws SQLException {
268280 TSWSPreparedStatement wsPreparedStatement = pstmt .unwrap (TSWSPreparedStatement .class );
269281 wsPreparedStatement .setTagSqlTypeNull (1 , Types .BOOLEAN );
270282 wsPreparedStatement .setTagSqlTypeNull (1 , Types .TINYINT );
@@ -281,7 +293,7 @@ public void testSetTagNull() throws SQLException {
281293 }
282294
283295 @ Test
284- public void testSetObject2 () throws SQLException {
296+ public void test112_SetObject2 () throws SQLException {
285297 TSWSPreparedStatement wsPreparedStatement = pstmt .unwrap (TSWSPreparedStatement .class );
286298 wsPreparedStatement .setObject (1 , null , Types .BOOLEAN );
287299 wsPreparedStatement .setObject (1 , null , Types .TINYINT );
0 commit comments