From 9ed4b24f6d1d6e5ef9119b8a22744eb16721b1eb Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Tue, 6 Oct 2009 21:31:40 +0200 Subject: Fixed tests 6, 11 and 12 --- .../java/it0006/test/HelloThirdPartyJNITest.java | 6 +- .../executable-dep-lib-static/pom.xml | 71 --------------------- .../src/main/c/HelloWorldExe.c | 9 --- .../lib-static/pom.xml | 74 ---------------------- .../lib-static/src/main/c/HelloWorldLib.c | 7 -- .../lib-static/src/main/include/HelloWorldLib.h | 6 -- .../lib-static/src/test/c/HelloWorldTest.c | 9 --- src/it/it0011-executable-dep-lib-static/pom.xml | 43 ++++++++++--- .../src/main/c/HelloWorldExe.c | 9 +++ .../jni-dep-lib-static/pom.xml | 72 --------------------- .../src/main/c/HelloWorldSharedLibJNI.c | 17 ----- .../mypackage/HelloWorldSharedLibJNI.java | 36 ----------- .../src/test/java/HelloWorldSharedLibJNITest.java | 52 --------------- .../it0012-jni-dep-lib-static/lib-static/pom.xml | 74 ---------------------- .../lib-static/src/main/c/HelloWorldLib.c | 7 -- .../lib-static/src/main/include/HelloWorldLib.h | 6 -- .../lib-static/src/test/c/HelloWorldTest.c | 9 --- src/it/it0012-jni-dep-lib-static/pom.xml | 50 +++++++++++---- .../src/main/c/HelloWorldSharedLibJNI.c | 36 +++++++++++ .../main/java/it0012/HelloWorldSharedLibJNI.java | 36 +++++++++++ .../it0012/test/HelloWorldSharedLibJNITest.java | 54 ++++++++++++++++ 21 files changed, 208 insertions(+), 475 deletions(-) delete mode 100644 src/it/it0011-executable-dep-lib-static/executable-dep-lib-static/pom.xml delete mode 100644 src/it/it0011-executable-dep-lib-static/executable-dep-lib-static/src/main/c/HelloWorldExe.c delete mode 100644 src/it/it0011-executable-dep-lib-static/lib-static/pom.xml delete mode 100644 src/it/it0011-executable-dep-lib-static/lib-static/src/main/c/HelloWorldLib.c delete mode 100644 src/it/it0011-executable-dep-lib-static/lib-static/src/main/include/HelloWorldLib.h delete mode 100644 src/it/it0011-executable-dep-lib-static/lib-static/src/test/c/HelloWorldTest.c create mode 100644 src/it/it0011-executable-dep-lib-static/src/main/c/HelloWorldExe.c delete mode 100644 src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/pom.xml delete mode 100644 src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/src/main/c/HelloWorldSharedLibJNI.c delete mode 100644 src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/src/main/java/com/mycompany/mypackage/HelloWorldSharedLibJNI.java delete mode 100644 src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/src/test/java/HelloWorldSharedLibJNITest.java delete mode 100644 src/it/it0012-jni-dep-lib-static/lib-static/pom.xml delete mode 100644 src/it/it0012-jni-dep-lib-static/lib-static/src/main/c/HelloWorldLib.c delete mode 100644 src/it/it0012-jni-dep-lib-static/lib-static/src/main/include/HelloWorldLib.h delete mode 100644 src/it/it0012-jni-dep-lib-static/lib-static/src/test/c/HelloWorldTest.c create mode 100644 src/it/it0012-jni-dep-lib-static/src/main/c/HelloWorldSharedLibJNI.c create mode 100644 src/it/it0012-jni-dep-lib-static/src/main/java/it0012/HelloWorldSharedLibJNI.java create mode 100644 src/it/it0012-jni-dep-lib-static/src/test/java/it0012/test/HelloWorldSharedLibJNITest.java (limited to 'src/it') 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 index 426f604..db6b80c 100644 --- 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 @@ -19,9 +19,9 @@ package it0006.test; * under the License. */ -import junit.framework.*; - import it0003.HelloWorldJNI; +import junit.framework.Assert; +import junit.framework.TestCase; public class HelloThirdPartyJNITest extends TestCase @@ -49,6 +49,6 @@ public class HelloThirdPartyJNITest { HelloWorldJNI app = new HelloWorldJNI(); - this.assertEquals( "Hello NAR World!", app.sayHello() ); + Assert.assertEquals( "Hello NAR World!", app.sayHello() ); } } diff --git a/src/it/it0011-executable-dep-lib-static/executable-dep-lib-static/pom.xml b/src/it/it0011-executable-dep-lib-static/executable-dep-lib-static/pom.xml deleted file mode 100644 index 6c78c71..0000000 --- a/src/it/it0011-executable-dep-lib-static/executable-dep-lib-static/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.nar - it0011-pom - 1.0-SNAPSHOT - - - it0011-executable-dep-lib-static - 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 - it0011-lib-static - 1.0-SNAPSHOT - - - diff --git a/src/it/it0011-executable-dep-lib-static/executable-dep-lib-static/src/main/c/HelloWorldExe.c b/src/it/it0011-executable-dep-lib-static/executable-dep-lib-static/src/main/c/HelloWorldExe.c deleted file mode 100644 index 4aa35d8..0000000 --- a/src/it/it0011-executable-dep-lib-static/executable-dep-lib-static/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/it0011-executable-dep-lib-static/lib-static/pom.xml b/src/it/it0011-executable-dep-lib-static/lib-static/pom.xml deleted file mode 100644 index 3ef44a4..0000000 --- a/src/it/it0011-executable-dep-lib-static/lib-static/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.nar - it0011-pom - 1.0-SNAPSHOT - - - it0011-lib-static - nar - - Maven NAR Static Library - 1.0-SNAPSHOT - - Simple static library and test file - - http://maven.apache.org/ - - - - install - - - maven-nar-plugin - true - - - - static - - - - - HelloWorldTest - static - - - - - - maven-surefire-plugin - - true - - - - - diff --git a/src/it/it0011-executable-dep-lib-static/lib-static/src/main/c/HelloWorldLib.c b/src/it/it0011-executable-dep-lib-static/lib-static/src/main/c/HelloWorldLib.c deleted file mode 100644 index 9f65143..0000000 --- a/src/it/it0011-executable-dep-lib-static/lib-static/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/it0011-executable-dep-lib-static/lib-static/src/main/include/HelloWorldLib.h b/src/it/it0011-executable-dep-lib-static/lib-static/src/main/include/HelloWorldLib.h deleted file mode 100644 index 8c50dfb..0000000 --- a/src/it/it0011-executable-dep-lib-static/lib-static/src/main/include/HelloWorldLib.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HelloWorldLib_H -#define HelloWorldLib_H - -extern char* HelloWorldLib_sayHello(); - -#endif diff --git a/src/it/it0011-executable-dep-lib-static/lib-static/src/test/c/HelloWorldTest.c b/src/it/it0011-executable-dep-lib-static/lib-static/src/test/c/HelloWorldTest.c deleted file mode 100644 index 4aa35d8..0000000 --- a/src/it/it0011-executable-dep-lib-static/lib-static/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/it0011-executable-dep-lib-static/pom.xml b/src/it/it0011-executable-dep-lib-static/pom.xml index 34142a2..74b92cd 100644 --- a/src/it/it0011-executable-dep-lib-static/pom.xml +++ b/src/it/it0011-executable-dep-lib-static/pom.xml @@ -29,21 +29,44 @@ under the License. ../it-parent/pom.xml - it0011-pom - pom + it0011-executable-dep-lib-static + nar Maven NAR Executable and Static Library 1.0-SNAPSHOT Executable depending on a static library. - - - install - - - executable-dep-lib-static - lib-static - + + integration-test + + + maven-nar-plugin + true + + + + executable + true + + + + + + maven-surefire-plugin + + true + + + + + + + + org.apache.maven.its.nar + it0010-lib-static + 1.0-SNAPSHOT + + diff --git a/src/it/it0011-executable-dep-lib-static/src/main/c/HelloWorldExe.c b/src/it/it0011-executable-dep-lib-static/src/main/c/HelloWorldExe.c new file mode 100644 index 0000000..4aa35d8 --- /dev/null +++ b/src/it/it0011-executable-dep-lib-static/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/it0012-jni-dep-lib-static/jni-dep-lib-static/pom.xml b/src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/pom.xml deleted file mode 100644 index b06ee18..0000000 --- a/src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.nar - it0012-pom - 1.0-SNAPSHOT - - - it0012-jni-dep-lib-static - 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 - it0012-lib-static - 1.0-SNAPSHOT - - - diff --git a/src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/src/main/c/HelloWorldSharedLibJNI.c b/src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/src/main/c/HelloWorldSharedLibJNI.c deleted file mode 100644 index e5b8e4b..0000000 --- a/src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/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/it0012-jni-dep-lib-static/jni-dep-lib-static/src/main/java/com/mycompany/mypackage/HelloWorldSharedLibJNI.java b/src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/src/main/java/com/mycompany/mypackage/HelloWorldSharedLibJNI.java deleted file mode 100644 index 0c64a53..0000000 --- a/src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/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/it0012-jni-dep-lib-static/jni-dep-lib-static/src/test/java/HelloWorldSharedLibJNITest.java b/src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/src/test/java/HelloWorldSharedLibJNITest.java deleted file mode 100644 index 393212d..0000000 --- a/src/it/it0012-jni-dep-lib-static/jni-dep-lib-static/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/it0012-jni-dep-lib-static/lib-static/pom.xml b/src/it/it0012-jni-dep-lib-static/lib-static/pom.xml deleted file mode 100644 index 034b27f..0000000 --- a/src/it/it0012-jni-dep-lib-static/lib-static/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.nar - it0012-pom - 1.0-SNAPSHOT - - - it0012-lib-static - nar - - Maven NAR Static Library - 1.0-SNAPSHOT - - Simple static library and test file - - http://maven.apache.org/ - - - - install - - - maven-nar-plugin - true - - - - static - - - - - HelloWorldTest - static - - - - - - maven-surefire-plugin - - true - - - - - diff --git a/src/it/it0012-jni-dep-lib-static/lib-static/src/main/c/HelloWorldLib.c b/src/it/it0012-jni-dep-lib-static/lib-static/src/main/c/HelloWorldLib.c deleted file mode 100644 index 9f65143..0000000 --- a/src/it/it0012-jni-dep-lib-static/lib-static/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/it0012-jni-dep-lib-static/lib-static/src/main/include/HelloWorldLib.h b/src/it/it0012-jni-dep-lib-static/lib-static/src/main/include/HelloWorldLib.h deleted file mode 100644 index 8c50dfb..0000000 --- a/src/it/it0012-jni-dep-lib-static/lib-static/src/main/include/HelloWorldLib.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HelloWorldLib_H -#define HelloWorldLib_H - -extern char* HelloWorldLib_sayHello(); - -#endif diff --git a/src/it/it0012-jni-dep-lib-static/lib-static/src/test/c/HelloWorldTest.c b/src/it/it0012-jni-dep-lib-static/lib-static/src/test/c/HelloWorldTest.c deleted file mode 100644 index 4aa35d8..0000000 --- a/src/it/it0012-jni-dep-lib-static/lib-static/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/it0012-jni-dep-lib-static/pom.xml b/src/it/it0012-jni-dep-lib-static/pom.xml index 20434be..d63def0 100644 --- a/src/it/it0012-jni-dep-lib-static/pom.xml +++ b/src/it/it0012-jni-dep-lib-static/pom.xml @@ -29,21 +29,45 @@ under the License. ../it-parent/pom.xml - it0012-pom - pom - - Maven NAR JNI and Static Library + it0012-jni-dep-lib-static + nar + + Maven NAR JNI 1.0-SNAPSHOT - JNI depending on a static library. + JNI - - - install - - - jni-dep-lib-static - lib-static - + + integration-test + + + maven-nar-plugin + true + + + + jni + it0012 + false + + + + + + maven-surefire-plugin + + true + + + + + + + + org.apache.maven.its.nar + it0010-lib-static + 1.0-SNAPSHOT + + diff --git a/src/it/it0012-jni-dep-lib-static/src/main/c/HelloWorldSharedLibJNI.c b/src/it/it0012-jni-dep-lib-static/src/main/c/HelloWorldSharedLibJNI.c new file mode 100644 index 0000000..e044f28 --- /dev/null +++ b/src/it/it0012-jni-dep-lib-static/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 "it0012_HelloWorldSharedLibJNI.h" + +JNIEXPORT jstring JNICALL Java_it0012_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/it0012-jni-dep-lib-static/src/main/java/it0012/HelloWorldSharedLibJNI.java b/src/it/it0012-jni-dep-lib-static/src/main/java/it0012/HelloWorldSharedLibJNI.java new file mode 100644 index 0000000..de48437 --- /dev/null +++ b/src/it/it0012-jni-dep-lib-static/src/main/java/it0012/HelloWorldSharedLibJNI.java @@ -0,0 +1,36 @@ +package it0012; + +/* + * 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/it0012-jni-dep-lib-static/src/test/java/it0012/test/HelloWorldSharedLibJNITest.java b/src/it/it0012-jni-dep-lib-static/src/test/java/it0012/test/HelloWorldSharedLibJNITest.java new file mode 100644 index 0000000..b3aac5c --- /dev/null +++ b/src/it/it0012-jni-dep-lib-static/src/test/java/it0012/test/HelloWorldSharedLibJNITest.java @@ -0,0 +1,54 @@ +package it0012.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 it0012.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