BAEL-4234: example of JNI registerNatives() method (#11745)

* BAEL-4234: example of JNI registerNatives() method

* fixed formatting in the cpp file

* removed camelcase in test package name
This commit is contained in:
Maciej Główka
2022-02-19 05:19:07 +01:00
committed by GitHub
parent 4bb39341c1
commit 13a7a1d7eb
5 changed files with 96 additions and 1 deletions
@@ -0,0 +1,26 @@
package com.baeldung.jni.registernatives;
import com.baeldung.jni.RegisterNativesHelloWorldJNI;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class JNIRegisterNativesManualTest {
@Before
public void setup() {
System.loadLibrary("native");
}
@Test
public void whenRegisteredNativeHelloWorld_thenOutputIsAsExpected() {
RegisterNativesHelloWorldJNI helloWorld = new RegisterNativesHelloWorldJNI();
helloWorld.register();
String helloFromNative = helloWorld.sayHello();
assertNotNull(helloFromNative);
assertTrue(helloFromNative.equals("Hello from registered native C++ !!"));
}
}