Branch data Line data Source code
1 : : /* Copyright 2006-2011 Savarese Software Research Corporation
2 : : *
3 : : * Licensed under the Apache License, Version 2.0 (the "License");
4 : : * you may not use this file except in compliance with the License.
5 : : * You may obtain a copy of the License at
6 : : *
7 : : * https://www.savarese.com/software/ApacheLicense-2.0
8 : : *
9 : : * Unless required by applicable law or agreed to in writing, software
10 : : * distributed under the License is distributed on an "AS IS" BASIS,
11 : : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : : * See the License for the specific language governing permissions and
13 : : * limitations under the License.
14 : : */
15 : :
16 : : #include <ssrc/wispers/ws_lua/service.h>
17 : : #include <ssrc/wispers/ws/call_util.h>
18 : : #include <ssrc/wispers/test/ServiceTestFixture.h>
19 : :
20 : : #define BOOST_TEST_MODULE ServiceTest
21 : : #include <boost/test/unit_test.hpp>
22 : :
23 : : using namespace ssrc::wispers::test;
24 : : using namespace NS_SSRC_WSPR_WS_LUA;
25 : : using namespace ssrc::wispers::ws;
26 : :
27 : : WISP_IMPORT(WebServiceProtocol, CallTwoWay);
28 : :
29 [ + - ]: 1 : struct ServiceTestOptions : public ssrc::wisp::test::TestOptions {
30 : : NS_SSRC_WSPR_WS_LUA::ServiceInitializer initializer;
31 : :
32 [ + - ]: 1 : ServiceTestOptions() {
33 [ + - ]: 1 : initializer.module_dir = MODULE_DIR;
34 [ + - + - : 1 : initializer.modules.push_back(HELLO_MODULE);
+ - ]
35 : 1 : }
36 : : };
37 : :
38 [ + - ]: 1 : struct WSServiceFixture : public ServiceTestFixture<NS_SSRC_WSPR_WS_LUA::Service, ServiceEventHandler, ServiceTestOptions, true>
39 : : {
40 : : service_thread call;
41 : :
42 [ + - + - ]: 1 : WSServiceFixture() : call(*serv) { }
43 : : };
44 : :
45 [ + - + - : 5 : BOOST_FIXTURE_TEST_CASE(test_call_two_way, WSServiceFixture) {
+ - ]
46 : : const CallTwoWay::return_type && result =
47 [ + - + - ]: 2 : call_two_way(call, serv->name(), "goodbye", session_ptr(),
48 [ + - ]: 1 : Parameter("action", "goodbye"),
49 [ + - + - : 4 : Parameter("message", "Adios amigos!"));
+ - + - +
- ]
50 : :
51 [ + + ]: 3 : for(unsigned int i = 0; i < 2; ++ i) {
52 [ + - ]: 2 : Properties *event = get_event(result.template_data, i);
53 [ + - + - : 2 : BOOST_REQUIRE(event != 0);
+ - + - +
- + - + -
- + ]
54 : :
55 [ + - + - : 2 : BOOST_CHECK_EQUAL(event->get<string>("", "call"), "goodbye");
+ - + - +
- + - + -
+ - - + ]
56 [ + - + - : 2 : BOOST_CHECK_EQUAL(event->get<string>("", "protocol"), "wspr.Hello");
+ - + - +
- + - + -
+ - - + ]
57 [ + - + - : 2 : BOOST_CHECK_EQUAL(event->get<string>("", "message"), "Adios amigos!");
+ - + - +
- + - + -
+ - - + ]
58 : : }
59 [ + - + - : 16 : }
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
|