diff --git a/.travis.yml b/.travis.yml
index 64249c6cf..73119057d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,7 @@ language: java
before_script:
- chmod 777 ./tests/travis/setup_arangodb.sh
- ./tests/travis/setup_arangodb.sh
-
+
install: mvn install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B -V
jdk:
diff --git a/ChangeLog b/ChangeLog
index 44adbc2b8..ec7460157 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+v4.1.0 (2016-10-xx)
+---------------------------
+* changed VelocyStream communication (send protocol header)
+* added ArangoUtil for manually de-/serialization
+
v4.0.0 (2016-10-17)
---------------------------
* replaced API
diff --git a/README.md b/README.md
index a8798a6b3..091dc9cb8 100644
--- a/README.md
+++ b/README.md
@@ -1,62 +1,63 @@
-
-
-
-# arangodb-java-driver
-
-2.7: [](https://travis-ci.org/arangodb/arangodb-java-driver)
-3.0: [](https://travis-ci.org/arangodb/arangodb-java-driver)
-3.1: [](https://travis-ci.org/arangodb/arangodb-java-driver)
-4.0: [](https://travis-ci.org/arangodb/arangodb-java-driver)
-master: [](https://travis-ci.org/arangodb/arangodb-java-driver)
-
-## Supported versions
-
-
-arangodb-java-driver | ArangoDB | network protocol | Java version |
-4.0.x | 3.1.x | VelocyStream | 1.6+ |
-3.1.x | 3.1.x | HTTP | 1.6+ |
-3.0.x | 3.0.x | HTTP | 1.6+ |
-2.7.4 | 2.7.x and 2.8.x | HTTP | 1.6+ |
-
-
-## Maven
-
-To add the driver to your project with maven, add the following code to your pom.xml
-(please use a driver with a version number compatible to your ArangoDB server's version):
-
-ArangoDB 3.1.X
-```XML
-
-
- com.arangodb
- arangodb-java-driver
- 4.0.0
-
- ....
-
-```
-
-If you want to test with a snapshot version (e.g. 4.0.0-SNAPSHOT), add the staging repository of oss.sonatype.org to your pom.xml:
-
-```XML
-
-
- arangodb-snapshots
- https://oss.sonatype.org/content/groups/staging
-
-
-```
-
-## Compile java driver
-
-```
-mvn clean install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B
-```
-
-# Learn more
-* [ArangoDB](https://www.arangodb.com/)
-* [ChangeLog](ChangeLog)
-* [Documentation](docs/documentation.md)
-* [Examples](src/test/java/com/arangodb/example)
-* [Tutorial](https://www.arangodb.com/tutorial-java/)
-* [JavaDoc](http://arangodb.github.io/arangodb-java-driver/javadoc-4_0/index.html)
+
+
+
+# arangodb-java-driver
+
+2.7: [](https://travis-ci.org/arangodb/arangodb-java-driver)
+3.0: [](https://travis-ci.org/arangodb/arangodb-java-driver)
+3.1: [](https://travis-ci.org/arangodb/arangodb-java-driver)
+4.1: [](https://travis-ci.org/arangodb/arangodb-java-driver)
+master: [](https://travis-ci.org/arangodb/arangodb-java-driver)
+
+## Supported versions
+
+
+arangodb-java-driver | ArangoDB | network protocol | Java version |
+4.1.x | 3.1.x | VelocyStream | 1.6+ |
+4.0.0 | 3.1.0-RC1 to 3.1.0-RC3 | VelocyStream | 1.6+ |
+3.1.x | 3.1.x | HTTP | 1.6+ |
+3.0.x | 3.0.x | HTTP | 1.6+ |
+2.7.4 | 2.7.x and 2.8.x | HTTP | 1.6+ |
+
+
+## Maven
+
+To add the driver to your project with maven, add the following code to your pom.xml
+(please use a driver with a version number compatible to your ArangoDB server's version):
+
+ArangoDB 3.1.X
+```XML
+
+
+ com.arangodb
+ arangodb-java-driver
+ 4.1.0
+
+ ....
+
+```
+
+If you want to test with a snapshot version (e.g. 4.0.0-SNAPSHOT), add the staging repository of oss.sonatype.org to your pom.xml:
+
+```XML
+
+
+ arangodb-snapshots
+ https://oss.sonatype.org/content/groups/staging
+
+
+```
+
+## Compile java driver
+
+```
+mvn clean install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B
+```
+
+# Learn more
+* [ArangoDB](https://www.arangodb.com/)
+* [ChangeLog](ChangeLog)
+* [Documentation](docs/documentation.md)
+* [Examples](src/test/java/com/arangodb/example)
+* [Tutorial](https://www.arangodb.com/tutorials/tutorial-sync-java-driver/)
+* [JavaDoc](http://arangodb.github.io/arangodb-java-driver/javadoc-4_0/index.html)
diff --git a/docs/aql.md b/docs/aql.md
index d6a9ee28c..efca9fbca 100644
--- a/docs/aql.md
+++ b/docs/aql.md
@@ -39,3 +39,5 @@ or return the AQL result as VelocyPack:
System.out.println(obj.get("name").getAsString());
}
```
+
+**Note**: The parameter `type` in `query()` has to match the result of the query, otherwise you get an VPackParserException. E.g. you set `type` to `BaseDocument` or a POJO and the query result is an array or simple type, you get an VPackParserException caused by VPackValueTypeException: Expecting type OBJECT.
\ No newline at end of file
diff --git a/docs/serialization.md b/docs/serialization.md
index 28705ed41..026ef493a 100644
--- a/docs/serialization.md
+++ b/docs/serialization.md
@@ -1,75 +1,112 @@
-# serialization / deserialization
-## JavaBeans
-The driver can serialize/deserialize JavaBeans. They need at least a constructor without parameter.
-
-``` Java
- public class MyObject {
-
- private String name;
- private Gender gender;
- private int age;
-
- public MyObject() {
- super();
- }
-
- }
-```
-
-## internal fields
-To use Arango-internal fields (like _id, _key, _rev, _from, _to) in your JavaBeans, use the annotation `DocumentField`.
-
-``` Java
- public class MyObject {
-
- @DocumentField(Type.KEY)
- private String key;
-
- private String name;
- private Gender gender;
- private int age;
-
- public MyObject() {
- super();
- }
-
- }
-```
-
-## serialized fieldnames
-To use a different serialized name for a field, use the annotation `SerializedName`.
-
-``` Java
- public class MyObject {
-
- @SerializedName("title")
- private String name;
-
- private Gender gender;
- private int age;
-
- public MyObject() {
- super();
- }
-
- }
-```
-
-## ignore fields
-To ignore fields at serialization/deserialization, use the annotation `Expose`
-
-``` Java
- public class MyObject {
-
- @Expose
- private String name;
- @Expose(serialize = true, deserialize = false)
- private Gender gender;
- private int age;
-
- public MyObject() {
- super();
- }
-
- }
-```
+# serialization / deserialization
+## JavaBeans
+The driver can serialize/deserialize JavaBeans. They need at least a constructor without parameter.
+
+``` Java
+ public class MyObject {
+
+ private String name;
+ private Gender gender;
+ private int age;
+
+ public MyObject() {
+ super();
+ }
+
+ }
+```
+
+## internal fields
+To use Arango-internal fields (like _id, _key, _rev, _from, _to) in your JavaBeans, use the annotation `DocumentField`.
+
+``` Java
+ public class MyObject {
+
+ @DocumentField(Type.KEY)
+ private String key;
+
+ private String name;
+ private Gender gender;
+ private int age;
+
+ public MyObject() {
+ super();
+ }
+
+ }
+```
+
+## serialized fieldnames
+To use a different serialized name for a field, use the annotation `SerializedName`.
+
+``` Java
+ public class MyObject {
+
+ @SerializedName("title")
+ private String name;
+
+ private Gender gender;
+ private int age;
+
+ public MyObject() {
+ super();
+ }
+
+ }
+```
+
+## ignore fields
+To ignore fields at serialization/deserialization, use the annotation `Expose`
+
+``` Java
+ public class MyObject {
+
+ @Expose
+ private String name;
+ @Expose(serialize = true, deserialize = false)
+ private Gender gender;
+ private int age;
+
+ public MyObject() {
+ super();
+ }
+
+ }
+```
+
+## custom de-/serializer
+``` Java
+ ArangoDB arangoDB = new ArangoDB.Builder()
+ .registerDeserializer(MyObject.class, new VPackDeserializer() {
+ @Override
+ public MyObject deserialize(
+ final VPackSlice parent,
+ final VPackSlice vpack,
+ final VPackDeserializationContext context) throws VPackException {
+
+ final MyObject obj = new MyObject();
+ obj.setName(vpack.get("name").getAsString());
+ return obj;
+ }
+ }).registerSerializer(MyObject.class, new VPackSerializer() {
+ @Override
+ public void serialize(
+ final VPackBuilder builder,
+ final String attribute,
+ final MyObject value,
+ final VPackSerializationContext context) throws VPackException {
+
+ builder.add(attribute, ValueType.OBJECT);
+ builder.add("name", value.getName());
+ builder.close();
+ }
+ }).build();
+```
+
+## manually de-/serialization
+To de-/serialize from and to VelocyPack before or after a database call, use the `ArangoUtil` from the method `util()` in `ArangoDB`, `ArangoDatabase`, `ArangoCollection`, `ArangoGraph`, `ArangoEdgeCollection`or `ArangoVertexCollection`.
+
+``` Java
+ ArangoDB arangoDB = new ArangoDB.Builder();
+ arangoDB.util().deserialize(vpack, type);
+```
\ No newline at end of file
diff --git a/docs/setup.md b/docs/setup.md
index b2252d874..b3fd201c6 100644
--- a/docs/setup.md
+++ b/docs/setup.md
@@ -43,4 +43,14 @@ Example for arangodb.properties:
arangodb.user=root
arangodb.password=
+```
+
+## SSL
+
+To use SSL, you have to set the configuration `useSsl` to `true` and set a `SSLContext`. (see [example code](../src/test/java/com/arangodb/example/ssl/SslExample.java))
+
+``` Java
+
+ ArangoDB arangoDB = new ArangoDB.Builder().useSsl(true).sslContext(sc).build();
+
```
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 549d31afd..9d7f3ccb1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.arangodb
arangodb-java-driver
- 4.0.0
+ 4.1.0
2016
jar
diff --git a/src/main/java/com/arangodb/ArangoCursor.java b/src/main/java/com/arangodb/ArangoCursor.java
index bda830f0a..7c4515835 100644
--- a/src/main/java/com/arangodb/ArangoCursor.java
+++ b/src/main/java/com/arangodb/ArangoCursor.java
@@ -49,7 +49,7 @@ public class ArangoCursor implements Iterator, Closeable {
private final boolean cached;
private final ArangoCursorExecute execute;
- public ArangoCursor(final InternalArangoDatabase, ?, ?> db, final ArangoCursorExecute execute,
+ protected ArangoCursor(final InternalArangoDatabase, ?, ?> db, final ArangoCursorExecute execute,
final Class type, final CursorEntity result) {
super();
this.execute = execute;
diff --git a/src/main/java/com/arangodb/ArangoDB.java b/src/main/java/com/arangodb/ArangoDB.java
index 48ef297a7..25c56efb9 100644
--- a/src/main/java/com/arangodb/ArangoDB.java
+++ b/src/main/java/com/arangodb/ArangoDB.java
@@ -29,6 +29,7 @@
import com.arangodb.entity.ArangoDBVersion;
import com.arangodb.entity.LogEntity;
+import com.arangodb.entity.LogLevelEntity;
import com.arangodb.entity.UserEntity;
import com.arangodb.internal.ArangoDBConstants;
import com.arangodb.internal.ArangoExecutor.ResponseDeserializer;
@@ -173,8 +174,8 @@ public Builder registerDeserializer(final Class clazz, final VPackDeseria
return this;
}
- public Builder regitserInstanceCreator(final Class clazz, final VPackInstanceCreator creator) {
- vpackBuilder.regitserInstanceCreator(clazz, creator);
+ public Builder registerInstanceCreator(final Class clazz, final VPackInstanceCreator creator) {
+ vpackBuilder.registerInstanceCreator(clazz, creator);
return this;
}
@@ -230,7 +231,7 @@ public ArangoDatabase db(final String name) {
}
/**
- * creates a new database
+ * Creates a new database
*
* @see API
* Documentation
@@ -244,6 +245,8 @@ public Boolean createDatabase(final String name) throws ArangoDBException {
}
/**
+ * Retrieves a list of all existing databases
+ *
* @see API
* Documentation
* @return a list of all existing databases
@@ -254,6 +257,8 @@ public Collection getDatabases() throws ArangoDBException {
}
/**
+ * Retrieves a list of all databases the current user can access
+ *
* @see API
* Documentation
@@ -264,6 +269,22 @@ public Collection getAccessibleDatabases() throws ArangoDBException {
return executor.execute(getAccessibleDatabasesRequest(db().name()), getDatabaseResponseDeserializer());
}
+ /**
+ * List available database to the specified user
+ *
+ * @see API
+ * Documentation
+ * @param user
+ * The name of the user for which you want to query the databases
+ * @return
+ * @throws ArangoDBException
+ */
+ public Collection getAccessibleDatabasesFor(final String user) throws ArangoDBException {
+ return executor.execute(getAccessibleDatabasesForRequest(db().name(), user),
+ getAccessibleDatabasesForResponseDeserializer());
+ }
+
/**
* Returns the server name and version number.
*
@@ -415,4 +436,25 @@ public LogEntity getLogs(final LogOptions options) throws ArangoDBException {
return executor.execute(getLogsRequest(options), LogEntity.class);
}
+ /**
+ * Returns the server's current loglevel settings.
+ *
+ * @return the server's current loglevel settings
+ * @throws ArangoDBException
+ */
+ public LogLevelEntity getLogLevel() throws ArangoDBException {
+ return executor.execute(getLogLevelRequest(), LogLevelEntity.class);
+ }
+
+ /**
+ * Modifies and returns the server's current loglevel settings.
+ *
+ * @param entity
+ * loglevel settings
+ * @return the server's current loglevel settings
+ * @throws ArangoDBException
+ */
+ public LogLevelEntity setLogLevel(final LogLevelEntity entity) throws ArangoDBException {
+ return executor.execute(setLogLevelRequest(entity), LogLevelEntity.class);
+ }
}
diff --git a/src/main/java/com/arangodb/entity/LogLevelEntity.java b/src/main/java/com/arangodb/entity/LogLevelEntity.java
new file mode 100644
index 000000000..39552759c
--- /dev/null
+++ b/src/main/java/com/arangodb/entity/LogLevelEntity.java
@@ -0,0 +1,200 @@
+/*
+ * 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.entity;
+
+/**
+ * @author Mark - mark at arangodb.com
+ *
+ */
+public class LogLevelEntity {
+
+ public enum LogLevel {
+ FATAL, ERROR, WARNING, INFO, DEBUG, TRACE, DEFAULT;
+ }
+
+ private LogLevel agency;
+ private LogLevel agencycomm;
+ private LogLevel cluster;
+ private LogLevel collector;
+ private LogLevel communication;
+ private LogLevel compactor;
+ private LogLevel config;
+ private LogLevel datafiles;
+ private LogLevel graphs;
+ private LogLevel heartbeat;
+ private LogLevel mmap;
+ private LogLevel performance;
+ private LogLevel queries;
+ private LogLevel replication;
+ private LogLevel requests;
+ private LogLevel startup;
+ private LogLevel threads;
+ private LogLevel v8;
+
+ public LogLevelEntity() {
+ super();
+ }
+
+ public LogLevel getAgency() {
+ return agency;
+ }
+
+ public void setAgency(final LogLevel agency) {
+ this.agency = agency;
+ }
+
+ public LogLevel getAgencycomm() {
+ return agencycomm;
+ }
+
+ public void setAgencycomm(final LogLevel agencycomm) {
+ this.agencycomm = agencycomm;
+ }
+
+ public LogLevel getCluster() {
+ return cluster;
+ }
+
+ public void setCluster(final LogLevel cluster) {
+ this.cluster = cluster;
+ }
+
+ public LogLevel getCollector() {
+ return collector;
+ }
+
+ public void setCollector(final LogLevel collector) {
+ this.collector = collector;
+ }
+
+ public LogLevel getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(final LogLevel communication) {
+ this.communication = communication;
+ }
+
+ public LogLevel getCompactor() {
+ return compactor;
+ }
+
+ public void setCompactor(final LogLevel compactor) {
+ this.compactor = compactor;
+ }
+
+ public LogLevel getConfig() {
+ return config;
+ }
+
+ public void setConfig(final LogLevel config) {
+ this.config = config;
+ }
+
+ public LogLevel getDatafiles() {
+ return datafiles;
+ }
+
+ public void setDatafiles(final LogLevel datafiles) {
+ this.datafiles = datafiles;
+ }
+
+ public LogLevel getGraphs() {
+ return graphs;
+ }
+
+ public void setGraphs(final LogLevel graphs) {
+ this.graphs = graphs;
+ }
+
+ public LogLevel getHeartbeat() {
+ return heartbeat;
+ }
+
+ public void setHeartbeat(final LogLevel heartbeat) {
+ this.heartbeat = heartbeat;
+ }
+
+ public LogLevel getMmap() {
+ return mmap;
+ }
+
+ public void setMmap(final LogLevel mmap) {
+ this.mmap = mmap;
+ }
+
+ public LogLevel getPerformance() {
+ return performance;
+ }
+
+ public void setPerformance(final LogLevel performance) {
+ this.performance = performance;
+ }
+
+ public LogLevel getQueries() {
+ return queries;
+ }
+
+ public void setQueries(final LogLevel queries) {
+ this.queries = queries;
+ }
+
+ public LogLevel getReplication() {
+ return replication;
+ }
+
+ public void setReplication(final LogLevel replication) {
+ this.replication = replication;
+ }
+
+ public LogLevel getRequests() {
+ return requests;
+ }
+
+ public void setRequests(final LogLevel requests) {
+ this.requests = requests;
+ }
+
+ public LogLevel getStartup() {
+ return startup;
+ }
+
+ public void setStartup(final LogLevel startup) {
+ this.startup = startup;
+ }
+
+ public LogLevel getThreads() {
+ return threads;
+ }
+
+ public void setThreads(final LogLevel threads) {
+ this.threads = threads;
+ }
+
+ public LogLevel getV8() {
+ return v8;
+ }
+
+ public void setV8(final LogLevel v8) {
+ this.v8 = v8;
+ }
+
+}
diff --git a/src/main/java/com/arangodb/internal/ArangoDBConstants.java b/src/main/java/com/arangodb/internal/ArangoDBConstants.java
index f357d1c1c..234ba95cb 100644
--- a/src/main/java/com/arangodb/internal/ArangoDBConstants.java
+++ b/src/main/java/com/arangodb/internal/ArangoDBConstants.java
@@ -56,6 +56,7 @@ public class ArangoDBConstants {
public static final String PATH_API_QUERY_SLOW = "/_api/query/slow";
public static final String PATH_API_TRAVERSAL = "/_api/traversal";
public static final String PATH_API_ADMIN_LOG = "/_admin/log";
+ public static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level";
public static final String PATH_API_ADMIN_ROUTING_RELOAD = "/_admin/routing/reload";
public static final String ENCRYPTION_PLAIN = "plain";
diff --git a/src/main/java/com/arangodb/internal/ArangoExecuteable.java b/src/main/java/com/arangodb/internal/ArangoExecuteable.java
index 5fb27ee17..3a1b95292 100644
--- a/src/main/java/com/arangodb/internal/ArangoExecuteable.java
+++ b/src/main/java/com/arangodb/internal/ArangoExecuteable.java
@@ -21,6 +21,7 @@
package com.arangodb.internal;
import com.arangodb.internal.velocystream.Connection;
+import com.arangodb.util.ArangoUtil;
/**
* @author Mark - mark at arangodb.com
@@ -35,4 +36,7 @@ public ArangoExecuteable(final E executor) {
this.executor = executor;
}
+ public ArangoUtil util() {
+ return executor.util();
+ }
}
diff --git a/src/main/java/com/arangodb/internal/ArangoExecutor.java b/src/main/java/com/arangodb/internal/ArangoExecutor.java
index 1360bf677..db7dec023 100644
--- a/src/main/java/com/arangodb/internal/ArangoExecutor.java
+++ b/src/main/java/com/arangodb/internal/ArangoExecutor.java
@@ -22,17 +22,16 @@
import java.lang.reflect.Type;
import java.util.Map;
-import java.util.concurrent.Future;
import java.util.regex.Pattern;
import com.arangodb.ArangoDBException;
import com.arangodb.internal.velocystream.Communication;
import com.arangodb.internal.velocystream.Connection;
+import com.arangodb.util.ArangoUtil;
import com.arangodb.velocypack.VPack;
import com.arangodb.velocypack.VPackParser;
import com.arangodb.velocypack.VPackSlice;
import com.arangodb.velocypack.exception.VPackException;
-import com.arangodb.velocypack.exception.VPackParserException;
import com.arangodb.velocystream.Response;
/**
@@ -48,40 +47,24 @@ public static interface ResponseDeserializer {
private static final String REGEX_DOCUMENT_KEY = "[^/]+";
private static final String REGEX_DOCUMENT_ID = "[^/]+/[^/]+";
- protected final Communication communication;
- protected final VPack vpacker;
- protected final VPack vpackerNull;
- protected final VPackParser vpackParser;
- protected final DocumentCache documentCache;
- protected final CollectionCache collectionCache;
+ private final Communication communication;
+ private final DocumentCache documentCache;
+ private final CollectionCache collectionCache;
+ private final ArangoUtil util;
protected ArangoExecutor(final Communication communication, final VPack vpacker, final VPack vpackerNull,
final VPackParser vpackParser, final DocumentCache documentCache, final CollectionCache collectionCache) {
super();
this.communication = communication;
- this.vpacker = vpacker;
- this.vpackerNull = vpackerNull;
- this.vpackParser = vpackParser;
this.documentCache = documentCache;
this.collectionCache = collectionCache;
+ util = new ArangoUtil(vpacker, vpackerNull, vpackParser);
}
public Communication communication() {
return communication;
}
- protected VPack vpack() {
- return vpacker;
- }
-
- protected VPack vpackNull() {
- return vpackerNull;
- }
-
- protected VPackParser vpackParser() {
- return vpackParser;
- }
-
public DocumentCache documentCache() {
return documentCache;
}
@@ -90,6 +73,10 @@ protected CollectionCache collectionCache() {
return collectionCache;
}
+ protected ArangoUtil util() {
+ return util;
+ }
+
protected String createPath(final String... params) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < params.length; i++) {
@@ -117,94 +104,34 @@ protected void validateName(final String type, final String regex, final CharSeq
}
@SuppressWarnings("unchecked")
- protected T createResult(
- final VPack vpack,
- final VPackParser vpackParser,
- final Type type,
- final Response response) {
+ protected T createResult(final Type type, final Response response) {
return (T) ((type != Void.class && response.getBody() != null) ? deserialize(response.getBody(), type) : null);
}
- @SuppressWarnings("unchecked")
protected T deserialize(final VPackSlice vpack, final Type type) throws ArangoDBException {
- try {
- final T doc;
- if (type == String.class && !vpack.isString()) {
- doc = (T) vpackParser.toJson(vpack);
- } else {
- doc = vpacker.deserialize(vpack, type);
- }
- return doc;
- } catch (final VPackException e) {
- throw new ArangoDBException(e);
- }
+ return util.deserialize(vpack, type);
}
protected VPackSlice serialize(final Object entity) throws ArangoDBException {
- try {
- final VPackSlice vpack;
- if (String.class.isAssignableFrom(entity.getClass())) {
- vpack = vpackParser.fromJson((String) entity);
- } else {
- vpack = vpacker.serialize(entity);
- }
- return vpack;
- } catch (final VPackException e) {
- throw new ArangoDBException(e);
- }
+ return util.serialize(entity);
}
protected VPackSlice serialize(final Object entity, final boolean serializeNullValues) throws ArangoDBException {
- try {
- final VPackSlice vpack;
- if (String.class.isAssignableFrom(entity.getClass())) {
- vpack = vpackParser.fromJson((String) entity, serializeNullValues);
- } else {
- final VPack vp = serializeNullValues ? vpackerNull : vpacker;
- vpack = vp.serialize(entity);
- }
- return vpack;
- } catch (final VPackException e) {
- throw new ArangoDBException(e);
- }
+ return util.serialize(entity, serializeNullValues);
}
protected VPackSlice serialize(final Object entity, final Type type) throws ArangoDBException {
- try {
- return vpacker.serialize(entity, type);
- } catch (final VPackException e) {
- throw new ArangoDBException(e);
- }
+ return util.serialize(entity, type);
}
protected VPackSlice serialize(final Object entity, final Type type, final boolean serializeNullValues)
throws ArangoDBException {
- try {
- final VPack vp = serializeNullValues ? vpackerNull : vpacker;
- return vp.serialize(entity, type);
- } catch (final VPackException e) {
- throw new ArangoDBException(e);
- }
+ return util.serialize(entity, type, serializeNullValues);
}
protected VPackSlice serialize(final Object entity, final Type type, final Map additionalFields)
throws ArangoDBException {
- try {
- return vpacker.serialize(entity, type, additionalFields);
- } catch (final VPackParserException e) {
- throw new ArangoDBException(e);
- }
+ return util.serialize(entity, type, additionalFields);
}
- protected T unwrap(final Future future) throws ArangoDBException {
- try {
- return future.get();
- } catch (final Exception e) {
- final Throwable cause = e.getCause();
- if (cause != null && ArangoDBException.class.isAssignableFrom(cause.getClass())) {
- throw ArangoDBException.class.cast(cause);
- }
- throw new ArangoDBException(e);
- }
- }
}
diff --git a/src/main/java/com/arangodb/internal/ArangoExecutorSync.java b/src/main/java/com/arangodb/internal/ArangoExecutorSync.java
index cf3d1c43d..875607b18 100644
--- a/src/main/java/com/arangodb/internal/ArangoExecutorSync.java
+++ b/src/main/java/com/arangodb/internal/ArangoExecutorSync.java
@@ -47,7 +47,7 @@ public T execute(final Request request, final Type type) throws ArangoDBExce
return execute(request, new ResponseDeserializer() {
@Override
public T deserialize(final Response response) throws VPackException {
- return createResult(vpacker, vpackParser, type, response);
+ return createResult(type, response);
}
});
}
@@ -55,7 +55,7 @@ public T deserialize(final Response response) throws VPackException {
public T execute(final Request request, final ResponseDeserializer responseDeserializer)
throws ArangoDBException {
try {
- final Response response = communication.execute(request);
+ final Response response = communication().execute(request);
return responseDeserializer.deserialize(response);
} catch (final VPackException e) {
throw new ArangoDBException(e);
diff --git a/src/main/java/com/arangodb/internal/InternalArangoCollection.java b/src/main/java/com/arangodb/internal/InternalArangoCollection.java
index 7ca8c87e5..53b653f6f 100644
--- a/src/main/java/com/arangodb/internal/InternalArangoCollection.java
+++ b/src/main/java/com/arangodb/internal/InternalArangoCollection.java
@@ -106,7 +106,7 @@ public DocumentCreateEntity deserialize(final Response response) throws VPack
values.put(DocumentField.Type.ID, doc.getId());
values.put(DocumentField.Type.KEY, doc.getKey());
values.put(DocumentField.Type.REV, doc.getRev());
- executor.documentCache.setValues(value, values);
+ executor.documentCache().setValues(value, values);
return doc;
}
};
@@ -198,7 +198,7 @@ public DocumentUpdateEntity deserialize(final Response response) throws VPack
}
final Map values = new HashMap();
values.put(DocumentField.Type.REV, doc.getRev());
- executor.documentCache.setValues(value, values);
+ executor.documentCache().setValues(value, values);
return doc;
}
};
diff --git a/src/main/java/com/arangodb/internal/InternalArangoDB.java b/src/main/java/com/arangodb/internal/InternalArangoDB.java
index 954a4f8f0..fe2d5af4a 100644
--- a/src/main/java/com/arangodb/internal/InternalArangoDB.java
+++ b/src/main/java/com/arangodb/internal/InternalArangoDB.java
@@ -20,8 +20,12 @@
package com.arangodb.internal;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import com.arangodb.entity.LogLevelEntity;
import com.arangodb.entity.UserEntity;
import com.arangodb.internal.ArangoExecutor.ResponseDeserializer;
import com.arangodb.internal.velocystream.Connection;
@@ -86,6 +90,26 @@ protected Request getAccessibleDatabasesRequest(final String database) {
executor.createPath(ArangoDBConstants.PATH_API_DATABASE, ArangoDBConstants.USER));
}
+ protected Request getAccessibleDatabasesForRequest(final String database, final String user) {
+ return new Request(database, RequestType.GET,
+ executor.createPath(ArangoDBConstants.PATH_API_USER, user, ArangoDBConstants.DATABASE));
+ }
+
+ protected ResponseDeserializer> getAccessibleDatabasesForResponseDeserializer() {
+ return new ResponseDeserializer>() {
+ @Override
+ public Collection deserialize(final Response response) throws VPackException {
+ final VPackSlice result = response.getBody().get(ArangoDBConstants.RESULT);
+ final Collection dbs = new ArrayList();
+ for (final Iterator> iterator = result.objectIterator(); iterator
+ .hasNext();) {
+ dbs.add(iterator.next().getKey());
+ }
+ return dbs;
+ }
+ };
+ }
+
protected Request getVersionRequest() {
return new Request(ArangoDBConstants.SYSTEM, RequestType.GET, ArangoDBConstants.PATH_API_VERSION);
}
@@ -150,4 +174,14 @@ protected Request getLogsRequest(final LogOptions options) {
.putQueryParam(LogOptions.PROPERTY_SEARCH, params.getSearch())
.putQueryParam(LogOptions.PROPERTY_SORT, params.getSort());
}
+
+ protected Request getLogLevelRequest() {
+ return new Request(ArangoDBConstants.SYSTEM, RequestType.GET, ArangoDBConstants.PATH_API_ADMIN_LOG_LEVEL);
+ }
+
+ protected Request setLogLevelRequest(final LogLevelEntity entity) {
+ return new Request(ArangoDBConstants.SYSTEM, RequestType.PUT, ArangoDBConstants.PATH_API_ADMIN_LOG_LEVEL)
+ .setBody(executor.serialize(entity));
+ }
+
}
diff --git a/src/main/java/com/arangodb/internal/InternalArangoEdgeCollection.java b/src/main/java/com/arangodb/internal/InternalArangoEdgeCollection.java
index c42521b8e..6b23789e1 100644
--- a/src/main/java/com/arangodb/internal/InternalArangoEdgeCollection.java
+++ b/src/main/java/com/arangodb/internal/InternalArangoEdgeCollection.java
@@ -85,7 +85,7 @@ public EdgeEntity deserialize(final Response response) throws VPackException {
values.put(DocumentField.Type.ID, doc.getId());
values.put(DocumentField.Type.KEY, doc.getKey());
values.put(DocumentField.Type.REV, doc.getRev());
- executor.documentCache.setValues(value, values);
+ executor.documentCache().setValues(value, values);
return doc;
}
};
@@ -127,7 +127,7 @@ public EdgeUpdateEntity deserialize(final Response response) throws VPackExcepti
final EdgeUpdateEntity doc = executor.deserialize(body, EdgeUpdateEntity.class);
final Map values = new HashMap();
values.put(DocumentField.Type.REV, doc.getRev());
- executor.documentCache.setValues(value, values);
+ executor.documentCache().setValues(value, values);
return doc;
}
};
diff --git a/src/main/java/com/arangodb/internal/InternalArangoVertexCollection.java b/src/main/java/com/arangodb/internal/InternalArangoVertexCollection.java
index 455ac3919..4f2699642 100644
--- a/src/main/java/com/arangodb/internal/InternalArangoVertexCollection.java
+++ b/src/main/java/com/arangodb/internal/InternalArangoVertexCollection.java
@@ -90,7 +90,7 @@ public VertexEntity deserialize(final Response response) throws VPackException {
values.put(DocumentField.Type.ID, doc.getId());
values.put(DocumentField.Type.KEY, doc.getKey());
values.put(DocumentField.Type.REV, doc.getRev());
- executor.documentCache.setValues(value, values);
+ executor.documentCache().setValues(value, values);
return doc;
}
};
@@ -132,7 +132,7 @@ public VertexUpdateEntity deserialize(final Response response) throws VPackExcep
final VertexUpdateEntity doc = executor.deserialize(body, VertexUpdateEntity.class);
final Map values = new HashMap();
values.put(DocumentField.Type.REV, doc.getRev());
- executor.documentCache.setValues(value, values);
+ executor.documentCache().setValues(value, values);
return doc;
}
};
diff --git a/src/main/java/com/arangodb/internal/velocystream/Connection.java b/src/main/java/com/arangodb/internal/velocystream/Connection.java
index 7629de4f6..6be7dadb7 100644
--- a/src/main/java/com/arangodb/internal/velocystream/Connection.java
+++ b/src/main/java/com/arangodb/internal/velocystream/Connection.java
@@ -49,6 +49,7 @@
public abstract class Connection {
private static final Logger LOGGER = LoggerFactory.getLogger(Connection.class);
+ private static final byte[] PROTOCOL_HEADER = "VST/1.0\r\n\r\n".getBytes();
private final String host;
private final Integer port;
@@ -109,6 +110,7 @@ public synchronized void open() throws IOException {
}
((SSLSocket) socket).startHandshake();
}
+ sendProtocolHeader();
}
public synchronized void close() {
@@ -124,6 +126,14 @@ public synchronized void close() {
}
}
+ private void sendProtocolHeader() throws IOException {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(String.format("Send velocystream protocol header to %s", socket));
+ }
+ outputStream.write(PROTOCOL_HEADER);
+ outputStream.flush();
+ }
+
protected synchronized void writeIntern(final Message message, final Collection chunks) {
for (final Chunk chunk : chunks) {
try {
diff --git a/src/main/java/com/arangodb/model/GraphCreateOptions.java b/src/main/java/com/arangodb/model/GraphCreateOptions.java
index d05e0f88a..e5fe5c96f 100644
--- a/src/main/java/com/arangodb/model/GraphCreateOptions.java
+++ b/src/main/java/com/arangodb/model/GraphCreateOptions.java
@@ -88,6 +88,12 @@ public Boolean getIsSmart() {
return isSmart;
}
+ /**
+ *
+ * @param isSmart
+ * Define if the created graph should be smart. This only has effect in Enterprise version.
+ * @return options
+ */
public GraphCreateOptions isSmart(final Boolean isSmart) {
this.isSmart = isSmart;
return this;
@@ -97,16 +103,29 @@ public Integer getNumberOfShards() {
return getOptions().getNumberOfShards();
}
- public void numberOfShards(final Integer numberOfShards) {
+ /**
+ * @param numberOfShards
+ * The number of shards that is used for every collection within this graph. Cannot be modified later.
+ * @return options
+ */
+ public GraphCreateOptions numberOfShards(final Integer numberOfShards) {
getOptions().setNumberOfShards(numberOfShards);
+ return this;
}
public String getSmartGraphAttribute() {
return getOptions().getSmartGraphAttribute();
}
- public void smartGraphAttribute(final String smartGraphAttribute) {
+ /**
+ * @param smartGraphAttribute
+ * The attribute name that is used to smartly shard the vertices of a graph. Every vertex in this Graph
+ * has to have this attribute. Cannot be modified later.
+ * @return options
+ */
+ public GraphCreateOptions smartGraphAttribute(final String smartGraphAttribute) {
getOptions().setSmartGraphAttribute(smartGraphAttribute);
+ return this;
}
private SmartOptions getOptions() {
diff --git a/src/main/java/com/arangodb/util/ArangoUtil.java b/src/main/java/com/arangodb/util/ArangoUtil.java
new file mode 100644
index 000000000..9f9c8ee7a
--- /dev/null
+++ b/src/main/java/com/arangodb/util/ArangoUtil.java
@@ -0,0 +1,188 @@
+/*
+ * 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.util;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import com.arangodb.ArangoDBException;
+import com.arangodb.velocypack.VPack;
+import com.arangodb.velocypack.VPackParser;
+import com.arangodb.velocypack.VPackSlice;
+import com.arangodb.velocypack.exception.VPackException;
+import com.arangodb.velocypack.exception.VPackParserException;
+
+/**
+ * @author Mark - mark at arangodb.com
+ *
+ */
+public class ArangoUtil {
+
+ private final VPack vpacker;
+ private final VPack vpackerNull;
+ private final VPackParser vpackParser;
+
+ public ArangoUtil(final VPack vpacker, final VPack vpackerNull, final VPackParser vpackParser) {
+ super();
+ this.vpacker = vpacker;
+ this.vpackerNull = vpackerNull;
+ this.vpackParser = vpackParser;
+ }
+
+ /**
+ * Deserialze a given VelocPack to an instance of a given type
+ *
+ * @param vpack
+ * The VelocyPack to deserialize
+ * @param type
+ * The target type to deserialize to. Use String for raw Json.
+ * @return The deserialized VelocyPack
+ * @throws ArangoDBException
+ */
+ @SuppressWarnings("unchecked")
+ public T deserialize(final VPackSlice vpack, final Type type) throws ArangoDBException {
+ try {
+ final T doc;
+ if (type == String.class && !vpack.isString()) {
+ doc = (T) vpackParser.toJson(vpack);
+ } else {
+ doc = vpacker.deserialize(vpack, type);
+ }
+ return doc;
+ } catch (final VPackException e) {
+ throw new ArangoDBException(e);
+ }
+ }
+
+ /**
+ * Serialize a given Object to VelocyPack
+ *
+ * @param entity
+ * The Object to serialize. If it is from type String, it will be handled as a Json.
+ * @return The serialized VelocyPack
+ * @throws ArangoDBException
+ */
+ public VPackSlice serialize(final Object entity) throws ArangoDBException {
+ try {
+ final VPackSlice vpack;
+ if (String.class.isAssignableFrom(entity.getClass())) {
+ vpack = vpackParser.fromJson((String) entity);
+ } else {
+ vpack = vpacker.serialize(entity);
+ }
+ return vpack;
+ } catch (final VPackException e) {
+ throw new ArangoDBException(e);
+ }
+ }
+
+ /**
+ * Serialize a given Object to VelocyPack
+ *
+ * @param entity
+ * The Object to serialize. If it is from type String, it will be handled as a Json.
+ * @param serializeNullValues
+ * Whether or not null values should be excluded from serialization.
+ * @return the serialized VelocyPack
+ * @throws ArangoDBException
+ */
+ public VPackSlice serialize(final Object entity, final boolean serializeNullValues) throws ArangoDBException {
+ try {
+ final VPackSlice vpack;
+ if (String.class.isAssignableFrom(entity.getClass())) {
+ vpack = vpackParser.fromJson((String) entity, serializeNullValues);
+ } else {
+ final VPack vp = serializeNullValues ? vpackerNull : vpacker;
+ vpack = vp.serialize(entity);
+ }
+ return vpack;
+ } catch (final VPackException e) {
+ throw new ArangoDBException(e);
+ }
+ }
+
+ /**
+ * Serialize a given Object to VelocyPack. This method is for serialization of types with generic parameter like
+ * Collection, List, Map.
+ *
+ * @param entity
+ * The Object to serialize
+ * @param type
+ * The source type of the Object.
+ * @return the serialized VelocyPack
+ * @throws ArangoDBException
+ */
+ public VPackSlice serialize(final Object entity, final Type type) throws ArangoDBException {
+ try {
+ return vpacker.serialize(entity, type);
+ } catch (final VPackException e) {
+ throw new ArangoDBException(e);
+ }
+ }
+
+ /**
+ * Serialize a given Object to VelocyPack. This method is for serialization of types with generic parameter like
+ * Collection, List, Map.
+ *
+ * @param entity
+ * The Object to serialize
+ * @param type
+ * The source type of the Object.
+ * @param serializeNullValues
+ * Whether or not null values should be excluded from serialization.
+ * @return the serialized VelocyPack
+ * @throws ArangoDBException
+ */
+ public VPackSlice serialize(final Object entity, final Type type, final boolean serializeNullValues)
+ throws ArangoDBException {
+ try {
+ final VPack vp = serializeNullValues ? vpackerNull : vpacker;
+ return vp.serialize(entity, type);
+ } catch (final VPackException e) {
+ throw new ArangoDBException(e);
+ }
+ }
+
+ /**
+ * Serialize a given Object to VelocyPack. This method is for serialization of types with generic parameter like
+ * Collection, List, Map.
+ *
+ * @param entity
+ * The Object to serialize
+ * @param type
+ * The source type of the Object.
+ * @param serializeNullValues
+ * Whether or not null values should be excluded from serialization.
+ * @param additionalFields
+ * Additional Key/Value pairs to include in the created VelocyPack
+ * @return the serialized VelocyPack
+ * @throws ArangoDBException
+ */
+ public VPackSlice serialize(final Object entity, final Type type, final Map additionalFields)
+ throws ArangoDBException {
+ try {
+ return vpacker.serialize(entity, type, additionalFields);
+ } catch (final VPackParserException e) {
+ throw new ArangoDBException(e);
+ }
+ }
+
+}
diff --git a/src/main/java/com/arangodb/velocypack/VPack.java b/src/main/java/com/arangodb/velocypack/VPack.java
index b5fdb3c8c..15ba64a1f 100644
--- a/src/main/java/com/arangodb/velocypack/VPack.java
+++ b/src/main/java/com/arangodb/velocypack/VPack.java
@@ -161,7 +161,7 @@ public VPack.Builder registerDeserializer(
return this;
}
- public VPack.Builder regitserInstanceCreator(final Type type, final VPackInstanceCreator creator) {
+ public VPack.Builder registerInstanceCreator(final Type type, final VPackInstanceCreator creator) {
instanceCreators.put(type, creator);
return this;
}
diff --git a/src/test/java/com/arangodb/ArangoDBTest.java b/src/test/java/com/arangodb/ArangoDBTest.java
index 6ec0d2013..81f95606c 100644
--- a/src/test/java/com/arangodb/ArangoDBTest.java
+++ b/src/test/java/com/arangodb/ArangoDBTest.java
@@ -41,6 +41,7 @@
import com.arangodb.entity.ArangoDBVersion;
import com.arangodb.entity.LogEntity;
import com.arangodb.entity.LogLevel;
+import com.arangodb.entity.LogLevelEntity;
import com.arangodb.entity.UserEntity;
import com.arangodb.model.LogOptions;
import com.arangodb.model.LogOptions.SortOrder;
@@ -113,8 +114,17 @@ public void getAccessibleDatabases() {
final ArangoDB arangoDB = new ArangoDB.Builder().build();
final Collection dbs = arangoDB.getAccessibleDatabases();
assertThat(dbs, is(notNullValue()));
- assertThat(dbs.size(), is(1));
- assertThat(dbs.iterator().next(), is("_system"));
+ assertThat(dbs.size(), greaterThan(0));
+ assertThat(dbs, hasItem("_system"));
+ }
+
+ @Test
+ public void getAccessibleDatabasesFor() {
+ final ArangoDB arangoDB = new ArangoDB.Builder().build();
+ final Collection dbs = arangoDB.getAccessibleDatabasesFor("root");
+ assertThat(dbs, is(notNullValue()));
+ assertThat(dbs.size(), greaterThan(0));
+ assertThat(dbs, hasItem("_system"));
}
@Test
@@ -163,8 +173,7 @@ public void getUsersOnlyRoot() {
final ArangoDB arangoDB = new ArangoDB.Builder().build();
final Collection users = arangoDB.getUsers();
assertThat(users, is(notNullValue()));
- assertThat(users.size(), is(1));
- assertThat(users.iterator().next().getUser(), is(ROOT));
+ assertThat(users.size(), greaterThan(0));
}
@Test
@@ -361,4 +370,26 @@ public void getLogsSortDesc() {
}
}
+ @Test
+ public void getLogLevel() {
+ final ArangoDB arangoDB = new ArangoDB.Builder().build();
+ final LogLevelEntity logLevel = arangoDB.getLogLevel();
+ assertThat(logLevel, is(notNullValue()));
+ assertThat(logLevel.getAgency(), is(LogLevelEntity.LogLevel.INFO));
+ }
+
+ @Test
+ public void setLogLevel() {
+ final ArangoDB arangoDB = new ArangoDB.Builder().build();
+ final LogLevelEntity entity = new LogLevelEntity();
+ try {
+ entity.setAgency(LogLevelEntity.LogLevel.ERROR);
+ final LogLevelEntity logLevel = arangoDB.setLogLevel(entity);
+ assertThat(logLevel, is(notNullValue()));
+ assertThat(logLevel.getAgency(), is(LogLevelEntity.LogLevel.ERROR));
+ } finally {
+ entity.setAgency(LogLevelEntity.LogLevel.INFO);
+ arangoDB.setLogLevel(entity);
+ }
+ }
}
diff --git a/src/test/java/com/arangodb/ArangoDatabaseTest.java b/src/test/java/com/arangodb/ArangoDatabaseTest.java
index 9c5d2cc23..a5a0cc266 100644
--- a/src/test/java/com/arangodb/ArangoDatabaseTest.java
+++ b/src/test/java/com/arangodb/ArangoDatabaseTest.java
@@ -513,8 +513,8 @@ public void explainQuery() {
assertThat(plan.getCollections().size(), is(1));
assertThat(plan.getCollections().iterator().next().getName(), is("_apps"));
assertThat(plan.getCollections().iterator().next().getType(), is("read"));
- assertThat(plan.getEstimatedCost(), is(5));
- assertThat(plan.getEstimatedNrItems(), is(2));
+ assertThat(plan.getEstimatedCost(), greaterThan(0));
+ assertThat(plan.getEstimatedNrItems(), greaterThan(0));
assertThat(plan.getVariables().size(), is(1));
assertThat(plan.getVariables().iterator().next().getName(), is("i"));
assertThat(plan.getNodes().size(), is(3));
diff --git a/src/test/java/com/arangodb/util/ArangoUtilTest.java b/src/test/java/com/arangodb/util/ArangoUtilTest.java
new file mode 100644
index 000000000..c705e60a7
--- /dev/null
+++ b/src/test/java/com/arangodb/util/ArangoUtilTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.util;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.arangodb.ArangoDB;
+import com.arangodb.entity.BaseDocument;
+import com.arangodb.internal.ArangoExecutorSync;
+import com.arangodb.internal.InternalArangoDB;
+import com.arangodb.internal.velocystream.ConnectionSync;
+import com.arangodb.velocypack.Type;
+import com.arangodb.velocypack.VPackBuilder;
+import com.arangodb.velocypack.VPackSlice;
+import com.arangodb.velocypack.ValueType;
+import com.arangodb.velocystream.Response;
+
+/**
+ * @author Mark - mark at arangodb.com
+ *
+ */
+public class ArangoUtilTest {
+
+ private static ArangoUtil util;
+
+ @BeforeClass
+ public static void setup() {
+ final InternalArangoDB arangoDB = new ArangoDB.Builder().build();
+ util = arangoDB.util();
+ }
+
+ @Test
+ public void deseriarlize() {
+ final VPackBuilder builder = new VPackBuilder().add(ValueType.OBJECT).add("foo", "bar").close();
+ final BaseDocument doc = util.deserialize(builder.slice(), BaseDocument.class);
+ assertThat(doc.getAttribute("foo").toString(), is("bar"));
+ }
+
+ @Test
+ public void serialize() {
+ final BaseDocument entity = new BaseDocument();
+ entity.addAttribute("foo", "bar");
+ final VPackSlice vpack = util.serialize(entity);
+ assertThat(vpack.get("foo").isString(), is(true));
+ assertThat(vpack.get("foo").getAsString(), is("bar"));
+ }
+
+ @Test
+ public void serializeNullValues() {
+ final BaseDocument entity = new BaseDocument();
+ entity.addAttribute("foo", null);
+ final VPackSlice vpack = util.serialize(entity, true);
+ assertThat(vpack.get("foo").isNull(), is(true));
+ }
+
+ @Test
+ public void serializeType() {
+ final Collection list = new ArrayList();
+ list.add(new BaseDocument());
+ list.add(new BaseDocument());
+
+ final VPackSlice vpack = util.serialize(list, new Type>() {
+ }.getType());
+ assertThat(vpack.isArray(), is(true));
+ assertThat(vpack.getLength(), is(list.size()));
+ }
+
+}
diff --git a/src/test/java/com/arangodb/util/MapBuilderTest.java b/src/test/java/com/arangodb/util/MapBuilderTest.java
new file mode 100644
index 000000000..12832ecc1
--- /dev/null
+++ b/src/test/java/com/arangodb/util/MapBuilderTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.util;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+/**
+ * @author Mark - mark at arangodb.com
+ *
+ */
+public class MapBuilderTest {
+
+ @Test
+ public void build() {
+ final Map map = new MapBuilder().put("foo", "bar").get();
+ assertThat(map.size(), is(1));
+ assertThat(map.get("foo"), is(notNullValue()));
+ assertThat(map.get("foo").toString(), is("bar"));
+ }
+}
diff --git a/src/test/java/com/arangodb/velocypack/VPackSerializeDeserializeTest.java b/src/test/java/com/arangodb/velocypack/VPackSerializeDeserializeTest.java
index eb121b8dd..ac81e66eb 100644
--- a/src/test/java/com/arangodb/velocypack/VPackSerializeDeserializeTest.java
+++ b/src/test/java/com/arangodb/velocypack/VPackSerializeDeserializeTest.java
@@ -1279,7 +1279,7 @@ public void toInterface() throws VPackException {
}
final VPackSlice slice = builder.slice();
final VPack vPack = new VPack.Builder()
- .regitserInstanceCreator(TestEntityD.class, new VPackInstanceCreator() {
+ .registerInstanceCreator(TestEntityD.class, new VPackInstanceCreator() {
@Override
public TestEntityD createInstance() {
return new TestEntityDImpl();
diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml
index 425b55ef8..645d34624 100644
--- a/src/test/resources/logback-test.xml
+++ b/src/test/resources/logback-test.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/tests/travis/setup_arangodb.sh b/tests/travis/setup_arangodb.sh
index 0f3c1c4a9..a4c6ce749 100755
--- a/tests/travis/setup_arangodb.sh
+++ b/tests/travis/setup_arangodb.sh
@@ -29,9 +29,8 @@ echo "Starting ArangoDB '${ARANGOD}'"
${ARANGOD} \
--database.directory ${TMP_DIR} \
--configuration none \
- --server.endpoint vpp+tcp://127.0.0.1:8529 \
- --server.endpoint vpp+ssl://127.0.0.1:8530 \
- --server.endpoint tcp://127.0.0.1:8531 \
+ --server.endpoint tcp://127.0.0.1:8529 \
+ --server.endpoint ssl://127.0.0.1:8530 \
--ssl.keyfile ./server.pem \
--javascript.app-path ${ARANGODB_DIR}/js/apps \
--javascript.startup-directory ${ARANGODB_DIR}/js \
@@ -48,8 +47,8 @@ if [ "x$process" == "x" ]; then
exit 1
fi
-echo "Waiting until ArangoDB is ready on port 8531"
-while [[ -z `curl -uroot: -s 'http://127.0.0.1:8531/_api/version' ` ]] ; do
+echo "Waiting until ArangoDB is ready on port 8529"
+while [[ -z `curl -uroot: -s 'http://127.0.0.1:8529/_api/version' ` ]] ; do
echo -n "."
sleep 2s
done