mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-23 23:12:31 +00:00
73 lines
2.7 KiB
Bash
Executable File
73 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Tests for MeshMS Java API.
|
|
#
|
|
# Copyright 2014 Serval Project Inc.
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# as published by the Free Software Foundation; either version 2
|
|
# of the License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
source "${0%/*}/../testframework.sh"
|
|
source "${0%/*}/../testdefs.sh"
|
|
source "${0%/*}/../testdefs_java.sh"
|
|
|
|
setup() {
|
|
setup_servald
|
|
setup_servald_so
|
|
compile_java_classes
|
|
set_instance +A
|
|
executeOk_servald config \
|
|
set log.console.level debug \
|
|
set debug.httpd on
|
|
create_identities 5
|
|
configure_servald_server() {
|
|
add_servald_interface
|
|
executeOk_servald config \
|
|
set rhizome.api.restful.users.joe.password bloggs
|
|
}
|
|
start_servald_server
|
|
}
|
|
|
|
teardown() {
|
|
stop_all_servald_servers
|
|
kill_all_servald_processes
|
|
assert_no_servald_processes
|
|
report_all_servald_servers
|
|
}
|
|
|
|
doc_MeshmsListConversations="Java API list MeshMS conversations"
|
|
setup_MeshmsListConversations() {
|
|
setup
|
|
# create 3 threads, with all permutations of incoming and outgoing messages
|
|
executeOk_servald meshms send message $SIDA1 $SIDA2 "Message One"
|
|
executeOk_servald meshms send message $SIDA3 $SIDA1 "Message Two"
|
|
executeOk_servald meshms send message $SIDA1 $SIDA4 "Message Three"
|
|
executeOk_servald meshms send message $SIDA4 $SIDA1 "Message Four"
|
|
}
|
|
test_MeshmsListConversations() {
|
|
executeJavaOk org.servalproject.test.Meshms meshms-list-conversations $SIDA1
|
|
assertStdoutLineCount '==' 3
|
|
assertStdoutGrep "my_sid=$SIDA1, their_sid=$SIDA2, read=true, last_message=0, read_offset=0"
|
|
assertStdoutGrep "my_sid=$SIDA1, their_sid=$SIDA3, read=false, last_message=14, read_offset=0"
|
|
assertStdoutGrep "my_sid=$SIDA1, their_sid=$SIDA4, read=false, last_message=18, read_offset=0"
|
|
executeOk_servald meshms read messages $SIDA1
|
|
executeJavaOk org.servalproject.test.Meshms meshms-list-conversations $SIDA1
|
|
assertStdoutLineCount '==' 3
|
|
assertStdoutGrep "my_sid=$SIDA1, their_sid=$SIDA2, read=true, last_message=0, read_offset=0"
|
|
assertStdoutGrep "my_sid=$SIDA1, their_sid=$SIDA3, read=true, last_message=14, read_offset=14"
|
|
assertStdoutGrep "my_sid=$SIDA1, their_sid=$SIDA4, read=true, last_message=18, read_offset=18"
|
|
}
|
|
|
|
runTests "$@"
|