Skip to content

Commit 97d05f7

Browse files
BoxStore: move closed test next to open tests.
1 parent b1983aa commit 97d05f7

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

tests/objectbox-java-test/src/test/java/io/objectbox/BoxStoreTest.java

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,46 @@ public void testUnalignedMemoryAccess() {
4040
BoxStore.testUnalignedMemoryAccess();
4141
}
4242

43+
@Test
44+
public void testEmptyTransaction() {
45+
Transaction transaction = store.beginTx();
46+
transaction.commit();
47+
}
48+
49+
@Test
50+
public void testSameBox() {
51+
Box<TestEntity> box1 = store.boxFor(TestEntity.class);
52+
Box<TestEntity> box2 = store.boxFor(TestEntity.class);
53+
assertSame(box1, box2);
54+
}
55+
56+
@Test(expected = RuntimeException.class)
57+
public void testBoxForUnknownEntity() {
58+
store.boxFor(getClass());
59+
}
60+
61+
@Test
62+
public void testRegistration() {
63+
assertEquals("TestEntity", store.getDbName(TestEntity.class));
64+
assertEquals(TestEntity.class, store.getEntityInfo(TestEntity.class).getEntityClass());
65+
}
66+
67+
@Test
68+
public void testCloseThreadResources() {
69+
Box<TestEntity> box = store.boxFor(TestEntity.class);
70+
Cursor<TestEntity> reader = box.getReader();
71+
box.releaseReader(reader);
72+
73+
Cursor<TestEntity> reader2 = box.getReader();
74+
box.releaseReader(reader2);
75+
assertSame(reader, reader2);
76+
77+
store.closeThreadResources();
78+
Cursor<TestEntity> reader3 = box.getReader();
79+
box.releaseReader(reader3);
80+
assertNotSame(reader, reader3);
81+
}
82+
4383
@Test
4484
public void testClose() {
4585
BoxStore store = this.store;
@@ -110,46 +150,6 @@ private void assertThrowsStoreIsClosed(ThrowingRunnable runnable) {
110150
assertEquals("Store is closed", ex.getMessage());
111151
}
112152

113-
@Test
114-
public void testEmptyTransaction() {
115-
Transaction transaction = store.beginTx();
116-
transaction.commit();
117-
}
118-
119-
@Test
120-
public void testSameBox() {
121-
Box<TestEntity> box1 = store.boxFor(TestEntity.class);
122-
Box<TestEntity> box2 = store.boxFor(TestEntity.class);
123-
assertSame(box1, box2);
124-
}
125-
126-
@Test(expected = RuntimeException.class)
127-
public void testBoxForUnknownEntity() {
128-
store.boxFor(getClass());
129-
}
130-
131-
@Test
132-
public void testRegistration() {
133-
assertEquals("TestEntity", store.getDbName(TestEntity.class));
134-
assertEquals(TestEntity.class, store.getEntityInfo(TestEntity.class).getEntityClass());
135-
}
136-
137-
@Test
138-
public void testCloseThreadResources() {
139-
Box<TestEntity> box = store.boxFor(TestEntity.class);
140-
Cursor<TestEntity> reader = box.getReader();
141-
box.releaseReader(reader);
142-
143-
Cursor<TestEntity> reader2 = box.getReader();
144-
box.releaseReader(reader2);
145-
assertSame(reader, reader2);
146-
147-
store.closeThreadResources();
148-
Cursor<TestEntity> reader3 = box.getReader();
149-
box.releaseReader(reader3);
150-
assertNotSame(reader, reader3);
151-
}
152-
153153
@Test(expected = DbException.class)
154154
public void testPreventTwoBoxStoresWithSameFileOpenend() {
155155
createBoxStore();

0 commit comments

Comments
 (0)