Access System Properties from a Mock

Hello MicroEJ team,

Is it possible to access System Properties from a Mock ?

I would like to set the following System Property in my application launcher: mock.myproperty=myvalue and get its value in my mock.

Regards,

Fabrice

Hi,

It is possible to extend the launch phase by adding a custom extension script in your Platform.

Here is an example of such script:

  • Download init-hil-addproperties.zip
  • Create a dropins/scripts directory in your Platform configuration project
  • Extract init-hil-addproperties.zip in this folder

Take a look to dropins/scripts/init-hil-addproperties/init.xml: this script automatically embeds all Application options starting with com.mycompany.mock as system properties.

This can be updated at your convenience.

In your mock project, you can retrieve it using System.getProperty(''com.mycompany.mock.myOption")

–Frédéric

Hi Frédéric,

Thanks ! This is working fine.

Fabrice

Hi,

If the VEE Port is built in SDK 6, it is also possible to access properties from a Mock by adding the init-hil-addproperties.zip provided by @frederic.riviere in the VEE Port project:

  • Create a dropins/scripts directory in the VEE Port project
  • Extract init-hil-addproperties.zip in this directory

You can then define the Application option in the configuration/common.properties file of your project or pass it as System property with the prefix microej.option:
./gradlew runOnSimulator -D"microej.option.com.mycompany.mock.myOption=myValue"

Denis