Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.io.protocols.data;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
---|
5 |
|
---|
6 | import java.io.IOException;
|
---|
7 | import java.net.URL;
|
---|
8 | import java.net.URLConnection;
|
---|
9 |
|
---|
10 | import org.junit.jupiter.api.BeforeEach;
|
---|
11 | import org.junit.jupiter.api.Test;
|
---|
12 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
13 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Unit tests of {@link Handler} class.
|
---|
17 | */
|
---|
18 | class HandlerTest {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Use the test rules to remove any layers and reset state.
|
---|
22 | */
|
---|
23 | @RegisterExtension
|
---|
24 | public final JOSMTestRules rules = new JOSMTestRules();
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Setup test.
|
---|
28 | */
|
---|
29 | @BeforeEach
|
---|
30 | public void setUp() {
|
---|
31 | Handler.install();
|
---|
32 | }
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Reads a base-64 image.
|
---|
36 | * @throws IOException if any I/O error occurs
|
---|
37 | */
|
---|
38 | @Test
|
---|
39 | void testBase64Image() throws IOException {
|
---|
40 | // Red dot image, taken from https://en.wikipedia.org/wiki/Data_URI_scheme#HTML
|
---|
41 | URLConnection connection = new Handler().openConnection(new URL("data:image/png;base64," +
|
---|
42 | "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4"+
|
---|
43 | "//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="));
|
---|
44 | connection.connect();
|
---|
45 | assertNotNull(connection.getInputStream());
|
---|
46 | }
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.