Skip to content

Commit 754a064

Browse files
committed
[ECO-5553] Fixed channel delta encoding integration test assertions
for modes and params
1 parent 8c85761 commit 754a064

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void attach_with_channel_params_channels_get() {
174174
channel.attach();
175175
(new ChannelWaiter(channel)).waitFor(ChannelState.attached);
176176
assertEquals("Verify attached state reached", ChannelState.attached, channel.state);
177-
assertEquals("Verify channel params", channel.getParams(), options.params);
177+
assertEquals("Verify channel params", options.params, channel.getParams());
178178
assertArrayEquals("Verify channel modes", new ChannelMode[] { ChannelMode.subscribe }, channel.getModes());
179179
} catch (AblyException e) {
180180
e.printStackTrace();
@@ -208,7 +208,7 @@ public void attach_with_channel_params_set_options() {
208208
channel.attach();
209209
(new ChannelWaiter(channel)).waitFor(ChannelState.attached);
210210
assertEquals("Verify attached state reached", ChannelState.attached, channel.state);
211-
assertEquals("Verify channel params", channel.getParams(), options.params);
211+
assertEquals("Verify channel params", options.params, channel.getParams());
212212
assertArrayEquals("Verify channel modes", new ChannelMode[] { ChannelMode.subscribe }, channel.getModes());
213213
} catch (AblyException e) {
214214
e.printStackTrace();
@@ -285,7 +285,10 @@ public void attach_with_channel_params_modes_and_channel_modes() {
285285
(new ChannelWaiter(channel)).waitFor(ChannelState.attached);
286286
assertEquals("Verify attached state reached", ChannelState.attached, channel.state);
287287
assertEquals("Verify channel params", channel.getParams(), options.params);
288-
assertArrayEquals("Verify channel modes", new ChannelMode[] { ChannelMode.subscribe, ChannelMode.presence }, channel.getModes());
288+
// modes in params overrides individual modes in options
289+
assertThat("Verify channel modes", Arrays.asList(channel.getModes()),
290+
Matchers.containsInAnyOrder(ChannelMode.presence, ChannelMode.subscribe));
291+
289292
} catch (AblyException e) {
290293
e.printStackTrace();
291294
fail("init0: Unexpected exception instantiating library");

lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.ably.lib.transport.ConnectionManager;
1212
import io.ably.lib.transport.ITransport;
1313
import io.ably.lib.transport.WebSocketTransport;
14+
import io.ably.lib.types.ChannelOptions;
1415
import io.ably.lib.types.ClientOptions;
1516
import io.ably.lib.types.Message;
1617
import io.ably.lib.types.MessageExtras;
@@ -20,6 +21,7 @@
2021
import org.junit.Test;
2122
import org.junit.rules.Timeout;
2223

24+
import java.util.Map;
2325
import java.util.Objects;
2426

2527
import static org.junit.Assert.assertEquals;
@@ -52,6 +54,8 @@ public void simple_delta_codec() {
5254

5355
(new ChannelWaiter(channel)).waitFor(ChannelState.attached);
5456

57+
assertEquals("Verify channel params", Map.of("delta", "vcdiff"), channel.getParams());
58+
5559
for (int i = 0; i < testData.length; i++) {
5660
channel.publish(Integer.toString(i), testData[i]);
5761
}
@@ -90,14 +94,18 @@ private void delta_failure_recovery(final ITransport.Factory websocketFactory, S
9094
opts.transportFactory = websocketFactory;
9195
ably = new AblyRealtime(opts);
9296

93-
/* create a channel */
94-
final Channel channel = ably.channels.get("[?delta=vcdiff]" + testName);
97+
ChannelOptions options = new ChannelOptions();
98+
options.params = Map.of("delta", "vcdiff");
99+
/* create a channel with channelOptions set to vcdiff*/
100+
final Channel channel = ably.channels.get(testName, options);
95101

96102
/* attach */
97103
channel.attach();
98104
(new ChannelWaiter(channel)).waitFor(ChannelState.attached);
99105
assertEquals("Verify attached state reached", channel.state, ChannelState.attached);
100106

107+
assertEquals("Verify channel params", Map.of("delta", "vcdiff"), channel.getParams());
108+
101109
/* subscribe */
102110
MessageWaiter messageWaiter = new MessageWaiter(channel);
103111

0 commit comments

Comments
 (0)