1 | <html> |
---|
2 | <head> |
---|
3 | <title>Test Service</title> |
---|
4 | <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script> |
---|
5 | <script type="text/javascript"> |
---|
6 | dojo.provide("dojox.wire.ml.tests.markup.Service"); |
---|
7 | |
---|
8 | dojo.require("dojo.parser"); |
---|
9 | dojo.require("doh.runner"); |
---|
10 | dojo.require("dojox.wire.ml.Service"); |
---|
11 | dojo.require("dojox.wire.ml.Invocation"); |
---|
12 | dojo.require("dojox.wire.ml.Transfer"); |
---|
13 | |
---|
14 | dojox.wire.ml.tests.markup.Service = { |
---|
15 | query: {name: "a"} |
---|
16 | }; |
---|
17 | |
---|
18 | dojo.addOnLoad(function(){ |
---|
19 | doh.register("dojox.wire.ml.tests.markup.Service", [ |
---|
20 | |
---|
21 | function test_Service_url(t){ |
---|
22 | var d = new doh.Deferred(); |
---|
23 | dojo.connect(dijit.byId("Invocation1"), "onComplete", function(result){ |
---|
24 | t.assertEqual("a", dojox.wire.ml.tests.markup.Service.target.a); |
---|
25 | var o = result.toObject(); |
---|
26 | t.assertEqual("a", o.item.name); // test XmlElement.toObject() |
---|
27 | t.assertEqual("b", o.item.data); // test XmlElement.toObject() |
---|
28 | |
---|
29 | d.callback(true); |
---|
30 | }); |
---|
31 | dojo.connect(dijit.byId("Invocation1"), "onError", function(error){ |
---|
32 | d.errback(error); |
---|
33 | }); |
---|
34 | dojo.publish("invokeGetXml"); |
---|
35 | return d; |
---|
36 | }, |
---|
37 | |
---|
38 | function test_Service_serviceUrl(t){ |
---|
39 | var d = new doh.Deferred(); |
---|
40 | dojo.connect(dijit.byId("Invocation2"), "onComplete", function(){ |
---|
41 | t.assertEqual("a", dojox.wire.ml.tests.markup.Service.result.item.name); |
---|
42 | d.callback(true); |
---|
43 | }); |
---|
44 | dojo.connect(dijit.byId("Invocation2"), "onError", function(error){ |
---|
45 | d.errback(error); |
---|
46 | }); |
---|
47 | dojo.publish("invokeGetJson"); |
---|
48 | return d; |
---|
49 | } |
---|
50 | |
---|
51 | ]); |
---|
52 | doh.run(); |
---|
53 | }); |
---|
54 | </script> |
---|
55 | </head> |
---|
56 | <body> |
---|
57 | <div dojoType="dojox.wire.ml.Service" |
---|
58 | id="Service1" |
---|
59 | url="Service/XML.smd"></div> |
---|
60 | <div dojoType="dojox.wire.ml.Invocation" |
---|
61 | id="Invocation1" |
---|
62 | triggerTopic="invokeGetXml" |
---|
63 | object="Service1" |
---|
64 | method="get" |
---|
65 | parameters="dojox.wire.ml.tests.markup.Service.query"> |
---|
66 | </div> |
---|
67 | <div dojoType="dojox.wire.ml.Transfer" |
---|
68 | trigger="Invocation1" |
---|
69 | triggerEvent="onComplete" |
---|
70 | source="arguments[0].item.name" |
---|
71 | target="dojox.wire.ml.tests.markup.Service.target.a"></div> |
---|
72 | <div dojoType="dojox.wire.ml.Service" |
---|
73 | id="Service2" |
---|
74 | serviceType="JSON" |
---|
75 | serviceUrl="Service/{name}.json"></div> |
---|
76 | <div dojoType="dojox.wire.ml.Invocation" |
---|
77 | id="Invocation2" |
---|
78 | triggerTopic="invokeGetJson" |
---|
79 | object="Service2" |
---|
80 | method="get" |
---|
81 | parameters="dojox.wire.ml.tests.markup.Service.query" |
---|
82 | result="dojox.wire.ml.tests.markup.Service.result"></div> |
---|
83 | </body> |
---|
84 | </html> |
---|