Merge branch 'master' into master
diff --git a/.travis.yml b/.travis.yml
index 89e6d65..cfc882e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,26 @@
language: cpp
+sudo: required
+dist: trusty
-script: true
\ No newline at end of file
+before_install:
+- sudo apt-get update
+- sudo apt-get install -y git gcc-4.8 g++-4.8 autoconf cmake libtool wget unzip libbz2-dev zlib1g-dev
+- sudo apt-get install -y python-dev
+
+install:
+- sudo sh install_boostpython.sh >> tmp_install_boostpython.txt
+- mkdir rocketmqlib
+- cd rocketmqlib
+- wget https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/linux/1.2.0/RHEL7.x/librocketmq.tar.gz
+- tar -xzf librocketmq.tar.gz
+- sudo cp librocketmq.so librocketmq.a /usr/local/lib/
+- sudo cp -r rocketmq /usr/local/include/
+- cd ../
+
+before_script:
+- export LD_LIBRARY_PATH=/usr/local/lib
+
+script:
+- mkdir build && cd build
+- cmake ../ -DBoost_USE_STATIC_LIBS=OFF -DROCKETMQ_USE_STATIC_LIBS=OFF
+- make
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7df3c84..39d0766 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,9 @@
#* See the License for the specific language governing permissions and
#* limitations under the License.
#*/
+
+project(rocketmq-client-python)
+
cmake_minimum_required(VERSION 2.6)
set(CMAKE_MACOSX_RPATH 1)
@@ -205,11 +208,10 @@
set(HAVE_SOCKLEN_T 1)
option(TEST "Build test cases" OFF)
-
if (TEST)
enable_testing()
option(gtest_build_tests OFF)
- add_subdirectory(third_party/googletest/googletest)
+ #add_subdirectory(third_party/googletest/googletest)
include_directories(SYSTEM ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
add_subdirectory(unitests)
endif ()
diff --git a/README.md b/README.md
index ca1409e..f52295c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
-## RocketMQ Client Python [](https://www.apache.org/licenses/LICENSE-2.0.html)
-
+## RocketMQ Client Python
+[](https://www.apache.org/licenses/LICENSE-2.0.html)
+[](https://travis-ci.org/apache/rocketmq-client-python)
* RocketMQ Python client is developed on top of [rocketmq-client-cpp](https://github.com/apache/rocketmq-client-cpp), which has been proven robust and widely adopted within Alibaba Group by many business units for more than three years.
----------
diff --git a/install_gtest.sh b/install_gtest.sh
new file mode 100755
index 0000000..324e06f
--- /dev/null
+++ b/install_gtest.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+# 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.
+
+VERSION=1.8.1
+PACKAGENAME=release-${VERSION}
+GTEST=googletest-release-${VERSION}
+release-1.8.1.tar.gz
+
+if [ ! -d ${HOME}/${GTEST} ]; then
+ if [ -e ${HOME}/${GTEST}.tar.gz ]; then
+ echo "Find Packge ${HOME}/${GTEST}.tar.gz......."
+ else
+ wget -O ${HOME}/${GTEST}.tar.gz https://github.com/abseil/googletest/archive/${PACKAGENAME}.tar.gz
+ fi
+ if [ $? -ne 0 ];then
+ exit 1
+ fi
+ tar -xzf ${HOME}/${GTEST}.tar.gz -C ${HOME}
+ if [ $? -ne 0 ];then
+ exit 1
+ fi
+else
+ echo "Find GTest Source:${HOME}/${GTEST}, Build and install....."
+fi
+
+cd ${HOME}/${GTEST}
+
+mkdir build; cd build
+echo "Start build google test"
+ cmake .. -DCMAKE_CXX_FLAGS=-fPIC -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF
+ if [ $? -ne 0 ];then
+ exit 1
+ fi
+ make
+ if [ $? -ne 0 ];then
+ exit 1
+ fi
+ make install
+
+ if [ ! -f /usr/local/lib/libgtest.a ]
+ then
+ echo "#######Error: Install gtest failed.#########"
+ exit 1
+ fi
+
+echo "Finish build gtest library."
diff --git a/src/PythonWrapper.h b/src/PythonWrapper.h
index 2ad8255..7e66948 100644
--- a/src/PythonWrapper.h
+++ b/src/PythonWrapper.h
@@ -99,6 +99,8 @@
//push consumer
int PySetPullConsumerNameServerDomain(void *consumer, const char *domain);
+//version
+const char *PyGetVersion();
#ifdef __cplusplus
};
diff --git a/third_party/googletest/README.md b/third_party/googletest/README.md
deleted file mode 100644
index 39da329..0000000
--- a/third_party/googletest/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-### Google Test
-
------------------------
-Download [googletest source](https://github.com/abseil/googletest)
diff --git a/unitests/CMakeLists.txt b/unitests/CMakeLists.txt
index 02004ae..3e3e349 100644
--- a/unitests/CMakeLists.txt
+++ b/unitests/CMakeLists.txt
@@ -14,18 +14,60 @@
#* See the License for the specific language governing permissions and
#* limitations under the License.
#*/
+project(UnitTest)
+if (WIN32)
+ find_package(gtest)
+elseif (APPLE)
+ find_package(gtest)
+else ()
+ set(GTEST_INCLUDE_DIRS /usr/local/include)
+ set(GTEST_LIBRARY_DIRS /usr/local/lib)
+ set(GTEST_LIBRARIES /usr/local/lib/libgtest.a)
+ set(GTEST_FOUND true)
+endif (WIN32)
+if (GTEST_FOUND)
+ message(STATUS "** GTEST Include dir: ${GTEST_INCLUDE_DIRS}")
+ message(STATUS "** GTEST Libraries dir: ${GTEST_LIBRARY_DIRS}")
+ message(STATUS "** GTEST Libraries: ${GTEST_LIBRARIES}")
+ include_directories(${GTEST_INCLUDE_DIRS})
+else ()
+ message(FATAL_ERROR "Missing library: gtest ")
+endif ()
+file(GLOB_RECURSE SRC_FILES ${CMAKE_SOURCE_DIR}/src/*.cpp)
+file(GLOB_RECURSE TEST_SRC_FILES ${CMAKE_SOURCE_DIR}/unitests/*.cpp)
+
+# subdirs
+SET(SUB_DIRS)
+file(GLOB children ${CMAKE_SOURCE_DIR}/src/*.h)
+FOREACH (child ${children})
+ IF (IS_DIRECTORY ${child})
+ LIST(APPEND SUB_DIRS ${child})
+ ENDIF ()
+ENDFOREACH ()
+LIST(APPEND SUB_DIRS ${CMAKE_SOURCE_DIR}/src)
+include_directories(${CMAKE_SOURCE_DIR}/include)
+include_directories(${SUB_DIRS})
+
+message(STATUS "All Source File" ${SRC_FILES})
+message(STATUS "All Test Source File" ${TEST_SRC_FILES})
+#message(STATUS "All Head File Dir" ${SUB_DIRS})
add_executable(runUnitTests
- PythonWrapperTest.cpp
- )
+ ${TEST_SRC_FILES}
+ ${SRC_FILES}
+ )
target_link_libraries(runUnitTests
- dl
- gtest)
+ dl
+ ${ROCKETMQ_LIBRARIES}
+ ${Boost_LIBRARIES}
+ ${PYTHON_LIBRARIES}
+ ${GTEST_LIBRARIES})
if (UNIX AND NOT APPLE)
- target_link_libraries(runUnitTests rt)
+ target_link_libraries(runUnitTests rt)
endif ()
set_target_properties(runUnitTests PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+add_test(runUnitTests ${CMAKE_BINARY_DIR}/runUnitTests)
diff --git a/unitests/PythonWrapperTest.cpp b/unitests/PythonWrapperTest.cpp
index 5989335..1004597 100644
--- a/unitests/PythonWrapperTest.cpp
+++ b/unitests/PythonWrapperTest.cpp
@@ -15,12 +15,42 @@
* limitations under the License.
*/
#include "gtest/gtest.h"
+#include "PythonWrapper.h"
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
+ return ret;
+}
+TEST(Version, testVersion) {
+ const char *version = PyGetVersion();
+ const char *versionExp = PyGetVersion();
+ ASSERT_STREQ(version,versionExp);
+}
+TEST(Message, testCreateMessage) {
+ ASSERT_TRUE(1 == 1);
}
-TEST(Message, testCreateMessage) {
-ASSERT_TRUE(1 == 1);
+TEST(Message, testSetMessageTopic) {
+ ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testSetMessageKey) {
+ ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testSetMessageTag) {
+ ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testSetMessageValue) {
+ ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testSetMessageDelayLevel) {
+ ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testDestroyMessage) {
+ ASSERT_TRUE(1 == 1);
}