1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.plugins;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
7 | import org.junit.jupiter.api.Test;
|
---|
8 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
9 |
|
---|
10 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Unit tests of {@link PluginException} class.
|
---|
14 | */
|
---|
15 | class PluginExceptionTest {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Setup test.
|
---|
19 | */
|
---|
20 | @RegisterExtension
|
---|
21 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
22 | public JOSMTestRules test = new JOSMTestRules();
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Unit test of {@link PluginException#PluginException}.
|
---|
26 | */
|
---|
27 | @Test
|
---|
28 | void testPluginDownloadException() {
|
---|
29 | PluginException ex = new PluginException("foo");
|
---|
30 | assertEquals("foo", ex.getMessage());
|
---|
31 | NullPointerException npe = new NullPointerException();
|
---|
32 | ex = new PluginException("bar", npe);
|
---|
33 | assertEquals("An error occurred in plugin bar", ex.getMessage());
|
---|
34 | assertEquals(npe, ex.getCause());
|
---|
35 | ex = new PluginException(null, "foobar", npe);
|
---|
36 | assertEquals("An error occurred in plugin foobar", ex.getMessage());
|
---|
37 | assertEquals(npe, ex.getCause());
|
---|
38 | }
|
---|
39 | }
|
---|