summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-03 20:55:35 +0200
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-03 20:55:35 +0200
commit3705f9d9adaca497801c532d3f3087041f5504b4 (patch)
treed26af9c2b0931019946325476b72b8d8ef7d3b0f /src
parenta5f5d1479039db6bd093ffa828d975cd00e45ea6 (diff)
downloadmaven-nar-plugin-3705f9d9adaca497801c532d3f3087041f5504b4.tar.gz
maven-nar-plugin-3705f9d9adaca497801c532d3f3087041f5504b4.tar.bz2
maven-nar-plugin-3705f9d9adaca497801c532d3f3087041f5504b4.tar.xz
maven-nar-plugin-3705f9d9adaca497801c532d3f3087041f5504b4.zip
Added test 5
Diffstat (limited to 'src')
-rw-r--r--src/it/it0003-jni/pom.xml1
-rw-r--r--src/it/it0005-jni-static/pom.xml72
-rw-r--r--src/it/it0005-jni-static/src/main/c/HelloWorldStaticJNI.c16
-rw-r--r--src/it/it0005-jni-static/src/main/java/com/mycompany/mypackage/HelloWorldStaticJNI.java15
-rw-r--r--src/it/it0005-jni-static/src/test/java/HelloWorldStaticJNITest.java25
5 files changed, 129 insertions, 0 deletions
diff --git a/src/it/it0003-jni/pom.xml b/src/it/it0003-jni/pom.xml
index 8c1881b..eaf71c6 100644
--- a/src/it/it0003-jni/pom.xml
+++ b/src/it/it0003-jni/pom.xml
@@ -43,6 +43,7 @@ under the License.
<maven.test.skip>true</maven.test.skip>
</properties>
-->
+
<build>
<defaultGoal>integration-test</defaultGoal>
<plugins>
diff --git a/src/it/it0005-jni-static/pom.xml b/src/it/it0005-jni-static/pom.xml
new file mode 100644
index 0000000..97f51e5
--- /dev/null
+++ b/src/it/it0005-jni-static/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.its.nar</groupId>
+ <artifactId>it-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../it-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>it0005-jni-static</artifactId>
+ <packaging>nar</packaging>
+
+ <name>Maven NAR Static JNI Test</name>
+ <version>1.0-SNAPSHOT</version>
+ <description>
+ Simple Static JNI Library
+ </description>
+ <url>http://maven.apache.org/</url>
+<!--
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+-->
+
+ <build>
+ <defaultGoal>integration-test</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-nar-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <runtime>static</runtime>
+ <libraries>
+ <library>
+ <type>jni</type>
+ <narSystemPackage>com.mycompany.mypackage</narSystemPackage>
+ <linkCPP>false</linkCPP>
+ </library>
+ </libraries>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/it0005-jni-static/src/main/c/HelloWorldStaticJNI.c b/src/it/it0005-jni-static/src/main/c/HelloWorldStaticJNI.c
new file mode 100644
index 0000000..62b181b
--- /dev/null
+++ b/src/it/it0005-jni-static/src/main/c/HelloWorldStaticJNI.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include "com_mycompany_mypackage_HelloWorldStaticJNI.h"
+
+JNIEXPORT jstring JNICALL Java_com_mycompany_mypackage_HelloWorldStaticJNI_sayHello( JNIEnv *env, jobject obj ) {
+ jstring value; /* the return value */
+
+ char buf[40]; /* working buffer (really only need 20 ) */
+
+
+ sprintf ( buf, "%s", "Hello Static NAR World!" );
+
+ value = (*env)->NewStringUTF( env, buf );
+
+ return value;
+}
+
diff --git a/src/it/it0005-jni-static/src/main/java/com/mycompany/mypackage/HelloWorldStaticJNI.java b/src/it/it0005-jni-static/src/main/java/com/mycompany/mypackage/HelloWorldStaticJNI.java
new file mode 100644
index 0000000..f08de6a
--- /dev/null
+++ b/src/it/it0005-jni-static/src/main/java/com/mycompany/mypackage/HelloWorldStaticJNI.java
@@ -0,0 +1,15 @@
+package com.mycompany.mypackage;
+
+public class HelloWorldStaticJNI {
+ static {
+ NarSystem.loadLibrary();
+ }
+
+ public native String sayHello();
+
+ public static void main( String[] args ) {
+ HelloWorldStaticJNI app = new HelloWorldStaticJNI();
+ System.out.println( app.sayHello() );
+ }
+}
+
diff --git a/src/it/it0005-jni-static/src/test/java/HelloWorldStaticJNITest.java b/src/it/it0005-jni-static/src/test/java/HelloWorldStaticJNITest.java
new file mode 100644
index 0000000..c647f95
--- /dev/null
+++ b/src/it/it0005-jni-static/src/test/java/HelloWorldStaticJNITest.java
@@ -0,0 +1,25 @@
+import junit.framework.*;
+
+import com.mycompany.mypackage.HelloWorldStaticJNI;
+
+public class HelloWorldStaticJNITest extends TestCase {
+
+ public HelloWorldStaticJNITest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testNativeHelloWorldJNI() throws Exception {
+ HelloWorldStaticJNI app = new HelloWorldStaticJNI();
+
+ this.assertEquals( "Hello Static NAR World!", app.sayHello() );
+ }
+}
+