File: abyss.cpp

package info (click to toggle)
xmlrpc-c 1.60.05-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,132 kB
  • sloc: ansic: 55,332; cpp: 13,541; sh: 3,321; makefile: 2,556; perl: 593; xml: 134
file content (115 lines) | stat: -rw-r--r-- 2,518 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*=============================================================================
                                  abyss
===============================================================================
  Test the Abyss server C++ facilities of XML-RPC for C/C++.
  
=============================================================================*/
#define WIN32_LEAN_AND_MEAN  /* required by xmlrpc-c/abyss.h */

#include <string>

using namespace std;

#include "xmlrpc-c/girerr.hpp"
using girerr::error;
using girerr::throwf;
#include "xmlrpc-c/base.hpp"
#include "xmlrpc-c/AbyssServer.hpp"
#include "xmlrpc-c/AbyssEnvironment.hpp"
#include "xmlrpc-c/AbyssChanSwitch.hpp"
#ifdef _WIN32
#include "xmlrpc-c/AbyssChanSwitchWin.hpp"
#else
#include "xmlrpc-c/AbyssChanSwitchUnix.hpp"
#endif

using namespace xmlrpc_c;

#include "tools.hpp"
#include "abyss.hpp"



// We need 'global' because methods of class addHandlerTestSuite call
// functions in the Abyss C library.  By virtue of global's static
// storage class, the program loader will call its constructor and
// destructor and thus initialize and terminate the Abyss C library.

static const AbyssEnvironment global;

namespace {



class addHandlerTestSuite : public testSuite {

public:
    virtual string suiteName() {
        return "addHandlerTestSuite";
    }
    virtual void runtests(unsigned int const) {

        class AbyssReqHandler_Test : public AbyssServer::ReqHandler {
        public:
            AbyssReqHandler_Test() {}

            void
            handleRequest(AbyssServer::Session * const ,
                          bool *                 const ) {}
        };

#ifdef _WIN32
        AbyssChanSwitchWin chanSwitch(8080);
#else
        AbyssChanSwitchUnix chanSwitch(8080);
#endif

        AbyssServer abyssServer(&chanSwitch);

        AbyssReqHandler_Test abyssReqHandler;

        abyssServer.addRequestHandler(&abyssReqHandler);
    }
};



class createTestSuite : public testSuite {

public:
    virtual string suiteName() {
        return "createTestSuite";
    }
    virtual void runtests(unsigned int const) {
#ifdef _WIN32
        AbyssChanSwitchWin chanSwitch(8080);
#else
        AbyssChanSwitchUnix chanSwitch(8080);
#endif
        AbyssServer abyssServer(&chanSwitch);

    }
};



}  // namespace



string
abyssTestSuite::suiteName() {
    return "abyssTestSuite";
}


void
abyssTestSuite::runtests(unsigned int const indentation) {

    createTestSuite().run(indentation+1);

    addHandlerTestSuite().run(indentation+1);
}