Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests and update readme #10

Merged
merged 3 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/netlicesning-client-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ jobs:
apt-get update
apt-get upgrade -y
- name: Install required dependencies
run: apt-get install -y git g++ cmake libcurl4-openssl-dev
run: apt-get install -y git g++ cmake libcurl4-openssl-dev libboost-all-dev
- name: Build with CMake
run: |
mkdir build
cd build
cmake ..
cmake .. -DBUILD_TESTS=yes
make
- name: Run tests
run: |
cd tests
./run_tests
- name: Run Demo App
run: |
cd build
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@

# Generated and working files and directories
tests/run_tests
build
build*
.vscode
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(CURL REQUIRED)

if (BUILD_TESTS)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.40 REQUIRED unit_test_framework)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.40 REQUIRED unit_test_framework)
endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
Expand All @@ -22,7 +22,7 @@ set(LIBS ${LIBS} ${CURL_LIBRARIES} ${JSONCPP_LIBRARIES})
set(BUILD_SHARED_LIBS OFF)

add_definitions(-DCURL_STATICLIB)
if(UNIX)
if (UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")
endif()

Expand All @@ -37,7 +37,7 @@ target_link_libraries(netlicensing ${LIBS})
# demo client
file(GLOB client_demo_headers client_demo/${db2lp_component}/*h)
file(GLOB client_demo_sources client_demo/${db2lp_component}/*cc)
add_executable(netlicensing-client-demo ${client_demo_headers} ${client_demo_sources} )
add_executable(netlicensing-client-demo ${client_demo_headers} ${client_demo_sources})
target_link_libraries(netlicensing-client-demo netlicensing ${LIBS})

if (BUILD_TESTS)
Expand Down
43 changes: 38 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ C++ wrapper for Labs64 NetLicensing [RESTful API](https://netlicensing.io/wiki/r
Visit Labs64 NetLicensing at https://netlicensing.io

## Dependencies
1. C++11 STL
2. [libcurl](https://github.com/curl/curl) (with libcurl's transitive dependencies)
3. [jsoncpp](https://github.com/open-source-parsers/jsoncpp) (included)
1. C++11 toolset + STL
2. cmake
3. [libcurl](https://github.com/curl/curl) (with libcurl's transitive dependencies)
4. [jsoncpp](https://github.com/open-source-parsers/jsoncpp) (included)
5. [boost](https://www.boost.org/) (optional, needed for unit tests)


## Compatibility

Expand All @@ -32,6 +35,7 @@ Windows 10 | Visual studio 14 2015 x86 - x64
Windows 10 | Visual studio 15 2017 x86 - x64
macOS Mojave | Xcode 10.1


## Windows build

### Build curl
Expand All @@ -58,12 +62,14 @@ macOS Mojave | Xcode 10.1
(replace `-G` argument with your actual version / platform, see [`cmake` documentation](https://cmake.org/cmake/help/latest/))
5. Open solution created in `NetLicensingClient-cpp\build` directory in Visual Studio and build the library and demo client.


## Linux build

### Build NetLincesing-cpp
1. Download the latest release and unpack to `NetLicensingClient-cpp` (or checkout [master](https://github.com/Labs64/NetLicensingClient-cpp.git) to build the latest development version)
2. Install **curl** (for development, including C headers and libraries). E.g. in **Ubuntu**:
```sudo apt-get install libcurl4-openssl```
2. Install **libcurl** (for development, including C headers and libraries). E.g. in **Ubuntu**:
```sudo apt-get install libcurl4-openssl-dev```
3. Install **boost**: ```sudo apt-get install libboost-all-dev```
3. In the `NetLicensingClient-cpp` directory create `build/` subdirectory
4. Execute:
```
Expand All @@ -77,6 +83,33 @@ macOS Mojave | Xcode 10.1
Unit tests require [**Boost**](https://www.boost.org) Unit Test Framework. To build project with the unit tests activated add cmake option `-DBUILD_TESTS=yes`. The tests must be executed from `tests/` subdirectory on Linux or `tests\Debug\` on Windows in order to properly locate the JSON files with test data.


## Linux build using docker

_TODO: full description_

1. Prepare container
- Image: ubuntu:22.04
- apt-get update
- apt-get install cmake g++ libcurl4-openssl-dev libboost-all-dev

2. Map `NetLicensingClient-cpp` or clone it inside the container

3. Build as described in [Linux Build](#linux-build)


## MacOS build

_TODO: full description_

1. Prepare environment:
- Install XCode 10.1+
- Install `homebrew`
- `libcurl` is provided
- `brew install cmake boost`

2. Build as described in [Linux Build](#linux-build)


## Execution environment

**libcurl** dynamic library should be either installed system-wide or otherwise available for the loading at run-time (typically located in the same directory as your executable)
2 changes: 2 additions & 0 deletions include/netlicensing/mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "netlicensing/token.h"
#include "netlicensing/transaction.h"
#include "netlicensing/licensing_model.h"
#include "netlicensing/license_type.h"
#include "netlicensing/license_template.h"

namespace netlicensing {

Expand Down
2 changes: 1 addition & 1 deletion tests/run_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TestObserver {
BOOST_AUTO_TEST_SUITE(test_mapper)

BOOST_AUTO_TEST_CASE(initial_test) {
std::string str = read_whole_file("../json/product.json");
std::string str = read_whole_file("product.json");
BOOST_REQUIRE(!str.empty());
Json::Value root;
Json::Reader reader;
Expand Down
Loading