diff --git a/src/main/java/com/arangodb/async/ArangoDBAsync.java b/src/main/java/com/arangodb/async/ArangoDBAsync.java index b86c66ec3..888e616c8 100644 --- a/src/main/java/com/arangodb/async/ArangoDBAsync.java +++ b/src/main/java/com/arangodb/async/ArangoDBAsync.java @@ -44,6 +44,7 @@ import com.arangodb.internal.util.ArangoSerializerImpl; import com.arangodb.internal.util.DefaultArangoSerialization; import com.arangodb.internal.velocystream.VstCommunicationSync; +import com.arangodb.internal.velocystream.VstConnectionFactorySync; import com.arangodb.model.DBCreateOptions; import com.arangodb.model.LogOptions; import com.arangodb.model.UserCreateOptions; @@ -775,12 +776,22 @@ public synchronized ArangoDBAsync build() { final int max = maxConnections != null ? Math.max(1, maxConnections) : ArangoDefaults.MAX_CONNECTIONS_VST_DEFAULT; - final ConnectionFactory connectionFactory = new VstConnectionFactoryAsync(host, timeout, connectionTtl, + final ConnectionFactory syncConnectionFactory = new VstConnectionFactorySync(host, timeout, connectionTtl, keepAliveInterval, useSsl, sslContext); - final HostResolver hostResolver = createHostResolver(createHostList(max, connectionFactory), max, - connectionFactory); - final HostHandler hostHandler = createHostHandler(hostResolver); - return new ArangoDBAsyncImpl(asyncBuilder(hostHandler), util, syncBuilder(hostHandler), hostResolver, + final ConnectionFactory asyncConnectionFactory = new VstConnectionFactoryAsync(host, timeout, connectionTtl, + keepAliveInterval, useSsl, sslContext); + final HostResolver syncHostResolver = createHostResolver(createHostList(max, syncConnectionFactory), max, + syncConnectionFactory); + final HostResolver asyncHostResolver = createHostResolver(createHostList(max, asyncConnectionFactory), max, + asyncConnectionFactory); + final HostHandler syncHostHandler = createHostHandler(syncHostResolver); + final HostHandler asyncHostHandler = createHostHandler(asyncHostResolver); + return new ArangoDBAsyncImpl( + asyncBuilder(asyncHostHandler), + util, + syncBuilder(syncHostHandler), + asyncHostResolver, + syncHostResolver, new ArangoContext()); } diff --git a/src/main/java/com/arangodb/async/internal/ArangoDBAsyncImpl.java b/src/main/java/com/arangodb/async/internal/ArangoDBAsyncImpl.java index 04183570b..d2c6ff2f0 100644 --- a/src/main/java/com/arangodb/async/internal/ArangoDBAsyncImpl.java +++ b/src/main/java/com/arangodb/async/internal/ArangoDBAsyncImpl.java @@ -52,17 +52,24 @@ public class ArangoDBAsyncImpl extends InternalArangoDB imp private final CommunicationProtocol cp; - public ArangoDBAsyncImpl(final VstCommunicationAsync.Builder commBuilder, final ArangoSerializationFactory util, - final VstCommunicationSync.Builder syncbuilder, final HostResolver hostResolver, final ArangoContext context) { + public ArangoDBAsyncImpl( + final VstCommunicationAsync.Builder asyncCommBuilder, + final ArangoSerializationFactory util, + final VstCommunicationSync.Builder syncCommBuilder, + final HostResolver asyncHostResolver, + final HostResolver syncHostResolver, + final ArangoContext context + ) { - super(new ArangoExecutorAsync(commBuilder.build(util.get(Serializer.INTERNAL)), util, new DocumentCache()), util, context); + super(new ArangoExecutorAsync(asyncCommBuilder.build(util.get(Serializer.INTERNAL)), util, new DocumentCache()), util, context); - final VstCommunication cacheCom = syncbuilder.build(util.get(Serializer.INTERNAL)); + final VstCommunication cacheCom = syncCommBuilder.build(util.get(Serializer.INTERNAL)); cp = new VstProtocol(cacheCom); ArangoExecutorSync arangoExecutorSync = new ArangoExecutorSync(cp, util, new DocumentCache()); - hostResolver.init(arangoExecutorSync, util.get(Serializer.INTERNAL)); + asyncHostResolver.init(arangoExecutorSync, util.get(Serializer.INTERNAL)); + syncHostResolver.init(arangoExecutorSync, util.get(Serializer.INTERNAL)); } diff --git a/src/test/java/com/arangodb/async/ArangoDBTest.java b/src/test/java/com/arangodb/async/ArangoDBTest.java index edbfee5c2..25f23a022 100644 --- a/src/test/java/com/arangodb/async/ArangoDBTest.java +++ b/src/test/java/com/arangodb/async/ArangoDBTest.java @@ -54,9 +54,6 @@ public class ArangoDBTest { private static final String USER = "mit dem mund"; private static final String PW = "machts der hund"; - @ClassRule - public static TestRule acquireHostListRule = TestUtils.acquireHostListRule; - private boolean isEnterprise() { final ArangoDB arangoDB = new ArangoDB.Builder().build(); return arangoDB.getVersion().getLicense() == License.ENTERPRISE; @@ -74,7 +71,7 @@ private boolean isAtLeastVersion(final int major, final int minor) { @Test public void getVersion() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.getVersion() .whenComplete((version, ex) -> { assertThat(version, is(notNullValue())); @@ -86,7 +83,7 @@ public void getVersion() throws InterruptedException, ExecutionException { @Test(timeout = 2000) public void nestedGetVersion() { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); for (int i = 0; i < 100; i++) { try { arangoDB.getVersion() @@ -129,7 +126,7 @@ public void nestedGetVersion() { @Test public void createDatabase() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.createDatabase(BaseTest.TEST_DB) .whenComplete((result, ex) -> assertThat(result, is(true))) .get(); @@ -141,7 +138,7 @@ public void createDatabaseWithOptions() throws ExecutionException, InterruptedEx assumeTrue(isCluster()); assumeTrue(isAtLeastVersion(3, 6)); - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final String dbName = "testDB-" + UUID.randomUUID().toString(); final Boolean resultCreate = arangoDB.createDatabase(new DBCreateOptions() .name(dbName) @@ -169,7 +166,7 @@ public void createDatabaseWithOptionsSatellite() throws ExecutionException, Inte assumeTrue(isEnterprise()); assumeTrue(isAtLeastVersion(3, 6)); - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final String dbName = "testDB-" + UUID.randomUUID().toString(); final Boolean resultCreate = arangoDB.createDatabase(new DBCreateOptions() .name(dbName) @@ -193,7 +190,7 @@ public void createDatabaseWithOptionsSatellite() throws ExecutionException, Inte @Test public void deleteDatabase() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final Boolean resultCreate = arangoDB.createDatabase(BaseTest.TEST_DB).get(); assertThat(resultCreate, is(true)); arangoDB.db(BaseTest.TEST_DB).drop() @@ -203,7 +200,7 @@ public void deleteDatabase() throws InterruptedException, ExecutionException { @Test public void getDatabases() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); Collection dbs = arangoDB.getDatabases().get(); assertThat(dbs, is(notNullValue())); assertThat(dbs.size(), is(greaterThan(0))); @@ -219,7 +216,7 @@ public void getDatabases() throws InterruptedException, ExecutionException { @Test public void getAccessibleDatabases() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.getAccessibleDatabases() .whenComplete((dbs, ex) -> { assertThat(dbs, is(notNullValue())); @@ -231,7 +228,7 @@ public void getAccessibleDatabases() throws InterruptedException, ExecutionExcep @Test public void getAccessibleDatabasesFor() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.getAccessibleDatabasesFor("root") .whenComplete((dbs, ex) -> { assertThat(dbs, is(notNullValue())); @@ -244,7 +241,7 @@ public void getAccessibleDatabasesFor() throws InterruptedException, ExecutionEx @Test public void createUser() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); try { arangoDB.createUser(USER, PW, null) .whenComplete((result, ex) -> { @@ -259,14 +256,14 @@ public void createUser() throws InterruptedException, ExecutionException { @Test public void deleteUser() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.createUser(USER, PW, null).get(); arangoDB.deleteUser(USER).get(); } @Test public void getUserRoot() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.getUser(ROOT) .whenComplete((user, ex) -> { assertThat(user, is(notNullValue())); @@ -277,7 +274,7 @@ public void getUserRoot() throws InterruptedException, ExecutionException { @Test public void getUser() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); try { arangoDB.createUser(USER, PW, null).get(); arangoDB.getUser(USER) @@ -291,7 +288,7 @@ public void getUser() throws InterruptedException, ExecutionException { @Test public void getUsersOnlyRoot() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.getUsers() .whenComplete((users, ex) -> { assertThat(users, is(notNullValue())); @@ -302,7 +299,7 @@ public void getUsersOnlyRoot() throws InterruptedException, ExecutionException { @Test public void getUsers() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); try { arangoDB.createUser(USER, PW, null).get(); arangoDB.getUsers() @@ -322,7 +319,7 @@ public void getUsers() throws InterruptedException, ExecutionException { @Test public void updateUserNoOptions() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); try { arangoDB.createUser(USER, PW, null).get(); arangoDB.updateUser(USER, null).get(); @@ -333,7 +330,7 @@ public void updateUserNoOptions() throws InterruptedException, ExecutionExceptio @Test public void updateUser() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); try { final Map extra = new HashMap<>(); extra.put("hund", false); @@ -364,7 +361,7 @@ public void updateUser() throws InterruptedException, ExecutionException { @Test public void replaceUser() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); try { final Map extra = new HashMap<>(); extra.put("hund", false); @@ -397,7 +394,7 @@ public void replaceUser() throws InterruptedException, ExecutionException { @Test public void updateUserDefaultDatabaseAccess() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); try { arangoDB.createUser(USER, PW).get(); arangoDB.grantDefaultDatabaseAccess(USER, Permissions.RW).get(); @@ -408,7 +405,7 @@ public void updateUserDefaultDatabaseAccess() throws InterruptedException, Execu @Test public void updateUserDefaultCollectionAccess() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); try { arangoDB.createUser(USER, PW).get(); arangoDB.grantDefaultCollectionAccess(USER, Permissions.RW).get(); @@ -419,7 +416,7 @@ public void updateUserDefaultCollectionAccess() throws InterruptedException, Exe @Test public void authenticationFailPassword() throws InterruptedException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).password("no").build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().password("no").build(); try { arangoDB.getVersion().get(); fail(); @@ -430,7 +427,7 @@ public void authenticationFailPassword() throws InterruptedException { @Test public void authenticationFailUser() throws InterruptedException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).user("no").build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().user("no").build(); try { arangoDB.getVersion().get(); fail(); @@ -441,7 +438,19 @@ public void authenticationFailUser() throws InterruptedException { @Test public void execute() throws VPackException, InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); + arangoDB + .execute(new Request("_system", RequestType.GET, "/_api/version")) + .whenComplete((response, ex) -> { + assertThat(response.getBody(), is(notNullValue())); + assertThat(response.getBody().get("version").isString(), is(true)); + }) + .get(); + } + + @Test + public void execute_acquireHostList_enabled() throws VPackException, InterruptedException, ExecutionException { + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(true).build(); arangoDB .execute(new Request("_system", RequestType.GET, "/_api/version")) .whenComplete((response, ex) -> { @@ -453,7 +462,7 @@ public void execute() throws VPackException, InterruptedException, ExecutionExce @Test public void getLogs() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.getLogs(null) .whenComplete((logs, ex) -> { assertThat(logs, is(notNullValue())); @@ -468,7 +477,7 @@ public void getLogs() throws InterruptedException, ExecutionException { @Test public void getLogsUpto() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final LogEntity logs = arangoDB.getLogs(null).get(); arangoDB.getLogs(new LogOptions().upto(LogLevel.WARNING)) .whenComplete((logsUpto, ex) -> { @@ -481,7 +490,7 @@ public void getLogsUpto() throws InterruptedException, ExecutionException { @Test public void getLogsLevel() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final LogEntity logs = arangoDB.getLogs(null).get(); arangoDB.getLogs(new LogOptions().level(LogLevel.INFO)) .whenComplete((logsInfo, ex) -> { @@ -494,7 +503,7 @@ public void getLogsLevel() throws InterruptedException, ExecutionException { @Test public void getLogsStart() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final LogEntity logs = arangoDB.getLogs(null).get(); assertThat(logs.getLid(), not(empty())); arangoDB.getLogs(new LogOptions().start(logs.getLid().get(0) + 1)) @@ -507,7 +516,7 @@ public void getLogsStart() throws InterruptedException, ExecutionException { @Test public void getLogsSize() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final LogEntity logs = arangoDB.getLogs(null).get(); assertThat(logs.getLid().size(), greaterThan(0)); arangoDB.getLogs(new LogOptions().size(logs.getLid().size() - 1)) @@ -520,7 +529,7 @@ public void getLogsSize() throws InterruptedException, ExecutionException { @Test public void getLogsOffset() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final LogEntity logs = arangoDB.getLogs(null).get(); assertThat(logs.getTotalAmount(), greaterThan(0L)); arangoDB.getLogs(new LogOptions().offset((int) (logs.getTotalAmount() - 1))) @@ -533,7 +542,7 @@ public void getLogsOffset() throws InterruptedException, ExecutionException { @Test public void getLogsSearch() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final LogEntity logs = arangoDB.getLogs(null).get(); arangoDB.getLogs(new LogOptions().search(BaseTest.TEST_DB)) .whenComplete((logsSearch, ex) -> { @@ -545,7 +554,7 @@ public void getLogsSearch() throws InterruptedException, ExecutionException { @Test public void getLogsSortAsc() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.getLogs(new LogOptions().sort(SortOrder.asc)) .whenComplete((logs, ex) -> { assertThat(logs, is(notNullValue())); @@ -560,7 +569,7 @@ public void getLogsSortAsc() throws InterruptedException, ExecutionException { @Test public void getLogsSortDesc() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.getLogs(new LogOptions().sort(SortOrder.desc)) .whenComplete((logs, ex) -> { assertThat(logs, is(notNullValue())); @@ -575,7 +584,7 @@ public void getLogsSortDesc() throws InterruptedException, ExecutionException { @Test public void getLogLevel() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.getLogLevel() .whenComplete((logLevel, ex) -> { assertThat(logLevel, is(notNullValue())); @@ -586,7 +595,7 @@ public void getLogLevel() throws InterruptedException, ExecutionException { @Test public void setLogLevel() throws InterruptedException, ExecutionException { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final LogLevelEntity entity = new LogLevelEntity(); try { entity.setAgency(LogLevelEntity.LogLevel.ERROR); diff --git a/src/test/java/com/arangodb/async/ArangoSslTest.java b/src/test/java/com/arangodb/async/ArangoSslTest.java index 7bf67adc4..a520b3fe1 100644 --- a/src/test/java/com/arangodb/async/ArangoSslTest.java +++ b/src/test/java/com/arangodb/async/ArangoSslTest.java @@ -68,7 +68,7 @@ public void connect() throws Exception { final SSLContext sc = SSLContext.getInstance("TLS"); sc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false) + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder() .loadProperties(ArangoSslTest.class.getResourceAsStream("/arangodb-ssl.properties")).useSsl(true) .sslContext(sc).build(); final ArangoDBVersion version = arangoDB.getVersion().get(); @@ -79,7 +79,7 @@ public void connect() throws Exception { @Ignore public void connectWithoutValidSslContext() throws Exception { try { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false) + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder() .loadProperties(ArangoSslTest.class.getResourceAsStream("/arangodb-ssl.properties")).useSsl(true) .build(); arangoDB.getVersion().get(); diff --git a/src/test/java/com/arangodb/async/BaseTest.java b/src/test/java/com/arangodb/async/BaseTest.java index af0e7e27f..f30438070 100644 --- a/src/test/java/com/arangodb/async/BaseTest.java +++ b/src/test/java/com/arangodb/async/BaseTest.java @@ -40,13 +40,10 @@ public abstract class BaseTest { static ArangoDBAsync arangoDB; static ArangoDatabaseAsync db; - @ClassRule - public static TestRule acquireHostListRule = TestUtils.acquireHostListRule; - @BeforeClass public static void init() throws InterruptedException, ExecutionException { if (arangoDB == null) { - arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + arangoDB = new ArangoDBAsync.Builder().build(); } if (arangoDB.db(TEST_DB).exists().get()) { diff --git a/src/test/java/com/arangodb/async/CommunicationTest.java b/src/test/java/com/arangodb/async/CommunicationTest.java index f4bdfc647..11477a130 100644 --- a/src/test/java/com/arangodb/async/CommunicationTest.java +++ b/src/test/java/com/arangodb/async/CommunicationTest.java @@ -36,7 +36,7 @@ public class CommunicationTest { @Test @Ignore public void disconnect() { - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); final CompletableFuture> result = arangoDB.db().query("return sleep(1)", null, null, null); arangoDB.shutdown(); diff --git a/src/test/java/com/arangodb/async/ConcurrencyTest.java b/src/test/java/com/arangodb/async/ConcurrencyTest.java index be51f1377..07bcbe4b5 100644 --- a/src/test/java/com/arangodb/async/ConcurrencyTest.java +++ b/src/test/java/com/arangodb/async/ConcurrencyTest.java @@ -42,7 +42,7 @@ public class ConcurrencyTest { @Before public void initialize() { - arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + arangoDB = new ArangoDBAsync.Builder().build(); } /** diff --git a/src/test/java/com/arangodb/async/TestUtils.java b/src/test/java/com/arangodb/async/TestUtils.java deleted file mode 100644 index 53a02e485..000000000 --- a/src/test/java/com/arangodb/async/TestUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * DISCLAIMER - * - * Copyright 2016 ArangoDB GmbH, Cologne, Germany - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright holder is ArangoDB GmbH, Cologne, Germany - */ - - -package com.arangodb.async; - - -import org.junit.rules.TestRule; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import static org.junit.Assume.assumeTrue; - -/** - * @author Michele Rastelli - */ -class TestUtils { - static final TestRule acquireHostListRule = (base, description) -> { - assumeTrue(!TestUtils.isAcquireHostList()); - return base; - }; - - private static boolean isAcquireHostList() { - InputStream in = TestUtils.class.getResourceAsStream("/arangodb.properties"); - final Properties properties = new Properties(); - try { - properties.load(in); - } catch (IOException e) { - e.printStackTrace(); - return false; - } - return Boolean.parseBoolean(String.valueOf(properties.get("arangodb.acquireHostList"))); - } - -} diff --git a/src/test/java/com/arangodb/async/debug/ConsolidationIntervalMsec.java b/src/test/java/com/arangodb/async/debug/ConsolidationIntervalMsec.java index 8bb5c1a42..1b0a83b4e 100644 --- a/src/test/java/com/arangodb/async/debug/ConsolidationIntervalMsec.java +++ b/src/test/java/com/arangodb/async/debug/ConsolidationIntervalMsec.java @@ -48,7 +48,7 @@ public class ConsolidationIntervalMsec extends BaseTest { public void consolidationIntervalMsec() throws ExecutionException, InterruptedException { assumeTrue(isAtLeastVersion(3, 4)); - ArangoDBAsync arango = new ArangoDBAsync.Builder().acquireHostList(false) + ArangoDBAsync arango = new ArangoDBAsync.Builder() .user("root") .password("test") .build(); diff --git a/src/test/java/com/arangodb/async/example/ExampleBase.java b/src/test/java/com/arangodb/async/example/ExampleBase.java index 7937db7c7..abf1ffaaa 100644 --- a/src/test/java/com/arangodb/async/example/ExampleBase.java +++ b/src/test/java/com/arangodb/async/example/ExampleBase.java @@ -41,7 +41,7 @@ public class ExampleBase { @BeforeClass public static void setUp() throws InterruptedException, ExecutionException { - arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + arangoDB = new ArangoDBAsync.Builder().build(); if (arangoDB.db(DB_NAME).exists().get()) { arangoDB.db(DB_NAME).drop().get(); } diff --git a/src/test/java/com/arangodb/async/example/graph/AQLActorsAndMoviesExample.java b/src/test/java/com/arangodb/async/example/graph/AQLActorsAndMoviesExample.java index 66c9c04cb..2601df202 100644 --- a/src/test/java/com/arangodb/async/example/graph/AQLActorsAndMoviesExample.java +++ b/src/test/java/com/arangodb/async/example/graph/AQLActorsAndMoviesExample.java @@ -53,7 +53,7 @@ public class AQLActorsAndMoviesExample { @BeforeClass public static void setUp() throws InterruptedException, ExecutionException { - arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + arangoDB = new ArangoDBAsync.Builder().build(); if (arangoDB.db(TEST_DB).exists().get()) { arangoDB.db(TEST_DB).drop().get(); } diff --git a/src/test/java/com/arangodb/async/example/graph/BaseGraphTest.java b/src/test/java/com/arangodb/async/example/graph/BaseGraphTest.java index b96e6dbf7..ac5621891 100644 --- a/src/test/java/com/arangodb/async/example/graph/BaseGraphTest.java +++ b/src/test/java/com/arangodb/async/example/graph/BaseGraphTest.java @@ -46,7 +46,7 @@ public abstract class BaseGraphTest { @BeforeClass public static void init() throws InterruptedException, ExecutionException { if (arangoDB == null) { - arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).build(); + arangoDB = new ArangoDBAsync.Builder().build(); } if (arangoDB.db(TEST_DB).exists().get()) { arangoDB.db(TEST_DB).drop().get(); diff --git a/src/test/java/com/arangodb/async/example/ssl/SslExample.java b/src/test/java/com/arangodb/async/example/ssl/SslExample.java index 6e211416d..e7b3b2148 100644 --- a/src/test/java/com/arangodb/async/example/ssl/SslExample.java +++ b/src/test/java/com/arangodb/async/example/ssl/SslExample.java @@ -66,7 +66,7 @@ public void connect() throws Exception { final SSLContext sc = SSLContext.getInstance("TLS"); sc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false) + final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder() .loadProperties(SslExample.class.getResourceAsStream("/arangodb-ssl.properties")).useSsl(true) .sslContext(sc).build(); final ArangoDBVersion version = arangoDB.getVersion().get(); diff --git a/src/test/java/com/arangodb/async/serde/CustomSerdeTest.java b/src/test/java/com/arangodb/async/serde/CustomSerdeTest.java index 96f00770b..19d49a063 100644 --- a/src/test/java/com/arangodb/async/serde/CustomSerdeTest.java +++ b/src/test/java/com/arangodb/async/serde/CustomSerdeTest.java @@ -60,7 +60,7 @@ public void init() throws ExecutionException, InterruptedException { mapper.configure(WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED, true); mapper.configure(USE_BIG_INTEGER_FOR_INTS, true); }); - ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().acquireHostList(false).serializer(arangoJack).build(); + ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().serializer(arangoJack).build(); String TEST_DB = "custom-serde-test"; db = arangoDB.db(TEST_DB);