forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestartPolicySerializingTest.java
More file actions
49 lines (40 loc) · 1.75 KB
/
Copy pathRestartPolicySerializingTest.java
File metadata and controls
49 lines (40 loc) · 1.75 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
45
46
47
48
49
package com.github.dockerjava.api.model;
import com.github.dockerjava.test.serdes.JSONTestHelper;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* 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 RestartPolicySerializingTest {
@Test
// --restart no
public void noRestart() throws Exception {
String json = JSONTestHelper.getMapper().writeValueAsString(RestartPolicy.noRestart());
assertEquals(json, "{\"MaximumRetryCount\":0,\"Name\":\"\"}");
}
@Test
// --restart always
public void alwaysRestart() throws Exception {
String json = JSONTestHelper.getMapper().writeValueAsString(RestartPolicy.alwaysRestart());
assertEquals(json, "{\"MaximumRetryCount\":0,\"Name\":\"always\"}");
}
@Test
// --restart unless-stopped
public void unlessStoppedRestart() throws Exception {
String json = JSONTestHelper.getMapper().writeValueAsString(RestartPolicy.unlessStoppedRestart());
assertEquals(json, "{\"MaximumRetryCount\":0,\"Name\":\"unless-stopped\"}");
}
@Test
// --restart on-failure
public void onFailureRestart() throws Exception {
String json = JSONTestHelper.getMapper().writeValueAsString(RestartPolicy.onFailureRestart(0));
assertEquals(json, "{\"MaximumRetryCount\":0,\"Name\":\"on-failure\"}");
}
@Test
// --restart on-failure:2
public void onFailureRestartWithCount() throws Exception {
String json = JSONTestHelper.getMapper().writeValueAsString(RestartPolicy.onFailureRestart(2));
assertEquals(json, "{\"MaximumRetryCount\":2,\"Name\":\"on-failure\"}");
}
}