|
|
|
@ -29,11 +29,11 @@
|
|
|
|
|
"stomp_frame.txt"
|
|
|
|
|
(setq recieved (stomp-read-frame (current-buffer)))
|
|
|
|
|
|
|
|
|
|
(should (equal (alist-get 'command recieved) "BLA"))
|
|
|
|
|
(should (equal (alist-get 'headers recieved)
|
|
|
|
|
'(("ok" . "bye")
|
|
|
|
|
("some-header" . "value"))))
|
|
|
|
|
(should (equal (alist-get 'content recieved) "content\n"))))
|
|
|
|
|
(should (equal "BLA" (alist-get 'command recieved)))
|
|
|
|
|
(should (equal '(("ok" . "bye")
|
|
|
|
|
("some-header" . "value"))
|
|
|
|
|
(alist-get 'headers recieved)))
|
|
|
|
|
(should (equal "content\n" (alist-get 'content recieved)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest can-read-carriage-return-frame ()
|
|
|
|
|
"Can read a simple frame with headers and content, containing carriage returns"
|
|
|
|
@ -41,11 +41,11 @@
|
|
|
|
|
"stomp_frame_cr.txt"
|
|
|
|
|
(setq recieved (stomp-read-frame (current-buffer)))
|
|
|
|
|
|
|
|
|
|
(should (equal (alist-get 'command recieved) "BLA"))
|
|
|
|
|
(should (equal (alist-get 'headers recieved)
|
|
|
|
|
'(("ok" . "bye")
|
|
|
|
|
("some-header" . "value"))))
|
|
|
|
|
(should (equal (alist-get 'content recieved) "content\r\n"))))
|
|
|
|
|
(should (equal "BLA" (alist-get 'command recieved)))
|
|
|
|
|
(should (equal '(("ok" . "bye")
|
|
|
|
|
("some-header" . "value"))
|
|
|
|
|
(alist-get 'headers recieved)))
|
|
|
|
|
(should (equal "content\r\n" (alist-get 'content recieved)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest can-read-fixed-length-frame ()
|
|
|
|
|
"Can read a frame that has a content-length header correctly"
|
|
|
|
@ -53,11 +53,11 @@
|
|
|
|
|
"content_length_frame.txt"
|
|
|
|
|
(setq recieved (stomp-read-frame (current-buffer)))
|
|
|
|
|
|
|
|
|
|
(should (equal (alist-get 'command recieved) "MESSAGE"))
|
|
|
|
|
(should (equal (alist-get 'headers recieved)
|
|
|
|
|
'(("destination" . "/banana/kiwi")
|
|
|
|
|
("content-length" . "11"))))
|
|
|
|
|
(should (equal (alist-get 'content recieved) "jwe\u0000jsiwli\u0000"))))
|
|
|
|
|
(should (equal "MESSAGE" (alist-get 'command recieved)))
|
|
|
|
|
(should (equal '(("destination" . "/banana/kiwi")
|
|
|
|
|
("content-length" . "11"))
|
|
|
|
|
(alist-get 'headers recieved)))
|
|
|
|
|
(should (equal "jwe\u0000jsiwli\u0000" (alist-get 'content recieved)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest returns-nil-when-incomplete-frame ()
|
|
|
|
|
"When there is no complete frame at the top of a buffer, read-frame
|
|
|
|
@ -66,7 +66,7 @@
|
|
|
|
|
"incomplete_frame.txt"
|
|
|
|
|
(setq recieved (stomp-read-frame (current-buffer)))
|
|
|
|
|
|
|
|
|
|
(should (equal recieved nil))))
|
|
|
|
|
(should (equal nil recieved))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest returns-nil-when-incomplete-frame-no-headers ()
|
|
|
|
|
"When no 'end of headers' marker can be found, stomp-read-frame should return nil"
|
|
|
|
@ -83,7 +83,7 @@
|
|
|
|
|
(let ((buffer (current-buffer)))
|
|
|
|
|
(stomp-delete-frame buffer nil)
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(should (equal (buffer-string) "BLA\nsome-header:value\nok:bye\n\ncontent\n\u0000\n"))))))
|
|
|
|
|
(should (equal "BLA\nsome-header:value\nok:bye\n\ncontent\n\u0000\n" (buffer-string)))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest can-compose-frame ()
|
|
|
|
|
"Can compose a valid STOMP frame from a LISP datastructure"
|
|
|
|
@ -92,4 +92,4 @@
|
|
|
|
|
(map-put headers "header" "value")
|
|
|
|
|
(map-put frame 'headers headers)
|
|
|
|
|
(map-put frame 'content "Some content")
|
|
|
|
|
(should (equal (stomp-frame-to-string frame) "SEND\nheader:value\n\nSome content\u0000"))))
|
|
|
|
|
(should (equal "SEND\nheader:value\n\nSome content\u0000" (stomp-frame-to-string frame)))))
|
|
|
|
|