Unify exceptions for unsupported message types (#2908)
This commit is contained in:
parent
b0155446ab
commit
43cbb9edda
|
|
@ -47,16 +47,10 @@ public class JsonHubProtocol implements HubProtocol {
|
||||||
hubMessages.add(new InvocationMessage(target, new Object[] {args}));
|
hubMessages.add(new InvocationMessage(target, new Object[] {args}));
|
||||||
break;
|
break;
|
||||||
case STREAM_ITEM:
|
case STREAM_ITEM:
|
||||||
throw new UnsupportedOperationException("Support for streaming is not yet available");
|
|
||||||
case COMPLETION:
|
case COMPLETION:
|
||||||
//Don't care yet
|
|
||||||
break;
|
|
||||||
case STREAM_INVOCATION:
|
case STREAM_INVOCATION:
|
||||||
//Don't care yet;
|
|
||||||
throw new UnsupportedOperationException("Support for streaming is not yet available");
|
|
||||||
case CANCEL_INVOCATION:
|
case CANCEL_INVOCATION:
|
||||||
// Not tracking invocations yet
|
throw new UnsupportedOperationException(String.format("The message type %s is not supported yet.", messageType));
|
||||||
break;
|
|
||||||
case PING:
|
case PING:
|
||||||
//Ping
|
//Ping
|
||||||
hubMessages.add(new PingMessage());
|
hubMessages.add(new PingMessage());
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ public class JsonHubProtocolTest {
|
||||||
@Test
|
@Test
|
||||||
public void ParseSingleUnsupportedStreamItemMessage() {
|
public void ParseSingleUnsupportedStreamItemMessage() {
|
||||||
exceptionRule.expect(UnsupportedOperationException.class);
|
exceptionRule.expect(UnsupportedOperationException.class);
|
||||||
exceptionRule.expectMessage("Support for streaming is not yet available");
|
exceptionRule.expectMessage("The message type STREAM_ITEM is not supported yet.");
|
||||||
String stringifiedMessage = "{\"type\":2,\"Id\":1,\"Item\":42}\u001E";
|
String stringifiedMessage = "{\"type\":2,\"Id\":1,\"Item\":42}\u001E";
|
||||||
HubMessage[] messages = jsonHubProtocol.parseMessages(stringifiedMessage);
|
HubMessage[] messages = jsonHubProtocol.parseMessages(stringifiedMessage);
|
||||||
}
|
}
|
||||||
|
|
@ -111,8 +111,25 @@ public class JsonHubProtocolTest {
|
||||||
@Test
|
@Test
|
||||||
public void ParseSingleUnsupportedStreamInvocationMessage() {
|
public void ParseSingleUnsupportedStreamInvocationMessage() {
|
||||||
exceptionRule.expect(UnsupportedOperationException.class);
|
exceptionRule.expect(UnsupportedOperationException.class);
|
||||||
exceptionRule.expectMessage("Support for streaming is not yet available");
|
exceptionRule.expectMessage("The message type STREAM_INVOCATION is not supported yet.");
|
||||||
String stringifiedMessage = "{\"type\":4,\"Id\":1,\"target\":\"test\",\"arguments\":[42]}\u001E";
|
String stringifiedMessage = "{\"type\":4,\"Id\":1,\"target\":\"test\",\"arguments\":[42]}\u001E";
|
||||||
|
|
||||||
|
HubMessage[] messages = jsonHubProtocol.parseMessages(stringifiedMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ParseSingleUnsupportedCancelInvocationMessage() {
|
||||||
|
exceptionRule.expect(UnsupportedOperationException.class);
|
||||||
|
exceptionRule.expectMessage("The message type CANCEL_INVOCATION is not supported yet.");
|
||||||
|
String stringifiedMessage = "{\"type\":5,\"invocationId\":123}\u001E";
|
||||||
|
HubMessage[] messages = jsonHubProtocol.parseMessages(stringifiedMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ParseSingleUnsupportedCompletionMessage() {
|
||||||
|
exceptionRule.expect(UnsupportedOperationException.class);
|
||||||
|
exceptionRule.expectMessage("The message type COMPLETION is not supported yet.");
|
||||||
|
String stringifiedMessage = "{\"type\":3,\"invocationId\":123}\u001E";
|
||||||
HubMessage[] messages = jsonHubProtocol.parseMessages(stringifiedMessage);
|
HubMessage[] messages = jsonHubProtocol.parseMessages(stringifiedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue