mirror of
https://gitlab.com/spaceti-app/integrations/common/server-sdk.git
synced 2026-07-13 00:30:42 +02:00
Merge branch 'feat/compression' into 'master'
added compression with tests See merge request spaceti-app/integrations/common/server-sdk!1
This commit is contained in:
commit
8dd81d9e23
5
common.pri
Normal file
5
common.pri
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
SDK_ROOT=$$PWD
|
||||||
|
SDK_TEST_PATH=$$SDK_ROOT/test/data
|
||||||
|
|
||||||
|
DEFINES += SDK_ROOT='\\"$$SDK_ROOT\\"'
|
||||||
|
DEFINES += SDK_TEST_PATH='\\"$$SDK_TEST_PATH\\"'
|
||||||
@ -14,7 +14,5 @@ OTHER_FILES += \
|
|||||||
scripts/* \
|
scripts/* \
|
||||||
doc/Doxy* \
|
doc/Doxy* \
|
||||||
doc/pages/* \
|
doc/pages/* \
|
||||||
serversdk.pri \
|
*.pri \
|
||||||
serversdkint.pri \
|
|
||||||
|
|
||||||
message($$OUT_ROOT)
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ SDKDIR=$$ROOT_OUT/src/serversdk
|
|||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$SDKDIR/release/ -lserversdk
|
win32:CONFIG(release, debug|release): LIBS += -L$$SDKDIR/release/ -lserversdk
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$SDKDIR/debug/ -lserversdk
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$SDKDIR/debug/ -lserversdk
|
||||||
else:unix: LIBS += -L$$SDKDIR/ -lserversdk
|
else:unix: LIBS += -L$$SDKDIR/ -lserversdk -lz
|
||||||
|
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/src/
|
INCLUDEPATH += $$PWD/src/
|
||||||
|
|||||||
@ -14,6 +14,7 @@ SOURCES += \
|
|||||||
$$PWD/loggermessage.cpp \
|
$$PWD/loggermessage.cpp \
|
||||||
$$PWD/requestmanager.cpp \
|
$$PWD/requestmanager.cpp \
|
||||||
$$PWD/request.cpp \
|
$$PWD/request.cpp \
|
||||||
|
$$PWD/utils.cpp \
|
||||||
$$PWD/soaprequest.cpp
|
$$PWD/soaprequest.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
@ -23,5 +24,7 @@ HEADERS += \
|
|||||||
$$PWD/loggermessage.h \
|
$$PWD/loggermessage.h \
|
||||||
$$PWD/requestmanager.h \
|
$$PWD/requestmanager.h \
|
||||||
$$PWD/request.h \
|
$$PWD/request.h \
|
||||||
|
$$PWD/utils.h \
|
||||||
$$PWD/soaprequest.h
|
$$PWD/soaprequest.h
|
||||||
|
|
||||||
|
include(../../common.pri)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "compression.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@ -6,14 +6,14 @@
|
|||||||
#include <zlib.h> // gzip decompress
|
#include <zlib.h> // gzip decompress
|
||||||
|
|
||||||
|
|
||||||
namespace core {
|
namespace serversdk {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Decompress gzip data
|
* @brief Decompress gzip data
|
||||||
* @param compressed gzip data
|
* @param compressed gzip data
|
||||||
* @return decompressed data
|
* @return decompressed data
|
||||||
*/
|
*/
|
||||||
QByteArray Compression::decompress(const QByteArray &compressed)
|
QByteArray Utils::decompress(const QByteArray &compressed)
|
||||||
{
|
{
|
||||||
if (compressed.size() <= 4) {
|
if (compressed.size() <= 4) {
|
||||||
qWarning("gUncompress: Input data is truncated");
|
qWarning("gUncompress: Input data is truncated");
|
||||||
@ -80,13 +80,10 @@ QByteArray Compression::decompress(const QByteArray &compressed)
|
|||||||
* @param subpath ( e.g. test/data )
|
* @param subpath ( e.g. test/data )
|
||||||
* @return absolute path to desired subpath in source folder
|
* @return absolute path to desired subpath in source folder
|
||||||
*/
|
*/
|
||||||
QString Compression::sourcePath(const QString &subpath)
|
QString Utils::sourcePath(const QString &subpath)
|
||||||
{
|
{
|
||||||
QDir dir(__FILE__);
|
const QString path = QStringLiteral(SDK_TEST_PATH);
|
||||||
dir.cdUp();
|
QDir dir(path);
|
||||||
dir.cdUp();
|
|
||||||
dir.cdUp();
|
|
||||||
|
|
||||||
return dir.absoluteFilePath(subpath);
|
return dir.absoluteFilePath(subpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +92,7 @@ QString Compression::sourcePath(const QString &subpath)
|
|||||||
* @param subpath ( e.g. test/data/gizp.src )
|
* @param subpath ( e.g. test/data/gizp.src )
|
||||||
* @return data of file - QByteArray
|
* @return data of file - QByteArray
|
||||||
*/
|
*/
|
||||||
QByteArray Compression::sourceData(const QString &subpath)
|
QByteArray Utils::sourceData(const QString &subpath)
|
||||||
{
|
{
|
||||||
// Get data from file
|
// Get data from file
|
||||||
QString filePath = sourcePath(subpath);
|
QString filePath = sourcePath(subpath);
|
||||||
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
namespace core {
|
namespace serversdk {
|
||||||
|
|
||||||
class Compression
|
class Utils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static QByteArray decompress(const QByteArray &compressed);
|
static QByteArray decompress(const QByteArray &compressed);
|
||||||
@ -15,5 +15,4 @@ public:
|
|||||||
static QByteArray sourceData(const QString &subpath);
|
static QByteArray sourceData(const QString &subpath);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace core
|
} // namespace serversdk
|
||||||
|
|
||||||
9
test/auto/UtilsTest/UtilsTest.pro
Normal file
9
test/auto/UtilsTest/UtilsTest.pro
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
QT += testlib
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
CONFIG += qt console warn_on depend_includepath testcase
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
SOURCES += tst_utilstest.cpp
|
||||||
41
test/auto/UtilsTest/tst_utilstest.cpp
Normal file
41
test/auto/UtilsTest/tst_utilstest.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Filip Bucek - All Rights Reserved
|
||||||
|
* Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
* Proprietary and confidential
|
||||||
|
* Written by Filip Bucek <fbucek@invloop.cz>, 2019
|
||||||
|
*/
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
// add necessary includes here
|
||||||
|
|
||||||
|
class UtilsTest : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
UtilsTest();
|
||||||
|
~UtilsTest();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void test_case1();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
UtilsTest::UtilsTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilsTest::~UtilsTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void UtilsTest::test_case1()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_APPLESS_MAIN(UtilsTest)
|
||||||
|
|
||||||
|
#include "tst_utilstest.moc"
|
||||||
6
test/auto/auto.pro
Normal file
6
test/auto/auto.pro
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
|
SUBDIRS += \
|
||||||
|
basic \
|
||||||
|
unittests \
|
||||||
|
utils
|
||||||
11
test/auto/basic/basic.pro
Normal file
11
test/auto/basic/basic.pro
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
QT += testlib
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
CONFIG += qt console warn_on depend_includepath testcase
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
SOURCES += tst_basictest.cpp
|
||||||
|
|
||||||
|
include(../../../serversdkint.pri)
|
||||||
41
test/auto/basic/tst_basictest.cpp
Normal file
41
test/auto/basic/tst_basictest.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Filip Bucek - All Rights Reserved
|
||||||
|
* Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
* Proprietary and confidential
|
||||||
|
* Written by Filip Bucek <fbucek@invloop.cz>, 2019
|
||||||
|
*/
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
// add necessary includes here
|
||||||
|
|
||||||
|
class basicTest : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
basicTest();
|
||||||
|
~basicTest();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void test_case1();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
basicTest::basicTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
basicTest::~basicTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void basicTest::test_case1()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_APPLESS_MAIN(basicTest)
|
||||||
|
|
||||||
|
#include "tst_basictest.moc"
|
||||||
11
test/auto/compress/compress.pro
Normal file
11
test/auto/compress/compress.pro
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
QT += testlib
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
CONFIG += qt console warn_on depend_includepath testcase
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
SOURCES += tst_decompresstest.cpp
|
||||||
|
|
||||||
|
include(../../../serversdkint.pri)
|
||||||
41
test/auto/compress/tst_decompresstest.cpp
Normal file
41
test/auto/compress/tst_decompresstest.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Filip Bucek - All Rights Reserved
|
||||||
|
* Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
* Proprietary and confidential
|
||||||
|
* Written by Filip Bucek <fbucek@invloop.cz>, 2019
|
||||||
|
*/
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
// add necessary includes here
|
||||||
|
|
||||||
|
class decompressTest : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
decompressTest();
|
||||||
|
~decompressTest();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void test_case1();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
decompressTest::decompressTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
decompressTest::~decompressTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void decompressTest::test_case1()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_APPLESS_MAIN(decompressTest)
|
||||||
|
|
||||||
|
#include "tst_decompresstest.moc"
|
||||||
@ -1,19 +1,19 @@
|
|||||||
#include "tst_request.h"
|
#include "tst_request.h"
|
||||||
|
|
||||||
#include "serversdk/request.h"
|
#include "serversdk/request.h"
|
||||||
|
|
||||||
namespace serversdk {
|
namespace serversdk {
|
||||||
|
|
||||||
void RequestTest::basicAuthorization_test()
|
void RequestTest::basicAuthorization_test()
|
||||||
{
|
{
|
||||||
QString expected = "Basic VGVzdGVyOlRlc3Q=";
|
QString expected = "Basic VGVzdGVyOlRlc3Q=";
|
||||||
Request req;
|
Request req;
|
||||||
req.setUserName("Tester");
|
req.setUserName("Tester");
|
||||||
req.setPassword("Test");
|
req.setPassword("Test");
|
||||||
|
|
||||||
QCOMPARE(req.basicAuthorization(), expected);
|
QCOMPARE(req.basicAuthorization(), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(serversdk::RequestTest)
|
QTEST_APPLESS_MAIN(serversdk::RequestTest)
|
||||||
@ -1,21 +1,21 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
namespace serversdk {
|
namespace serversdk {
|
||||||
|
|
||||||
class RequestTest : public QObject
|
class RequestTest : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
// Default testcases ( not needed to declare it )
|
// Default testcases ( not needed to declare it )
|
||||||
// Q_SLOT void initTestCase();
|
// Q_SLOT void initTestCase();
|
||||||
// Q_SLOT void cleanupTestCase();
|
// Q_SLOT void cleanupTestCase();
|
||||||
// void wont_run(); // no Q_SLOT ( only slots will be runned within tests )
|
// void wont_run(); // no Q_SLOT ( only slots will be runned within tests )
|
||||||
|
|
||||||
|
|
||||||
Q_SLOT void basicAuthorization_test();
|
Q_SLOT void basicAuthorization_test();
|
||||||
};
|
};
|
||||||
|
|
||||||
} //
|
} //
|
||||||
@ -6,4 +6,4 @@ SOURCES += \
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
tst_request.h
|
tst_request.h
|
||||||
|
|
||||||
include(../../serversdkint.pri)
|
include(../../../serversdkint.pri)
|
||||||
56
test/auto/utils/tst_utilstest.cpp
Normal file
56
test/auto/utils/tst_utilstest.cpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include "serversdk/utils.h"
|
||||||
|
|
||||||
|
class UtilsTest : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
UtilsTest() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_SLOT void sourcePathTest();
|
||||||
|
Q_SLOT void sourceDataTest();
|
||||||
|
Q_SLOT void decompresTest();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void UtilsTest::sourcePathTest()
|
||||||
|
{
|
||||||
|
QCOMPARE(serversdk::Utils::sourcePath(""), QStringLiteral(SDK_TEST_PATH));
|
||||||
|
|
||||||
|
QString path = serversdk::Utils::sourcePath("");
|
||||||
|
QFileInfo info(path);
|
||||||
|
QVERIFY(info.exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UtilsTest::sourceDataTest()
|
||||||
|
{
|
||||||
|
qint32 expected = 895;
|
||||||
|
QByteArray data = serversdk::Utils::sourceData("gzip.src");
|
||||||
|
QCOMPARE(data.count(), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UtilsTest::decompresTest()
|
||||||
|
{
|
||||||
|
QByteArray expectedData = serversdk::Utils::sourceData("gzip.src");
|
||||||
|
int expectedSize = 895;
|
||||||
|
QCOMPARE( expectedData.count(), expectedSize);
|
||||||
|
|
||||||
|
QByteArray compressedData = serversdk::Utils::sourceData("gzip.compressed");
|
||||||
|
int compressedSize = 411;
|
||||||
|
QCOMPARE( compressedData.count(), compressedSize);
|
||||||
|
|
||||||
|
QByteArray decompressedData = serversdk::Utils::decompress(compressedData);
|
||||||
|
|
||||||
|
QCOMPARE(decompressedData.count(), expectedSize);
|
||||||
|
QCOMPARE(decompressedData, expectedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_MAIN(UtilsTest)
|
||||||
|
|
||||||
|
#include "tst_utilstest.moc"
|
||||||
12
test/auto/utils/utils.pro
Normal file
12
test/auto/utils/utils.pro
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
QT += testlib
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
CONFIG += qt console warn_on depend_includepath testcase
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
SOURCES += tst_utilstest.cpp
|
||||||
|
|
||||||
|
include(../../test.pri)
|
||||||
|
|
||||||
BIN
test/data/gzip.compressed
Normal file
BIN
test/data/gzip.compressed
Normal file
Binary file not shown.
15
test/data/gzip.src
Normal file
15
test/data/gzip.src
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
Příliš žluťoušký kůň
|
||||||
|
compresed using: gzip -c gzip.src > gzip.compressed
|
||||||
|
|
||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
|
||||||
|
<SOAP-ENV:Body>
|
||||||
|
<ns5689:LatLonListSubgrid xmlns:ns5689="uri:DWMLgen">
|
||||||
|
<lowerLeftLatitude xsi:type="xsd:string">35.00</lowerLeftLatitude>
|
||||||
|
<lowerLeftLongitude xsi:type="xsd:string">-82.00</lowerLeftLongitude>
|
||||||
|
<upperRightLatitude xsi:type="xsd:string">35.5</upperRightLatitude>
|
||||||
|
<upperRightLongitude xsi:type="xsd:string">-81.50</upperRightLongitude>
|
||||||
|
<resolution xsi:type="xsd:string">20.0</resolution>
|
||||||
|
</ns5689:LatLonListSubgrid>
|
||||||
|
</SOAP-ENV:Body>
|
||||||
|
</SOAP-ENV:Envelope>
|
||||||
3
test/test.pri
Normal file
3
test/test.pri
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
include(../common.pri)
|
||||||
|
include(../serversdkint.pri)
|
||||||
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
unittests
|
auto \
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user