File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed
src/test/java/com/codename1 Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 3333 <groupId >org.apache.maven.plugins</groupId >
3434 <artifactId >maven-surefire-plugin</artifactId >
3535 <version >3.2.1</version >
36+ <configuration >
37+ <!-- Run each test in its own forked JVM to ensure an isolated classloader. -->
38+ <forkCount >1</forkCount >
39+ <reuseForks >false</reuseForks >
40+ </configuration >
3641 </plugin >
3742 <plugin >
3843 <groupId >org.jacoco</groupId >
Original file line number Diff line number Diff line change 11package com .codename1 .io ;
22
3+ import com .codename1 .impl .ImplementationFactory ;
34import com .codename1 .junit .EdtTest ;
45import com .codename1 .testing .TestCodenameOneImplementation ;
56import com .codename1 .ui .Display ;
@@ -17,6 +18,15 @@ class CacheMapTest {
1718 @ BeforeEach
1819 void setUp () {
1920 implementation = new TestCodenameOneImplementation (true );
21+ ImplementationFactory .setInstance (new ImplementationFactory () {
22+ @ Override
23+ public Object createImplementation () {
24+ return implementation ;
25+ }
26+ });
27+ if (!Display .isInitialized ()) {
28+ Display .init (null );
29+ }
2030 Util .setImplementation (implementation );
2131 Storage .setStorageInstance (null );
2232 }
@@ -25,6 +35,7 @@ void setUp() {
2535 void tearDown () {
2636 Storage .setStorageInstance (null );
2737 Util .setImplementation (null );
38+ Display .deinitialize ();
2839 }
2940
3041 @ Test
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ class PropertiesPackageTest extends UITestBase {
2525
2626 @ BeforeEach
2727 void setup () throws Exception {
28- CN . callSeriallyAndWait ( new Runnable () {
28+ Runnable setupTask = new Runnable () {
2929 public void run () {
3030 originalPreferencesLocation = Preferences .getPreferencesLocation ();
3131 Preferences .setPreferencesLocation ("PropertiesTest-" + System .nanoTime ());
@@ -36,12 +36,17 @@ public void run() {
3636 PropertyBase .bindGlobalGetListener (null );
3737 PropertyBase .bindGlobalSetListener (null );
3838 }
39- });
39+ };
40+ if (CN .isEdt ()) {
41+ setupTask .run ();
42+ } else {
43+ CN .callSeriallyAndWait (setupTask );
44+ }
4045 }
4146
4247 @ AfterEach
4348 void tearDown () throws Exception {
44- CN . callSeriallyAndWait ( new Runnable () {
49+ Runnable teardownTask = new Runnable () {
4550 public void run () {
4651 PropertyBase .bindGlobalGetListener (null );
4752 PropertyBase .bindGlobalSetListener (null );
@@ -52,7 +57,12 @@ public void run() {
5257 Storage .getInstance ().clearCache ();
5358 implementation .clearStorage ();
5459 }
55- });
60+ };
61+ if (CN .isEdt ()) {
62+ teardownTask .run ();
63+ } else {
64+ CN .callSeriallyAndWait (teardownTask );
65+ }
5666 }
5767
5868 @ EdtTest
You can’t perform that action at this time.
0 commit comments