SQLite Android Bindings
Check-in [251698dcb8]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add tests for new extension loading code to android app
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | api-level-9
Files: files | file ages | folders
SHA1: 251698dcb8b5161358d47d6de27eebea6a6a5872
User & Date: pjw 2017-05-02 15:20:55
Context
2017-05-02
15:20
Add tests for new extension loading code to android app Leaf check-in: 251698dcb8 user: pjw tags: api-level-9
14:39
Throw SQLiteMisuseException if built with SQLITE_OMIT_LOAD_EXTENSION and client attempts to enable extension load check-in: 566a4f756b user: pjw tags: api-level-9
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to sqlite3test/src/main/java/org/sqlite/customsqlitetest/MainActivity.java.

433
434
435
436
437
438
439

440
441
442
443
444
445
446
...
491
492
493
494
495
496
497
498
499
500
501































































































            csr_test_2();
            thread_test_1();
            thread_test_2();
            see_test_1();
            see_test_2();
            stmt_jrnl_test_1();
            json_test_1();


            myTV.append("\n" + myNErr + " errors from " + myNTest + " tests\n");
        } catch(Exception e) {
            myTV.append("Exception: " + e.toString() + "\n");
            myTV.append(android.util.Log.getStackTraceString(e) + "\n");
        }
    }
................................................................................
        s = db.compileStatement("Select x from t1 where json_extract(x, '$.Foo') > 1 order by json_extract(x, '$.Foo') limit 1");
        res = s.simpleQueryForString();
        db.setTransactionSuccessful();
        db.endTransaction();
        test_result("json_test_1.3", res, r2, t2);

        s.close();

        db.close();
    }
}






































































































>







 










|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
...
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
            csr_test_2();
            thread_test_1();
            thread_test_2();
            see_test_1();
            see_test_2();
            stmt_jrnl_test_1();
            json_test_1();
            load_extension_test_1();

            myTV.append("\n" + myNErr + " errors from " + myNTest + " tests\n");
        } catch(Exception e) {
            myTV.append("Exception: " + e.toString() + "\n");
            myTV.append(android.util.Log.getStackTraceString(e) + "\n");
        }
    }
................................................................................
        s = db.compileStatement("Select x from t1 where json_extract(x, '$.Foo') > 1 order by json_extract(x, '$.Foo') limit 1");
        res = s.simpleQueryForString();
        db.setTransactionSuccessful();
        db.endTransaction();
        test_result("json_test_1.3", res, r2, t2);

        s.close();

        db.close();
    }

    public void load_extension_test_1() throws Exception {
        long t0 = System.nanoTime();
        SQLiteDatabase.deleteDatabase(DB_PATH);
        SQLiteDatabase db = SQLiteDatabase.openDatabase(DB_PATH.getAbsolutePath(), null, SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.ENABLE_LOAD_EXTENSION);

        Cursor c = null;
        try {
            c = db.rawQuery("select load_extension('foo')", new String[] {});
            c.moveToFirst();
            c.close();
            c = null;
        } catch (Exception e) {
            String exp = "dlopen failed";
            test_result("load_extension_1.1", e.getMessage().substring(0,exp.length()), exp, t0);
        } finally {
            if (c != null) {
                c.close();
                c = null;
            }
        }
        t0 = System.nanoTime();

        db.disableLoadExtension();
        try {
            c = db.rawQuery("select load_extension('foo')", new String[] {});
            c.moveToFirst();
            c.close();
            c = null;
        } catch (Exception e) {
            String exp = "not authorized";
            test_result("load_extension_1.2", e.getMessage().substring(0,exp.length()), exp, t0);
        } finally {
            if (c != null) {
                c.close();
                c = null;
            }
        }
        t0 = System.nanoTime();

        db.enableLoadExtension();
        try {
            c = db.rawQuery("select load_extension('foo')", new String[] {});
            c.moveToFirst();
            c.close();
            c = null;
        } catch (Exception e) {
            String exp = "dlopen failed";
            test_result("load_extension_1.3", e.getMessage().substring(0,exp.length()), exp, t0);
        } finally {
            if (c != null) {
                c.close();
                c = null;
            }
        }
        t0 = System.nanoTime();

        db.close();

        db = SQLiteDatabase.openDatabase(DB_PATH.getAbsolutePath(), null, SQLiteDatabase.CREATE_IF_NECESSARY);
        db.disableLoadExtension();
        try {
            c = db.rawQuery("select load_extension('foo')", new String[] {});
            c.moveToFirst();
            c.close();
            c = null;
        } catch (Exception e) {
            String exp = "not authorized";
            test_result("load_extension_1.4", e.getMessage().substring(0,exp.length()), exp, t0);
        } finally {
            if (c != null) {
                c.close();
                c = null;
            }
        }
        t0 = System.nanoTime();

        db.enableLoadExtension();
        try {
            c = db.rawQuery("select load_extension('foo')", new String[] {});
            c.moveToFirst();
            c.close();
            c = null;
        } catch (Exception e) {
            String exp = "dlopen failed";
            test_result("load_extension_1.5", e.getMessage().substring(0,exp.length()), exp, t0);
        } finally {
            if (c != null) {
                c.close();
                c = null;
            }
        }

        db.close();
    }
}