11package com .openfin .desktop ;
22
3- import com .sun .javafx .binding .StringFormatter ;
43import org .json .JSONArray ;
54import org .json .JSONObject ;
65import org .junit .AfterClass ;
98import org .slf4j .Logger ;
109import org .slf4j .LoggerFactory ;
1110
12- import javax .print .attribute .standard .ReferenceUriSchemesSupported ;
13- import java .util .Objects ;
1411import java .util .UUID ;
1512import java .util .concurrent .CountDownLatch ;
1613import java .util .concurrent .TimeUnit ;
@@ -30,15 +27,15 @@ public class SystemTest {
3027
3128 private static final String DESKTOP_UUID = SystemTest .class .getName ();
3229 private static DesktopConnection desktopConnection ;
33- private static System runtimeSystem ;
30+ private static OpenFinRuntime runtime ;
3431 private static final String openfin_app_url = "http://test.openf.in/test.html" ;
3532
3633 @ BeforeClass
3734 public static void setup () throws Exception {
3835 logger .debug ("starting" );
3936 desktopConnection = TestUtils .setupConnection (DESKTOP_UUID );
4037 if (desktopConnection != null ) {
41- runtimeSystem = new System (desktopConnection );
38+ runtime = new OpenFinRuntime (desktopConnection );
4239 }
4340 }
4441
@@ -50,7 +47,7 @@ public static void teardown() throws Exception {
5047 @ Test
5148 public void getDeviceId () throws Exception {
5249 CountDownLatch latch = new CountDownLatch (1 );
53- runtimeSystem .getDeviceId (new AckListener () {
50+ runtime .getDeviceId (new AckListener () {
5451 @ Override
5552 public void onSuccess (Ack ack ) {
5653 if (ack .isSuccessful ()) {
@@ -70,7 +67,7 @@ public void onError(Ack ack) {
7067 private String getRuntimeVersion () throws Exception {
7168 CountDownLatch latch = new CountDownLatch (1 );
7269 AtomicReference <String > atomicReference = new AtomicReference <>();
73- runtimeSystem .getVersion (new AckListener () {
70+ runtime .getVersion (new AckListener () {
7471 @ Override
7572 public void onSuccess (Ack ack ) {
7673 if (ack .isSuccessful ()) {
@@ -92,7 +89,7 @@ public void onError(Ack ack) {
9289 @ Test
9390 public void getProcessList () throws Exception {
9491 CountDownLatch latch = new CountDownLatch (1 );
95- runtimeSystem .getProcessList (new AckListener () {
92+ runtime .getProcessList (new AckListener () {
9693 @ Override
9794 public void onSuccess (Ack ack ) {
9895 if (ack .isSuccessful ()) {
@@ -122,7 +119,7 @@ public void onError(Ack ack) {
122119 @ Test
123120 public void getLogList () throws Exception {
124121 CountDownLatch latch = new CountDownLatch (1 );
125- runtimeSystem .getLogList (new AckListener () {
122+ runtime .getLogList (new AckListener () {
126123 @ Override
127124 public void onSuccess (Ack ack ) {
128125 if (ack .isSuccessful ()) {
@@ -152,7 +149,7 @@ public void onError(Ack ack) {
152149 public void wrietAndReadLog () throws Exception {
153150 CountDownLatch writeLatch = new CountDownLatch (1 );
154151 String text = UUID .randomUUID ().toString (); // text to write
155- runtimeSystem .log ("info" , text , new AckListener () {
152+ runtime .log ("info" , text , new AckListener () {
156153 @ Override
157154 public void onSuccess (Ack ack ) {
158155 if (ack .isSuccessful ()) {
@@ -168,7 +165,7 @@ public void onError(Ack ack) {
168165 assertEquals ("writing log timeout" , writeLatch .getCount (), 0 );
169166 // text should be written to debug.log
170167 CountDownLatch latch = new CountDownLatch (1 );
171- runtimeSystem .getLog ("debug.log" , new AckListener () {
168+ runtime .getLog ("debug.log" , new AckListener () {
172169 @ Override
173170 public void onSuccess (Ack ack ) {
174171 if (ack .isSuccessful ()) {
@@ -190,7 +187,7 @@ public void onError(Ack ack) {
190187 @ Test
191188 public void getMonitorInfo () throws Exception {
192189 CountDownLatch latch = new CountDownLatch (1 );
193- runtimeSystem .getMonitorInfo (new AckListener () {
190+ runtime .getMonitorInfo (new AckListener () {
194191 @ Override
195192 public void onSuccess (Ack ack ) {
196193 if (ack .isSuccessful ()) {
@@ -215,7 +212,7 @@ public void getAllWindows() throws Exception {
215212 ApplicationOptions options = TestUtils .getAppOptions ();
216213 Application application = TestUtils .runApplication (options , desktopConnection );
217214 CountDownLatch latch = new CountDownLatch (1 );
218- runtimeSystem .getAllWindows (new AckListener () {
215+ runtime .getAllWindows (new AckListener () {
219216 @ Override
220217 public void onSuccess (Ack ack ) {
221218 if (ack .isSuccessful ()) {
@@ -243,7 +240,7 @@ public void getAllApplications() throws Exception {
243240 ApplicationOptions options = TestUtils .getAppOptions ();
244241 Application application = TestUtils .runApplication (options , desktopConnection );
245242 CountDownLatch latch = new CountDownLatch (1 );
246- runtimeSystem .getAllApplications (new AckListener () {
243+ runtime .getAllApplications (new AckListener () {
247244 @ Override
248245 public void onSuccess (Ack ack ) {
249246 if (ack .isSuccessful ()) {
@@ -269,7 +266,7 @@ public void onError(Ack ack) {
269266 @ Test
270267 public void getMousePosition () throws Exception {
271268 CountDownLatch latch = new CountDownLatch (1 );
272- runtimeSystem .getMousePosition (new AckListener () {
269+ runtime .getMousePosition (new AckListener () {
273270 @ Override
274271 public void onSuccess (Ack ack ) {
275272 if (ack .isSuccessful ()) {
@@ -294,7 +291,7 @@ public void onError(Ack ack) {
294291 @ Test
295292 public void getConfig () throws Exception {
296293 CountDownLatch latch = new CountDownLatch (1 );
297- runtimeSystem .getConfig (null , new AckListener () {
294+ runtime .getConfig (null , new AckListener () {
298295 @ Override
299296 public void onSuccess (Ack ack ) {
300297 if (ack .isSuccessful ()) {
@@ -325,7 +322,7 @@ public void showDeveloperTools() throws Exception {
325322 Application application = TestUtils .runApplication (options , desktopConnection );
326323 CountDownLatch latch = new CountDownLatch (1 );
327324 // show dev tool for main window of the app. Name of the main window is same as UUID
328- runtimeSystem .showDeveloperTools (options .getUUID (), options .getUUID (), new AckListener () {
325+ runtime .showDeveloperTools (options .getUUID (), options .getUUID (), new AckListener () {
329326 @ Override
330327 public void onSuccess (Ack ack ) {
331328 if (ack .isSuccessful ()) {
@@ -347,7 +344,7 @@ public void addAndRemoveEventListeners() throws Exception {
347344 EventListener listener = (actionEvent -> {});
348345 for (String eventType : events ) {
349346 CountDownLatch latch = new CountDownLatch (1 );
350- runtimeSystem .addEventListener (eventType , listener , new AckListener () {
347+ runtime .addEventListener (eventType , listener , new AckListener () {
351348 @ Override
352349 public void onSuccess (Ack ack ) {
353350 if (ack .isSuccessful ()) {
@@ -364,7 +361,7 @@ public void onError(Ack ack) {
364361 }
365362 for (String eventType : events ) {
366363 CountDownLatch latch = new CountDownLatch (1 );
367- runtimeSystem .removeEventListener (eventType , listener , new AckListener () {
364+ runtime .removeEventListener (eventType , listener , new AckListener () {
368365 @ Override
369366 public void onSuccess (Ack ack ) {
370367 if (ack .isSuccessful ()) {
@@ -385,7 +382,7 @@ public void onError(Ack ack) {
385382 public void startAndTerminateExternalProcess () throws Exception {
386383 CountDownLatch startLatch = new CountDownLatch (1 );
387384 AtomicReference <String > processUuid = new AtomicReference <>();
388- runtimeSystem .launchExternalProcess ("notepad.exe" , "" , result -> {
385+ runtime .launchExternalProcess ("notepad.exe" , "" , result -> {
389386 processUuid .set (result .getProcessUuid ());
390387 logger .debug (String .format ("launch process %s" , processUuid .get ()));
391388 startLatch .countDown ();
@@ -401,7 +398,7 @@ public void onError(Ack ack) {
401398 startLatch .await (10 , TimeUnit .SECONDS );
402399 assertEquals ("launchExternalProcess timeout" , startLatch .getCount (), 0 );
403400 CountDownLatch terminateLatch = new CountDownLatch (1 );
404- runtimeSystem .terminateExternalProcess (processUuid .get (), 2000 , false , result -> {
401+ runtime .terminateExternalProcess (processUuid .get (), 2000 , false , result -> {
405402 logger .debug (String .format ("terminate process %s %s" , processUuid .get (), result .getProcessUuid ()));
406403 if (result .getProcessUuid ().equals (processUuid .get ())) {
407404 logger .debug (String .format ("External process exit code %s" , result .getResult ()));
@@ -426,7 +423,7 @@ public void onError(Ack ack) {
426423 public void getEnvironmentVariables () throws Exception {
427424 String [] envVarNames = {"LOCALAPPDATA" , "USERNAME" };
428425 CountDownLatch latch = new CountDownLatch (1 );
429- runtimeSystem .getEnvironmentVariables (envVarNames , new AckListener () {
426+ runtime .getEnvironmentVariables (envVarNames , new AckListener () {
430427 @ Override
431428 public void onSuccess (Ack ack ) {
432429 if (ack .isSuccessful ()) {
@@ -451,7 +448,7 @@ public void onError(Ack ack) {
451448 @ Test
452449 public void deleteCacheOnRestart () throws Exception {
453450 CountDownLatch latch = new CountDownLatch (1 );
454- runtimeSystem .deleteCacheOnRestart (new AckListener () {
451+ runtime .deleteCacheOnRestart (new AckListener () {
455452 @ Override
456453 public void onSuccess (Ack ack ) {
457454 if (ack .isSuccessful ()) {
@@ -470,7 +467,7 @@ public void onError(Ack ack) {
470467 @ Test
471468 public void clearCache () throws Exception {
472469 CountDownLatch latch = new CountDownLatch (1 );
473- runtimeSystem .clearCache (true , true , true , true , true , new AckListener () {
470+ runtime .clearCache (true , true , true , true , true , new AckListener () {
474471 @ Override
475472 public void onSuccess (Ack ack ) {
476473 if (ack .isSuccessful ()) {
@@ -492,7 +489,7 @@ public void restartRuntime() throws Exception {
492489 String version1 = getRuntimeVersion ();
493490 TestUtils .teardownDesktopConnection (desktopConnection );
494491 desktopConnection = TestUtils .setupConnection (DESKTOP_UUID );
495- runtimeSystem = new System (desktopConnection );
492+ runtime = new OpenFinRuntime (desktopConnection );
496493 String version2 = getRuntimeVersion ();
497494 assertEquals (version1 , version2 );
498495 }
0 commit comments