forked from loafle/openapi-generator-original
Cpp restbed server improvements (#13030)
* Keep old implementation of cpp-restbed generator as cpp-restbed-server-deprecated * Refactor operation path processing * Restructure samples directory to better allow writing tests * Improve templates for cpp-restbed-server Improve templates * Add integration tests * Improvement in templates for cpp-restbed-server * Fix tests * Improve cpp-restbed generator * Improve cpp-restbed-server * Add more tests * Add suppoert for arrays of enums in query params * Generate CMakeLists.txt * Small improvements and example in Readme * Add integration tests to maven project * Update doc
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
|
||||
add_custom_target(run_all_java_client_test_for_cpp_server)
|
||||
|
||||
define_property(GLOBAL
|
||||
PROPERTY LAST_JAVA_CLIENT_TEST
|
||||
BRIEF_DOCS Used to order the tests to run after each other
|
||||
FULL_DOCS The tests are ordered by defining a dependency chain)
|
||||
set_property(GLOBAL
|
||||
PROPERTY LAST_JAVA_CLIENT_TEST run_all_java_client_test_for_cpp_server)
|
||||
|
||||
set(RUN_CLIENT_TESTS_SHELL_TEMPLATE "run_java_client_tests_template.txt")
|
||||
|
||||
function(run_java_client_test_for_cpp_server TARGET_NAME)
|
||||
set(TEST_SERVER_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}")
|
||||
|
||||
set(RUN_TESTS_TARGET run_${TARGET_NAME}_test)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/cmake/${RUN_CLIENT_TESTS_SHELL_TEMPLATE}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${RUN_TESTS_TARGET}.sh
|
||||
@ONLY)
|
||||
|
||||
add_custom_target(${RUN_TESTS_TARGET}
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${RUN_TESTS_TARGET}.sh
|
||||
DEPENDS ${TARGET_NAME}
|
||||
USES_TERMINAL
|
||||
COMMENT "Running tests: ${TARGET_NAME}")
|
||||
|
||||
get_property(LAST_TEST
|
||||
GLOBAL
|
||||
PROPERTY LAST_JAVA_CLIENT_TEST)
|
||||
add_dependencies(run_all_java_client_test_for_cpp_server ${RUN_TESTS_TARGET})
|
||||
add_dependencies(${LAST_TEST} ${RUN_TESTS_TARGET})
|
||||
set_property(GLOBAL
|
||||
PROPERTY LAST_JAVA_CLIENT_TEST ${RUN_TESTS_TARGET})
|
||||
|
||||
endfunction()
|
||||
25
samples/server/petstore/cpp-restbed/cmake/dependencies.cmake
Normal file
25
samples/server/petstore/cpp-restbed/cmake/dependencies.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
## Restbed
|
||||
FetchContent_Declare(
|
||||
restbed
|
||||
GIT_REPOSITORY https://github.com/Corvusoft/restbed
|
||||
GIT_TAG 4.7
|
||||
)
|
||||
|
||||
set(BUILD_TESTS OFF CACHE BOOL "Disable internal restbed tests")
|
||||
set(BUILD_SSL OFF CACHE BOOL "Disable SSL")
|
||||
FetchContent_MakeAvailable(restbed)
|
||||
|
||||
FetchContent_GetProperties(restbed)
|
||||
if(NOT restbed_POPULATED)
|
||||
|
||||
FetchContent_Populate(restbed)
|
||||
add_subdirectory(${restbed_SOURCE_DIR} ${restbed_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
## Boost
|
||||
find_package(Boost 1.7.0 COMPONENTS system unit_test_framework REQUIRED)
|
||||
28
samples/server/petstore/cpp-restbed/cmake/run_java_client_tests_template.txt
Executable file
28
samples/server/petstore/cpp-restbed/cmake/run_java_client_tests_template.txt
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
echo "Running ${SCRIPTPATH}"
|
||||
|
||||
echo Running @TEST_SERVER_EXECUTABLE@
|
||||
@TEST_SERVER_EXECUTABLE@ &
|
||||
pid=$!
|
||||
|
||||
|
||||
function kill_test_server()
|
||||
{
|
||||
kill -9 $pid
|
||||
}
|
||||
|
||||
trap kill_test_server EXIT
|
||||
|
||||
echo Running Java client tests
|
||||
cd "@CMAKE_CURRENT_LIST_DIR@/../../java_client"
|
||||
./gradlew --no-daemon clean test --tests "test_@TARGET_NAME@.*" -i
|
||||
|
||||
set +e
|
||||
kill $pid
|
||||
|
||||
echo Done running @TEST_SERVER_EXECUTABLE@
|
||||
Reference in New Issue
Block a user