summaryrefslogtreecommitdiff
path: root/indra/test/message_tut.cpp
blob: b2c84d5f548f6ae587f55a1420a7aa84a066c1e3 (plain)
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
/**
 * @file lldatapacker_tut.cpp
 * @date 2007-04
 * @brief LLDataPacker test cases.
 *
 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

#include <tut/tut.h>
#include "linden_common.h"
#include "lltut.h"

#include "llapr.h"
#include "llversion.h"
#include "message.h"
#include "message_prehash.h"

namespace
{
	struct Response : public LLHTTPNode::Response
	{
		virtual void result(const LLSD&) {}
		virtual void status(S32 code, const std::string& message) 
		{
			mStatus = code;
		}
		S32 mStatus;
	};
}

namespace tut
{	
	struct LLMessageSystemTestData 
	{
		LLMessageSystemTestData()
		{
			static bool init = false;
			if(! init)
			{
				ll_init_apr();
				init_prehash_data();
				init = true;
			}

			// currently test disconnected message system
			start_messaging_system("notafile", 13035,
								   LL_VERSION_MAJOR,
								   LL_VERSION_MINOR,        
								   LL_VERSION_PATCH,        
								   FALSE,        
								   "notasharedsecret");
		}

		~LLMessageSystemTestData()
		{
			// not end_messaging_system()
			delete gMessageSystem;
			gMessageSystem = NULL;
		}
	};
	
	typedef test_group<LLMessageSystemTestData>	LLMessageSystemTestGroup;
	typedef LLMessageSystemTestGroup::object		LLMessageSystemTestObject;
	LLMessageSystemTestGroup messageTestGroup("LLMessageSystem");
	
	template<> template<>
	void LLMessageSystemTestObject::test<1>()
		// dispatch unknown message
	{
		const char* name = "notamessasge";
		const LLSD message;
		const LLPointer<Response> response = new Response();
		gMessageSystem->dispatch(name, message, response);
		ensure_equals(response->mStatus, 404);
	}
}