Skip to content

Commit

Permalink
PubNub SDK v5.1.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
client-engineering-bot committed Dec 16, 2020
1 parent 94c3234 commit cbb2802
Show file tree
Hide file tree
Showing 103 changed files with 4,418 additions and 598 deletions.
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
* @kleewho @bartk @qsoftdevelopment @Chesteer89
* @kleewho @bartk @Chesteer89
.travis/* @parfeon @kleewho @bartk @Chesteer89
README.md @polarweasel @samiahmedsiddiqui @techwritermat
53 changes: 50 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
name: kotlin
version: 5.0.2
version: 5.1.0
schema: 1
scm: github.com/pubnub/kotlin
files:
- build/libs/pubnub-kotlin-5.0.2-all.jar
- build/libs/pubnub-kotlin-5.1.0-all.jar
changelog:
-
version: v5.1.0
date: 2020-12-16
changes:
-
type: feature
text: "Files support includes sending, downloading, listing, deleting together with notifications about file events."
-
type: feature
text: "New methods can set and remove memberships/channelMembers in one call."
-
type: feature
text: "New field `page` can be returned from the backend in case there's more data to fetch for the original query. This new field can be used directly in new `fetchMessages` and `getMessagesActions` method versions. The old versions in which paging information was in separate arguments has been deprecated."
-
type: feature
text: "FetchMessages has a default limit of 100 for single-channel call."
-
type: bug
text: "Make PNMessageActionResultevent accessible (no longer internal)."
-
type: bug
text: "Method `addMemberships` has been deprecated and shouldn't be used in the future."
-
version: v5.0.2
date: 2020-10-20
Expand All @@ -13,7 +35,7 @@ changelog:
type: bug
text: "Remove Instant to improve Android version compatibility."
-
version: 5.0.2
version: 5.1.0
date: 2020-09-28
changes:
-
Expand Down Expand Up @@ -104,6 +126,31 @@ features:
- SUBSCRIBE-MESSAGE-ACTIONS-LISTENER
signal:
- SIGNAL-SEND
objects:
- OBJECTS-FILTERING
- OBJECTS-SORTING
- OBJECTS-GET-ALL-UUID-METADATA
- OBJECTS-GET-UUID-METADATA
- OBJECTS-SET-UUID-METADATA
- OBJECTS-REMOVE-UUID-METADATA
- OBJECTS-GET-ALL-CHANNEL-METADATA
- OBJECTS-GET-CHANNEL-METADATA
- OBJECTS-SET-CHANNEL-METADATA
- OBJECTS-REMOVE-CHANNEL-METADATA
- OBJECTS-GET-MEMBERSHIPS-V2
- OBJECTS-SET-MEMBERSHIPS-V2
- OBJECTS-REMOVE-MEMBERSHIPS-V2
- OBJECTS-GET-CHANNEL-MEMBERS-V2
- OBJECTS-SET-CHANNEL-MEMBERS-V2
- OBJECTS-REMOVE-CHANNEL-MEMBERS-V2
- OBJECTS-MANAGE-MEMBERSHIPS-V2
- OBJECTS-MANAGE-CHANNEL-MEMBERS-V2
files:
- FILES-DELETE-FILE
- FILES-DOWNLOAD-FILE
- FILES-GET-FILE-URL
- FILES-LIST-FILES
- FILES-SEND-FILE
unsubscribe:
- UNSUBSCRIBE-ALL
- UNSUBSCRIBE-SUPPRESS-LEAVE-EVENTS
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## [v5.1.0](https://github.com/pubnub/kotlin/releases/tag/v5.1.0)
December 16 2020

[Full Changelog](https://github.com/pubnub/kotlin/compare/v5.0.2...v5.1.0)

- Files support includes sending, downloading, listing, deleting together with notifications about file events.
- New methods can set and remove memberships/channelMembers in one call.
- New field `page` can be returned from the backend in case there's more data to fetch for the original query. This new field can be used directly in new `fetchMessages` and `getMessagesActions` method versions. The old versions in which paging information was in separate arguments has been deprecated.
- FetchMessages has a default limit of 100 for single-channel call.
- Make PNMessageActionResultevent accessible (no longer internal).
- Method `addMemberships` has been deprecated and shouldn't be used in the future.


5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = 'com.pubnub'
version = '5.0.2'
version = '5.1.0'

repositories {
mavenCentral()
Expand Down Expand Up @@ -52,7 +52,8 @@ dependencies {

api 'com.google.code.gson:gson:2.8.6'
implementation "com.squareup.retrofit2:converter-gson:2.6.2"

implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'
compile 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9'
implementation "org.slf4j:slf4j-api:1.7.28"

implementation "org.json:json:20190722"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.pubnub.api.integration

import com.pubnub.api.CommonUtils.randomChannel
import com.pubnub.api.PubNub
import com.pubnub.api.callbacks.SubscribeCallback
import com.pubnub.api.enums.PNStatusCategory
import com.pubnub.api.models.consumer.PNStatus
import com.pubnub.api.models.consumer.files.PNFileUploadResult
import com.pubnub.api.models.consumer.pubsub.PNMessageResult
import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult
import com.pubnub.api.models.consumer.pubsub.PNSignalResult
import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult
import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult
import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult
import org.junit.Assert
import org.junit.Test
import java.io.ByteArrayInputStream
import java.io.InputStream
import java.nio.charset.StandardCharsets
import java.util.Scanner
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit

class FilesIntegrationTest : BaseIntegrationTest() {
@Test
fun uploadListDownloadDeleteWithCipher() {
uploadListDownloadDelete(true)
}

@Test
fun uploadListDownloadDeleteWithoutCipher() {
uploadListDownloadDelete(false)
}

private fun uploadListDownloadDelete(withCipher: Boolean) {
if (withCipher) {
pubnub.configuration.cipherKey = "enigma"
}
val channel: String = randomChannel()
val content = "This is content"
val message = "This is message"
val meta = "This is meta"
val fileName = "fileName$channel.txt"
val connectedLatch = CountDownLatch(1)
val fileEventReceived = CountDownLatch(1)
pubnub.addListener(object : LimitedListener() {
override fun status(pubnub: PubNub, pnStatus: PNStatus) {
if (pnStatus.category === PNStatusCategory.PNConnectedCategory) {
connectedLatch.countDown()
}
}

override fun file(pubnub: PubNub, pnFileEventResult: PNFileEventResult) {
if (pnFileEventResult.file.name == fileName) {
fileEventReceived.countDown()
}
}
})
pubnub.subscribe(channels = listOf(channel))
connectedLatch.await(10, TimeUnit.SECONDS)
val sendResult: PNFileUploadResult? = ByteArrayInputStream(content.toByteArray(StandardCharsets.UTF_8)).use {
pubnub.sendFile(
channel = channel,
fileName = fileName,
inputStream = it,
message = message,
meta = meta
).sync()
}

if (sendResult == null) {
Assert.fail()
return
}
fileEventReceived.await(10, TimeUnit.SECONDS)
val (_, _, _, data) = pubnub.listFiles(channel = channel).sync()!!
val fileFoundOnList = data.find { it.id == sendResult.file.id } != null

Assert.assertTrue(fileFoundOnList)
val (_, byteStream) = pubnub.downloadFile(
channel = channel,
fileName = fileName,
fileId = sendResult.file.id
)
.sync()!!
byteStream?.use {
Assert.assertEquals(content, readToString(it))
}
pubnub.deleteFile(channel = channel,
fileName = fileName,
fileId = sendResult.file.id)
.sync()
}

private fun readToString(inputStream: InputStream): String {
Scanner(inputStream).useDelimiter("\\A").use { s -> return if (s.hasNext()) s.next() else "" }
}

private abstract class LimitedListener : SubscribeCallback() {
override fun presence(pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult) {}
override fun message(pubnub: PubNub, pnMessageResult: PNMessageResult) {}
override fun signal(pubnub: PubNub, pnSignalResult: PNSignalResult) {}
override fun objects(pubnub: PubNub, objectEvent: PNObjectEventResult) {}
override fun messageAction(pubnub: PubNub, pnMessageActionResult: PNMessageActionResult) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.pubnub.api.CommonUtils.randomValue
import com.pubnub.api.CommonUtils.retry
import com.pubnub.api.PubNubError
import com.pubnub.api.await
import com.pubnub.api.models.consumer.PNBoundedPage
import com.pubnub.api.models.consumer.message_actions.PNMessageAction
import com.pubnub.api.param
import org.junit.Assert.assertEquals
Expand Down Expand Up @@ -124,7 +125,9 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
retry {
pubnub.fetchMessages(
channels = listOf(expectedChannelName),
maximumPerChannel = 25
page = PNBoundedPage(
limit = 25
)
).sync()!!.run {
channels[expectedChannelName]!!.forEach {
assertNotNull(it.message)
Expand All @@ -144,7 +147,7 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
retry {
pubnub.fetchMessages(
channels = listOf(expectedChannelName),
maximumPerChannel = 25,
page = PNBoundedPage(limit = 25),
includeMeta = true
).sync()!!.run {
channels[expectedChannelName]!!.forEach {
Expand Down Expand Up @@ -176,9 +179,9 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
retry {
pubnub.fetchMessages(
channels = listOf(expectedChannelName),
maximumPerChannel = 25,
includeMessageActions = true,
includeMeta = false
page = PNBoundedPage(limit = 25),
includeMeta = false,
includeMessageActions = true
).sync()!!.run {
channels[expectedChannelName]!!.forEach {
assertNotNull(it.message)
Expand Down Expand Up @@ -211,9 +214,9 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
retry {
pubnub.fetchMessages(
channels = listOf(expectedChannelName),
maximumPerChannel = 25,
includeMessageActions = true,
includeMeta = true
page = PNBoundedPage(limit = 25),
includeMeta = true,
includeMessageActions = true
).sync()!!.run {
channels[expectedChannelName]!!.forEach {
assertNotNull(it.message)
Expand Down Expand Up @@ -242,7 +245,9 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
retry {
pubnub.fetchMessages(
channels = expectedChannelNames,
maximumPerChannel = 25
page = PNBoundedPage(
limit = 25
)
).sync()!!.run {
expectedChannelNames.forEach { expectedChannel ->
channels[expectedChannel]!!.forEach {
Expand Down Expand Up @@ -285,7 +290,9 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
retry {
pubnub.fetchMessages(
channels = listOf(expectedChannelName),
maximumPerChannel = 100
page = PNBoundedPage(
limit = 100
)
).sync()!!.apply {
assertEquals(10, channels[expectedChannelName]!!.size)
channels[expectedChannelName]!!.forEach {
Expand Down Expand Up @@ -447,7 +454,9 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
fun testFetchSingleChannel_NoActions_Limit_Low() {
pubnub.fetchMessages(
channels = listOf(randomValue()),
maximumPerChannel = -1
page = PNBoundedPage(
limit = -1
)
).await { _, status ->
assertEquals("1", status.param("max"))
}
Expand All @@ -457,7 +466,9 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
fun testFetchSingleChannel_NoActions_Limit_Valid() {
pubnub.fetchMessages(
channels = listOf(randomValue()),
maximumPerChannel = 15
page = PNBoundedPage(
limit = 15
)
).await { _, status ->
assertEquals("15", status.param("max"))
}
Expand All @@ -467,7 +478,9 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
fun testFetchSingleChannel_NoActions_Limit_High() {
pubnub.fetchMessages(
channels = listOf(randomValue()),
maximumPerChannel = 100
page = PNBoundedPage(
limit = 100
)
).await { _, status ->
assertEquals("25", status.param("max"))
}
Expand All @@ -487,8 +500,10 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
fun testFetchSingleChannel_WithActions_Limit_Low() {
pubnub.fetchMessages(
channels = listOf(randomValue()),
includeMessageActions = true,
maximumPerChannel = -1
page = PNBoundedPage(
limit = -1
),
includeMessageActions = true
).await { _, status ->
assertEquals("25", status.param("max"))
}
Expand All @@ -498,8 +513,10 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
fun testFetchSingleChannel_WithActions_Limit_High() {
pubnub.fetchMessages(
channels = listOf(randomValue()),
includeMessageActions = true,
maximumPerChannel = 200
page = PNBoundedPage(
limit = 200
),
includeMessageActions = true
).await { _, status ->
assertEquals("25", status.param("max"))
}
Expand All @@ -509,8 +526,10 @@ class HistoryIntegrationTest : BaseIntegrationTest() {
fun testFetchSingleChannel_WithActions_Limit_Valid() {
pubnub.fetchMessages(
channels = listOf(randomValue()),
includeMessageActions = true,
maximumPerChannel = 15
page = PNBoundedPage(
limit = 15
),
includeMessageActions = true
).await { _, status ->
assertEquals("15", status.param("max"))
}
Expand Down
Loading

0 comments on commit cbb2802

Please sign in to comment.