OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2022-01-13 4545664bbece1b1b185945376b344b1660669a53
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
module("Stomp Message");
 
test("Send and receive a message", function() {
  var body = Math.random();
  
  var client = Stomp.client(TEST.url);
  client.debug = TEST.debug;
  client.connect(TEST.login, TEST.password,
    function() {
      client.subscribe(TEST.destination, function(message)
      {
        start();
        equals(message.body, body);
        client.disconnect();
      });
      
      client.send(TEST.destination, {}, body);
    });
    stop(TEST.timeout);
});
 
test("Send and receive a message with a JSON body", function() {
  
  var client = Stomp.client(TEST.url);
  var payload = {text: "hello", bool: true, value: Math.random()};
  
  client.connect(TEST.login, TEST.password,
    function() {
      client.subscribe(TEST.destination, function(message)
      {
        start();
        var res = JSON.parse(message.body);
        equals(res.text, payload.text);
        equals(res.bool, payload.bool);
        equals(res.value, payload.value);
        client.disconnect();
      });
      
      client.send(TEST.destination, {}, JSON.stringify(payload));
    });
    stop(TEST.timeout);
});