Skip to content

Commit 551451a

Browse files
sacOO7ttypic
authored andcommitted
[ECO-5056] Added test for getObjects when liveobjects plugin is not installed
1 parent 8e193bc commit 551451a

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,29 @@ public void connect_should_not_rewrite_immediate_attach() throws AblyException {
26172617
}
26182618
}
26192619

2620+
@Test
2621+
public void channel_get_objects_throws_exception() throws AblyException {
2622+
ClientOptions opts = createOptions(testVars.keys[0].keyStr);
2623+
try (AblyRealtime ably = new AblyRealtime(opts)) {
2624+
2625+
/* wait until connected */
2626+
new ConnectionWaiter(ably.connection).waitFor(ConnectionState.connected);
2627+
assertEquals("Verify connected state reached", ably.connection.state, ConnectionState.connected);
2628+
2629+
/* create a channel and attach */
2630+
final Channel channel = ably.channels.get("channel");
2631+
channel.attach();
2632+
new ChannelWaiter(channel).waitFor(ChannelState.attached);
2633+
assertEquals("Verify attached state reached", channel.state, ChannelState.attached);
2634+
2635+
AblyException exception = assertThrows(AblyException.class, channel::getObjects);
2636+
assertNotNull(exception);
2637+
assertEquals(40019, exception.errorInfo.code);
2638+
assertEquals(400, exception.errorInfo.statusCode);
2639+
assertTrue(exception.errorInfo.message.contains("LiveObjects plugin hasn't been installed"));
2640+
}
2641+
}
2642+
26202643
static class DetachingProtocolListener implements DebugOptions.RawProtocolListener {
26212644

26222645
public Channel theChannel;

liveobjects/src/test/kotlin/io/ably/lib/objects/unit/HelpersTest.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ class HelpersTest {
7676
fun testRetrieveObjectsGCGracePeriodDeferredInvokesOnConnectedWithValue() {
7777
val adapter = getMockObjectsAdapter()
7878
val connManager = adapter.connectionManager
79+
val connection = adapter.connection
7980

8081
var value: Long? = null
81-
every { adapter.connection.once(ConnectionEvent.connected, any()) } answers {
82+
every { connection.once(ConnectionEvent.connected, any()) } answers {
8283
val listener = secondArg<ConnectionStateListener>()
8384
connManager.setPrivateField("objectsGCGracePeriod", 456L)
8485
listener.onConnectionStateChanged(mockk(relaxed = true))
@@ -87,23 +88,24 @@ class HelpersTest {
8788
adapter.retrieveObjectsGCGracePeriod { v -> value = v }
8889

8990
assertEquals(456L, value)
90-
verify(exactly = 1) { adapter.connection.once(ConnectionEvent.connected, any()) }
91+
verify(exactly = 1) { connection.once(ConnectionEvent.connected, any()) }
9192
}
9293

9394
@Test
9495
fun testRetrieveObjectsGCGracePeriodDeferredInvokesOnConnectedWithNull() {
9596
val adapter = getMockObjectsAdapter()
97+
val connection = adapter.connection
9698

9799
var value: Long? = null
98-
every { adapter.connection.once(ConnectionEvent.connected, any()) } answers {
100+
every { connection.once(ConnectionEvent.connected, any()) } answers {
99101
val listener = secondArg<ConnectionStateListener>()
100102
listener.onConnectionStateChanged(mockk(relaxed = true))
101103
}
102104

103105
adapter.retrieveObjectsGCGracePeriod { v -> value = v }
104106

105107
assertNull(value)
106-
verify(exactly = 1) { adapter.connection.once(ConnectionEvent.connected, any()) }
108+
verify(exactly = 1) { connection.once(ConnectionEvent.connected, any()) }
107109
}
108110

109111
@Test

0 commit comments

Comments
 (0)