You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2013/01/04 16:52:47 UTC

svn commit: r1428936 - in /qpid/proton/branches/jni-binding: proton-c/bindings/java/ proton-c/bindings/java/jni/src/main/java/org/apache/qpid/proton/engine/jni/ proton-c/bindings/java/jni/src/main/resources/ proton-c/bindings/java/jni/src/main/resource...

Author: kwall
Date: Fri Jan  4 15:52:46 2013
New Revision: 1428936

URL: http://svn.apache.org/viewvc?rev=1428936&view=rev
Log:
NO-JIRA: Proton system tests

* Added first simple java system test working for both stacks.
* Added factory to create proton objects (located via ServiceLoader).
* Added factory impl to both stacks.
* Removed JNI_LIBRARIES from swig_link_libraries command.  This was giving unwanted dependencies on libjawt, libmawt.so etc
* Used set_target_properties in bindings/java to work around difference in behaviour between cmake 2.6 and 2.8 re. lib prefix on .so's.

Added:
    qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/java/org/apache/qpid/proton/engine/jni/JNIEngineFactory.java
    qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/resources/
    qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/resources/META-INF/
    qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/resources/META-INF/services/
    qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory
    qpid/proton/branches/jni-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/engine/EngineFactory.java
    qpid/proton/branches/jni-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/EngineFactoryImpl.java
    qpid/proton/branches/jni-binding/proton-j/proton/src/main/resources/
    qpid/proton/branches/jni-binding/proton-j/proton/src/main/resources/META-INF/
    qpid/proton/branches/jni-binding/proton-j/proton/src/main/resources/META-INF/services/
    qpid/proton/branches/jni-binding/proton-j/proton/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory
    qpid/proton/branches/jni-binding/tests/proton-system-tests/
    qpid/proton/branches/jni-binding/tests/proton-system-tests/pom.xml
    qpid/proton/branches/jni-binding/tests/proton-system-tests/run-tests.sh   (with props)
    qpid/proton/branches/jni-binding/tests/proton-system-tests/src/
    qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/
    qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/
    qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/
    qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/apache/
    qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/apache/qpid/
    qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/apache/qpid/proton/
    qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/apache/qpid/proton/systemtests/
    qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/apache/qpid/proton/systemtests/SimpleTest.java
Modified:
    qpid/proton/branches/jni-binding/proton-c/bindings/java/CMakeLists.txt

Modified: qpid/proton/branches/jni-binding/proton-c/bindings/java/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/proton-c/bindings/java/CMakeLists.txt?rev=1428936&r1=1428935&r2=1428936&view=diff
==============================================================================
--- qpid/proton/branches/jni-binding/proton-c/bindings/java/CMakeLists.txt (original)
+++ qpid/proton/branches/jni-binding/proton-c/bindings/java/CMakeLists.txt Fri Jan  4 15:52:46 2013
@@ -27,9 +27,17 @@ add_subdirectory(api)
 SET(CMAKE_SWIG_FLAGS -package org.apache.qpid.proton.jni)
 SET(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}/jni/src/main/java/org/apache/qpid/proton/jni)
 
+message( "JNI_LIBRARIES" ${JNI_LIBRARIES} )
+message( "JAVA_AWT_LIBRARY" ${JAVA_AWT_LIBRARY} )
+
+
 swig_add_module(proton-swig java java.i)
 include_directories(${JNI_INCLUDE_DIRS})
-swig_link_libraries(proton-swig ${BINDING_DEPS} ${JNI_LIBRARIES} )
+swig_link_libraries(proton-swig ${BINDING_DEPS}  )
+
+set_target_properties(proton-swig
+    PROPERTIES
+    PREFIX "lib")
 
 add_custom_command(OUTPUT ${CMAKE_SWIG_OUTDIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SWIG_OUTDIR} COMMENT "Creating target directory for Proton-JNI sources")
 add_custom_target(protonjnioutdir ALL DEPENDS ${CMAKE_SWIG_OUTDIR})
@@ -46,4 +54,6 @@ set(CMAKE_JAVA_INCLUDE_PATH ${CMAKE_CURR
 # TODO: We are relying on shell expansion to find the swig generated sources. Surely there is a better way?
 add_jar(proton-jni ${CMAKE_SWIG_OUTDIR}/*.java ${THUNKING_SOURCES_ABS})
 
+add_custom_command(TARGET proton-jni POST_BUILD COMMAND ${Java_JAR_EXECUTABLE} uvf proton-jni-${PN_VERSION}.jar -C ${PROJECT_SOURCE_DIR}/jni/src/main/resources META-INF)
+
 add_dependencies(proton-jni proton-api proton-swig)

Added: qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/java/org/apache/qpid/proton/engine/jni/JNIEngineFactory.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/java/org/apache/qpid/proton/engine/jni/JNIEngineFactory.java?rev=1428936&view=auto
==============================================================================
--- qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/java/org/apache/qpid/proton/engine/jni/JNIEngineFactory.java (added)
+++ qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/java/org/apache/qpid/proton/engine/jni/JNIEngineFactory.java Fri Jan  4 15:52:46 2013
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.proton.engine.jni;
+
+import java.util.logging.Logger;
+
+import org.apache.qpid.proton.engine.Connection;
+import org.apache.qpid.proton.engine.EngineFactory;
+import org.apache.qpid.proton.engine.Transport;
+
+public class JNIEngineFactory implements EngineFactory
+{
+    private static final Logger LOGGER = Logger.getLogger(JNIEngineFactory.class.getName());
+
+    public JNIEngineFactory()
+    {
+        String libname = "proton-swig";
+
+        LOGGER.info("About to load library " + libname);
+
+        System.loadLibrary(libname);
+
+        LOGGER.info("Successfully loaded library " + libname);
+    }
+
+    @Override
+    public Connection createConnection()
+    {
+        return new JNIConnection();
+    }
+
+    @Override
+    public Transport createTransport()
+    {
+        return new JNITransport();
+    }
+
+}

Added: qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory?rev=1428936&view=auto
==============================================================================
--- qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory (added)
+++ qpid/proton/branches/jni-binding/proton-c/bindings/java/jni/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory Fri Jan  4 15:52:46 2013
@@ -0,0 +1 @@
+org.apache.qpid.proton.engine.jni.JNIEngineFactory
\ No newline at end of file

Added: qpid/proton/branches/jni-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/engine/EngineFactory.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/engine/EngineFactory.java?rev=1428936&view=auto
==============================================================================
--- qpid/proton/branches/jni-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/engine/EngineFactory.java (added)
+++ qpid/proton/branches/jni-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/engine/EngineFactory.java Fri Jan  4 15:52:46 2013
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.proton.engine;
+
+public interface EngineFactory
+{
+    Connection createConnection();
+    Transport createTransport();
+}

Added: qpid/proton/branches/jni-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/EngineFactoryImpl.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/EngineFactoryImpl.java?rev=1428936&view=auto
==============================================================================
--- qpid/proton/branches/jni-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/EngineFactoryImpl.java (added)
+++ qpid/proton/branches/jni-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/EngineFactoryImpl.java Fri Jan  4 15:52:46 2013
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.proton.engine.impl;
+
+import org.apache.qpid.proton.engine.Connection;
+import org.apache.qpid.proton.engine.EngineFactory;
+import org.apache.qpid.proton.engine.Transport;
+
+public class EngineFactoryImpl implements EngineFactory
+{
+
+    @Override
+    public Connection createConnection()
+    {
+        return new ConnectionImpl();
+    }
+
+    @Override
+    public Transport createTransport()
+    {
+        return new TransportImpl();
+    }
+
+}

Added: qpid/proton/branches/jni-binding/proton-j/proton/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/proton-j/proton/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory?rev=1428936&view=auto
==============================================================================
--- qpid/proton/branches/jni-binding/proton-j/proton/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory (added)
+++ qpid/proton/branches/jni-binding/proton-j/proton/src/main/resources/META-INF/services/org.apache.qpid.proton.engine.EngineFactory Fri Jan  4 15:52:46 2013
@@ -0,0 +1 @@
+org.apache.qpid.proton.engine.impl.EngineFactoryImpl
\ No newline at end of file

Added: qpid/proton/branches/jni-binding/tests/proton-system-tests/pom.xml
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/tests/proton-system-tests/pom.xml?rev=1428936&view=auto
==============================================================================
--- qpid/proton/branches/jni-binding/tests/proton-system-tests/pom.xml (added)
+++ qpid/proton/branches/jni-binding/tests/proton-system-tests/pom.xml Fri Jan  4 15:52:46 2013
@@ -0,0 +1,67 @@
+<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</groupId>
+    <artifactId>apache</artifactId>
+    <version>12</version>
+  </parent>
+  <groupId>org.apache.qpid</groupId>
+  <artifactId>proton-system-tests</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+
+  <properties>
+    <junit-version>4.10</junit-version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.qpid</groupId>
+      <artifactId>proton-api</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+  <profiles>
+    <profile>
+      <id>proton-j</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.qpid</groupId>
+          <artifactId>proton</artifactId>
+          <version>1.0-SNAPSHOT</version>
+          <scope>runtime</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>proton-c</id>
+      <dependencies>
+        <!--  PHTODO -->
+      </dependencies>
+    </profile>
+  </profiles>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+          <optimize>true</optimize>
+          <debug>true</debug>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Added: qpid/proton/branches/jni-binding/tests/proton-system-tests/run-tests.sh
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/tests/proton-system-tests/run-tests.sh?rev=1428936&view=auto
==============================================================================
--- qpid/proton/branches/jni-binding/tests/proton-system-tests/run-tests.sh (added)
+++ qpid/proton/branches/jni-binding/tests/proton-system-tests/run-tests.sh Fri Jan  4 15:52:46 2013
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+set -x
+
+M2_REPO=/home/$USER/.m2/repository
+CLASSPATH=.
+CLASSPATH=$CLASSPATH:$M2_REPO/junit/junit/4.10/junit-4.10.jar
+CLASSPATH=$CLASSPATH:target/test-classes/
+CLASSPATH=$CLASSPATH:$M2_REPO/org/apache/qpid/proton-api/1.0-SNAPSHOT/proton-api-1.0-SNAPSHOT.jar
+
+# Java implementation
+# CLASSPATH=$CLASSPATH:/home/V510279/.m2/repository/org/apache/qpid/proton/1.0-SNAPSHOT/proton-1.0-SNAPSHOT.jar
+
+
+# C implementation
+PROTON_HOME=../..
+CLASSPATH=$CLASSPATH:$PROTON_HOME/proton-c/build/bindings/java/proton-jni-0.2.jar
+JNI_PATH=$PROTON_HOME/proton-c/build/bindings/java:$PROTON_HOME/proton-c/build
+export LD_LIBRARY_PATH=$JNI_PATH:$LD_LIBRARY_PATH
+# JNI_STUFF="-Djava.library.path=$JNI_PATH"
+
+java -cp $CLASSPATH $JNI_STUFF org.junit.runner.JUnitCore org.apache.qpid.proton.systemtests.SimpleTest

Propchange: qpid/proton/branches/jni-binding/tests/proton-system-tests/run-tests.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/apache/qpid/proton/systemtests/SimpleTest.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/apache/qpid/proton/systemtests/SimpleTest.java?rev=1428936&view=auto
==============================================================================
--- qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/apache/qpid/proton/systemtests/SimpleTest.java (added)
+++ qpid/proton/branches/jni-binding/tests/proton-system-tests/src/test/java/org/apache/qpid/proton/systemtests/SimpleTest.java Fri Jan  4 15:52:46 2013
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.proton.systemtests;
+
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import org.apache.qpid.proton.engine.Connection;
+import org.apache.qpid.proton.engine.Endpoint;
+import org.apache.qpid.proton.engine.EndpointState;
+import org.apache.qpid.proton.engine.EngineFactory;
+import org.apache.qpid.proton.engine.Transport;
+import org.junit.Test;
+
+public class SimpleTest
+{
+
+    @Test
+    public void test()
+    {
+        EngineFactory engineFactory = createEngineFactory();
+
+        Connection connection1 = engineFactory.createConnection();
+        Connection connection2 = engineFactory.createConnection();;
+        Transport transport1 = engineFactory.createTransport();
+        transport1.bind(connection1);
+
+        Transport transport2 = engineFactory.createTransport();
+        transport2.bind(connection2);
+
+        assertEquals(EndpointState.UNINITIALIZED, connection1.getLocalState());
+        assertEquals(EndpointState.UNINITIALIZED, connection1.getRemoteState());
+
+        connection1.open();
+        connection2.open();
+    }
+
+    private EngineFactory createEngineFactory()
+    {
+        ServiceLoader<EngineFactory> engineFactoryServiceLoader = ServiceLoader.load(EngineFactory.class);
+        Iterator<EngineFactory> serviceLoaderIterator = engineFactoryServiceLoader.iterator();
+        assertTrue("Can't find service loader for engineFactory", serviceLoaderIterator.hasNext());
+        EngineFactory engineFactory = serviceLoaderIterator.next();
+        return engineFactory;
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org