Skip to content

Commit 34d97dc

Browse files
UserUser
authored andcommitted
optimize tests (too many open http connections) -step 3
1 parent 7f71f93 commit 34d97dc

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

src/test/java/com/arangodb/ArangoTestSuite.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.arangodb;
1818

19+
import org.junit.AfterClass;
20+
import org.junit.BeforeClass;
1921
import org.junit.runner.RunWith;
2022
import org.junit.runners.Suite;
2123
import org.junit.runners.Suite.SuiteClasses;
@@ -121,4 +123,15 @@
121123

122124
public class ArangoTestSuite {
123125

126+
@BeforeClass
127+
public static void setup() {
128+
BaseTest.__setup();
129+
BaseTest.MANAGE_SETUP = false;
130+
}
131+
132+
@AfterClass
133+
public static void shutdown() {
134+
BaseTest.MANAGE_SETUP = true;
135+
BaseTest.__shutdown();
136+
}
124137
}

src/test/java/com/arangodb/BaseTest.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,37 @@ public abstract class BaseTest {
3030

3131
protected static final String DATABASE_NAME = "unitTestDatabase";
3232

33+
protected static boolean MANAGE_SETUP = true;
3334
protected static ArangoConfigure configure;
3435
protected static ArangoDriver driver;
3536

3637
@BeforeClass
3738
public static void __setup() {
38-
final ArangoConfigure configure = new ArangoConfigure();
39-
configure.setConnectRetryCount(2);
40-
configure.init();
41-
final ArangoDriver driver = new ArangoDriver(configure);
39+
if (MANAGE_SETUP) {
40+
final ArangoConfigure configure = new ArangoConfigure();
41+
configure.setConnectRetryCount(2);
42+
configure.init();
43+
final ArangoDriver driver = new ArangoDriver(configure);
4244

45+
BaseTest.driver = driver;
46+
BaseTest.configure = configure;
47+
}
4348
try {
4449
driver.createDatabase(DATABASE_NAME);
4550
} catch (final ArangoException e) {
4651
}
4752
driver.setDefaultDatabase(DATABASE_NAME);
48-
49-
BaseTest.driver = driver;
50-
BaseTest.configure = configure;
5153
}
5254

5355
@AfterClass
5456
public static void __shutdown() {
55-
try {
56-
driver.deleteDatabase(DATABASE_NAME);
57-
} catch (final ArangoException e) {
57+
if (MANAGE_SETUP) {
58+
try {
59+
driver.deleteDatabase(DATABASE_NAME);
60+
} catch (final ArangoException e) {
61+
}
62+
configure.shutdown();
5863
}
59-
configure.shutdown();
6064
}
6165

6266
protected boolean isMinimumVersion(final String version) throws ArangoException {

0 commit comments

Comments
 (0)