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:
+26
@@ -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++ !!"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user