-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added configuration parameter serdeProviderClass
- Loading branch information
Showing
11 changed files
with
146 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
test-functional/src/test/resources/arangodb-config-test.properties
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
test-non-functional/src/test/java/serde/SerdeConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package serde; | ||
|
||
import com.arangodb.ArangoDB; | ||
import com.arangodb.config.ArangoConfigProperties; | ||
import com.arangodb.serde.ArangoSerde; | ||
import com.arangodb.serde.jackson.internal.JacksonSerdeImpl; | ||
import com.arangodb.serde.jackson.json.JacksonJsonSerdeProvider; | ||
import com.arangodb.serde.jackson.vpack.JacksonVPackSerdeProvider; | ||
import com.arangodb.serde.jsonb.JsonbSerde; | ||
import com.arangodb.serde.jsonb.JsonbSerdeProvider; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.lang.invoke.VarHandle; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class SerdeConfigurationTest { | ||
private final VarHandle JACKSON_SERDE_IMPL_MAPPER; | ||
{ | ||
try { | ||
JACKSON_SERDE_IMPL_MAPPER = MethodHandles | ||
.privateLookupIn(JacksonSerdeImpl.class, MethodHandles.lookup()) | ||
.findVarHandle(JacksonSerdeImpl.class, "mapper", ObjectMapper.class); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Test | ||
void vpackSerdeProvider() { | ||
ArangoDB adb = new ArangoDB.Builder() | ||
.host("foo", 1111) | ||
.serdeProviderClass(JacksonVPackSerdeProvider.class) | ||
.build(); | ||
|
||
ArangoSerde serde = adb.getSerde().getUserSerde(); | ||
assertThat(serde).isInstanceOf(JacksonSerdeImpl.class); | ||
|
||
ObjectMapper mapper = (ObjectMapper) JACKSON_SERDE_IMPL_MAPPER.get(serde); | ||
assertThat(mapper.getFactory().getFormatName()).isEqualTo("Velocypack"); | ||
} | ||
|
||
@Test | ||
void jsonSerdeProvider() { | ||
ArangoDB adb = new ArangoDB.Builder() | ||
.host("foo", 1111) | ||
.serdeProviderClass(JacksonJsonSerdeProvider.class) | ||
.build(); | ||
|
||
ArangoSerde serde = adb.getSerde().getUserSerde(); | ||
assertThat(serde).isInstanceOf(JacksonSerdeImpl.class); | ||
|
||
ObjectMapper mapper = (ObjectMapper) JACKSON_SERDE_IMPL_MAPPER.get(serde); | ||
assertThat(mapper.getFactory().getFormatName()).isEqualTo("JSON"); | ||
} | ||
|
||
|
||
@Test | ||
void jsonBSerdeProvider() { | ||
ArangoDB adb = new ArangoDB.Builder() | ||
.host("foo", 1111) | ||
.serdeProviderClass(JsonbSerdeProvider.class) | ||
.build(); | ||
|
||
ArangoSerde serde = adb.getSerde().getUserSerde(); | ||
assertThat(serde).isInstanceOf(JsonbSerde.class); | ||
} | ||
|
||
@Test | ||
void jsonBSerdeProviderFromConfigFile() { | ||
ArangoDB adb = new ArangoDB.Builder() | ||
.loadProperties(ArangoConfigProperties.fromFile("arangodb-serde-provider.properties")) | ||
.build(); | ||
|
||
ArangoSerde serde = adb.getSerde().getUserSerde(); | ||
assertThat(serde).isInstanceOf(JsonbSerde.class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test-non-functional/src/test/resources/arangodb-serde-provider.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
arangodb.hosts=172.28.0.1:8529 | ||
arangodb.password=test | ||
arangodb.serdeProviderClass=com.arangodb.serde.jsonb.JsonbSerdeProvider |