summaryrefslogtreecommitdiff
path: root/src/it/it0003-jni/src
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-03 14:53:01 +0200
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-03 14:53:01 +0200
commit1b3f5eb617863b4d4c2e1c29b48a1efba2bdf5ff (patch)
treee8831dc2e66d61d394773582f1068ef0c10963d3 /src/it/it0003-jni/src
parentf16721c64008697a5b37c002f3b201d15e556c7a (diff)
downloadmaven-nar-plugin-1b3f5eb617863b4d4c2e1c29b48a1efba2bdf5ff.tar.gz
maven-nar-plugin-1b3f5eb617863b4d4c2e1c29b48a1efba2bdf5ff.tar.bz2
maven-nar-plugin-1b3f5eb617863b4d4c2e1c29b48a1efba2bdf5ff.tar.xz
maven-nar-plugin-1b3f5eb617863b4d4c2e1c29b48a1efba2bdf5ff.zip
Added test 3
Diffstat (limited to 'src/it/it0003-jni/src')
-rw-r--r--src/it/it0003-jni/src/main/c/HelloWorldJNI.c16
-rw-r--r--src/it/it0003-jni/src/main/java/com/mycompany/mypackage/HelloWorldJNI.java15
-rw-r--r--src/it/it0003-jni/src/test/java/HelloWorldJNITest.java25
3 files changed, 56 insertions, 0 deletions
diff --git a/src/it/it0003-jni/src/main/c/HelloWorldJNI.c b/src/it/it0003-jni/src/main/c/HelloWorldJNI.c
new file mode 100644
index 0000000..716722e
--- /dev/null
+++ b/src/it/it0003-jni/src/main/c/HelloWorldJNI.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include "com_mycompany_mypackage_HelloWorldJNI.h"
+
+JNIEXPORT jstring JNICALL Java_com_mycompany_mypackage_HelloWorldJNI_sayHello( JNIEnv *env, jobject obj ) {
+ jstring value; /* the return value */
+
+ char buf[40]; /* working buffer (really only need 20 ) */
+
+
+ sprintf ( buf, "%s", "Hello NAR World!" );
+
+ value = (*env)->NewStringUTF( env, buf );
+
+ return value;
+}
+
diff --git a/src/it/it0003-jni/src/main/java/com/mycompany/mypackage/HelloWorldJNI.java b/src/it/it0003-jni/src/main/java/com/mycompany/mypackage/HelloWorldJNI.java
new file mode 100644
index 0000000..2af3f3c
--- /dev/null
+++ b/src/it/it0003-jni/src/main/java/com/mycompany/mypackage/HelloWorldJNI.java
@@ -0,0 +1,15 @@
+package com.mycompany.mypackage;
+
+public class HelloWorldJNI {
+ static {
+ NarSystem.loadLibrary();
+ }
+
+ public native String sayHello();
+
+ public static void main( String[] args ) {
+ HelloWorldJNI app = new HelloWorldJNI();
+ System.out.println( app.sayHello() );
+ }
+}
+
diff --git a/src/it/it0003-jni/src/test/java/HelloWorldJNITest.java b/src/it/it0003-jni/src/test/java/HelloWorldJNITest.java
new file mode 100644
index 0000000..683c321
--- /dev/null
+++ b/src/it/it0003-jni/src/test/java/HelloWorldJNITest.java
@@ -0,0 +1,25 @@
+import junit.framework.*;
+
+import com.mycompany.mypackage.HelloWorldJNI;
+
+public class HelloWorldJNITest extends TestCase {
+
+ public HelloWorldJNITest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testNativeHelloWorldJNI() throws Exception {
+ HelloWorldJNI app = new HelloWorldJNI();
+
+ this.assertEquals( "Hello NAR World!", app.sayHello() );
+ }
+}
+