summaryrefslogtreecommitdiff
path: root/icespider/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'icespider/unittests')
-rw-r--r--icespider/unittests/testCompile.cpp44
-rw-r--r--icespider/unittests/testRoutes.json218
2 files changed, 122 insertions, 140 deletions
diff --git a/icespider/unittests/testCompile.cpp b/icespider/unittests/testCompile.cpp
index 063d691..4fb7827 100644
--- a/icespider/unittests/testCompile.cpp
+++ b/icespider/unittests/testCompile.cpp
@@ -38,31 +38,25 @@ BOOST_AUTO_TEST_CASE( testLoadConfiguration )
BOOST_REQUIRE_EQUAL("common", cfg->name);
BOOST_REQUIRE_EQUAL(10, cfg->routes.size());
- BOOST_REQUIRE_EQUAL("index", cfg->routes[0]->name);
- BOOST_REQUIRE_EQUAL("/", cfg->routes[0]->path);
- BOOST_REQUIRE_EQUAL(HttpMethod::GET, cfg->routes[0]->method);
- BOOST_REQUIRE_EQUAL("TestIceSpider.TestApi.index", cfg->routes[0]->operation);
- BOOST_REQUIRE_EQUAL(0, cfg->routes[0]->params.size());
-
- BOOST_REQUIRE_EQUAL("item", cfg->routes[1]->name);
- BOOST_REQUIRE_EQUAL("/view/{s}/{i}", cfg->routes[1]->path);
- BOOST_REQUIRE_EQUAL(2, cfg->routes[1]->params.size());
-
- BOOST_REQUIRE_EQUAL("del", cfg->routes[2]->name);
- BOOST_REQUIRE_EQUAL(HttpMethod::DELETE, cfg->routes[2]->method);
- BOOST_REQUIRE_EQUAL(1, cfg->routes[2]->params.size());
-
- BOOST_REQUIRE_EQUAL("update", cfg->routes[3]->name);
- BOOST_REQUIRE_EQUAL(HttpMethod::POST, cfg->routes[3]->method);
- BOOST_REQUIRE_EQUAL(2, cfg->routes[3]->params.size());
-
- BOOST_REQUIRE_EQUAL("mashStruct", cfg->routes[6]->name);
- BOOST_REQUIRE_EQUAL(HttpMethod::GET, cfg->routes[6]->method);
- BOOST_REQUIRE_EQUAL(3, cfg->routes[6]->params.size());
-
- BOOST_REQUIRE_EQUAL("mashClass", cfg->routes[7]->name);
- BOOST_REQUIRE_EQUAL(HttpMethod::GET, cfg->routes[7]->method);
- BOOST_REQUIRE_EQUAL(3, cfg->routes[7]->params.size());
+ BOOST_REQUIRE_EQUAL("/", cfg->routes["index"]->path);
+ BOOST_REQUIRE_EQUAL(HttpMethod::GET, cfg->routes["index"]->method);
+ BOOST_REQUIRE_EQUAL("TestIceSpider.TestApi.index", cfg->routes["index"]->operation);
+ BOOST_REQUIRE_EQUAL(0, cfg->routes["index"]->params.size());
+
+ BOOST_REQUIRE_EQUAL("/view/{s}/{i}", cfg->routes["item"]->path);
+ BOOST_REQUIRE_EQUAL(2, cfg->routes["item"]->params.size());
+
+ BOOST_REQUIRE_EQUAL(HttpMethod::DELETE, cfg->routes["del"]->method);
+ BOOST_REQUIRE_EQUAL(1, cfg->routes["del"]->params.size());
+
+ BOOST_REQUIRE_EQUAL(HttpMethod::POST, cfg->routes["update"]->method);
+ BOOST_REQUIRE_EQUAL(2, cfg->routes["update"]->params.size());
+
+ BOOST_REQUIRE_EQUAL(HttpMethod::GET, cfg->routes["mashStruct"]->method);
+ BOOST_REQUIRE_EQUAL(3, cfg->routes["mashStruct"]->params.size());
+
+ BOOST_REQUIRE_EQUAL(HttpMethod::GET, cfg->routes["mashClass"]->method);
+ BOOST_REQUIRE_EQUAL(3, cfg->routes["mashClass"]->params.size());
BOOST_REQUIRE_EQUAL(1, cfg->slices.size());
BOOST_REQUIRE_EQUAL("test-api.ice", cfg->slices[0]);
diff --git a/icespider/unittests/testRoutes.json b/icespider/unittests/testRoutes.json
index 52add90..13a6806 100644
--- a/icespider/unittests/testRoutes.json
+++ b/icespider/unittests/testRoutes.json
@@ -1,132 +1,120 @@
{
"name": "common",
"headers": [ "xsltStreamSerializer.h" ],
- "routes": [
- {
- "name": "index",
- "path": "/",
- "method": "GET",
- "outputSerializers": [
- {
- "contentType": "text/html",
- "serializer": "IceSpider.XsltStreamSerializer",
- "params": [ "\"xslt/transform.xslt\"" ]
- }
- ],
- "operation": "TestIceSpider.TestApi.index"
- },
- {
- "name": "item",
- "path": "/view/{s}/{i}",
- "method": "GET",
- "operation": "TestIceSpider.TestApi.withParams"
- },
- {
- "name": "del",
- "path": "/{s}",
- "method": "DELETE",
- "operation": "TestIceSpider.TestApi.returnNothing"
- },
- {
- "name": "update",
- "path": "/{id}",
- "method": "POST",
- "operation": "TestIceSpider.TestApi.complexParam",
- "params": {
- "s": {
- "source": "URL",
- "key": "id",
- "isOptional": true
+ "routes": {
+ "index": {
+ "path": "/",
+ "method": "GET",
+ "outputSerializers": {
+ "text/html": {
+ "serializer": "IceSpider.XsltStreamSerializer",
+ "params": [ "\"xslt/transform.xslt\"" ]
+ }
},
- "m": {
- "source": "Body"
+ "operation": "TestIceSpider.TestApi.index"
+ },
+ "item": {
+ "path": "/view/{s}/{i}",
+ "method": "GET",
+ "operation": "TestIceSpider.TestApi.withParams"
+ },
+ "del": {
+ "path": "/{s}",
+ "method": "DELETE",
+ "operation": "TestIceSpider.TestApi.returnNothing"
+ },
+ "update": {
+ "path": "/{id}",
+ "method": "POST",
+ "operation": "TestIceSpider.TestApi.complexParam",
+ "params": {
+ "s": {
+ "source": "URL",
+ "key": "id",
+ "isOptional": true
+ },
+ "m": {
+ "source": "Body"
+ }
}
- }
- },
- {
- "name": "defaultItem",
- "path": "/item/{s}",
- "method": "GET",
- "operation": "TestIceSpider.TestApi.withParams",
- "params": {
- "i": {
- "default": "1234"
+ },
+ "defaultItem": {
+ "path": "/item/{s}",
+ "method": "GET",
+ "operation": "TestIceSpider.TestApi.withParams",
+ "params": {
+ "i": {
+ "default": "1234"
+ }
}
- }
- },
- {
- "name": "itemWithDefault",
- "path": "/item/{s}/{i}",
- "method": "GET",
- "operation": "TestIceSpider.TestApi.withParams",
- "params": {
- "i": {
- "default": "1234"
+ },
+ "itemWithDefault":{
+ "path": "/item/{s}/{i}",
+ "method": "GET",
+ "operation": "TestIceSpider.TestApi.withParams",
+ "params": {
+ "i": {
+ "default": "1234"
+ }
}
- }
- },
- {
- "name": "mashStruct",
- "path": "/mashS/{s}/{t}/{i}",
- "method": "GET",
- "type": "TestIceSpider.Mash1",
- "operations": {
- "a": {
- "operation": "TestIceSpider.TestApi.withParams"
- },
- "b": {
- "operation": "TestIceSpider.TestApi.withParams",
- "paramOverrides": {
- "s": "t"
+ },
+ "mashStruct": {
+ "path": "/mashS/{s}/{t}/{i}",
+ "method": "GET",
+ "type": "TestIceSpider.Mash1",
+ "operations": {
+ "a": {
+ "operation": "TestIceSpider.TestApi.withParams"
+ },
+ "b": {
+ "operation": "TestIceSpider.TestApi.withParams",
+ "paramOverrides": {
+ "s": "t"
+ }
}
}
- }
- },
- {
- "name": "mashClass",
- "path": "/mashC/{s}/{t}/{i}",
- "method": "GET",
- "type": "TestIceSpider.Mash2",
- "operations": {
- "a": {
- "operation": "TestIceSpider.TestApi.withParams"
- },
- "b": {
- "operation": "TestIceSpider.TestApi.withParams",
- "paramOverrides": {
- "s": "t"
+ },
+ "mashClass": {
+ "path": "/mashC/{s}/{t}/{i}",
+ "method": "GET",
+ "type": "TestIceSpider.Mash2",
+ "operations": {
+ "a": {
+ "operation": "TestIceSpider.TestApi.withParams"
+ },
+ "b": {
+ "operation": "TestIceSpider.TestApi.withParams",
+ "paramOverrides": {
+ "s": "t"
+ }
}
}
- }
- },
- {
- "name": "override",
- "path": "/override",
- "method": "GET",
- "outputSerializers": [
- {
- "contentType": "application/xml",
- "serializer": "IceSpider.XsltStreamSerializer",
- "params": [ "\"xslt/transform.xslt\"" ]
- }
- ],
- "operation": "TestIceSpider.TestApi.index"
- },
- {
- "name": "search",
- "path": "/search",
- "method": "GET",
- "operation": "TestIceSpider.TestApi.withParams",
- "params": {
- "s": {
- "source": "QueryString"
+ },
+ "override": {
+ "path": "/override",
+ "method": "GET",
+ "outputSerializers": {
+ "application/xml": {
+ "serializer": "IceSpider.XsltStreamSerializer",
+ "params": [ "\"xslt/transform.xslt\"" ]
+ }
},
- "i": {
- "source": "QueryString"
+ "operation": "TestIceSpider.TestApi.index"
+ },
+ "search": {
+ "path": "/search",
+ "method": "GET",
+ "operation": "TestIceSpider.TestApi.withParams",
+ "params": {
+ "s": {
+ "source": "QueryString"
+ },
+ "i": {
+ "source": "QueryString"
+ }
}
}
- }
- ],
+ },
"slices": [
"test-api.ice"
]