Skip to content

Commit 97a4fc7

Browse files
authored
[DE-50] tests refactoring (#425)
* migration from Hamcrest to AssertJ * migration from Junit4 to Junit5 * native image tests
1 parent b0da77d commit 97a4fc7

File tree

102 files changed

+11868
-12111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+11868
-12111
lines changed

.github/workflows/maven.yml

+2-40
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,18 @@ jobs:
5454
with:
5555
java-version: ${{matrix.java-version}}
5656
distribution: 'adopt'
57+
cache: maven
5758
- name: Start Database
5859
run: ./docker/start_db.sh
5960
env:
6061
ARANGO_LICENSE_KEY: ${{ secrets.ARANGO_LICENSE_KEY }}
6162
STARTER_MODE: ${{matrix.topology}}
6263
DOCKER_IMAGE: ${{matrix.docker-img}}
6364
DATABASE_EXTENDED_NAMES: ${{matrix.db-ext-names}}
64-
- name: Cache local Maven repository
65-
uses: actions/cache@v2
66-
with:
67-
path: ~/.m2/repository
68-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
69-
restore-keys: ${{ runner.os }}-maven-
7065
- name: Info
7166
run: mvn -version
7267
- name: Test
7368
run: mvn --no-transfer-progress test -DargLine="-Duser.language=${{matrix.user-language}}"
74-
- name: Collect docker logs on failure
75-
if: ${{ cancelled() || failure() }}
76-
uses: jwalton/gh-docker-logs@v1
77-
with:
78-
dest: './logs'
79-
- name: Tar logs
80-
if: ${{ cancelled() || failure() }}
81-
run: tar cvzf ./logs.tgz ./logs
82-
- name: Upload logs to GitHub
83-
if: ${{ cancelled() || failure() }}
84-
uses: actions/upload-artifact@master
85-
with:
86-
name: logs-${{github.job}}.tgz
87-
path: ./logs.tgz
8869

8970
# test encodeURIComponent() and normalize('NFC') comparing to Javascript behavior
9071
test-graalvm:
@@ -128,19 +109,14 @@ jobs:
128109
with:
129110
java-version: ${{matrix.java-version}}
130111
distribution: 'adopt'
112+
cache: maven
131113
- name: Start Database
132114
run: ./docker/start_db.sh
133115
env:
134116
ARANGO_LICENSE_KEY: ${{ secrets.ARANGO_LICENSE_KEY }}
135117
STARTER_MODE: ${{matrix.topology}}
136118
DOCKER_IMAGE: ${{matrix.docker-img}}
137119
DATABASE_EXTENDED_NAMES: ${{matrix.db-ext-names}}
138-
- name: Cache local Maven repository
139-
uses: actions/cache@v2
140-
with:
141-
path: ~/.m2/repository
142-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
143-
restore-keys: ${{ runner.os }}-maven-
144120
- name: Set JWT
145121
run: |
146122
ENDPOINT=$(./docker/find_active_endpoint.sh)
@@ -152,17 +128,3 @@ jobs:
152128
run: mvn -version
153129
- name: Test
154130
run: mvn --no-transfer-progress test -DargLine="-Duser.language=${{matrix.user-language}}"
155-
- name: Collect docker logs on failure
156-
if: ${{ cancelled() || failure() }}
157-
uses: jwalton/gh-docker-logs@v1
158-
with:
159-
dest: './logs'
160-
- name: Tar logs
161-
if: ${{ cancelled() || failure() }}
162-
run: tar cvzf ./logs.tgz ./logs
163-
- name: Upload logs to GitHub
164-
if: ${{ cancelled() || failure() }}
165-
uses: actions/upload-artifact@master
166-
with:
167-
name: logs.tgz
168-
path: ./logs.tgz

.github/workflows/native.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Native Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags: [ v** ]
7+
8+
jobs:
9+
test-native:
10+
timeout-minutes: 20
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
docker-img:
17+
- docker.io/arangodb/enterprise:3.9.0
18+
topology:
19+
- cluster
20+
db-ext-names:
21+
- false
22+
java-version:
23+
- 11
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: graalvm/setup-graalvm@v1
28+
with:
29+
version: 'latest'
30+
java-version: ${{matrix.java-version}}
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
components: 'native-image'
33+
- name: Start Database
34+
run: ./docker/start_db.sh
35+
env:
36+
ARANGO_LICENSE_KEY: ${{ secrets.ARANGO_LICENSE_KEY }}
37+
STARTER_MODE: ${{matrix.topology}}
38+
DOCKER_IMAGE: ${{matrix.docker-img}}
39+
DATABASE_EXTENDED_NAMES: ${{matrix.db-ext-names}}
40+
- name: Info
41+
run: mvn -version
42+
- name: Test Native
43+
run: mvn -Pnative --no-transfer-progress test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
/docker/jwtSecret
1111

1212
/docker/data
13+
/test-results-native/

dev-README.md

+13
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,16 @@
33
## native image reflection configuration
44

55
To generate reflection configuration run `helper.NativeImageHelper` and copy the generated json to `src/main/resources/META-INF/native-image/com.arangodb/arangodb-java-driver/reflect-config.json`.
6+
7+
8+
## test native
9+
10+
```shell
11+
mvn -Pnative test
12+
```
13+
14+
## test ssl
15+
16+
```shell
17+
mvn test -Dtest=com.arangodb.ArangoSslTest -DSslTest=true
18+
```

pom.xml

+41-11
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,40 @@
5858
<doclint>none</doclint>
5959
</properties>
6060
</profile>
61+
<profile>
62+
<id>native</id>
63+
<build>
64+
<plugins>
65+
<plugin>
66+
<groupId>org.apache.maven.plugins</groupId>
67+
<artifactId>maven-surefire-plugin</artifactId>
68+
<version>3.0.0-M5</version>
69+
</plugin>
70+
<plugin>
71+
<groupId>org.graalvm.buildtools</groupId>
72+
<artifactId>native-maven-plugin</artifactId>
73+
<version>0.9.11</version>
74+
<extensions>true</extensions>
75+
<executions>
76+
<execution>
77+
<id>test-native</id>
78+
<goals>
79+
<goal>generateTestResourceConfig</goal>
80+
<goal>test</goal>
81+
</goals>
82+
<phase>test</phase>
83+
</execution>
84+
</executions>
85+
<configuration>
86+
<skip>false</skip>
87+
<buildArgs>
88+
<buildArg>--no-fallback</buildArg>
89+
</buildArgs>
90+
</configuration>
91+
</plugin>
92+
</plugins>
93+
</build>
94+
</profile>
6195
</profiles>
6296

6397
<build>
@@ -145,7 +179,7 @@
145179
<plugin>
146180
<groupId>org.apache.maven.plugins</groupId>
147181
<artifactId>maven-surefire-plugin</artifactId>
148-
<version>2.22.2</version>
182+
<version>3.0.0-M5</version>
149183
<configuration>
150184
<includes>
151185
<include>**/*Test.java</include>
@@ -214,13 +248,14 @@
214248
<scope>test</scope>
215249
</dependency>
216250
<dependency>
217-
<groupId>org.junit.vintage</groupId>
218-
<artifactId>junit-vintage-engine</artifactId>
251+
<groupId>org.junit.jupiter</groupId>
252+
<artifactId>junit-jupiter-params</artifactId>
219253
<scope>test</scope>
220254
</dependency>
221255
<dependency>
222-
<groupId>org.hamcrest</groupId>
223-
<artifactId>hamcrest-all</artifactId>
256+
<groupId>org.assertj</groupId>
257+
<artifactId>assertj-core</artifactId>
258+
<version>3.22.0</version>
224259
<scope>test</scope>
225260
</dependency>
226261
<dependency>
@@ -232,7 +267,7 @@
232267
<dependency>
233268
<groupId>org.graalvm.sdk</groupId>
234269
<artifactId>graal-sdk</artifactId>
235-
<version>21.2.0</version>
270+
<version>22.0.0.2</version>
236271
<scope>test</scope>
237272
</dependency>
238273
</dependencies>
@@ -286,11 +321,6 @@
286321
<type>pom</type>
287322
<scope>import</scope>
288323
</dependency>
289-
<dependency>
290-
<groupId>org.hamcrest</groupId>
291-
<artifactId>hamcrest-all</artifactId>
292-
<version>1.3</version>
293-
</dependency>
294324
</dependencies>
295325
</dependencyManagement>
296326

src/main/java/com/arangodb/entity/EdgeDefinition.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public EdgeDefinition satellites(final String... satellites) {
7878
return this;
7979
}
8080

81-
private static class Options {
81+
public static class Options {
8282
private Collection<String> satellites;
8383
}
8484
}

src/main/java/com/arangodb/entity/arangosearch/AnalyzerEntity.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
package com.arangodb.entity.arangosearch;
2222

23+
import java.util.Collection;
24+
import java.util.HashSet;
2325
import java.util.Map;
2426
import java.util.Set;
2527

@@ -30,7 +32,7 @@
3032
@Deprecated
3133
public class AnalyzerEntity {
3234

33-
private Set<AnalyzerFeature> features;
35+
private Collection<AnalyzerFeature> features;
3436
private AnalyzerType type;
3537
private String name;
3638
private Map<String, Object> properties;
@@ -39,7 +41,7 @@ public AnalyzerEntity() {
3941
}
4042

4143
public Set<AnalyzerFeature> getFeatures() {
42-
return features;
44+
return features != null ? new HashSet<>(features) : null;
4345
}
4446

4547
public void setFeatures(Set<AnalyzerFeature> features) {

src/main/java/com/arangodb/entity/arangosearch/ConsolidationPolicy.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@
2525
*/
2626
public class ConsolidationPolicy {
2727

28-
private final ConsolidationType type;
28+
private ConsolidationType type;
2929
private Double threshold;
3030
private Long segmentThreshold;
3131

32-
private ConsolidationPolicy(final ConsolidationType type) {
33-
super();
34-
this.type = type;
32+
public ConsolidationPolicy() {
3533
}
3634

3735
public static ConsolidationPolicy of(final ConsolidationType type) {
38-
return new ConsolidationPolicy(type);
36+
return new ConsolidationPolicy().type(type);
37+
}
38+
39+
public ConsolidationPolicy type(final ConsolidationType type) {
40+
this.type = type;
41+
return this;
3942
}
4043

4144
/**

src/main/java/com/arangodb/entity/arangosearch/analyzer/SearchAnalyzer.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.arangodb.entity.arangosearch.AnalyzerFeature;
2626
import com.arangodb.entity.arangosearch.AnalyzerType;
2727

28+
import java.util.Collection;
29+
import java.util.HashSet;
2830
import java.util.Objects;
2931
import java.util.Set;
3032

@@ -34,7 +36,7 @@
3436
public abstract class SearchAnalyzer implements Entity {
3537
private String name;
3638
private AnalyzerType type;
37-
private Set<AnalyzerFeature> features;
39+
private Collection<AnalyzerFeature> features;
3840

3941
/**
4042
* @return The Analyzer name.
@@ -62,7 +64,7 @@ public void setType(AnalyzerType type) {
6264
* @return The set of features to set on the Analyzer generated fields.
6365
*/
6466
public Set<AnalyzerFeature> getFeatures() {
65-
return features;
67+
return features != null ? new HashSet<>(features) : null;
6668
}
6769

6870
public void setFeatures(Set<AnalyzerFeature> features) {
@@ -73,10 +75,10 @@ public void setFeatures(Set<AnalyzerFeature> features) {
7375
public boolean equals(Object o) {
7476
if (this == o) return true;
7577
if (o == null || getClass() != o.getClass()) return false;
76-
SearchAnalyzer analyzer = (SearchAnalyzer) o;
77-
return Objects.equals(name, analyzer.name) &&
78-
type == analyzer.type &&
79-
Objects.equals(features, analyzer.features);
78+
SearchAnalyzer that = (SearchAnalyzer) o;
79+
return Objects.equals(getName(), that.getName())
80+
&& getType() == that.getType()
81+
&& Objects.equals(getFeatures(), that.getFeatures());
8082
}
8183

8284
@Override

src/main/java/com/arangodb/model/AqlQueryExplainOptions.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private Options getOptions() {
114114
return options;
115115
}
116116

117-
private static class Options {
117+
public static class Options {
118118
private Optimizer optimizer;
119119
private Integer maxNumberOfPlans;
120120
private Boolean allPlans;
@@ -127,7 +127,7 @@ protected Optimizer getOptimizer() {
127127
}
128128
}
129129

130-
private static class Optimizer {
130+
public static class Optimizer {
131131
private Collection<String> rules;
132132
}
133133
}

src/main/java/com/arangodb/model/AqlQueryOptions.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ private Options getOptions() {
410410
return options;
411411
}
412412

413-
private static class Options implements Serializable {
413+
public static class Options implements Serializable {
414414

415415
private static final long serialVersionUID = 1L;
416416

@@ -446,7 +446,7 @@ protected Collection<String> getShardIds() {
446446

447447
}
448448

449-
private static class Optimizer {
449+
public static class Optimizer {
450450
private Collection<String> rules;
451451
}
452452

src/main/java/com/arangodb/model/VertexCollectionCreateOptions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public VertexCollectionCreateOptions satellites(final String... satellites) {
6565
return this;
6666
}
6767

68-
private static class Options {
68+
public static class Options {
6969
private Collection<String> satellites;
7070
}
7171

0 commit comments

Comments
 (0)