8000 [DE-707] fix VPACK support (#297) · arangodb/spring-data@02f3acc · GitHub
[go: up one dir, main page]

Skip to content

Commit 02f3acc

Browse files
authored
[DE-707] fix VPACK support (#297)
* added content-type configuration to support VPACK * CI: added protocol test matrix * archuint tests: deps on internal classes (DE-764) * updated arangodb-java-driver to version 7.5.0 * updated javadoc
1 parent dc567e6 commit 02f3acc

File tree

6 files changed

+116
-45
lines changed

6 files changed

+116
-45
lines changed

.github/workflows/maven.yml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ jobs:
2929
fail-fast: false
3030
matrix:
3131
docker-img:
32-
- docker.io/arangodb/arangodb:3.9.11
33-
- docker.io/arangodb/arangodb:3.10.10
34-
- docker.io/arangodb/arangodb:3.11.3
32+
- docker.io/arangodb/arangodb:3.10.12
33+
- docker.io/arangodb/arangodb:3.11.6
3534
topology:
3635
- single
3736
- cluster
38-
- activefailover
3937

4038
steps:
4139
- uses: actions/checkout@v3
@@ -50,14 +48,45 @@ jobs:
5048
- name: Start Database
5149
run: ./docker/start_db.sh
5250
env:
53-
ARANGO_LICENSE_KEY: ${{ secrets.ARANGO_LICENSE_KEY }}
5451
STARTER_MODE: ${{ matrix.topology }}
5552
DOCKER_IMAGE: ${{ matrix.docker-img }}
5653
- name: Info
5754
run: mvn -version
5855
- name: Test
5956
run: mvn --no-transfer-progress test
6057

58+
test-protocols:
59+
60+
timeout-minutes: 20
61+
runs-on: ubuntu-latest
62+
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
protocol:
67+
- 'VST'
68+
- 'HTTP_VPACK'
69+
- 'HTTP_JSON'
70+
- 'HTTP2_VPACK'
71+
- 'HTTP2_JSON'
72+
73+
steps:
74+
- uses: actions/checkout@v3
75+
with:
76+
fetch-depth: 0
77+
- name: Set up JDK
78+
uses: actions/setup-java@v3
79+
with:
80+
java-version: 17
81+
distribution: 'adopt'
82+
cache: maven
83+
- name: Start Database
84+
run: ./docker/start_db.sh
85+
- name: Info
86+
run: mvn -version
87+
- name: Test
88+
run: mvn --no-transfer-progress test -Darangodb.protocol=${{matrix.protocol}}
89+
6190
test-spring-boot-versions:
6291

6392
timeout-minutes: 20
@@ -66,11 +95,6 @@ jobs:
6695
strategy:
6796
fail-fast: false
6897
matrix:
69-
docker-img:
70-
- docker.io/arangodb/arangodb:3.11.3
71-
topology:
72-
- single
73-
- cluster
7498
spring-boot-version:
7599
- 3.0.10
76100
- 3.1.3
@@ -87,10 +111,6 @@ jobs:
87111
cache: maven
88112
- name: Start Database
89113
run: ./docker/start_db.sh
90-
env:
91-
ARANGO_LICENSE_KEY: ${{ secrets.ARANGO_LICENSE_KEY }}
92-
STARTER_MODE: ${{ matrix.topology }}
93-
DOCKER_IMAGE: ${{ matrix.docker-img }}
94114
- name: Info
95115
run: mvn -version
96116
- name: Install

integration-tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.arangodb</groupId>
3232
<artifactId>jackson-dataformat-velocypack</artifactId>
33-
<version>4.1.0</version>
33+
<version>4.2.0</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>org.springframework.boot</groupId>

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<properties>
5757
<java-module-name>com.arangodb.springframework</java-module-name>
5858
<jaxb.version>2.3.1</jaxb.version> <!-- fix dependency convergence-->
59-
<arangodb.version>7.4.0</arangodb.version>
59+
<arangodb.version>7.5.0</arangodb.version>
6060
<slf4j>2.0.7</slf4j>
6161
</properties>
6262

@@ -267,6 +267,11 @@
267267
<version>1.5.0</version>
268268
<scope>test</scope>
269269
</dependency>
270+
<dependency>
271+
<groupId>com.tngtech.archunit</groupId>
272+
<artifactId>archunit-junit5</artifactId>
273+
<version>1.2.1</version>
274+
</dependency>
270275
</dependencies>
271276

272277
<dependencyManagement>

src/main/java/com/arangodb/springframework/config/ArangoConfiguration.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import java.util.Optional;
1111
import java.util.Set;
1212

13+
import com.arangodb.ContentType;
1314
import com.arangodb.serde.ArangoSerde;
15+
import com.arangodb.serde.jackson.JacksonMapperProvider;
1416
import com.fasterxml.jackson.core.JsonProcessingException;
1517
import com.fasterxml.jackson.databind.ObjectMapper;
1618
import org.springframework.context.annotation.Bean;
@@ -58,6 +60,18 @@ public interface ArangoConfiguration {
5860

5961
String database();
6062

63+
/**
64+
* Override to set the data format to use in {@link #serde()}. It must match the content-type required by the
65+
* protocol used in the driver, e.g. set to {@link ContentType#VPACK} for protocols
66+
* {@link com.arangodb.Protocol#VST}, {@link com.arangodb.Protocol#HTTP_VPACK} and
67+
* {@link com.arangodb.Protocol#HTTP2_VPACK}, or set to {@link ContentType#VPACK} otherwise.
68+
*
69+
* @return the content-type to use in {@link #serde()}
70+
*/
71+
default ContentType contentType() {
72+
return ContentType.JSON;
73+
}
74+
6175
@Bean
6276
default ArangoOperations arangoTemplate() throws Exception {
6377
return new ArangoTemplate(arango().serde(serde()).build(), database(), arangoConverter(), resolverFactory());
@@ -66,7 +80,7 @@ default ArangoOperations arangoTemplate() throws Exception {
6680
@Bean
6781
default ArangoSerde serde() throws Exception {
6882
return new ArangoSerde() {
69-
private final ObjectMapper om = new ObjectMapper();
83+
private final ObjectMapper om = JacksonMapperProvider.of(contentType());
7084
private final ArangoConverter converter = arangoConverter();
7185

7286
@Override

src/test/java/arch/InternalsTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package arch;
2+
3+
import com.tngtech.archunit.core.importer.ImportOption;
4+
import com.tngtech.archunit.junit.AnalyzeClasses;
5+
import com.tngtech.archunit.junit.ArchTest;
6+
import com.tngtech.archunit.lang.ArchRule;
7+
8+
import static com.tngtech.archunit.core.domain.JavaClass.Predicates.resideInAPackage;
9+
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
10+
11+
@AnalyzeClasses(packages = "com.arangodb.springframework..", importOptions = {ImportOption.DoNotIncludeTests.class})
12+
public class InternalsTest {
13+
@ArchTest
14+
public static final ArchRule noInternalDependency = noClasses().that()
15+
.resideInAPackage("com.arangodb.springframework..")
16+
.should().dependOnClassesThat()
17+
.areAssignableTo(resideInAPackage("..internal.."));
18+
19+
}

src/test/java/com/arangodb/springframework/ArangoTestConfiguration.java

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121
package com.arangodb.springframework;
2222

2323
import com.arangodb.ArangoDB;
24+
import com.arangodb.ContentType;
25+
import com.arangodb.Protocol;
2426
import com.arangodb.config.ArangoConfigProperties;
27+
import com.arangodb.internal.serde.ContentTypeFactory;
2528
import com.arangodb.springframework.annotation.EnableArangoAuditing;
2629
import com.arangodb.springframework.annotation.EnableArangoRepositories;
2730
import com.arangodb.springframework.config.ArangoConfiguration;
2831
import com.arangodb.springframework.core.mapping.CustomMappingTest;
2932
import com.arangodb.springframework.testdata.Person;
33+
import org.springframework.beans.factory.annotation.Value;
3034
import org.springframework.context.annotation.Bean;
3135
import org.springframework.context.annotation.ComponentScan;
3236
import org.springframework.context.annotation.Configuration;
@@ -37,44 +41,53 @@
3741
import java.util.Collection;
3842

3943
/**
40-
*
4144
* @author Mark Vollmary
4245
* @author Christian Lechner
4346
*/
4447
@Configuration
45-
@ComponentScan({ "com.arangodb.springframework.component", "com.arangodb.springframework.core.mapping.event" })
48+
@ComponentScan({"com.arangodb.springframework.component", "com.arangodb.springframework.core.mapping.event"})
4649
@EnableArangoRepositories(basePackages = {
47-
"com.arangodb.springframework.repository",
48-
"com.arangodb.springframework.example.polymorphic.repository",
49-
"com.arangodb.springframework.debug.repository"},
50-
namedQueriesLocation = "classpath*:arango-named-queries-test.properties")
50+
"com.arangodb.springframework.repository",
51+
"com.arangodb.springframework.example.polymorphic.repository",
52+
"com.arangodb.springframework.debug.repository"},
53+
namedQueriesLocation = "classpath*:arango-named-queries-test.properties")
5154
@EnableArangoAuditing(auditorAwareRef = "auditorProvider")
5255
public class ArangoTestConfiguration implements ArangoConfiguration {
5356

54-
public static final String DB = "spring-test-db";
57+
public static final String DB = "spring-test-db";
58+
59+
@Value("${arangodb.protocol:HTTP2_JSON}")
60+
private Protocol protocol;
61+
62+
@Override
63+
public ArangoDB.Builder arango() {
64+
return new ArangoDB.Builder()
65+
.loadProperties(ArangoConfigProperties.fromFile())
66+
.protocol(protocol);
67+
}
5568

56-
@Override
57-
public ArangoDB.Builder arango() {
58-
return new ArangoDB.Builder().loadProperties(ArangoConfigProperties.fromFile());
59-
}
69+
@Override
70+
public ContentType contentType() {
71+
return ContentTypeFactory.of(protocol);
72+
}
6073

61-
@Override
62-
public String database() {
63-
return DB;
64-
}
74+
@Override
75+
public String database() {
76+
return DB;
77+
}
6578

66-
@Override
67-
public Collection<Converter<?, ?>> customConverters() {
68-
final Collection<Converter<?, ?>> converters = new ArrayList<>();
69-
converters.add(new CustomMappingTest.CustomJsonNodeReadTestConverter());
70-
converters.add(new CustomMappingTest.CustomJsonNodeWriteTestConverter());
71-
converters.add(new CustomMappingTest.CustomDBEntityReadTestConverter());
72-
converters.add(new CustomMappingTest.CustomDBEntityWriteTestConverter());
73-
return converters;
74-
}
79+
@Override
80+
public Collection<Converter<?, ?>> customConverters() {
81+
final Collection<Converter<?, ?>> converters = new ArrayList<>();
82+
converters.add(new CustomMappingTest.CustomJsonNodeReadTestConverter());
83+
converters.add(new CustomMappingTest.CustomJsonNodeWriteTestConverter());
84+
converters.add(new CustomMappingTest.CustomDBEntityReadTestConverter());
85+
converters.add(new CustomMappingTest.CustomDBEntityWriteTestConverter());
86+
return converters;
87+
}
7588

76-
@Bean
77-
public AuditorAware<Person> auditorProvider() {
78-
return new AuditorProvider();
79-
}
89+
@Bean
90+
public AuditorAware<Person> auditorProvider() {
91+
return new AuditorProvider();
92+
}
8093
}

0 commit comments

Comments
 (0)
0