Skip to content

Commit df54509

Browse files
committed
faster tests
1 parent 5ea5e80 commit df54509

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

src/test/java/com/arangodb/springframework/AbstractArangoTest.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,25 @@
2020

2121
package com.arangodb.springframework;
2222

23-
import org.junit.After;
23+
import com.arangodb.springframework.core.ArangoOperations;
24+
import org.junit.AfterClass;
2425
import org.junit.Before;
2526
import org.junit.runner.RunWith;
2627
import org.springframework.beans.factory.annotation.Autowired;
2728
import org.springframework.test.context.ContextConfiguration;
2829
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
2930

30-
import com.arangodb.springframework.core.ArangoOperations;
31+
import javax.annotation.PostConstruct;
3132

3233
/**
3334
* @author Mark Vollmary
34-
*
3535
*/
3636
@RunWith(SpringJUnit4ClassRunner.class)
37-
@ContextConfiguration(classes = { ArangoTestConfiguration.class })
37+
@ContextConfiguration(classes = {ArangoTestConfiguration.class})
3838
public abstract class AbstractArangoTest {
3939

40+
private static volatile ArangoOperations staticTemplate;
41+
4042
@Autowired
4143
protected ArangoOperations template;
4244
protected final Class<?>[] collections;
@@ -48,17 +50,20 @@ protected AbstractArangoTest(final Class<?>... collections) {
4850

4951
@Before
5052
public void before() {
51-
try {
52-
for (final Class<?> collection : collections) {
53-
template.collection(collection).truncate();
54-
}
55-
} catch (final Exception e) {
53+
for (final Class<?> collection : collections) {
54+
template.collection(collection).truncate();
5655
}
5756
}
5857

59-
@After
60-
public void after() {
61-
template.dropDatabase();
58+
@AfterClass
59+
public static void afterClass() {
60+
staticTemplate.dropDatabase();
61+
}
62+
63+
64+
@PostConstruct
65+
private void postConstruct() {
66+
staticTemplate = template;
6267
}
6368

6469
}

src/test/java/com/arangodb/springframework/core/mapping/MultiTenancyDBLevelMappingTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ public void cleanup() {
8989
template.dropDatabase();
9090
tenantProvider.setId(TENANT01);
9191
template.dropDatabase();
92-
tenantProvider.setId("");
93-
template.dropDatabase();
9492
}
9593

9694
}

src/test/java/com/arangodb/springframework/core/template/ArangoTemplateTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,10 @@ public String getId() {
409409
public void upsertWithUserGeneratedKey() {
410410
final NewEntityTest entity = new NewEntityTest("test");
411411
template.upsert(entity, UpsertStrategy.REPLACE);
412-
assertThat(template.collection(NewEntityTest.class).count(), is(1L));
412+
assertThat(template.exists("test", NewEntityTest.class), is(true));
413413
entity.setPersisted(true);
414414
template.upsert(entity, UpsertStrategy.REPLACE);
415-
assertThat(template.collection(NewEntityTest.class).count(), is(1L));
415+
assertThat(template.exists("test", NewEntityTest.class), is(true));
416416
}
417417

418418
@SuppressWarnings("deprecation")

0 commit comments

Comments
 (0)