|
8 | 8 | import static org.junit.Assert.assertTrue; |
9 | 9 | import static org.junit.Assert.fail; |
10 | 10 |
|
11 | | -import java.io.IOException; |
12 | 11 | import java.util.ArrayList; |
13 | 12 | import java.util.HashMap; |
14 | 13 | import java.util.List; |
|
20 | 19 | import com.google.gson.JsonElement; |
21 | 20 | import com.google.gson.JsonObject; |
22 | 21 | import com.google.gson.JsonPrimitive; |
| 22 | +import io.ably.lib.test.util.AblyCommonsReader; |
23 | 23 | import io.ably.lib.types.ChannelOptions; |
24 | 24 | import io.ably.lib.types.MessageAction; |
25 | 25 | import io.ably.lib.types.MessageExtras; |
|
47 | 47 | import io.ably.lib.test.common.Helpers.MessageWaiter; |
48 | 48 | import io.ably.lib.test.common.Helpers; |
49 | 49 | import io.ably.lib.test.common.ParameterizedTest; |
50 | | -import io.ably.lib.test.common.Setup; |
51 | 50 | import io.ably.lib.transport.ConnectionManager; |
52 | 51 | import io.ably.lib.types.AblyException; |
53 | 52 | import io.ably.lib.types.Callback; |
|
59 | 58 |
|
60 | 59 | public class RealtimeMessageTest extends ParameterizedTest { |
61 | 60 |
|
62 | | - private static final String testMessagesEncodingFile = "ably-common/test-resources/messages-encoding.json"; |
| 61 | + private static final String testMessagesEncodingFile = "test-resources/messages-encoding.json"; |
63 | 62 | private static Gson gson = new Gson(); |
64 | 63 |
|
65 | 64 | @Rule |
@@ -532,13 +531,7 @@ public void ensure_disconnect_with_error_does_not_move_to_failed() { |
532 | 531 | @Test |
533 | 532 | public void messages_encoding_fixtures() { |
534 | 533 | MessagesEncodingData fixtures; |
535 | | - try { |
536 | | - fixtures = (MessagesEncodingData) Setup.loadJson(testMessagesEncodingFile, MessagesEncodingData.class); |
537 | | - } catch(IOException e) { |
538 | | - fail(); |
539 | | - return; |
540 | | - } |
541 | | - |
| 534 | + fixtures = AblyCommonsReader.read(testMessagesEncodingFile, MessagesEncodingData.class); |
542 | 535 | AblyRealtime ably = null; |
543 | 536 | try { |
544 | 537 | ClientOptions opts = createOptions(testVars.keys[0].keyStr); |
@@ -597,12 +590,7 @@ public MessagesEncodingDataItem[] handleResponse(HttpCore.Response response, Err |
597 | 590 | @Test |
598 | 591 | public void messages_msgpack_and_json_encoding_is_compatible() { |
599 | 592 | MessagesEncodingData fixtures; |
600 | | - try { |
601 | | - fixtures = (MessagesEncodingData) Setup.loadJson(testMessagesEncodingFile, MessagesEncodingData.class); |
602 | | - } catch(IOException e) { |
603 | | - fail(); |
604 | | - return; |
605 | | - } |
| 593 | + fixtures = AblyCommonsReader.read(testMessagesEncodingFile, MessagesEncodingData.class); |
606 | 594 |
|
607 | 595 | // Publish each data type through raw JSON POST and retrieve through MsgPack and JSON. |
608 | 596 |
|
@@ -884,15 +872,10 @@ public void message_from_encoded_json_object() throws AblyException { |
884 | 872 | public void messages_from_encoded_json_array() throws AblyException { |
885 | 873 | JsonArray fixtures = null; |
886 | 874 | 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 | | - } |
| 875 | + testMessages = AblyCommonsReader.read(testMessagesEncodingFile, MessagesData.class); |
| 876 | + JsonObject jsonObject = AblyCommonsReader.read(testMessagesEncodingFile, JsonObject.class); |
| 877 | + //We use this as-is for decoding purposes. |
| 878 | + fixtures = jsonObject.getAsJsonArray("messages"); |
896 | 879 |
|
897 | 880 | Message[] decodedMessages = Message.fromEncodedArray(fixtures, null); |
898 | 881 | for(int index = 0; index < decodedMessages.length; index++) { |
|
0 commit comments