Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mattelacchiato/androiDBTest
base: 37df764301
...
head fork: mattelacchiato/androiDBTest
compare: b4efa70cfc
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
2  .classpath
@@ -4,6 +4,6 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry combineaccessrules="false" kind="src" path="/androiDBExample"/>
- <classpathentry kind="src" path="androidb_src_main_java"/>
+ <classpathentry kind="src" path="androiDB_src_main_java"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
4 .project
@@ -33,9 +33,9 @@
</natures>
<linkedResources>
<link>
- <name>androidb_src_main_java</name>
+ <name>androiDB_src_main_java</name>
<type>2</type>
- <locationURI>_android_androidb_c85e97d3/src/main/java</locationURI>
+ <locationURI>_android_androiDB_c85e93d3/src/main/java</locationURI>
</link>
</linkedResources>
</projectDescription>
View
2  default.properties
@@ -11,4 +11,4 @@
split.density=false
# Project target.
target=android-3
-android.library.reference.1=../androidb
+android.library.reference.1=../androiDB
View
8 src/de/splitstudio/androidb/MetadataTest.java
@@ -17,7 +17,7 @@ protected void setUp() throws Exception {
String dbFilename = "test.db";
dbFile = getContext().getDatabasePath(dbFilename);
dbFile.delete();
- db = getContext().openOrCreateDatabase(dbFilename, SQLiteDatabase.CREATE_IF_NECESSARY, null);
+ db = Table.openOrCreateDB(getContext());
assertTrue(db.isOpen());
assertFalse(db.isReadOnly());
//assertTrue(db.isDbLockedByCurrentThread());
@@ -31,9 +31,9 @@ protected void tearDown() throws Exception {
}
public void testConstructor_createMetadataTable() {
- Table table = new TableExample(getContext());
- Metadata metadata = new Metadata(db);
- assertTrue(metadata.findByName("TableColumnWithAnnotations"));
+ Table table = new TableExample();
+ Metadata metadata = new Metadata();
+ assertTrue(metadata.findByName(table.getTableName()));
assertEquals(table.getVersion(), metadata.getTableVersion());
}
}
View
10 src/de/splitstudio/androidb/TableExample.java
@@ -15,22 +15,12 @@
*/
package de.splitstudio.androidb;
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
import de.splitstudio.androidb.annotation.Column;
import de.splitstudio.androidb.annotation.TableMetaData;
@TableMetaData(version = 4)
public class TableExample extends Table {
- public TableExample(final Context context) {
- super(context);
- }
-
- public TableExample(final SQLiteDatabase db) {
- super(db);
- }
-
@Column
String text;
View
41 src/de/splitstudio/androidb/TableTest.java
@@ -20,11 +20,12 @@
@Override
protected void setUp() throws Exception {
super.setUp();
+ Table.openOrCreateDB(getContext());
String dbFilename = "test.db";
getContext().getDatabasePath(dbFilename).delete();
Table.createdTables.clear();
- table = new TableExample(getContext());
- db = table.getDb();
+ table = new TableExample();
+ db = Table.getDb();
}
@Override
@@ -34,7 +35,7 @@ protected void tearDown() throws Exception {
}
public void testConstructorWithContext_createDbFile() {
- new TableExample(getContext());
+ new TableExample();
assertTrue(getContext().getDatabasePath(Table.DB_FILENAME).exists());
}
@@ -45,17 +46,17 @@ public void testConstructor_createTable() {
public void testConstructor_tableCreated_noTableInDb() {
table.drop();
Table.createdTables.add(TABLE_NAME);
- new TableExample(getContext());
+ new TableExample();
assertEquals(0, TestHelper.getTableCount(TABLE_NAME, db));
}
public void testConstructor_tableWithNewId_callOnUpgrade() {
table.save();
- Metadata metadata = new Metadata(db);
+ Metadata metadata = new Metadata();
metadata.findByName(TABLE_NAME);
metadata.setTableVersion(1).save();
- table = new TableExample(getContext());
+ table = new TableExample();
Cursor cursor = table.all();
assertEquals(0, cursor.getCount());
cursor.close();
@@ -116,7 +117,7 @@ public void test_find_withId_trueAndFilled() {
table.save();
Long id = table._id;
- TableExample tableDB = new TableExample(getContext());
+ TableExample tableDB = new TableExample();
tableDB.find(id);
assertEquals(table, tableDB);
@@ -130,7 +131,7 @@ public void test_insert_allColumnsInserted() {
table.insert();
Long id = table._id;
- table = new TableExample(getContext());
+ table = new TableExample();
table.find(id);
assertEquals(amount, table.amount);
@@ -164,14 +165,14 @@ public void test_update_withIdInDb_true() {
table.amount = 3.14f;
assertEquals(true, table.update());
- table = new TableExample(getContext());
+ table = new TableExample();
table.find(42L);
assertEquals(3.14f, table.amount);
}
public void test_save_noId_insert() {
table.save();
- table = new TableExample(getContext());
+ table = new TableExample();
table.save();
Cursor all = table.all();
assertEquals(2, all.getCount());
@@ -190,7 +191,7 @@ public void test_drop_dropExistingTable_droppedAndRemovedFromMemoryAndMetadata()
table.drop();
assertEquals(0, TestHelper.getTableCount(table.getTableName(), db));
assertEquals(false, Table.createdTables.contains(table.getClass()));
- assertEquals(false, new Metadata(db).findByName(TABLE_NAME));
+ assertEquals(false, new Metadata().findByName(TABLE_NAME));
}
public void test_drop_dropNotExistingTable_noOneCares() {
@@ -199,7 +200,7 @@ public void test_drop_dropNotExistingTable_noOneCares() {
}
public void test_equals_equalTable_true() {
- TableExample table2 = new TableExample(getContext());
+ TableExample table2 = new TableExample();
table._id = 42L;
table.amount = 3.14f;
table.text = new String("foo");
@@ -210,7 +211,7 @@ public void test_equals_equalTable_true() {
}
public void test_equals_unequalTable_false() {
- TableExample table2 = new TableExample(getContext());
+ TableExample table2 = new TableExample();
table._id = 42L;
table.amount = 3.14f;
table.text = new String("foo");
@@ -223,7 +224,7 @@ public void test_equals_unequalTable_false() {
public void test_getVersion_noObjectVersion_exception() {
class NotVersionedTable extends Table {
NotVersionedTable(final Context context) {
- super(context);
+ super();
}
}
@@ -238,7 +239,7 @@ public void test_getVersion_objectVersionZero_exception() {
@TableMetaData(version = 0)
class NotVersionedTable extends Table {
NotVersionedTable(final Context context) {
- super(context);
+ super();
}
}
@@ -257,7 +258,7 @@ public void test_fillFirst_emptyCursor_false() {
public void test_fillFirst_cursorMultipleRows_trueAndFirstFilled() {
table.insert();
- table = new TableExample(getContext());
+ table = new TableExample();
table.insert();
Cursor c = table.all();
@@ -268,7 +269,7 @@ public void test_fillFirst_cursorMultipleRows_trueAndFirstFilled() {
public void test_getColumnNamesAsList() {
List<String> expected = Arrays.asList("_id", "text", "amount");
- assertEquals(expected, table.getColumnNamesAsList());
+ assertEquals(expected, Table.getColumnNamesAsList(table.getClass()));
}
public void test_getFields_someColumns_someColumns() {
@@ -281,7 +282,7 @@ public void test_insert_withSQLInjection_gotEscaped() {
}
public void test_fill_emptyCursor_false() {
- TableExample tableExample = new TableExample(getContext());
+ TableExample tableExample = new TableExample();
Cursor all = tableExample.all();
assertEquals(false, tableExample.fill(all));
all.close();
@@ -290,7 +291,7 @@ public void test_fill_emptyCursor_false() {
public void test_fill_manyCursorEntries_trueAndFilled() {
table.amount = 3.14f;
table.save();
- table = new TableExample(getContext());
+ table = new TableExample();
table.amount = 42;
table.save();
@@ -304,7 +305,7 @@ public void test_fill_manyCursorEntries_trueAndFilled() {
public void test_fillAll_filled() {
table.amount = 2f;
table.save();
- table = new TableExample(getContext());
+ table = new TableExample();
table.amount = 3f;
table.save();

No commit comments for this range

Something went wrong with that request. Please try again.