Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
28e56b2f
Commit
28e56b2f
authored
Jan 06, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(REST API): добавил тест на '/'
parent
fd9b2b9d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
8 deletions
+34
-8
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+1
-1
UObject_SK.h
extensions/include/UObject_SK.h
+1
-1
UObject_SK.cc
extensions/lib/UObject_SK.cc
+2
-2
test_restapi_uniset.cc
extensions/tests/test_restapi_uniset.cc
+28
-2
UniSetObject.cc
src/ObjectRepository/UniSetObject.cc
+2
-2
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
28e56b2f
...
...
@@ -689,7 +689,7 @@ Poco::JSON::Object::Ptr <xsl:value-of select="$CLASSNAME"/>_SK::httpRequest( con
Poco::JSON::Object::Ptr
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::httpRequestLog( const Poco::URI::QueryParameters
&
p )
{
Poco::JSON::Object::Ptr jret = new Poco::JSON::Object();
jret->set(
myname,uniset::json::make_object("log", Debug::str(mylog->level()
)));
jret->set(
"log",Debug::str(mylog->level(
)));
return jret;
}
// -----------------------------------------------------------------------------
...
...
extensions/include/UObject_SK.h
View file @
28e56b2f
...
...
@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 201
6-12-23
+03:00
// generate timestamp: 201
7-01-06
+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
...
...
extensions/lib/UObject_SK.cc
View file @
28e56b2f
...
...
@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 201
6-12-23
+03:00
// generate timestamp: 201
7-01-06
+03:00
// -----------------------------------------------------------------------------
#include <memory>
#include <iomanip>
...
...
@@ -626,7 +626,7 @@ Poco::JSON::Object::Ptr UObject_SK::httpRequest( const std::string& req, const P
Poco
::
JSON
::
Object
::
Ptr
UObject_SK
::
httpRequestLog
(
const
Poco
::
URI
::
QueryParameters
&
p
)
{
Poco
::
JSON
::
Object
::
Ptr
jret
=
new
Poco
::
JSON
::
Object
();
jret
->
set
(
myname
,
uniset
::
json
::
make_object
(
"log"
,
Debug
::
str
(
mylog
->
level
()
)));
jret
->
set
(
"log"
,
Debug
::
str
(
mylog
->
level
(
)));
return
jret
;
}
// -----------------------------------------------------------------------------
...
...
extensions/tests/test_restapi_uniset.cc
View file @
28e56b2f
...
...
@@ -14,6 +14,7 @@ using namespace uniset;
using
namespace
uniset
::
extensions
;
// -----------------------------------------------------------------------------
static
std
::
shared_ptr
<
SMInterface
>
shm
;
// -----------------------------------------------------------------------------
static
void
init_test
()
{
shm
=
smiInstance
();
...
...
@@ -21,10 +22,9 @@ static void init_test()
REQUIRE
(
uniset_conf
()
!=
nullptr
);
}
// -----------------------------------------------------------------------------
TEST_CASE
(
"[REST
API]: "
,
"[restapi
]"
)
TEST_CASE
(
"[REST
API: conf]"
,
"[restapi][conf
]"
)
{
init_test
();
auto
conf
=
uniset_conf
();
std
::
string
s
=
shm
->
apiRequest
(
"/conf/get?2,Input5_S¶ms=iotype"
);
Poco
::
JSON
::
Parser
parser
;
...
...
@@ -59,5 +59,31 @@ TEST_CASE("[RESTAPI]: ", "[restapi]")
}
// -----------------------------------------------------------------------------
TEST_CASE
(
"[REST API: /]"
,
"[restapi][info]"
)
{
init_test
();
std
::
string
s
=
shm
->
apiRequest
(
"/"
);
Poco
::
JSON
::
Parser
parser
;
auto
result
=
parser
.
parse
(
s
);
// Ожидаемый формат ответа:
// {"object":{"id":5003,"isActive":true,"lostMessages":0,"maxSizeOfMessageQueue":1000,"msgCount":0,"name":"SharedMemory","objectType":"IONotifyController"}}
Poco
::
JSON
::
Object
::
Ptr
json
=
result
.
extract
<
Poco
::
JSON
::
Object
::
Ptr
>
();
REQUIRE
(
json
);
auto
jret
=
json
->
get
(
"object"
).
extract
<
Poco
::
JSON
::
Object
::
Ptr
>
();
REQUIRE
(
jret
);
auto
sm
=
shm
->
SM
();
REQUIRE
(
jret
->
get
(
"id"
).
convert
<
ObjectId
>
()
==
sm
->
getId
()
);
REQUIRE
(
jret
->
get
(
"name"
).
convert
<
std
::
string
>
()
==
sm
->
getName
()
);
REQUIRE
(
jret
->
get
(
"objectType"
).
convert
<
std
::
string
>
()
==
"IONotifyController"
);
REQUIRE
(
jret
->
get
(
"isActive"
).
convert
<
bool
>
()
==
true
);
REQUIRE
(
jret
->
get
(
"lostMessages"
).
convert
<
long
>
()
==
0
);
}
// -----------------------------------------------------------------------------
#endif // ifndef DISABLE_REST_API
// -----------------------------------------------------------------------------
src/ObjectRepository/UniSetObject.cc
View file @
28e56b2f
...
...
@@ -955,6 +955,7 @@ namespace uniset
// но если указан, то проверяем..
std
::
vector
<
std
::
string
>
seg
;
uri
.
getPathSegments
(
seg
);
size_t
qind
=
0
;
if
(
seg
.
size
()
>
0
&&
seg
[
0
]
==
"api"
)
...
...
@@ -977,8 +978,7 @@ namespace uniset
else
if
(
seg
.
size
()
==
1
)
qind
=
0
;
query
=
seg
[
qind
];
query
=
seg
.
empty
()
?
""
:
seg
[
qind
];
// обработка запроса..
if
(
query
==
"help"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment