Skip to content
Permalink
Browse files

[test] add coverage test

(cherry picked from commit a868402)
  • Loading branch information...
rusher committed Jan 22, 2019
1 parent f3dc5f1 commit d337275c11d0c12a2ab805c76d32bf9271e5ef1d
@@ -98,8 +98,8 @@
public static void initClass() throws SQLException {
createTable("bug716378",
"id int not null primary key auto_increment, test longblob, test2 blob, test3 text");
createTable("BlobTeststreamtest2", "id int primary key not null, st varchar(20), strm text",
"CHARSET utf8");
createTable("BlobTeststreamtest2", "id int primary key not null, st varchar(20), strm text"
+ ", strm2 text, strm3 text","CHARSET utf8");
createTable("BlobTeststreamtest3", "id int primary key not null, strm text", "CHARSET utf8");
createTable("BlobTestclobtest", "id int not null primary key, strm text", "CHARSET utf8");
createTable("BlobTestclobtest2", "strm text", "CHARSET utf8");
@@ -164,11 +164,13 @@ public void testCharacterStreamWithMultibyteCharacterAndLength() throws Throwabl
String toInsert1 = "Øbbcdefgh\njklmn\"";
String toInsert2 = "Øabcdefgh\njklmn\"";
PreparedStatement stmt = sharedConnection
.prepareStatement("insert into BlobTeststreamtest2 (id, st, strm) values (?,?,?)");
.prepareStatement("insert into BlobTeststreamtest2 (id, st, strm, strm2, strm3) values (?,?,?,?,?)");
stmt.setInt(1, 2);
stmt.setString(2, toInsert1);
Reader reader = new StringReader(toInsert2);
stmt.setCharacterStream(3, reader, 5);
stmt.setCharacterStream(4, null);
stmt.setCharacterStream(5, null, 5);
stmt.execute();

ResultSet rs = sharedConnection.createStatement()
@@ -182,6 +184,8 @@ public void testCharacterStreamWithMultibyteCharacterAndLength() throws Throwabl
}
assertEquals(toInsert1, rs.getString(2));
assertEquals(toInsert2.substring(0, 5), sb.toString());
assertNull(rs.getString(4));
assertNull(rs.getString(5));
}

@Test
@@ -209,7 +209,7 @@ public void prepareStmtMultiResultSets() throws Exception {

@Test
public void stmtInoutParam() throws SQLException {
try (Connection connection = setConnection("&dumpQueriesOnException")){
try (Connection connection = setConnection("&dumpQueriesOnException")) {
Statement stmt = connection.createStatement();
stmt.execute("{call inOutParam(1)}");
fail("must fail : statement cannot be use when there is out parameter");
@@ -1171,11 +1171,11 @@ public void dumpQueryOnException() throws Exception {
public void shouldNotDumpQueryOnExceptionByDefault() throws Exception {
String selectFromNonExistingTable = "select * from mango";
try {
Statement st = sharedConnection.createStatement();
st.execute(selectFromNonExistingTable);
} catch (SQLException sqle) {
assertFalse(sqle.getCause().getMessage().contains("Query is: " + selectFromNonExistingTable));
}
Statement st = sharedConnection.createStatement();
st.execute(selectFromNonExistingTable);
} catch (SQLException sqle) {
assertFalse(sqle.getCause().getMessage().contains("Query is: " + selectFromNonExistingTable));
}
}

/* CONJ-14
@@ -56,6 +56,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertArrayEquals;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
@@ -594,4 +595,29 @@ public void testInsertSelectBulk() throws SQLException {
}
}

@Test
public void largePrepareUpdate() throws SQLException {
createTable("largePrepareUpdate", "a int not null primary key auto_increment, t varchar(256)", "engine=innodb");
try (PreparedStatement stmt = sharedConnection.prepareStatement("insert into largePrepareUpdate(t) values(?)", Statement.RETURN_GENERATED_KEYS)) {
stmt.setString(1, "a");
long updateRes = stmt.executeLargeUpdate();
assertEquals(1L, updateRes);
assertEquals(1L, stmt.getUpdateCount());
assertEquals(1L, stmt.getLargeUpdateCount());

stmt.setString(1, "b");
stmt.addBatch();
stmt.setString(1, "c");
stmt.addBatch();
long[] batchRes = stmt.executeLargeBatch();
assertArrayEquals(new long[] {1,1}, batchRes);
ResultSet rs = stmt.getGeneratedKeys();
assertTrue(rs.next());
assertEquals(2, rs.getInt(1));

assertEquals(0L, stmt.getLargeMaxRows());
stmt.setLargeMaxRows(10_000L);
assertEquals(10_000L, stmt.getLargeMaxRows());
}
}
}

0 comments on commit d337275

Please sign in to comment.
You can’t perform that action at this time.