Skip to content

Commit 032dc75

Browse files
author
Quintin Willison
committed
Refactor existing system tests to make them more fragile.
The aim is to make protocol version bump oversights easier to spot in future.
1 parent 45aeed9 commit 032dc75

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,19 @@ public void realtime_websocket_param_test() {
7979
assertEquals("Verify correct key param", requestParameters.get("key"),
8080
Collections.singletonList(key));
8181

82-
/* Spec RTN2f */
83-
assertEquals("Verify correct version", requestParameters.get(Defaults.ABLY_VERSION_PARAM),
84-
Collections.singletonList(Defaults.ABLY_VERSION));
85-
86-
/* Spec RTN2g */
87-
assertEquals("Verify correct lib version", requestParameters.get(Defaults.ABLY_LIB_PARAM),
88-
Collections.singletonList(Defaults.ABLY_LIB_VERSION));
82+
/* Spec RTN2f
83+
* This test should not directly validate version against Defaults.ABLY_VERSION, nor
84+
* Defaults.ABLY_VERSION_PARAM, as ultimately the request param has been derived from those values.
85+
*/
86+
assertEquals("Verify correct version", requestParameters.get("v"),
87+
Collections.singletonList("1.2"));
88+
89+
/* Spec RTN2g
90+
* This test should not directly validate version against Defaults.ABLY_LIB_VERSION, nor
91+
* Defaults.ABLY_LIB_PARAM, as ultimately the request param has been derived from those values.
92+
*/
93+
assertEquals("Verify correct lib version", requestParameters.get("lib"),
94+
Collections.singletonList("java-1.2.1"));
8995

9096
/* Spec RTN2a */
9197
assertEquals("Verify correct format", requestParameters.get("format"),

lib/src/test/java/io/ably/lib/test/rest/HttpHeaderTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,14 @@ public void header_lib_channel_publish() {
7777
/* Get last headers */
7878
Map<String, String> headers = server.getHeaders();
7979

80-
/* Prepare checked header */
81-
String ably_version_header = Defaults.ABLY_VERSION_HEADER.toLowerCase();
82-
String ably_lib_header = Defaults.ABLY_LIB_HEADER.toLowerCase();
83-
84-
/* Check header */
80+
/* Check header
81+
* This test should not directly validate version against Defaults.ABLY_VERSION, Defaults.ABLY_LIB_VERSION,
82+
* Defaults.ABLY_VERSION_HEADER, nor Defaults.ABLY_LIB_HEADER, as ultimately these headers have been derived
83+
* from those values.
84+
*/
8585
Assert.assertNotNull("Expected headers", headers);
86-
Assert.assertTrue(String.format("Expected header %s", Defaults.ABLY_VERSION_HEADER), headers.containsKey(ably_version_header));
87-
Assert.assertEquals(headers.get(ably_version_header), Defaults.ABLY_VERSION);
88-
Assert.assertTrue(String.format("Expected header %s", Defaults.ABLY_LIB_HEADER), headers.containsKey(ably_lib_header));
89-
Assert.assertEquals(headers.get(ably_lib_header), Defaults.ABLY_LIB_VERSION);
86+
Assert.assertEquals(headers.get("x-ably-version"), "1.2");
87+
Assert.assertEquals(headers.get("x-ably-lib"), "java-1.2.1");
9088
} catch (AblyException e) {
9189
e.printStackTrace();
9290
Assert.fail("header_lib_channel_publish: Unexpected exception");

0 commit comments

Comments
 (0)