source: josm/trunk/test/unit/org/openstreetmap/josm/gui/layer/AbstractMapViewPaintableTest.java@ 17360

Last change on this file since 17360 was 17275, checked in by Don-vip, 3 years ago

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer;
3
4import static org.junit.jupiter.api.Assertions.assertFalse;
5import static org.junit.jupiter.api.Assertions.assertTrue;
6
7import java.util.concurrent.atomic.AtomicBoolean;
8
9import org.junit.jupiter.api.BeforeEach;
10import org.junit.jupiter.api.Test;
11import org.junit.jupiter.api.extension.RegisterExtension;
12import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationListener;
13import org.openstreetmap.josm.testutils.JOSMTestRules;
14
15import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
16
17/**
18 * Test of the base {@link AbstractMapViewPaintable} class
19 * @author Michael Zangl
20 */
21class AbstractMapViewPaintableTest {
22 /**
23 * No special test rules
24 */
25 @RegisterExtension
26 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
27 public JOSMTestRules test = new JOSMTestRules();
28
29 private Layer testLayer;
30
31 /**
32 * Create test layer
33 */
34 @BeforeEach
35 public void setUp() {
36 testLayer = new LayerManagerTest.TestLayer();
37 }
38
39 /**
40 * Test {@link Layer#invalidate()}
41 */
42 @Test
43 void testInvalidate() {
44 AtomicBoolean fired = new AtomicBoolean();
45 PaintableInvalidationListener listener = l -> fired.set(true);
46 testLayer.addInvalidationListener(listener);
47 assertFalse(fired.get());
48 testLayer.invalidate();
49 assertTrue(fired.get());
50
51 fired.set(false);
52 testLayer.removeInvalidationListener(listener);
53 testLayer.invalidate();
54 assertFalse(fired.get());
55 }
56}
Note: See TracBrowser for help on using the repository browser.