aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/wire/tests/markup/Service.html
blob: 0448c6164c079d4ad5010daac261735fe2ed3f43 (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
79
80
81
82
83
84
<html>
<head>
<title>Test Service</title>
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.provide("dojox.wire.ml.tests.markup.Service");

dojo.require("dojo.parser");
dojo.require("doh.runner");
dojo.require("dojox.wire.ml.Service");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.Transfer");

dojox.wire.ml.tests.markup.Service = {
	query: {name: "a"}
};

dojo.addOnLoad(function(){
	doh.register("dojox.wire.ml.tests.markup.Service", [

		function test_Service_url(t){
			var d = new doh.Deferred();
			dojo.connect(dijit.byId("Invocation1"), "onComplete", function(result){
 				t.assertEqual("a", dojox.wire.ml.tests.markup.Service.target.a);
 				var o = result.toObject();
				t.assertEqual("a", o.item.name); // test XmlElement.toObject()
				t.assertEqual("b", o.item.data); // test XmlElement.toObject()

 				d.callback(true);
 			});
			dojo.connect(dijit.byId("Invocation1"), "onError", function(error){
				d.errback(error);
			});
			dojo.publish("invokeGetXml");
			return d;
		},

		function test_Service_serviceUrl(t){
			var d = new doh.Deferred();
			dojo.connect(dijit.byId("Invocation2"), "onComplete", function(){
				t.assertEqual("a", dojox.wire.ml.tests.markup.Service.result.item.name);
				d.callback(true);
			});
			dojo.connect(dijit.byId("Invocation2"), "onError", function(error){
				d.errback(error);
			});
			dojo.publish("invokeGetJson");
			return d;
		}

	]);
	doh.run();
});
</script>
</head>
<body>
<div dojoType="dojox.wire.ml.Service"
	id="Service1"
	url="Service/XML.smd"></div>
<div dojoType="dojox.wire.ml.Invocation"
	id="Invocation1"
	triggerTopic="invokeGetXml"
	object="Service1"
	method="get"
	parameters="dojox.wire.ml.tests.markup.Service.query">
</div>
<div dojoType="dojox.wire.ml.Transfer"
	trigger="Invocation1"
	triggerEvent="onComplete"
	source="arguments[0].item.name"
	target="dojox.wire.ml.tests.markup.Service.target.a"></div>
<div dojoType="dojox.wire.ml.Service"
	id="Service2"
	serviceType="JSON"
	serviceUrl="Service/{name}.json"></div>
<div dojoType="dojox.wire.ml.Invocation"
	id="Invocation2"
	triggerTopic="invokeGetJson"
	object="Service2"
	method="get"
	parameters="dojox.wire.ml.tests.markup.Service.query"
	result="dojox.wire.ml.tests.markup.Service.result"></div>
</body>
</html>