00001
00033 #include <tut/tut.h>
00034
00035 #include "linden_common.h"
00036 #include "lltut.h"
00037 #include "llsd.h"
00038 #include "llservicebuilder.h"
00039
00040 namespace tut
00041 {
00042
00043 struct ServiceBuilderTestData {
00044 LLServiceBuilder mServiceBuilder;
00045 };
00046
00047 typedef test_group<ServiceBuilderTestData> ServiceBuilderTestGroup;
00048 typedef ServiceBuilderTestGroup::object ServiceBuilderTestObject;
00049
00050 ServiceBuilderTestGroup serviceBuilderTestGroup("ServiceBuilder");
00051
00052 template<> template<>
00053 void ServiceBuilderTestObject::test<1>()
00054 {
00055
00056 LLSD test_block;
00057 test_block["service-builder"] = "/agent/name";
00058 mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
00059 std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest");
00060 ensure_equals("Basic URL Creation", test_url , "/agent/name");
00061 }
00062
00063 template<> template<>
00064 void ServiceBuilderTestObject::test<2>()
00065 {
00066
00067 LLSD test_block;
00068 test_block["service-builder"] = "/agent/{$agent-id}/name";
00069 mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
00070 LLSD data_map;
00071 data_map["agent-id"] = "257c631f-a0c5-4f29-8a9f-9031feaae6c6";
00072 std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map);
00073 ensure_equals("Replacement URL Creation", test_url , "/agent/257c631f-a0c5-4f29-8a9f-9031feaae6c6/name");
00074 }
00075
00076 template<> template<>
00077 void ServiceBuilderTestObject::test<3>()
00078 {
00079
00080 LLSD test_block;
00081 test_block["service-builder"] = "/agent/{$agent-id}/name";
00082 mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
00083 std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilder");
00084 ensure_equals("Replacement URL Creation for Non-existant Service", test_url , "");
00085 }
00086
00087 template<> template<>
00088 void ServiceBuilderTestObject::test<4>()
00089 {
00090
00091 LLSD test_block;
00092 test_block["service-builder"] = "/agent/{$agent-id}/name";
00093 mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
00094 LLSD data_map;
00095 data_map["agent_id"] = "257c631f-a0c5-4f29-8a9f-9031feaae6c6";
00096 std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map);
00097 ensure_equals("Replacement URL Creation for Non-existant Service", test_url , "/agent/{$agent-id}/name");
00098 }
00099
00100 template<> template<>
00101 void ServiceBuilderTestObject::test<5>()
00102 {
00103 LLSD test_block;
00104 test_block["service-builder"] = "/proc/{$proc}{%params}";
00105 mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
00106 LLSD data_map;
00107 data_map["proc"] = "do/something/useful";
00108 data_map["params"]["estate_id"] = 1;
00109 data_map["params"]["query"] = "public";
00110 std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map);
00111 ensure_equals(
00112 "two part URL Creation",
00113 test_url ,
00114 "/proc/do/something/useful?estate_id=1&query=public");
00115 }
00116 }
00117