diff options
Diffstat (limited to 'linden/indra/test/message_tut.cpp')
-rw-r--r-- | linden/indra/test/message_tut.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/linden/indra/test/message_tut.cpp b/linden/indra/test/message_tut.cpp new file mode 100644 index 0000000..366c2b4 --- /dev/null +++ b/linden/indra/test/message_tut.cpp | |||
@@ -0,0 +1,97 @@ | |||
1 | /** | ||
2 | * @file lldatapacker_tut.cpp | ||
3 | * @date 2007-04 | ||
4 | * @brief LLDataPacker test cases. | ||
5 | * | ||
6 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * Second Life Viewer Source Code | ||
9 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
10 | * to you under the terms of the GNU General Public License, version 2.0 | ||
11 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
12 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
13 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
14 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlife.com/developers/opensource/flossexception | ||
20 | * | ||
21 | * By copying, modifying or distributing this software, you acknowledge | ||
22 | * that you have read and understood your obligations described above, | ||
23 | * and agree to abide by those obligations. | ||
24 | * | ||
25 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
27 | * COMPLETENESS OR PERFORMANCE. | ||
28 | */ | ||
29 | |||
30 | #include <tut/tut.h> | ||
31 | #include "lltut.h" | ||
32 | |||
33 | #include "llapr.h" | ||
34 | #include "llversion.h" | ||
35 | #include "message.h" | ||
36 | #include "message_prehash.h" | ||
37 | |||
38 | namespace | ||
39 | { | ||
40 | struct Response : public LLHTTPNode::Response | ||
41 | { | ||
42 | virtual void result(const LLSD&) {} | ||
43 | virtual void status(S32 code, const std::string& message) | ||
44 | { | ||
45 | mStatus = code; | ||
46 | } | ||
47 | S32 mStatus; | ||
48 | }; | ||
49 | } | ||
50 | |||
51 | namespace tut | ||
52 | { | ||
53 | struct LLMessageSystemTestData | ||
54 | { | ||
55 | LLMessageSystemTestData() | ||
56 | { | ||
57 | static bool init = false; | ||
58 | if(! init) | ||
59 | { | ||
60 | ll_init_apr(); | ||
61 | init_prehash_data(); | ||
62 | init = true; | ||
63 | } | ||
64 | |||
65 | // currently test disconnected message system | ||
66 | start_messaging_system("notafile", 13035, | ||
67 | LL_VERSION_MAJOR, | ||
68 | LL_VERSION_MINOR, | ||
69 | LL_VERSION_PATCH, | ||
70 | FALSE, | ||
71 | "notasharedsecret"); | ||
72 | } | ||
73 | |||
74 | ~LLMessageSystemTestData() | ||
75 | { | ||
76 | // not end_messaging_system() | ||
77 | delete gMessageSystem; | ||
78 | gMessageSystem = NULL; | ||
79 | } | ||
80 | }; | ||
81 | |||
82 | typedef test_group<LLMessageSystemTestData> LLMessageSystemTestGroup; | ||
83 | typedef LLMessageSystemTestGroup::object LLMessageSystemTestObject; | ||
84 | LLMessageSystemTestGroup messageTestGroup("LLMessageSystem"); | ||
85 | |||
86 | template<> template<> | ||
87 | void LLMessageSystemTestObject::test<1>() | ||
88 | // dispatch unknown message | ||
89 | { | ||
90 | const char* name = "notamessasge"; | ||
91 | const LLSD message; | ||
92 | const LLPointer<Response> response = new Response(); | ||
93 | gMessageSystem->dispatch(name, message, response); | ||
94 | ensure_equals(response->mStatus, 404); | ||
95 | } | ||
96 | } | ||
97 | |||