2020import javafx .application .Application ;
2121import javafxlibrary .exceptions .JavaFXLibraryFatalException ;
2222import javafxlibrary .exceptions .JavaFXLibraryNonFatalException ;
23- import javafxlibrary .utils .HelperFunctions ;
23+ import javafxlibrary .utils .RobotLog ;
2424import javafxlibrary .utils .TestFxAdapter ;
2525import org .robotframework .javalib .annotation .ArgumentNames ;
2626import org .robotframework .javalib .annotation .RobotKeyword ;
3333
3434import static javafxlibrary .utils .HelperFunctions .createWrapperApplication ;
3535import static javafxlibrary .utils .HelperFunctions .getMainClassFromJarFile ;
36- import static javafxlibrary .utils .HelperFunctions .robotLog ;
3736
3837@ RobotKeywords
3938public class ApplicationLauncher extends TestFxAdapter {
@@ -47,10 +46,9 @@ public class ApplicationLauncher extends TestFxAdapter {
4746 @ ArgumentNames ({"appName" , "*args" })
4847 public void launchJavafxApplication (String appName , String ... appArgs ) {
4948 try {
50- HelperFunctions . robotLog ( "INFO" , "Starting application:" + appName );
49+ RobotLog . info ( "Starting application:" + appName );
5150 createNewSession (appName , appArgs );
52- HelperFunctions .robotLog ("INFO" , "Application: " + appName + " started." );
53-
51+ RobotLog .info ("Application: " + appName + " started." );
5452 } catch (Exception e ) {
5553 throw new JavaFXLibraryNonFatalException ("Unable to launch application: " + appName , e );
5654 }
@@ -67,7 +65,7 @@ public void launchJavafxApplication(String appName, String... appArgs) {
6765 + "| Launch Swing Application | _TestApplication.jar_ |\n " )
6866 @ ArgumentNames ({"appName" , "*args" })
6967 public void launchSwingApplication (String appName , String ... appArgs ) {
70- HelperFunctions . robotLog ( "INFO" , "Starting application:" + appName );
68+ RobotLog . info ( "Starting application:" + appName );
7169 Class c ;
7270
7371 try {
@@ -82,15 +80,15 @@ public void launchSwingApplication(String appName, String... appArgs) {
8280
8381 Application app = createWrapperApplication (c , appArgs );
8482 createNewSession (app );
85- HelperFunctions . robotLog ( "INFO" , "Application: " + appName + " started." );
83+ RobotLog . info ( "Application: " + appName + " started." );
8684 }
8785
8886 private void _addPathToClassPath (String path ) {
8987 URLClassLoader classLoader = (URLClassLoader ) ClassLoader .getSystemClassLoader ();
9088
91- HelperFunctions . robotLog ( "INFO" , " Setting following path to Classpath: " + path );
89+ RobotLog . info ( " Setting following path to Classpath: " + path );
9290
93- try {
91+ try {
9492 Method method = URLClassLoader .class .getDeclaredMethod ("addURL" , URL .class );
9593 method .setAccessible (true );
9694 method .invoke (classLoader , (new File (path )).toURI ().toURL () );
@@ -110,10 +108,12 @@ private void _addPathToClassPath(String path) {
110108 public void setToClasspath (String path ) {
111109 if (path .endsWith ("*" )) {
112110 path = path .substring (0 , path .length () - 1 );
113- HelperFunctions .robotLog ("INFO" , "Adding all jars from directory: " + path );
111+ RobotLog .info ("Adding all jars from directory: " + path );
112+
114113 try {
115114 File directory = new File (path );
116115 File [] fileList = directory .listFiles ();
116+
117117 for (File file : fileList ) {
118118 if (file .getName ().endsWith (".jar" ))
119119 _addPathToClassPath (file .getAbsolutePath ());
@@ -132,10 +132,9 @@ public void logApplicationClasspath() {
132132 try {
133133 ClassLoader cl = ClassLoader .getSystemClassLoader ();
134134 URL [] urls = ((URLClassLoader ) cl ).getURLs ();
135- HelperFunctions .robotLog ("INFO" , "Printing out classpaths: \n " );
136- for (URL url : urls ) {
137- HelperFunctions .robotLog ("INFO" , url .getFile ());
138- }
135+ RobotLog .info ("Printing out classpaths: \n " );
136+ for (URL url : urls )
137+ RobotLog .info (url .getFile ());
139138 } catch (Exception e ) {
140139 throw new JavaFXLibraryNonFatalException ("Unable to log application classpaths" , e );
141140 }
@@ -174,7 +173,7 @@ public void logSystemProperties() {
174173 while (keys .hasMoreElements ()) {
175174 String key = (String ) keys .nextElement ();
176175 String value = (String ) p .get (key );
177- HelperFunctions . robotLog ( "INFO" , key + "=" + value );
176+ RobotLog . info ( key + "=" + value );
178177 }
179178 } catch (Exception e ) {
180179 throw new JavaFXLibraryNonFatalException ("Unable to log system properties" , e );
@@ -187,9 +186,9 @@ public void logSystemProperties() {
187186 public void closeJavafxApplication () {
188187
189188 try {
190- HelperFunctions . robotLog ( "INFO" , "Closing application..." );
189+ RobotLog . info ( "Closing application..." );
191190 deleteSession ();
192- HelperFunctions . robotLog ( "INFO" , "Application closed." );
191+ RobotLog . info ( "Application closed." );
193192 } catch (Exception e ) {
194193 throw new JavaFXLibraryNonFatalException ("Unable to close Java FX application." , e );
195194 }
@@ -200,17 +199,17 @@ public void closeJavafxApplication() {
200199 + "| Close Swing Application | \n " )
201200 public void closeSwingApplication () {
202201 try {
203- HelperFunctions . robotLog ( "INFO" , "Closing application..." );
202+ RobotLog . info ( "Closing application..." );
204203 deleteSwingSession ();
205- HelperFunctions . robotLog ( "INFO" , "Application closed." );
204+ RobotLog . info ( "Application closed." );
206205 } catch (Exception e ) {
207206 throw new JavaFXLibraryNonFatalException ("Unable to close JavaFXLibrary Swing Wrapper application." , e );
208207 }
209208 }
210209
211210 @ RobotKeyword ("Clears internal book keeping of all java objects." )
212211 public void clearObjectMap () {
213- robotLog ( "INFO" , "Clearing " + objectMap .size () + " objects from objectMap." );
212+ RobotLog . info ( "Clearing " + objectMap .size () + " objects from objectMap." );
214213 objectMap .clear ();
215214 }
216215
0 commit comments