|
20 | 20 | import com.google.gson.JsonElement; |
21 | 21 | import com.google.gson.JsonObject; |
22 | 22 | import com.google.gson.JsonPrimitive; |
| 23 | +import io.ably.lib.test.util.AblyCommonsReader; |
23 | 24 | import io.ably.lib.types.ChannelOptions; |
24 | 25 | import io.ably.lib.types.MessageAction; |
25 | 26 | import io.ably.lib.types.MessageExtras; |
|
59 | 60 |
|
60 | 61 | public class RealtimeMessageTest extends ParameterizedTest { |
61 | 62 |
|
62 | | - private static final String testMessagesEncodingFile = "ably-common/test-resources/messages-encoding.json"; |
| 63 | + private static final String testMessagesEncodingFile = "test-resources/messages-encoding.json"; |
63 | 64 | private static Gson gson = new Gson(); |
64 | 65 |
|
65 | 66 | @Rule |
@@ -532,13 +533,7 @@ public void ensure_disconnect_with_error_does_not_move_to_failed() { |
532 | 533 | @Test |
533 | 534 | public void messages_encoding_fixtures() { |
534 | 535 | MessagesEncodingData fixtures; |
535 | | - try { |
536 | | - fixtures = (MessagesEncodingData) Setup.loadJson(testMessagesEncodingFile, MessagesEncodingData.class); |
537 | | - } catch(IOException e) { |
538 | | - fail(); |
539 | | - return; |
540 | | - } |
541 | | - |
| 536 | + fixtures = AblyCommonsReader.read(testMessagesEncodingFile, MessagesEncodingData.class); |
542 | 537 | AblyRealtime ably = null; |
543 | 538 | try { |
544 | 539 | ClientOptions opts = createOptions(testVars.keys[0].keyStr); |
@@ -597,12 +592,7 @@ public MessagesEncodingDataItem[] handleResponse(HttpCore.Response response, Err |
597 | 592 | @Test |
598 | 593 | public void messages_msgpack_and_json_encoding_is_compatible() { |
599 | 594 | MessagesEncodingData fixtures; |
600 | | - try { |
601 | | - fixtures = (MessagesEncodingData) Setup.loadJson(testMessagesEncodingFile, MessagesEncodingData.class); |
602 | | - } catch(IOException e) { |
603 | | - fail(); |
604 | | - return; |
605 | | - } |
| 595 | + fixtures = AblyCommonsReader.read(testMessagesEncodingFile, MessagesEncodingData.class); |
606 | 596 |
|
607 | 597 | // Publish each data type through raw JSON POST and retrieve through MsgPack and JSON. |
608 | 598 |
|
@@ -884,15 +874,10 @@ public void message_from_encoded_json_object() throws AblyException { |
884 | 874 | public void messages_from_encoded_json_array() throws AblyException { |
885 | 875 | JsonArray fixtures = null; |
886 | 876 | MessagesData testMessages = null; |
887 | | - try { |
888 | | - testMessages = (MessagesData) Setup.loadJson(testMessagesEncodingFile, MessagesData.class); |
889 | | - JsonObject jsonObject = (JsonObject) Setup.loadJson(testMessagesEncodingFile, JsonObject.class); |
890 | | - //We use this as-is for decoding purposes. |
891 | | - fixtures = jsonObject.getAsJsonArray("messages"); |
892 | | - } catch(IOException e) { |
893 | | - fail(); |
894 | | - return; |
895 | | - } |
| 877 | + testMessages = AblyCommonsReader.read(testMessagesEncodingFile, MessagesData.class); |
| 878 | + JsonObject jsonObject = AblyCommonsReader.read(testMessagesEncodingFile, JsonObject.class); |
| 879 | + //We use this as-is for decoding purposes. |
| 880 | + fixtures = jsonObject.getAsJsonArray("messages"); |
896 | 881 |
|
897 | 882 | Message[] decodedMessages = Message.fromEncodedArray(fixtures, null); |
898 | 883 | for(int index = 0; index < decodedMessages.length; index++) { |
|
0 commit comments