Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 4fa901a

Browse files
committed
fix db creation in tests
1 parent 719486a commit 4fa901a

File tree

3 files changed

+9
-46
lines changed

3 files changed

+9
-46
lines changed

src/main/java/com/arangodb/tinkerpop/gremlin/client/ArangoDBGraphClient.java

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -131,66 +131,24 @@ public static ArangoDBGraphException getNamingConventionError(String cause, Stri
131131
private final ArangoDBGraph graph;
132132

133133
/**
134-
* Create a simple graph client and connect to the provided db. If the DB does not exist, the driver will try to
135-
* create one.
134+
* Create a simple graph client and connect to the provided db.
136135
*
137136
* @param graph the ArangoDB graph that uses this client
138137
* @param properties the ArangoDB configuration properties
139138
* @param dbname the ArangoDB name to connect to or create
140139
* @throws ArangoDBGraphException If the db does not exist and cannot be created
141140
*/
142-
143-
public ArangoDBGraphClient(ArangoDBGraph graph, Properties properties, String dbname) {
144-
this(graph, properties, dbname, false);
145-
}
146-
147-
/**
148-
* Create a simple graph client and connect to the provided db. The create flag controls what is the
149-
* behaviour if the db is not found
150-
*
151-
* @param graph the ArangoDB graph that uses this client
152-
* @param properties the ArangoDB configuration properties
153-
* @param dbname the ArangoDB name to connect to or create
154-
* @param createDatabase if true, the driver will attempt to crate the DB if it does not exist
155-
* @throws ArangoDBGraphException If the db does not exist and cannot be created
156-
*/
157-
158141
public ArangoDBGraphClient(
159142
ArangoDBGraph graph,
160143
Properties properties,
161-
String dbname,
162-
boolean createDatabase)
144+
String dbname)
163145
throws ArangoDBGraphException {
164146
logger.debug("Initiating the ArangoDb Client");
165147
this.graph = graph;
166148
db = new ArangoDB.Builder()
167149
.loadProperties(ArangoConfigProperties.fromProperties(properties))
168150
.build()
169151
.db(dbname);
170-
if (createDatabase) {
171-
if (!db.exists()) {
172-
logger.debug("DB not found, attemtping to create it.");
173-
try {
174-
if (!db.create()) {
175-
throw new ArangoDBGraphException("Unable to crate the database " + dbname);
176-
}
177-
} catch (ArangoDBException ex) {
178-
throw ArangoDBExceptions.getArangoDBException(ex);
179-
}
180-
}
181-
} else {
182-
boolean exists = false;
183-
try {
184-
exists = db.exists();
185-
} catch (ArangoDBException ex) {
186-
// Pass
187-
}
188-
if (!exists) {
189-
logger.error("Database does not exist, or the user has no access");
190-
throw new ArangoDBGraphException(String.format("DB not found or user has no access: %s@%s",
191-
properties.getProperty("arangodb.user"), dbname));
192-
}
193-
}
194152
}
195153

196154
/**

src/main/java/com/arangodb/tinkerpop/gremlin/structure/ArangoDBGraph.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public ArangoDBGraph(Configuration configuration) {
534534
shouldPrefixCollectionNames = arangoConfig.getBoolean(PROPERTY_KEY_SHOULD_PREFIX_COLLECTION_NAMES, true);
535535

536536
Properties arangoProperties = ConfigurationConverter.getProperties(arangoConfig);
537-
client = new ArangoDBGraphClient(this, arangoProperties, arangoConfig.getString(PROPERTY_KEY_DB_NAME), shouldPrefixCollectionNames);
537+
client = new ArangoDBGraphClient(this, arangoProperties, arangoConfig.getString(PROPERTY_KEY_DB_NAME));
538538

539539
ArangoGraph graph = client.getArangoGraph();
540540
GraphCreateOptions options = new GraphCreateOptions();

src/test/java/com/arangodb/tinkerpop/gremlin/util/TestGraphClient.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
public class TestGraphClient extends ArangoDBGraphClient {
1111

1212
public TestGraphClient(Properties properties, String dbname) throws ArangoDBGraphException {
13-
super(null, properties, dbname, false);
13+
super(null, properties, dbname);
14+
if (!db.exists()) {
15+
if (!db.create()) {
16+
throw new ArangoDBGraphException("Unable to crate the database " + dbname);
17+
}
18+
}
1419
}
1520

1621
public void deleteGraph(String name) {

0 commit comments

Comments
 (0)