-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade javase sqlite library to support arm m1 (#3823)
also added unit test for sqlite
- Loading branch information
Showing
4 changed files
with
52 additions
and
4 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
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
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
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,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; | ||
} | ||
} |