BAEL-2323 Adding files for native keyword tutorial (#5913)
* BAEL-2323 Adding files for native keyword tutorial * junit test files and native library * update test method name
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,10 @@
|
|||||||
|
package com.baeldung.nativekeyword;
|
||||||
|
|
||||||
|
public class DateTimeUtils {
|
||||||
|
|
||||||
|
public native String getSystemTime();
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.loadLibrary("nativedatetimeutils");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.baeldung.nativekeyword;
|
||||||
|
|
||||||
|
import com.baeldung.nativekeyword.DateTimeUtils;
|
||||||
|
|
||||||
|
public class NativeMainApp {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
DateTimeUtils dateTimeUtils = new DateTimeUtils();
|
||||||
|
String input = dateTimeUtils.getSystemTime();
|
||||||
|
System.out.println("System time is : " + input);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.baeldung.nativekeyword;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
public class DateTimeUtilsManualTest {
|
||||||
|
|
||||||
|
private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(DateTimeUtilsManualTest.class);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
System.loadLibrary("msvcr100");
|
||||||
|
System.loadLibrary("libgcc_s_sjlj-1");
|
||||||
|
System.loadLibrary("libstdc++-6");
|
||||||
|
System.loadLibrary("nativedatetimeutils");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenNativeLibsLoaded_thenNativeMethodIsAccessible() {
|
||||||
|
DateTimeUtils dateTimeUtils = new DateTimeUtils();
|
||||||
|
LOG.info("System time is : " + dateTimeUtils.getSystemTime());
|
||||||
|
assertNotNull(dateTimeUtils.getSystemTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user