Last change
on this file since 18690 was 18690, checked in by taylor.smock, 13 months ago |
See #16567: Convert all assertion calls to JUnit 5 (patch by gaben, modified)
The modifications are as follows:
- Merge DomainValidatorTest.testIDN and DomainValidatorTest.testIDNJava6OrLater
- Update some tests to use @ParameterizedTest (DomainValidatorTest)
- Replace various exception blocks with
assertThrows . These typically looked like
try {
// Something that should throw an exception here
fail("An exception should have been thrown");
} catch (Exception e) {
// Verify the exception matches expectations here
}
- Replace
assertTrue(val instanceof Clazz) with assertInstanceOf
- Replace JUnit 4 @Suite with JUnit 5 @Suite
Both the original patch and the modified patch fix various lint issues.
|
File size:
1.2 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import java.io.ByteArrayInputStream;
|
---|
7 | import java.io.ByteArrayOutputStream;
|
---|
8 | import java.io.ObjectInputStream;
|
---|
9 | import java.io.ObjectOutputStream;
|
---|
10 | import java.util.Arrays;
|
---|
11 |
|
---|
12 | import org.junit.jupiter.api.Test;
|
---|
13 |
|
---|
14 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
15 |
|
---|
16 | class WayDataTest {
|
---|
17 |
|
---|
18 | @Test
|
---|
19 | @SuppressFBWarnings(value = "OBJECT_DESERIALIZATION")
|
---|
20 | void testSerializationForDragAndDrop() throws Exception {
|
---|
21 | final WayData data = new WayData();
|
---|
22 | data.setNodeIds(Arrays.asList(1415L, 9265L, 3589L, 7932L, 3846L));
|
---|
23 | data.setId(314);
|
---|
24 | data.setVersion(14);
|
---|
25 | data.setChangesetId(314159);
|
---|
26 | final Object readData;
|
---|
27 | try (ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
---|
28 | ObjectOutputStream out = new ObjectOutputStream(bytes)) {
|
---|
29 | out.writeObject(data);
|
---|
30 | try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) {
|
---|
31 | readData = in.readObject();
|
---|
32 | }
|
---|
33 | }
|
---|
34 | assertEquals(data.toString(), readData.toString());
|
---|
35 | }
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.