-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests to attempt reproducing github issue #16
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package net.ucanaccess.jdbc; | ||
|
||
import net.ucanaccess.test.UcanaccessBaseFileTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.lang.System.Logger.Level; | ||
import java.math.BigDecimal; | ||
import java.sql.Date; | ||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
import java.sql.Types; | ||
import java.time.LocalDate; | ||
|
||
class GithubIssue16Test extends UcanaccessBaseFileTest { | ||
|
||
@Test | ||
void testIssue16() throws SQLException { | ||
init(); | ||
|
||
String tbl = "`Donation Detail`"; | ||
Date sqlDt = Date.valueOf(LocalDate.now()); | ||
BigDecimal amt = new BigDecimal(0.01); | ||
|
||
try (PreparedStatement ps = ucanaccess.prepareStatement( | ||
"INSERT INTO " + tbl + " (`Donor_ID`, `Batch`, `Donation Date`, `Deposit Date`, `Donation Type`, `Amount`, `Designation`, `Notes`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")) { | ||
|
||
ps.setInt(1, 1); | ||
ps.setNull(2, Types.INTEGER); | ||
ps.setDate(3, sqlDt); | ||
ps.setDate(4, sqlDt); | ||
ps.setString(5, "donation_type"); | ||
ps.setBigDecimal(6, amt); | ||
ps.setString(7, "designation"); | ||
ps.setString(8, null); | ||
|
||
int rows = ps.executeUpdate(); | ||
getLogger().log(Level.INFO, "Updated: {0} row(s)", rows); | ||
|
||
checkQuery("SELECT * FROM " + tbl + " WHERE Donor_ID=1", | ||
recs(rec(1, null, sqlDt, sqlDt, "donation_type", amt, "designation", null))); | ||
} | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
src/test/java/net/ucanaccess/jdbc/GithubIssue16VersionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package net.ucanaccess.jdbc; | ||
|
||
import net.ucanaccess.test.AccessVersionSource; | ||
import net.ucanaccess.test.UcanaccessBaseTest; | ||
import net.ucanaccess.type.AccessVersion; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
|
||
import java.lang.System.Logger.Level; | ||
import java.math.BigDecimal; | ||
import java.sql.Date; | ||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
import java.sql.Types; | ||
import java.time.LocalDate; | ||
|
||
class GithubIssue16VersionTest extends UcanaccessBaseTest { | ||
|
||
@ParameterizedTest(name = "[{index}] {0}") | ||
@AccessVersionSource | ||
void testIssue16(AccessVersion _accessVersion) throws SQLException { | ||
init(_accessVersion); | ||
|
||
String tbl = "`Donation Detail`"; | ||
Date sqlDt = Date.valueOf(LocalDate.now()); | ||
BigDecimal amt = new BigDecimal(0.01); | ||
|
||
executeStatements(String.join(" ", "CREATE TABLE", tbl, "(" | ||
, "Donor_ID INTEGER," | ||
, "Batch INTEGER, " | ||
, "[Donation Date] DATETIME," | ||
, "[Deposit Date] DATETIME, " | ||
, "[Donation Type] TEXT(64)," | ||
, "[Amount] NUMERIC(12,3)," | ||
, "[Designation] TEXT(64)" | ||
, ")")); | ||
|
||
try (PreparedStatement ps = ucanaccess.prepareStatement( | ||
"INSERT INTO " + tbl + " (`Donor_ID`, `Batch`, `Donation Date`, `Deposit Date`, `Donation Type`, `Amount`, `Designation`) VALUES (?, ?, ?, ?, ?, ?, ?)")) { | ||
|
||
ps.setInt(1, 1); | ||
ps.setNull(2, Types.INTEGER); | ||
ps.setDate(3, sqlDt); | ||
ps.setDate(4, sqlDt); | ||
ps.setString(5, "donation_type"); | ||
ps.setBigDecimal(6, amt); | ||
ps.setString(7, "designation"); | ||
|
||
int rows = ps.executeUpdate(); | ||
getLogger().log(Level.INFO, "Updated: {0} row(s)", rows); | ||
|
||
checkQuery("SELECT * FROM " + tbl + " WHERE Donor_ID=1", | ||
recs(rec(1, null, sqlDt, sqlDt, "donation_type", amt, "designation"))); | ||
|
||
// executeStatements("DROP TABLE " + tbl); | ||
} | ||
} | ||
|
||
} |
Binary file not shown.