mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-20 17:33:08 +00:00
Fix MeshMS Java API when MeshMS disabled
If the MeshMS REST API is disabled, then the JSON response omits the MeshMS status code, so the Java client API now handles this case.
This commit is contained in:
parent
4891348684
commit
8ac156376d
@ -80,15 +80,18 @@ public class MeshMSCommon
|
||||
json.consume("http_status_message");
|
||||
json.consume(JSONTokeniser.Token.COLON);
|
||||
status.http_status_message = json.consume(String.class);
|
||||
json.consume(JSONTokeniser.Token.COMMA);
|
||||
json.consume("meshms_status_code");
|
||||
json.consume(JSONTokeniser.Token.COLON);
|
||||
status.meshms_status_code = MeshMSStatus.fromCode(json.consume(Integer.class));
|
||||
json.consume(JSONTokeniser.Token.COMMA);
|
||||
json.consume("meshms_status_message");
|
||||
json.consume(JSONTokeniser.Token.COLON);
|
||||
status.meshms_status_message = json.consume(String.class);
|
||||
json.consume(JSONTokeniser.Token.END_OBJECT);
|
||||
Object tok = json.nextToken();
|
||||
if (tok == JSONTokeniser.Token.COMMA) {
|
||||
json.consume("meshms_status_code");
|
||||
json.consume(JSONTokeniser.Token.COLON);
|
||||
status.meshms_status_code = MeshMSStatus.fromCode(json.consume(Integer.class));
|
||||
json.consume(JSONTokeniser.Token.COMMA);
|
||||
json.consume("meshms_status_message");
|
||||
json.consume(JSONTokeniser.Token.COLON);
|
||||
status.meshms_status_message = json.consume(String.class);
|
||||
tok = json.nextToken();
|
||||
}
|
||||
json.match(tok, JSONTokeniser.Token.END_OBJECT);
|
||||
json.consume(JSONTokeniser.Token.EOF);
|
||||
return status;
|
||||
}
|
||||
@ -99,6 +102,9 @@ public class MeshMSCommon
|
||||
|
||||
protected static void throwRestfulResponseExceptions(Status status, URL url) throws MeshMSException, ServalDFailureException
|
||||
{
|
||||
if (status.meshms_status_code == null) {
|
||||
throw new ServalDFailureException("missing meshms_status_code from " + url);
|
||||
}
|
||||
switch (status.meshms_status_code) {
|
||||
case OK:
|
||||
case UPDATED:
|
||||
|
@ -49,14 +49,17 @@ set_extra_config() {
|
||||
:
|
||||
}
|
||||
|
||||
doc_MeshmsDisabled="Java API failure when rhizome is disabled"
|
||||
doc_MeshmsDisabled="Java API fails when rhizome is disabled"
|
||||
setup_MeshmsDisabled() {
|
||||
setup
|
||||
executeOk_servald config set rhizome.enable off sync
|
||||
}
|
||||
test_MeshmsDisabled() {
|
||||
executeJavaOk org.servalproject.test.Meshms meshms-list-conversations $SIDA1
|
||||
executeJava org.servalproject.test.Meshms meshms-list-conversations $SIDA1
|
||||
tfw_cat --stdout --stderr
|
||||
assertExitStatus != 0
|
||||
assertStderrGrep ServalDFailureException
|
||||
assertStderrGrep --ignore-case 'missing meshms_status_code'
|
||||
}
|
||||
|
||||
doc_MeshmsListConversations="Java API list MeshMS conversations"
|
||||
|
Loading…
x
Reference in New Issue
Block a user