11package org .freedesktop .dbus .test ;
22
3- import static org .junit .jupiter .api .Assertions .assertFalse ;
43import static org .junit .jupiter .api .Assertions .assertTrue ;
54import static org .junit .jupiter .api .Assertions .fail ;
65
@@ -30,6 +29,7 @@ public class TestCross {
3029 @ BeforeEach
3130 public void before () {
3231 serverThread = new ServerThread ();
32+ serverThread .setName ("Server Thread" );
3333 serverThread .start ();
3434 }
3535
@@ -40,17 +40,14 @@ public void after() {
4040 }
4141 }
4242
43-
44-
4543 @ Test
4644 public void testCross () throws InterruptedException {
4745 while (!serverReady ) {
4846 Thread .sleep (500L );
4947 }
5048
51- try {
49+ try ( DBusConnection conn = DBusConnection . getConnection ( DBusBusType . SESSION )) {
5250 /* init */
53- DBusConnection conn = DBusConnection .getConnection (DBusBusType .SESSION );
5451 CrossTestClient client = new CrossTestClient (conn );
5552 conn .exportObject ("/TestClient" , client );
5653 conn .addSigHandler (Binding .SampleSignals .Triggered .class , client );
@@ -73,13 +70,12 @@ public void testCross() throws InterruptedException {
7370 System .out .println (s .getKey () + " failed: " + msg );
7471 }
7572 }
76-
77- conn .disconnect ();
78- } catch (DBusException exDbe ) {
73+
74+ } catch (DBusException | IOException exDbe ) {
7975 exDbe .printStackTrace ();
80- }
76+ fail ("Exception while processing DBus" );
77+ }
8178
82- assertTrue (serverThread .getCts ().getNotdone ().isEmpty ()); // all tests should have been run
8379 }
8480
8581
@@ -105,20 +101,14 @@ public void run() {
105101 System .out .println (s + " ok" );
106102 }
107103 for (String s : cts .getNotdone ()) {
108- System .out .println (s + " untested" );
104+ System .out .println ("---> " + s + " untested" );
109105 }
110106 conn .disconnect ();
111- assertFalse (cts .getNotdone ().isEmpty (), "All tests should have been run" );
107+ assertTrue (cts .getNotdone ().isEmpty (), "All tests should have been run, following failed: " + String . join ( ", " , cts . getNotdone ()) );
112108 } catch (DBusException | IOException exDe ) {
113109 exDe .printStackTrace ();
114110 fail ("Exception while server running" );
115111 }
116112 }
117-
118- CrossTestServer getCts () {
119- return cts ;
120- }
121-
122-
123113 }
124114}
0 commit comments