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
43
44
45
46
47
48
49
50
module("Stomp Acknowledgement");
 
test("Subscribe using client ack mode, send a message and ack it", function() {
  
  var body = Math.random();
  
  var client = Stomp.client(TEST.url);
  
  client.debug = TEST.debug;
  client.connect(TEST.login, TEST.password, function() {
    var onmessage = function(message) {
      start();        
      // we should receive the 2nd message outside the transaction
      equals(message.body, body);
      var receipt = Math.random();
      client.onreceipt = function(frame) {
        equals(receipt, frame.headers['receipt-id'])
        client.disconnect();
      }
      message.ack({'receipt': receipt});
    }
    var sub = client.subscribe(TEST.destination, onmessage, {'ack': 'client'});      
    client.send(TEST.destination, {}, body);
  });
  stop(TEST.timeout);
});
 
test("Subscribe using client ack mode, send a message and nack it", function() {
  
  var body = Math.random();
  
  var client = Stomp.client(TEST.url);
  
  client.debug = TEST.debug;
  client.connect(TEST.login, TEST.password, function() {
    var onmessage = function(message) {
      start();        
      equals(message.body, body);
      var receipt = Math.random();
      client.onreceipt = function(frame) {
        equals(receipt, frame.headers['receipt-id'])
        client.disconnect();
      }
      message.nack({'receipt': receipt});
    }
    var sub = client.subscribe(TEST.destination, onmessage, {'ack': 'client'});      
    client.send(TEST.destination, {}, body);
  });
  stop(TEST.timeout);
});