From 2976ce494d27fbde4f02568526fa6aab0b16ad29 Mon Sep 17 00:00:00 2001 From: Steve Hannah Date: Sun, 4 Aug 2024 12:55:30 -0400 Subject: [PATCH] upgrade javase sqlite library to support arm m1 (#3823) also added unit test for sqlite --- Ports/JavaSE/build.xml | 2 +- Ports/JavaSE/nbproject/project.properties | 4 +- maven/javase/pom.xml | 2 +- .../test/com/codename1/db/SQLiteTest.java | 48 +++++++++++++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 tests/core/test/com/codename1/db/SQLiteTest.java diff --git a/Ports/JavaSE/build.xml b/Ports/JavaSE/build.xml index b99f1a7655..6884bc78cf 100644 --- a/Ports/JavaSE/build.xml +++ b/Ports/JavaSE/build.xml @@ -158,7 +158,7 @@ - + diff --git a/Ports/JavaSE/nbproject/project.properties b/Ports/JavaSE/nbproject/project.properties index a8ff185bc7..070233a736 100644 --- a/Ports/JavaSE/nbproject/project.properties +++ b/Ports/JavaSE/nbproject/project.properties @@ -35,13 +35,13 @@ file.reference.Filters.jar=../../../cn1-binaries/javase/Filters.jar file.reference.jcef.jar=../../../cn1-binaries/javase/jcef.jar file.reference.jmf-2.1.1e.jar=../../../cn1-binaries/javase/jmf-2.1.1e.jar file.reference.jfxrt.jar=../../../cn1-binaries/jfxrt.jar -file.reference.sqlite-jdbc-3.7.15-M1.jar=../../../cn1-binaries/javase/sqlite-jdbc-3.7.15-M1.jar +file.reference.sqlite-jdbc-3.46.0.1.jar=../../../cn1-binaries/javase/sqlite-jdbc-3.46.0.1.jar includes=** jar.compress=false javafx.path=../../../cn1-binaries/javafx/lib javac.classpath=\ ${reference.CodenameOne.jar}:\ - ${file.reference.sqlite-jdbc-3.7.15-M1.jar}:\ + ${file.reference.sqlite-jdbc-3.46.0.1.jar}:\ ${file.reference.Filters.jar}:\ ${file.reference.jcef.jar}:\ ${file.reference.jmf-2.1.1e.jar}:\ diff --git a/maven/javase/pom.xml b/maven/javase/pom.xml index f4ec708a5c..3ca4ec282e 100644 --- a/maven/javase/pom.xml +++ b/maven/javase/pom.xml @@ -21,7 +21,7 @@ org.xerial sqlite-jdbc - 3.7.15-M1 + 3.46.0.1 com.jhlabs diff --git a/tests/core/test/com/codename1/db/SQLiteTest.java b/tests/core/test/com/codename1/db/SQLiteTest.java new file mode 100644 index 0000000000..b05d50cb85 --- /dev/null +++ b/tests/core/test/com/codename1/db/SQLiteTest.java @@ -0,0 +1,48 @@ +package com.codename1.db; + +import com.codename1.testing.AbstractTest; +import com.codename1.ui.Display; + +public class SQLiteTest extends AbstractTest { + + @Override + public boolean runTest() throws Exception { + Database db = null; + Cursor cur = null; + try { + db = Display.getInstance().openOrCreate("MyDB.db"); + + db.execute("create table people (name TEXT, ssn TEXT, age INTEGER)"); + db.execute("insert into people (name, ssn, age) values ('John Doe', '123-45-6789', 25)"); + db.execute("insert into people (name, ssn, age) values ('Jane Doe', '987-65-4321', 30)"); + cur = db.executeQuery("select * from people"); + this.assertEqual(3, cur.getColumnCount(), "Column count mismatch"); + this.assertEqual("name", cur.getColumnName(0), "Column name mismatch"); + this.assertEqual("ssn", cur.getColumnName(1), "Column name mismatch"); + this.assertEqual("age", cur.getColumnName(2), "Column name mismatch"); + this.assertTrue(cur.next(), "No rows returned"); + this.assertEqual("John Doe", cur.getRow().getString(0), "Row data mismatch"); + this.assertEqual("123-45-6789", cur.getRow().getString(1), "Row data mismatch"); + this.assertEqual(25, cur.getRow().getInteger(2), "Row data mismatch"); + this.assertTrue(cur.next(), "No rows returned"); + this.assertEqual("Jane Doe", cur.getRow().getString(0), "Row data mismatch"); + this.assertEqual("987-65-4321", cur.getRow().getString(1), "Row data mismatch"); + this.assertEqual(30, cur.getRow().getInteger(2), "Row data mismatch"); + this.assertFalse(cur.next(), "Too many rows returned"); + } finally { + if(cur != null) { + cur.close(); + } + if(db != null) { + db.close(); + } + } + + return true; + } + + @Override + public boolean shouldExecuteOnEDT() { + return false; + } +}