Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/main/java/io/ably/lib/transport/Defaults.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

public class Defaults {
/* versions */
public static final float ABLY_VERSION_NUMBER = 1.0f;
public static final float ABLY_VERSION_NUMBER = 1.2f;
public static final String ABLY_VERSION = new DecimalFormat("0.0").format(ABLY_VERSION_NUMBER);
public static final String ABLY_LIB_VERSION = String.format("%s-%s", BuildConfig.LIBRARY_NAME, BuildConfig.VERSION);

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -79,13 +79,19 @@ public void realtime_websocket_param_test() {
assertEquals("Verify correct key param", requestParameters.get("key"),
Collections.singletonList(key));

/* Spec RTN2f */
assertEquals("Verify correct version", requestParameters.get(Defaults.ABLY_VERSION_PARAM),
Collections.singletonList(Defaults.ABLY_VERSION));

/* Spec RTN2g */
assertEquals("Verify correct lib version", requestParameters.get(Defaults.ABLY_LIB_PARAM),
Collections.singletonList(Defaults.ABLY_LIB_VERSION));
/* Spec RTN2f
* This test should not directly validate version against Defaults.ABLY_VERSION, nor
* Defaults.ABLY_VERSION_PARAM, as ultimately the request param has been derived from those values.
*/
assertEquals("Verify correct version", requestParameters.get("v"),
Collections.singletonList("1.2"));

/* Spec RTN2g
* This test should not directly validate version against Defaults.ABLY_LIB_VERSION, nor
* Defaults.ABLY_LIB_PARAM, as ultimately the request param has been derived from those values.
*/
assertEquals("Verify correct lib version", requestParameters.get("lib"),
Collections.singletonList("java-1.2.1"));

/* Spec RTN2a */
assertEquals("Verify correct format", requestParameters.get("format"),
Expand Down
16 changes: 7 additions & 9 deletions lib/src/test/java/io/ably/lib/test/rest/HttpHeaderTest.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,16 +77,14 @@ public void header_lib_channel_publish() {
/* Get last headers */
Map<String, String> headers = server.getHeaders();

/* Prepare checked header */
String ably_version_header = Defaults.ABLY_VERSION_HEADER.toLowerCase();
String ably_lib_header = Defaults.ABLY_LIB_HEADER.toLowerCase();

/* Check header */
/* Check header
* This test should not directly validate version against Defaults.ABLY_VERSION, Defaults.ABLY_LIB_VERSION,
* Defaults.ABLY_VERSION_HEADER, nor Defaults.ABLY_LIB_HEADER, as ultimately these headers have been derived
* from those values.
*/
Assert.assertNotNull("Expected headers", headers);
Assert.assertTrue(String.format("Expected header %s", Defaults.ABLY_VERSION_HEADER), headers.containsKey(ably_version_header));
Assert.assertEquals(headers.get(ably_version_header), Defaults.ABLY_VERSION);
Assert.assertTrue(String.format("Expected header %s", Defaults.ABLY_LIB_HEADER), headers.containsKey(ably_lib_header));
Assert.assertEquals(headers.get(ably_lib_header), Defaults.ABLY_LIB_VERSION);
Assert.assertEquals(headers.get("x-ably-version"), "1.2");
Assert.assertEquals(headers.get("x-ably-lib"), "java-1.2.1");
} catch (AblyException e) {
e.printStackTrace();
Assert.fail("header_lib_channel_publish: Unexpected exception");
Expand Down
12 changes: 12 additions & 0 deletions lib/src/test/java/io/ably/lib/transport/DefaultsTest.java
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
package io.ably.lib.transport;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class DefaultsTest {
@Test
public void versions() {
assertEquals("1.2", Defaults.ABLY_VERSION);
}
}