Skip to content

Commit 8f1fd69

Browse files
Adding test to query non encrypted database from SQLCipher for Android
1 parent 317b132 commit 8f1fd69

File tree

8 files changed

+132
-126
lines changed

8 files changed

+132
-126
lines changed
40 Bytes
Binary file not shown.

libs/sqlcipher.jar

0 Bytes
Binary file not shown.

libs/x86/libsqlcipher_android.so

4.03 KB
Binary file not shown.

net.zetetic.sqlcipher.test.iml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
<option name="RES_FOLDER_RELATIVE_PATH" value="/res" />
1010
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/assets" />
1111
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/libs" />
12-
<option name="REGENERATE_R_JAVA" value="true" />
13-
<option name="REGENERATE_JAVA_BY_AIDL" value="true" />
1412
<option name="USE_CUSTOM_APK_RESOURCE_FOLDER" value="false" />
1513
<option name="CUSTOM_APK_RESOURCE_FOLDER" value="/target/generated-sources/combined-resources/res" />
1614
<option name="USE_CUSTOM_COMPILER_MANIFEST" value="false" />
@@ -25,6 +23,7 @@
2523
<option name="PROGUARD_CFG_PATH" value="/proguard.cfg" />
2624
<resOverlayFolders />
2725
<includeSystemProguardFile>false</includeSystemProguardFile>
26+
<includeAssetsFromLibraries>true</includeAssetsFromLibraries>
2827
<additionalNativeLibs />
2928
</configuration>
3029
</facet>

net.zetetic.sqlcipher.test.ipr

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
<entry name="?*.tld" />
2424
<entry name="?*.ftl" />
2525
</wildcardResourcePatterns>
26-
<annotationProcessing enabled="false" useClasspath="true" />
26+
<annotationProcessing>
27+
<profile default="true" name="Default" enabled="false">
28+
<processorPath useClasspath="true" />
29+
</profile>
30+
</annotationProcessing>
2731
</component>
2832
<component name="CopyrightManager" default="">
2933
<module2copyright />
@@ -67,28 +71,6 @@
6771
</list>
6872
</option>
6973
</component>
70-
<component name="NullableNotNullManager">
71-
<option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
72-
<option name="myDefaultNotNull" value="org.jetbrains.annotations.NotNull" />
73-
<option name="myNullables">
74-
<value>
75-
<list size="3">
76-
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
77-
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
78-
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
79-
</list>
80-
</value>
81-
</option>
82-
<option name="myNotNulls">
83-
<value>
84-
<list size="3">
85-
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
86-
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
87-
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
88-
</list>
89-
</value>
90-
</option>
91-
</component>
9274
<component name="Palette2">
9375
<group name="Swing">
9476
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">

net.zetetic.sqlcipher.test.iws

Lines changed: 88 additions & 101 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package net.zetetic.tests;
2+
3+
import android.database.Cursor;
4+
import net.sqlcipher.database.SQLiteDatabase;
5+
import net.zetetic.ZeteticApplication;
6+
7+
import java.io.File;
8+
import java.io.IOException;
9+
10+
public class QueryNonEncryptedDatabaseTest extends SQLCipherTest {
11+
12+
@Override
13+
public boolean execute(SQLiteDatabase database) {
14+
15+
boolean success = false;
16+
try {
17+
File unencryptedDatabase = ZeteticApplication.getInstance().getDatabasePath("unencrypted.db");
18+
ZeteticApplication.getInstance().extractAssetToDatabaseDirectory("unencrypted.db");
19+
database.close();
20+
database = SQLiteDatabase.openOrCreateDatabase(unencryptedDatabase, "", null);
21+
Cursor cursor = database.rawQuery("select * from t1", new String[]{});
22+
cursor.moveToFirst();
23+
String a = cursor.getString(0);
24+
String b = cursor.getString(1);
25+
cursor.close();
26+
database.close();
27+
success = a.equals("one for the money") &&
28+
b.equals("two for the show");
29+
} catch (IOException e) {}
30+
return success;
31+
}
32+
33+
@Override
34+
public String getName() {
35+
return "Query Non-Encrypted Database Test";
36+
}
37+
}

src/main/java/net/zetetic/tests/TestSuiteRunner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ private List<SQLCipherTest> getTestsToRun(){
6363
tests.add(new VerifyOnUpgradeIsCalledTest());
6464
tests.add(new MigrationUserVersion());
6565
tests.add(new ExportToUnencryptedDatabase());
66+
tests.add(new QueryNonEncryptedDatabaseTest());
6667
return tests;
6768
}
6869
}

0 commit comments

Comments
 (0)