Kevin/Pekka,
Thanks for your comments. Now that I'm getting more familiar with this concept of remote libraries, I'm understanding better the design of current remote library API.
I'm going to change the approach and create a keyword to setup my test environment and configure the library rather than send the arguments to the java library constructor.
Just as a closure note I would like to show you what I was trying to do...
The reason I was trying to do that is because I have created my own logging configuration class within my project using the Java Logging API. I want to send my log files to the temp directory created by RIDE when a test execution is performed. One of the arguments I was trying to get is the ${OUTPUTDIR} variable. In this class, I am creating "on the fly" my own logging.properties file to configure the Java LogManager instead of using the default file provided by Java at %JAVA_HOME%\jre\lib\logging.properties.
Whenever you want to use the Java Logging API you need to run your Java app (in this case my library) with the jvm argument -Djava.util.logging.config.file=MyJavaLibrary.properties
(Here pointing to my own .properties file)
For example:
MyJavaLibrary.jar -Djava.util.logging.config.file=MyJavaLibrary.properties
However, I found the way to do it without sending the jvm argument to MyLibrary.jar but it requires to initialize and create my configuration when a new instance of my library is created. I thought the constructor of MyJavaLibrary was the properly way to do it.
I was tying to set up the log output directory in my properties file as follows:
java.util.logging.FileHandler.pattern=RIDEOutputDir\MyJavaLibrary.%u-%g.log
This is an example of MyJavaLibrary class
/**
* @author Alejandro Serrano
*/
public class MyJavaLibrary extends AnnotationLibrary {
/*
* Test library scope.
*/
public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL";
/*
* Test library Documentation.
* FIXME: Define the init library documentation...
*/
private static final String INIT_LIBRARY_DOCUMENTATION = "TBD......";
/*
* TODO: Define the intro library documentation....
*/
private Logger logger = Logger.getLogger(getClass().getSimpleName());
private static final int PORT = 8270;
/**
* MyJavaLibrary no-arg constructor. Invokes its own overloaded
* constructor that takes the outputDir and arg2, arg3... Strings needed to
* initialize the Java Application and MyJavaLibrary
* logging configuration.
*/
public MyJavaLibrary(){
this("", "");
}
/**
* MyJavaLibrary constructor.
* - Specifies under which packages the keywords are contained.
* - Initializes the library logging configuration.
*/
public MyJavaLibrary(final String outputDir, final String arg2){
super("com/myOrg/systemUnderTest/keyword/**/*.class");
logger.info("MyJavaLibrary keywords registered through AnnotationLibrary."); /*
* Validations for output dir goes here
*/
/*
* My logging configuration object....
*/
LoggingConfiguration libraryLogger = new LoggingConfiguration(outputDir);
libraryLogger.initializeLogging();
/*
* Important stuff to save the arg2, arg3, arg4... as an initial state and setup my test environment goes here
*/
}
/**
* Getting keyword documentation.
* Overriding this method including the equals comparison for '__init__' to provide
* the library documentation.
*/
@Override
public String getKeywordDocumentation(String keywordName) {
if (keywordName.equals("__init__")){
return INIT_LIBRARY_DOCUMENTATION;
}
return super.getKeywordDocumentation(keywordName);
}
/*
* Important code goes here
* ....
* ....
* ....
*/
/**
* Starts jrobotremoteserver needed to interact the RF Remote library.
* The RF Remote library interacts with actual library implementation
* through the java remote server using a simple remote protocol on top
* of an XML-RPC channel.
*/
public static void main(String[] args) throws Exception{
RemoteServer.configureLogging();
RemoteServer server = new RemoteServer();
server.addLibrary(MyJavaLibrary.class, PORT);
server.start();
}
}
I could initialize the logging configuration in the main method. However, I'm trying to build my Library to work either way in a Remote mode and in a "Normal" mode.
I'm going to figure out how to initialize my logging configuration in a different way.
Thank you very much for teaching me the concept of the remote libraries.
Alejandro.