This project explain how to create a mock for SNI and SP functions on the simulator.
For this example a native function will be used:
public static native int foo(); This function will be in MyClass
at my.package
- Add a native method to your Java application. This native method will
have two implementations:
- One in C code in the platform BSP project (this part is not covered in this document)
- One in Java (J2SE) in a new Java project for the simulator
- Create a new module project (https://docs.microej.com/en/latest/ApplicationDeveloperGuide/mmm.html#module-project-skeleton) using the
microej-mockskeleton. - Create a class with the same name, same package as your SNI
(e.g.
my.package.MyClass) - Implement the SNI function as public with the same signature (as
public, without thenativekeyword) (e.g.public native int foo())
- Build the Mock project (right click on the project >
Build Module). - A
.ripfile is created in thetarget~/artifactsfolder in the Mock project. - From the
.ripunzip the content ofcontentfolder into thedropinsfolder of your platform configuration project (e.g. [Platform-Name]-configuration/dropins). - Build you platform.
- Run your Java application on the simulator.
A mock can show a separate UI to ease input/output. An example is provided
- An application using native function Mock-Get-Started-MyApp
- A mock opening a UI Mock-Get-Started-MyMock
This example has been tested on:
- MicroEJ SDK 5.1.0
- With a platform that contains:
- EDC-1.2
- BON-1.3
- MICROUI-2.0
- SP-2.0
All dependencies are retrieved transitively by MicroEJ Module Manager.
N/A
None.