From 4c6faa3940488b1dc15ab5d2c75d4e61ddd24ca2 Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Tue, 6 Oct 2009 16:55:06 +0200 Subject: Fixed test 6, 8 and 9 --- src/it/it0001-executable/src/main/c/Executable.c | 19 ++++++ .../java/it0005/test/HelloWorldStaticJNITest.java | 3 +- .../lib/libit0003-jni-1.0-SNAPSHOT.jnilib | Bin 8648 -> 8616 bytes .../share/it0003-jni-1.0-SNAPSHOT.jar | Bin 4450 -> 4118 bytes .../src/test/java/HelloThirdPartyJNITest.java | 52 --------------- .../java/it0006/test/HelloThirdPartyJNITest.java | 54 +++++++++++++++ .../executable-dep-lib-shared/pom.xml | 70 ------------------- .../src/main/c/HelloWorldExe.c | 9 --- .../lib-shared/pom.xml | 74 --------------------- .../lib-shared/src/main/c/HelloWorldLib.c | 7 -- .../lib-shared/src/main/include/HelloWorldLib.h | 9 --- .../lib-shared/src/test/c/HelloWorldTest.c | 9 --- src/it/it0008-executable-dep-lib-shared/pom.xml | 42 +++++++++--- .../src/main/c/HelloWorldExe.c | 9 +++ .../jni-dep-lib-shared/pom.xml | 72 -------------------- .../src/main/c/HelloWorldSharedLibJNI.c | 17 ----- .../mypackage/HelloWorldSharedLibJNI.java | 36 ---------- .../src/test/java/HelloWorldSharedLibJNITest.java | 52 --------------- .../it0009-jni-dep-lib-shared/lib-shared/pom.xml | 74 --------------------- .../lib-shared/src/main/c/HelloWorldLib.c | 7 -- .../lib-shared/src/main/include/HelloWorldLib.h | 9 --- .../lib-shared/src/test/c/HelloWorldTest.c | 9 --- src/it/it0009-jni-dep-lib-shared/pom.xml | 44 +++++++++--- .../src/main/c/HelloWorldSharedLibJNI.c | 36 ++++++++++ .../main/java/it0009/HelloWorldSharedLibJNI.java | 36 ++++++++++ .../it0009/test/HelloWorldSharedLibJNITest.java | 55 +++++++++++++++ 26 files changed, 277 insertions(+), 527 deletions(-) delete mode 100644 src/it/it0006-jni-3rdparty/src/test/java/HelloThirdPartyJNITest.java create mode 100644 src/it/it0006-jni-3rdparty/src/test/java/it0006/test/HelloThirdPartyJNITest.java delete mode 100644 src/it/it0008-executable-dep-lib-shared/executable-dep-lib-shared/pom.xml delete mode 100644 src/it/it0008-executable-dep-lib-shared/executable-dep-lib-shared/src/main/c/HelloWorldExe.c delete mode 100644 src/it/it0008-executable-dep-lib-shared/lib-shared/pom.xml delete mode 100644 src/it/it0008-executable-dep-lib-shared/lib-shared/src/main/c/HelloWorldLib.c delete mode 100644 src/it/it0008-executable-dep-lib-shared/lib-shared/src/main/include/HelloWorldLib.h delete mode 100644 src/it/it0008-executable-dep-lib-shared/lib-shared/src/test/c/HelloWorldTest.c create mode 100644 src/it/it0008-executable-dep-lib-shared/src/main/c/HelloWorldExe.c delete mode 100644 src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/pom.xml delete mode 100644 src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/main/c/HelloWorldSharedLibJNI.c delete mode 100644 src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/main/java/com/mycompany/mypackage/HelloWorldSharedLibJNI.java delete mode 100644 src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/test/java/HelloWorldSharedLibJNITest.java delete mode 100644 src/it/it0009-jni-dep-lib-shared/lib-shared/pom.xml delete mode 100644 src/it/it0009-jni-dep-lib-shared/lib-shared/src/main/c/HelloWorldLib.c delete mode 100644 src/it/it0009-jni-dep-lib-shared/lib-shared/src/main/include/HelloWorldLib.h delete mode 100644 src/it/it0009-jni-dep-lib-shared/lib-shared/src/test/c/HelloWorldTest.c create mode 100644 src/it/it0009-jni-dep-lib-shared/src/main/c/HelloWorldSharedLibJNI.c create mode 100644 src/it/it0009-jni-dep-lib-shared/src/main/java/it0009/HelloWorldSharedLibJNI.java create mode 100644 src/it/it0009-jni-dep-lib-shared/src/test/java/it0009/test/HelloWorldSharedLibJNITest.java diff --git a/src/it/it0001-executable/src/main/c/Executable.c b/src/it/it0001-executable/src/main/c/Executable.c index d640602..19afb26 100644 --- a/src/it/it0001-executable/src/main/c/Executable.c +++ b/src/it/it0001-executable/src/main/c/Executable.c @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #include int main(int argc, char *argv[]) { diff --git a/src/it/it0005-jni-static/src/test/java/it0005/test/HelloWorldStaticJNITest.java b/src/it/it0005-jni-static/src/test/java/it0005/test/HelloWorldStaticJNITest.java index 0326d9a..45cb048 100644 --- a/src/it/it0005-jni-static/src/test/java/it0005/test/HelloWorldStaticJNITest.java +++ b/src/it/it0005-jni-static/src/test/java/it0005/test/HelloWorldStaticJNITest.java @@ -20,6 +20,7 @@ package it0005.test; */ import it0005.HelloWorldStaticJNI; +import junit.framework.Assert; import junit.framework.TestCase; public class HelloWorldStaticJNITest @@ -48,6 +49,6 @@ public class HelloWorldStaticJNITest { HelloWorldStaticJNI app = new HelloWorldStaticJNI(); - this.assertEquals( "Hello Static NAR World!", app.sayHello() ); + Assert.assertEquals( "Hello Static NAR World!", app.sayHello() ); } } diff --git a/src/it/it0006-jni-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/lib/libit0003-jni-1.0-SNAPSHOT.jnilib b/src/it/it0006-jni-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/lib/libit0003-jni-1.0-SNAPSHOT.jnilib index b7e52a4..5087599 100755 Binary files a/src/it/it0006-jni-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/lib/libit0003-jni-1.0-SNAPSHOT.jnilib and b/src/it/it0006-jni-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/lib/libit0003-jni-1.0-SNAPSHOT.jnilib differ diff --git a/src/it/it0006-jni-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/share/it0003-jni-1.0-SNAPSHOT.jar b/src/it/it0006-jni-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/share/it0003-jni-1.0-SNAPSHOT.jar index f2e29f5..c811a6a 100644 Binary files a/src/it/it0006-jni-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/share/it0003-jni-1.0-SNAPSHOT.jar and b/src/it/it0006-jni-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/share/it0003-jni-1.0-SNAPSHOT.jar differ diff --git a/src/it/it0006-jni-3rdparty/src/test/java/HelloThirdPartyJNITest.java b/src/it/it0006-jni-3rdparty/src/test/java/HelloThirdPartyJNITest.java deleted file mode 100644 index 837d670..0000000 --- a/src/it/it0006-jni-3rdparty/src/test/java/HelloThirdPartyJNITest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.*; - -import com.mycompany.mypackage.HelloWorldJNI; - -public class HelloThirdPartyJNITest - extends TestCase -{ - - public HelloThirdPartyJNITest( String name ) - { - super( name ); - } - - protected void setUp() - throws Exception - { - super.setUp(); - } - - protected void tearDown() - throws Exception - { - super.tearDown(); - } - - public void testNativeHelloThirdPartyJNI() - throws Exception - { - HelloWorldJNI app = new HelloWorldJNI(); - - this.assertEquals( "Hello NAR World!", app.sayHello() ); - } -} diff --git a/src/it/it0006-jni-3rdparty/src/test/java/it0006/test/HelloThirdPartyJNITest.java b/src/it/it0006-jni-3rdparty/src/test/java/it0006/test/HelloThirdPartyJNITest.java new file mode 100644 index 0000000..426f604 --- /dev/null +++ b/src/it/it0006-jni-3rdparty/src/test/java/it0006/test/HelloThirdPartyJNITest.java @@ -0,0 +1,54 @@ +package it0006.test; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.*; + +import it0003.HelloWorldJNI; + +public class HelloThirdPartyJNITest + extends TestCase +{ + + public HelloThirdPartyJNITest( String name ) + { + super( name ); + } + + protected void setUp() + throws Exception + { + super.setUp(); + } + + protected void tearDown() + throws Exception + { + super.tearDown(); + } + + public void testNativeHelloThirdPartyJNI() + throws Exception + { + HelloWorldJNI app = new HelloWorldJNI(); + + this.assertEquals( "Hello NAR World!", app.sayHello() ); + } +} diff --git a/src/it/it0008-executable-dep-lib-shared/executable-dep-lib-shared/pom.xml b/src/it/it0008-executable-dep-lib-shared/executable-dep-lib-shared/pom.xml deleted file mode 100644 index aa3498b..0000000 --- a/src/it/it0008-executable-dep-lib-shared/executable-dep-lib-shared/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.nar - it0008-pom - 1.0-SNAPSHOT - - - it0008-executable-dep-lib-shared - nar - - Maven NAR Executable - 1.0-SNAPSHOT - - Executable - - - - integration-test - - - maven-nar-plugin - true - - - - executable - true - - - - - - maven-surefire-plugin - - true - - - - - - - org.apache.maven.its.nar - it0008-lib-shared - 1.0-SNAPSHOT - - - diff --git a/src/it/it0008-executable-dep-lib-shared/executable-dep-lib-shared/src/main/c/HelloWorldExe.c b/src/it/it0008-executable-dep-lib-shared/executable-dep-lib-shared/src/main/c/HelloWorldExe.c deleted file mode 100644 index 4aa35d8..0000000 --- a/src/it/it0008-executable-dep-lib-shared/executable-dep-lib-shared/src/main/c/HelloWorldExe.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include "HelloWorldLib.h" - -int main(int argc, char *argv[]) { - printf("%s\n", HelloWorldLib_sayHello()); - return 0; -} - - diff --git a/src/it/it0008-executable-dep-lib-shared/lib-shared/pom.xml b/src/it/it0008-executable-dep-lib-shared/lib-shared/pom.xml deleted file mode 100644 index 4c46296..0000000 --- a/src/it/it0008-executable-dep-lib-shared/lib-shared/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.nar - it0008-pom - 1.0-SNAPSHOT - - - it0008-lib-shared - nar - - Maven NAR Shared Library - 1.0-SNAPSHOT - - Simple shared library and test file - - http://maven.apache.org/ - - - - install - - - maven-nar-plugin - true - - - - shared - - - - - HelloWorldTest - shared - - - - - - maven-surefire-plugin - - true - - - - - diff --git a/src/it/it0008-executable-dep-lib-shared/lib-shared/src/main/c/HelloWorldLib.c b/src/it/it0008-executable-dep-lib-shared/lib-shared/src/main/c/HelloWorldLib.c deleted file mode 100644 index 9f65143..0000000 --- a/src/it/it0008-executable-dep-lib-shared/lib-shared/src/main/c/HelloWorldLib.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "HelloWorldLib.h" - -char* HelloWorldLib_sayHello() { - return "Hello NAR LIB World!"; -} - diff --git a/src/it/it0008-executable-dep-lib-shared/lib-shared/src/main/include/HelloWorldLib.h b/src/it/it0008-executable-dep-lib-shared/lib-shared/src/main/include/HelloWorldLib.h deleted file mode 100644 index e801bec..0000000 --- a/src/it/it0008-executable-dep-lib-shared/lib-shared/src/main/include/HelloWorldLib.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef HelloWorldLib_H -#define HelloWorldLib_H - -#ifdef WIN32 -__declspec(dllexport) -#endif -extern char* HelloWorldLib_sayHello(); - -#endif diff --git a/src/it/it0008-executable-dep-lib-shared/lib-shared/src/test/c/HelloWorldTest.c b/src/it/it0008-executable-dep-lib-shared/lib-shared/src/test/c/HelloWorldTest.c deleted file mode 100644 index 4aa35d8..0000000 --- a/src/it/it0008-executable-dep-lib-shared/lib-shared/src/test/c/HelloWorldTest.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include "HelloWorldLib.h" - -int main(int argc, char *argv[]) { - printf("%s\n", HelloWorldLib_sayHello()); - return 0; -} - - diff --git a/src/it/it0008-executable-dep-lib-shared/pom.xml b/src/it/it0008-executable-dep-lib-shared/pom.xml index ad81553..7ce981b 100644 --- a/src/it/it0008-executable-dep-lib-shared/pom.xml +++ b/src/it/it0008-executable-dep-lib-shared/pom.xml @@ -29,21 +29,43 @@ under the License. ../it-parent/pom.xml - it0008-pom - pom + it0008-executable-dep-lib-shared + nar Maven NAR Executable and Shared Library 1.0-SNAPSHOT Executable depending on a shared library. - + - install - - - - executable-dep-lib-shared - lib-shared - + integration-test + + + maven-nar-plugin + true + + + + executable + true + + + + + + maven-surefire-plugin + + true + + + + + + + org.apache.maven.its.nar + it0007-lib-shared + 1.0-SNAPSHOT + + diff --git a/src/it/it0008-executable-dep-lib-shared/src/main/c/HelloWorldExe.c b/src/it/it0008-executable-dep-lib-shared/src/main/c/HelloWorldExe.c new file mode 100644 index 0000000..4aa35d8 --- /dev/null +++ b/src/it/it0008-executable-dep-lib-shared/src/main/c/HelloWorldExe.c @@ -0,0 +1,9 @@ +#include +#include "HelloWorldLib.h" + +int main(int argc, char *argv[]) { + printf("%s\n", HelloWorldLib_sayHello()); + return 0; +} + + diff --git a/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/pom.xml b/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/pom.xml deleted file mode 100644 index 45d3487..0000000 --- a/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.nar - it0009-pom - 1.0-SNAPSHOT - - - it0009-jni-dep-lib-shared - nar - - Maven NAR JNI - 1.0-SNAPSHOT - - JNI - - - - integration-test - - - maven-nar-plugin - true - - - - jni - com.mycompany.mypackage - false - - - - - - maven-surefire-plugin - - true - - - - - - - - org.apache.maven.its.nar - it0009-lib-shared - 1.0-SNAPSHOT - - - diff --git a/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/main/c/HelloWorldSharedLibJNI.c b/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/main/c/HelloWorldSharedLibJNI.c deleted file mode 100644 index e5b8e4b..0000000 --- a/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/main/c/HelloWorldSharedLibJNI.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include "HelloWorldLib.h" - -#include "com_mycompany_mypackage_HelloWorldSharedLibJNI.h" - -JNIEXPORT jstring JNICALL Java_com_mycompany_mypackage_HelloWorldSharedLibJNI_sayHello( JNIEnv *env, jobject obj ) { - jstring value; /* the return value */ - - char buf[80]; /* working buffer (really only need 20 ) */ - - sprintf ( buf, "%s", HelloWorldLib_sayHello()); - - value = (*env)->NewStringUTF( env, buf ); - - return value; -} - diff --git a/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/main/java/com/mycompany/mypackage/HelloWorldSharedLibJNI.java b/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/main/java/com/mycompany/mypackage/HelloWorldSharedLibJNI.java deleted file mode 100644 index 0c64a53..0000000 --- a/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/main/java/com/mycompany/mypackage/HelloWorldSharedLibJNI.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.mycompany.mypackage; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -public class HelloWorldSharedLibJNI -{ - static - { - NarSystem.loadLibrary(); - } - - public native String sayHello(); - - public static void main( String[] args ) - { - HelloWorldSharedLibJNI app = new HelloWorldSharedLibJNI(); - System.out.println( app.sayHello() ); - } -} diff --git a/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/test/java/HelloWorldSharedLibJNITest.java b/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/test/java/HelloWorldSharedLibJNITest.java deleted file mode 100644 index 393212d..0000000 --- a/src/it/it0009-jni-dep-lib-shared/jni-dep-lib-shared/src/test/java/HelloWorldSharedLibJNITest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.*; - -import com.mycompany.mypackage.HelloWorldSharedLibJNI; - -public class HelloWorldSharedLibJNITest - extends TestCase -{ - - public HelloWorldSharedLibJNITest( String name ) - { - super( name ); - } - - protected void setUp() - throws Exception - { - super.setUp(); - } - - protected void tearDown() - throws Exception - { - super.tearDown(); - } - - public void testNativeHelloWorldSharedLibJNI() - throws Exception - { - HelloWorldSharedLibJNI app = new HelloWorldSharedLibJNI(); - - this.assertEquals( "Hello NAR LIB World!", app.sayHello() ); - } -} diff --git a/src/it/it0009-jni-dep-lib-shared/lib-shared/pom.xml b/src/it/it0009-jni-dep-lib-shared/lib-shared/pom.xml deleted file mode 100644 index b29f03a..0000000 --- a/src/it/it0009-jni-dep-lib-shared/lib-shared/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.nar - it0009-pom - 1.0-SNAPSHOT - - - it0009-lib-shared - nar - - Maven NAR Shared Library - 1.0-SNAPSHOT - - Simple shared library and test file - - http://maven.apache.org/ - - - - install - - - maven-nar-plugin - true - - - - shared - - - - - HelloWorldTest - shared - - - - - - maven-surefire-plugin - - true - - - - - diff --git a/src/it/it0009-jni-dep-lib-shared/lib-shared/src/main/c/HelloWorldLib.c b/src/it/it0009-jni-dep-lib-shared/lib-shared/src/main/c/HelloWorldLib.c deleted file mode 100644 index 9f65143..0000000 --- a/src/it/it0009-jni-dep-lib-shared/lib-shared/src/main/c/HelloWorldLib.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "HelloWorldLib.h" - -char* HelloWorldLib_sayHello() { - return "Hello NAR LIB World!"; -} - diff --git a/src/it/it0009-jni-dep-lib-shared/lib-shared/src/main/include/HelloWorldLib.h b/src/it/it0009-jni-dep-lib-shared/lib-shared/src/main/include/HelloWorldLib.h deleted file mode 100644 index e801bec..0000000 --- a/src/it/it0009-jni-dep-lib-shared/lib-shared/src/main/include/HelloWorldLib.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef HelloWorldLib_H -#define HelloWorldLib_H - -#ifdef WIN32 -__declspec(dllexport) -#endif -extern char* HelloWorldLib_sayHello(); - -#endif diff --git a/src/it/it0009-jni-dep-lib-shared/lib-shared/src/test/c/HelloWorldTest.c b/src/it/it0009-jni-dep-lib-shared/lib-shared/src/test/c/HelloWorldTest.c deleted file mode 100644 index 4aa35d8..0000000 --- a/src/it/it0009-jni-dep-lib-shared/lib-shared/src/test/c/HelloWorldTest.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include "HelloWorldLib.h" - -int main(int argc, char *argv[]) { - printf("%s\n", HelloWorldLib_sayHello()); - return 0; -} - - diff --git a/src/it/it0009-jni-dep-lib-shared/pom.xml b/src/it/it0009-jni-dep-lib-shared/pom.xml index f6719de..e211c83 100644 --- a/src/it/it0009-jni-dep-lib-shared/pom.xml +++ b/src/it/it0009-jni-dep-lib-shared/pom.xml @@ -29,21 +29,45 @@ under the License. ../it-parent/pom.xml - it0009-pom - pom + it0009-jni-dep-lib-shared + nar Maven NAR JNI and Shared Library 1.0-SNAPSHOT JNI depending on a shared library. - - - install - - - jni-dep-lib-shared - lib-shared - + + integration-test + + + maven-nar-plugin + true + + + + jni + it0009 + false + + + + + + maven-surefire-plugin + + true + + + + + + + + org.apache.maven.its.nar + it0007-lib-shared + 1.0-SNAPSHOT + + diff --git a/src/it/it0009-jni-dep-lib-shared/src/main/c/HelloWorldSharedLibJNI.c b/src/it/it0009-jni-dep-lib-shared/src/main/c/HelloWorldSharedLibJNI.c new file mode 100644 index 0000000..fd23d83 --- /dev/null +++ b/src/it/it0009-jni-dep-lib-shared/src/main/c/HelloWorldSharedLibJNI.c @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include "HelloWorldLib.h" + +#include "it0009_HelloWorldSharedLibJNI.h" + +JNIEXPORT jstring JNICALL Java_it0009_HelloWorldSharedLibJNI_sayHello( JNIEnv *env, jobject obj ) { + jstring value; /* the return value */ + + char buf[80]; /* working buffer (really only need 20 ) */ + + sprintf ( buf, "%s", HelloWorldLib_sayHello()); + + value = (*env)->NewStringUTF( env, buf ); + + return value; +} + diff --git a/src/it/it0009-jni-dep-lib-shared/src/main/java/it0009/HelloWorldSharedLibJNI.java b/src/it/it0009-jni-dep-lib-shared/src/main/java/it0009/HelloWorldSharedLibJNI.java new file mode 100644 index 0000000..001ec98 --- /dev/null +++ b/src/it/it0009-jni-dep-lib-shared/src/main/java/it0009/HelloWorldSharedLibJNI.java @@ -0,0 +1,36 @@ +package it0009; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class HelloWorldSharedLibJNI +{ + static + { + NarSystem.loadLibrary(); + } + + public native String sayHello(); + + public static void main( String[] args ) + { + HelloWorldSharedLibJNI app = new HelloWorldSharedLibJNI(); + System.out.println( app.sayHello() ); + } +} diff --git a/src/it/it0009-jni-dep-lib-shared/src/test/java/it0009/test/HelloWorldSharedLibJNITest.java b/src/it/it0009-jni-dep-lib-shared/src/test/java/it0009/test/HelloWorldSharedLibJNITest.java new file mode 100644 index 0000000..5b9adc9 --- /dev/null +++ b/src/it/it0009-jni-dep-lib-shared/src/test/java/it0009/test/HelloWorldSharedLibJNITest.java @@ -0,0 +1,55 @@ +package it0009.test; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import it0009.HelloWorldSharedLibJNI; +import junit.framework.Assert; +import junit.framework.TestCase; + + +public class HelloWorldSharedLibJNITest + extends TestCase +{ + + public HelloWorldSharedLibJNITest( String name ) + { + super( name ); + } + + protected void setUp() + throws Exception + { + super.setUp(); + } + + protected void tearDown() + throws Exception + { + super.tearDown(); + } + + public void testNativeHelloWorldSharedLibJNI() + throws Exception + { + HelloWorldSharedLibJNI app = new HelloWorldSharedLibJNI(); + + Assert.assertEquals( "Hello NAR LIB World!", app.sayHello() ); + } +} -- cgit v1.2.3