forked from artipie/artipie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VertxMainITCase.java
92 lines (85 loc) · 2.93 KB
/
VertxMainITCase.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* The MIT License (MIT) Copyright (c) 2020-2021 artipie.com
* https://github.com/artipie/artipie/LICENSE.txt
*/
package com.artipie;
import com.artipie.test.ContainerResultMatcher;
import com.artipie.test.TestDeployment;
import java.io.IOException;
import org.cactoos.map.MapEntry;
import org.cactoos.map.MapOf;
import org.hamcrest.core.StringContains;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
* Test for {@link VertxMain}.
* @since 0.1
*/
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
final class VertxMainITCase {
/**
* Test deployments.
* @checkstyle VisibilityModifierCheck (15 lines)
*/
@RegisterExtension
final TestDeployment deployment = new TestDeployment(
new MapOf<>(
new MapEntry<>(
"artipie-config-key-present",
() -> TestDeployment.ArtipieContainer.defaultDefinition()
.withConfig("artipie-repo-config-key.yaml")
.withRepoConfig("binary/bin.yml", "my_configs/my-file")
),
new MapEntry<>(
"artipie-invalid-repo-config",
() -> TestDeployment.ArtipieContainer.defaultDefinition()
.withRepoConfig("invalid_repo.yaml", "my-file")
)
),
() -> new TestDeployment.ClientContainer("alpine:3.11")
.withWorkingDirectory("/w")
);
@BeforeEach
void setUp() throws IOException {
this.deployment.assertExec(
"Failed to install deps",
new ContainerResultMatcher(),
"apk", "add", "--no-cache", "curl"
);
}
@Test
void startsWhenNotValidRepoConfigsArePresent() throws IOException {
this.deployment.putBinaryToArtipie(
"artipie-invalid-repo-config",
"Hello world".getBytes(),
"/var/artipie/data/my-file/item.txt"
);
this.deployment.assertExec(
"Artipie isn't started or not responding 200",
new ContainerResultMatcher(
ContainerResultMatcher.SUCCESS,
new StringContains("HTTP/1.1 200 OK")
),
"curl", "-i", "-X", "GET",
"http://artipie-invalid-repo-config:8080/my-file/item.txt"
);
}
@Test
void worksWhenRepoConfigsKeyIsPresent() throws IOException {
this.deployment.putBinaryToArtipie(
"artipie-config-key-present",
"Hello world".getBytes(),
"/var/artipie/data/my-file/item.txt"
);
this.deployment.assertExec(
"Artipie isn't started or not responding 200",
new ContainerResultMatcher(
ContainerResultMatcher.SUCCESS,
new StringContains("HTTP/1.1 200 OK")
),
"curl", "-i", "-X", "GET",
"http://artipie-config-key-present:8080/my-file/item.txt"
);
}
}