forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVolumeBindsTest.java
More file actions
42 lines (33 loc) · 1.33 KB
/
Copy pathVolumeBindsTest.java
File metadata and controls
42 lines (33 loc) · 1.33 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
package com.github.dockerjava.api.model;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.github.dockerjava.test.serdes.JSONTestHelper;
import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
public class VolumeBindsTest {
@Test
public void usesToJson() throws Exception {
VolumeBinds binds = new VolumeBinds(
new VolumeBind("/bar", "/foo"),
new VolumeBind("/bop", "/bip")
);
String json = JSONTestHelper.getMapper().writeValueAsString(binds);
assertThat(json, is("{\"/foo\":\"/bar\",\"/bip\":\"/bop\"}"));
}
@Test
public void t() throws IOException {
String s = "{\"/data\":\"/some/path\"}";
VolumeBinds volumeBinds = JSONTestHelper.getMapper().readValue(s, VolumeBinds.class);
VolumeBind[] binds = volumeBinds.getBinds();
assertEquals(binds.length, 1);
assertEquals(binds[0].getHostPath(), "/some/path");
assertEquals(binds[0].getContainerPath(), "/data");
}
@Test(expected = JsonMappingException.class)
public void t1() throws IOException {
String s = "{\"/data\": {} }";
JSONTestHelper.getMapper().readValue(s, VolumeBinds.class);
}
}