Skip to content

Commit

Permalink
IGNITE-6141 Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skorotkov committed Aug 22, 2024
1 parent 846ea01 commit 0c84141
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public abstract class JdbcThinAbstractDmlStatementSelfTest extends JdbcThinAbstr
private static final String UTF_16 = "UTF-16"; // RAWTOHEX function use UTF-16 for conversion strings to byte arrays.

/** SQL SELECT query for verification. */
static final String SQL_SELECT = "select _key, id, firstName, lastName, age, blob, clob from Person";
static final String SQL_SELECT = "select _key, id, firstName, lastName, age, data, text from Person";

/** Connection. */
protected Connection conn;
Expand Down Expand Up @@ -124,8 +124,8 @@ IgniteConfiguration getBinaryConfiguration(String igniteInstanceName) throws Exc
e.addQueryField("age", Integer.class.getName(), null);
e.addQueryField("firstName", String.class.getName(), null);
e.addQueryField("lastName", String.class.getName(), null);
e.addQueryField("blob", byte[].class.getName(), null);
e.addQueryField("clob", String.class.getName(), null);
e.addQueryField("data", byte[].class.getName(), null);
e.addQueryField("text", String.class.getName(), null);

ccfg.setQueryEntities(Collections.singletonList(e));

Expand Down Expand Up @@ -167,8 +167,8 @@ final CacheConfiguration binaryCacheConfig() {
e.addQueryField("age", Integer.class.getName(), null);
e.addQueryField("firstName", String.class.getName(), null);
e.addQueryField("lastName", String.class.getName(), null);
e.addQueryField("blob", byte[].class.getName(), null);
e.addQueryField("clob", String.class.getName(), null);
e.addQueryField("data", byte[].class.getName(), null);
e.addQueryField("text", String.class.getName(), null);

cache.setQueryEntities(Collections.singletonList(e));

Expand Down Expand Up @@ -250,13 +250,13 @@ static class Person implements Serializable {
@QuerySqlField
private final int age;

/** Blob. */
/** Binary data (BLOB). */
@QuerySqlField
private final byte[] blob;
private final byte[] data;

/** Clob. */
/** CLOB. */
@QuerySqlField
private final String clob;
private final String text;

/**
* @param id ID.
Expand All @@ -273,8 +273,8 @@ static class Person implements Serializable {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
blob = getBytes(lastName);
clob = firstName + " " + lastName;
data = getBytes(lastName);
text = firstName + " " + lastName;
}

/** {@inheritDoc} */
Expand All @@ -288,8 +288,8 @@ static class Person implements Serializable {
if (age != person.age) return false;
if (firstName != null ? !firstName.equals(person.firstName) : person.firstName != null) return false;
if (lastName != null ? !lastName.equals(person.lastName) : person.lastName != null) return false;
if (clob != null ? !clob.equals(person.clob) : person.clob != null) return false;
return blob != null ? Arrays.equals(blob, person.blob) : person.blob == null;
if (text != null ? !text.equals(person.text) : person.text != null) return false;
return data != null ? Arrays.equals(data, person.data) : person.data == null;
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public abstract class JdbcThinAbstractUpdateStatementSelfTest extends JdbcThinAbstractDmlStatementSelfTest {
/** SQL query to populate cache. */
private static final String ITEMS_SQL = "insert into Person(_key, id, firstName, lastName, age, blob, clob) values " +
private static final String ITEMS_SQL = "insert into Person(_key, id, firstName, lastName, age, data, text) values " +
"('p1', 1, 'John', 'White', 25, RAWTOHEX('White'), 'John White'), " +
"('p2', 2, 'Joe', 'Black', 35, RAWTOHEX('Black'), 'Joe Black'), " +
"('p3', 3, 'Mike', 'Green', 40, RAWTOHEX('Green'), 'Mike Green')";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
*/
public class JdbcThinInsertStatementSelfTest extends JdbcThinAbstractDmlStatementSelfTest {
/** SQL query. */
private static final String SQL = "insert into Person(_key, id, firstName, lastName, age, blob, clob) values " +
private static final String SQL = "insert into Person(_key, id, firstName, lastName, age, data, text) values " +
"('p1', 1, 'John', 'White', 25, RAWTOHEX('White'), 'John White'), " +
"('p2', 2, 'Joe', 'Black', 35, RAWTOHEX('Black'), 'Joe Black'), " +
"('p3', 3, 'Mike', 'Green', 40, RAWTOHEX('Green'), 'Mike Green')";

/** SQL query. */
private static final String SQL_PREPARED = "insert into Person(_key, id, firstName, lastName, age, blob, clob) " +
private static final String SQL_PREPARED = "insert into Person(_key, id, firstName, lastName, age, data, text) " +
"values (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?)";

/** Test logger. */
Expand Down Expand Up @@ -120,26 +120,26 @@ public class JdbcThinInsertStatementSelfTest extends JdbcThinAbstractDmlStatemen
assertEquals("John", rs.getString("firstName"));
assertEquals("White", rs.getString("lastName"));
assertEquals(25, rs.getInt("age"));
assertEquals("White", str(getBytes(rs.getBlob("blob"))));
assertEquals("John White", str(rs.getClob("clob")));
assertEquals("White", str(getBytes(rs.getBlob("data"))));
assertEquals("John White", str(rs.getClob("text")));
break;

case 2:
assertEquals("p2", rs.getString("_key"));
assertEquals("Joe", rs.getString("firstName"));
assertEquals("Black", rs.getString("lastName"));
assertEquals(35, rs.getInt("age"));
assertEquals("Black", str(getBytes(rs.getBlob("blob"))));
assertEquals("Joe Black", str(rs.getClob("clob")));
assertEquals("Black", str(getBytes(rs.getBlob("data"))));
assertEquals("Joe Black", str(rs.getClob("text")));
break;

case 3:
assertEquals("p3", rs.getString("_key"));
assertEquals("Mike", rs.getString("firstName"));
assertEquals("Green", rs.getString("lastName"));
assertEquals(40, rs.getInt("age"));
assertEquals("Green", str(getBytes(rs.getBlob("blob"))));
assertEquals("Mike Green", str(rs.getClob("clob")));
assertEquals("Green", str(getBytes(rs.getBlob("data"))));
assertEquals("Mike Green", str(rs.getClob("text")));
System.out.println("CASE 3!!!!");
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
*/
public class JdbcThinMergeStatementSelfTest extends JdbcThinAbstractDmlStatementSelfTest {
/** SQL query. */
private static final String SQL = "merge into Person(_key, id, firstName, lastName, age, blob, clob) values " +
private static final String SQL = "merge into Person(_key, id, firstName, lastName, age, data, text) values " +
"('p1', 1, 'John', 'White', 25, RAWTOHEX('White'), 'John White'), " +
"('p2', 2, 'Joe', 'Black', 35, RAWTOHEX('Black'), 'Joe Black'), " +
"('p3', 3, 'Mike', 'Green', 40, RAWTOHEX('Green'), 'Mike Green')";

/** SQL query. */
protected static final String SQL_PREPARED = "merge into Person(_key, id, firstName, lastName, age, blob, clob) values " +
protected static final String SQL_PREPARED = "merge into Person(_key, id, firstName, lastName, age, data, text) values " +
"(?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?)";

/** Statement. */
Expand Down Expand Up @@ -74,26 +74,26 @@ public class JdbcThinMergeStatementSelfTest extends JdbcThinAbstractDmlStatement
assertEquals("John", rs.getString("firstName"));
assertEquals("White", rs.getString("lastName"));
assertEquals(25, rs.getInt("age"));
assertEquals("White", str(getBytes(rs.getBlob("blob"))));
assertEquals("John White", str(rs.getClob("clob")));
assertEquals("White", str(getBytes(rs.getBlob("data"))));
assertEquals("John White", str(rs.getClob("text")));
break;

case 2:
assertEquals("p2", rs.getString("_key"));
assertEquals("Joe", rs.getString("firstName"));
assertEquals("Black", rs.getString("lastName"));
assertEquals(35, rs.getInt("age"));
assertEquals("Black", str(getBytes(rs.getBlob("blob"))));
assertEquals("Joe Black", str(rs.getClob("clob")));
assertEquals("Black", str(getBytes(rs.getBlob("data"))));
assertEquals("Joe Black", str(rs.getClob("text")));
break;

case 3:
assertEquals("p3", rs.getString("_key"));
assertEquals("Mike", rs.getString("firstName"));
assertEquals("Green", rs.getString("lastName"));
assertEquals(40, rs.getInt("age"));
assertEquals("Green", str(getBytes(rs.getBlob("blob"))));
assertEquals("Mike Green", str(rs.getClob("clob")));
assertEquals("Green", str(getBytes(rs.getBlob("data"))));
assertEquals("Mike Green", str(rs.getClob("text")));
break;

default:
Expand Down

0 comments on commit 0c84141

Please sign in to comment.