Skip to content

Commit

Permalink
upgrade javase sqlite library to support arm m1 (#3823)
Browse files Browse the repository at this point in the history
also added unit test for sqlite
  • Loading branch information
shannah authored Aug 4, 2024
1 parent d116bb5 commit 2976ce4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Ports/JavaSE/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<copy file="../../../codenameone-skins/iphone5_os7.skin" tofile="src/iphone5.skin" />
<copy file="../../../codenameone-skins/xoom.skin" todir="src" / -->
<copydir src="${project.CodenameOne}/build/classes" dest="build/classes" />
<unjar src="../../../cn1-binaries/javase/sqlite-jdbc-3.7.15-M1.jar" dest="build/classes" />
<unjar src="../../../cn1-binaries/javase/sqlite-jdbc-3.46.0.1.jar" dest="build/classes" />
<unjar src="../../../cn1-binaries/javase/Filters.jar" dest="build/classes" />
</target>

Expand Down
4 changes: 2 additions & 2 deletions Ports/JavaSE/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}:\
Expand Down
2 changes: 1 addition & 1 deletion maven/javase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.7.15-M1</version>
<version>3.46.0.1</version>
</dependency>
<dependency>
<groupId>com.jhlabs</groupId>
Expand Down
48 changes: 48 additions & 0 deletions tests/core/test/com/codename1/db/SQLiteTest.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 2976ce4

Please sign in to comment.