forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestartPolicy_SerializingTest.java
More file actions
44 lines (35 loc) · 1.48 KB
/
Copy pathRestartPolicy_SerializingTest.java
File metadata and controls
44 lines (35 loc) · 1.48 KB
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
package com.github.dockerjava.api.model;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Compares serialization results of various {@link RestartPolicy}s with what Docker (as of 1.3.3) actually sends when executing
* <code>docker run --restart xxx</code>.
*/
public class RestartPolicy_SerializingTest {
private final ObjectMapper objectMapper = new ObjectMapper();
@Test
// --restart no
public void noRestart() throws Exception {
String json = objectMapper.writeValueAsString(RestartPolicy.noRestart());
assertEquals(json, "{\"MaximumRetryCount\":0,\"Name\":\"\"}");
}
@Test
// --restart always
public void alwaysRestart() throws Exception {
String json = objectMapper.writeValueAsString(RestartPolicy.alwaysRestart());
assertEquals(json, "{\"MaximumRetryCount\":0,\"Name\":\"always\"}");
}
@Test
// --restart on-failure
public void onFailureRestart() throws Exception {
String json = objectMapper.writeValueAsString(RestartPolicy.onFailureRestart(0));
assertEquals(json, "{\"MaximumRetryCount\":0,\"Name\":\"on-failure\"}");
}
@Test
// --restart on-failure:2
public void onFailureRestartWithCount() throws Exception {
String json = objectMapper.writeValueAsString(RestartPolicy.onFailureRestart(2));
assertEquals(json, "{\"MaximumRetryCount\":2,\"Name\":\"on-failure\"}");
}
}