Skip to content

Commit

Permalink
chore: spotless apply
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Aug 3, 2022
1 parent 10ab71c commit ff7a01a
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions src/test/java/org/sqlite/QueryTest.java
Expand Up @@ -9,8 +9,11 @@
// --------------------------------------
package org.sqlite;

import org.junit.jupiter.api.Test;
import org.sqlite.date.FastDateFormat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.sql.Clob;
import java.sql.Connection;
Expand All @@ -23,12 +26,8 @@
import java.util.Date;
import java.util.Properties;
import java.util.TimeZone;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
import org.sqlite.date.FastDateFormat;

public class QueryTest {
public Connection getConnection() throws SQLException {
Expand All @@ -52,8 +51,8 @@ public void createTable() throws Exception {
Connection conn = getConnection();
Statement stmt = conn.createStatement();
stmt.execute(
"CREATE TABLE IF NOT EXISTS sample "
+ "(id INTEGER PRIMARY KEY, descr VARCHAR(40))");
"CREATE TABLE IF NOT EXISTS sample "
+ "(id INTEGER PRIMARY KEY, descr VARCHAR(40))");
stmt.close();

stmt = conn.createStatement();
Expand Down Expand Up @@ -93,7 +92,7 @@ public void dateTimeTest() throws Exception {

Date now = new Date();
String date =
FastDateFormat.getInstance(SQLiteConfig.DEFAULT_DATE_STRING_FORMAT).format(now);
FastDateFormat.getInstance(SQLiteConfig.DEFAULT_DATE_STRING_FORMAT).format(now);

conn.createStatement().execute("insert into sample values(" + now.getTime() + ")");
conn.createStatement().execute("insert into sample values('" + date + "')");
Expand Down Expand Up @@ -129,11 +128,11 @@ public void dateTimeWithTimeZoneTest() throws Exception {

java.sql.Date now = new java.sql.Date(new Date().getTime());
FastDateFormat customFormat =
FastDateFormat.getInstance(SQLiteConfig.DEFAULT_DATE_STRING_FORMAT, customTimeZone);
FastDateFormat.getInstance(SQLiteConfig.DEFAULT_DATE_STRING_FORMAT, customTimeZone);
FastDateFormat utcFormat =
FastDateFormat.getInstance(SQLiteConfig.DEFAULT_DATE_STRING_FORMAT, utcTimeZone);
FastDateFormat.getInstance(SQLiteConfig.DEFAULT_DATE_STRING_FORMAT, utcTimeZone);
java.sql.Date nowLikeCustomZoneIsUtc =
new java.sql.Date(utcFormat.parse(customFormat.format(now)).getTime());
new java.sql.Date(utcFormat.parse(customFormat.format(now)).getTime());

PreparedStatement preparedStatement = null;
try {
Expand Down Expand Up @@ -239,7 +238,7 @@ public void concatTest() {

statement.executeUpdate("drop table if exists person");
statement.executeUpdate(
"create table person (id integer, name string, shortname string)");
"create table person (id integer, name string, shortname string)");
statement.executeUpdate("insert into person values(1, 'leo','L')");
statement.executeUpdate("insert into person values(2, 'yui','Y')");
statement.executeUpdate("insert into person values(3, 'abc', null)");
Expand All @@ -258,23 +257,23 @@ public void concatTest() {
statement.executeUpdate("insert into mxp values(3,2,'T')");

ResultSet rs =
statement.executeQuery(
"select group_concat(ifnull(shortname, name)) from mxp, person where mxp.mid=2 and mxp.pid=person.id and mxp.type='T'");
statement.executeQuery(
"select group_concat(ifnull(shortname, name)) from mxp, person where mxp.mid=2 and mxp.pid=person.id and mxp.type='T'");
while (rs.next()) {
// read the result set
assertEquals("Y,abc", rs.getString(1));
}
rs =
statement.executeQuery(
"select group_concat(ifnull(shortname, name)) from mxp, person where mxp.mid=1 and mxp.pid=person.id and mxp.type='T'");
statement.executeQuery(
"select group_concat(ifnull(shortname, name)) from mxp, person where mxp.mid=1 and mxp.pid=person.id and mxp.type='T'");
while (rs.next()) {
// read the result set
assertEquals("Y", rs.getString(1));
}

PreparedStatement ps =
conn.prepareStatement(
"select group_concat(ifnull(shortname, name)) from mxp, person where mxp.mid=? and mxp.pid=person.id and mxp.type='T'");
conn.prepareStatement(
"select group_concat(ifnull(shortname, name)) from mxp, person where mxp.mid=? and mxp.pid=person.id and mxp.type='T'");
ps.clearParameters();
ps.setInt(1, new Integer(2));
rs = ps.executeQuery();
Expand Down Expand Up @@ -332,8 +331,8 @@ public void clobTest() throws SQLException {
assertEquals("", clob.getSubString(1, 0));
assertEquals(content, clob.getSubString(1, length));
assertEquals(
content.substring(2, content.length() - 1),
clob.getSubString(3, content.length() - 3));
content.substring(2, content.length() - 1),
clob.getSubString(3, content.length() - 3));
} finally {
if (rs != null) rs.close();
}
Expand Down

0 comments on commit ff7a01a

Please sign in to comment.