Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import java.io.ByteArrayInputStream;
|
---|
5 | import java.io.ByteArrayOutputStream;
|
---|
6 | import java.io.ObjectInputStream;
|
---|
7 | import java.io.ObjectOutputStream;
|
---|
8 | import java.util.Arrays;
|
---|
9 |
|
---|
10 | import org.junit.Assert;
|
---|
11 | import org.junit.jupiter.api.Test;
|
---|
12 |
|
---|
13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
14 |
|
---|
15 | class WayDataTest {
|
---|
16 |
|
---|
17 | @Test
|
---|
18 | @SuppressFBWarnings(value = "OBJECT_DESERIALIZATION")
|
---|
19 | void testSerializationForDragAndDrop() throws Exception {
|
---|
20 | final WayData data = new WayData();
|
---|
21 | data.setNodeIds(Arrays.asList(1415L, 9265L, 3589L, 7932L, 3846L));
|
---|
22 | data.setId(314);
|
---|
23 | data.setVersion(14);
|
---|
24 | data.setChangesetId(314159);
|
---|
25 | final Object readData;
|
---|
26 | try (ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
---|
27 | ObjectOutputStream out = new ObjectOutputStream(bytes)) {
|
---|
28 | out.writeObject(data);
|
---|
29 | try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) {
|
---|
30 | readData = in.readObject();
|
---|
31 | }
|
---|
32 | }
|
---|
33 | Assert.assertEquals(data.toString(), readData.toString());
|
---|
34 | }
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.