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
45 changes: 45 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@
*/

plugins {
id 'org.jetbrains.kotlin.jvm' version "$kotlin_version"
id 'com.github.ben-manes.versions' version "$versions_updates_version"
id 'com.jfrog.artifactory' version '4.13.0' apply false
id 'com.jfrog.bintray' version '1.8.5' apply false
}

subprojects {
apply plugin: "org.jetbrains.kotlin.jvm"
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines_version")
implementation("io.strikt:strikt-core:$strikt_version") //assertion lib
}
}

allprojects {

group 'io.rsocket.tck'
Expand All @@ -33,4 +43,39 @@ allprojects {
enabled = false
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = [
"-XXLanguage:+InlineClasses",
"-Xuse-experimental=kotlin.time.ExperimentalTime"
]
}
}

compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = [
"-XXLanguage:+InlineClasses",
"-Xuse-experimental=kotlin.time.ExperimentalTime"
]
}
}

dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:$junit_version")
testRuntime("org.junit.jupiter:junit-jupiter-engine:$junit_version")
testRuntime("org.junit.vintage:junit-vintage-engine:$junit_version")
testImplementation("org.assertj:assertj-core:$assertj_version")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
implementation("io.netty:netty-buffer:$netty_version")
}
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ spek_version=2.0.10
junit_version=5.6.2
assertj_version=3.13.2
netty_version=4.1.48.Final
versions_updates_version=0.28.0
versions_updates_version=0.28.0
cucumber_version = 5.7.0
5 changes: 0 additions & 5 deletions rsocket-tck-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version "$kotlin_version"
id 'com.github.ben-manes.versions' version "$versions_updates_version"
}

apply plugin: "org.jetbrains.kotlin.jvm"

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ infix fun SetupFrame.expect(expected: SetupFrame): Unit = expectThat(this) {
get("resume token", SetupFrame::resumeToken).isEqualToResumeToken(expected.resumeToken)
get("metadata mime type", SetupFrame::metadataMimeType).isEqualTo(expected.metadataMimeType)
get("data mime type", SetupFrame::dataMimeType).isEqualTo(expected.dataMimeType)
get("payload", SetupFrame::payload).isEqualToPayload(expected.payload)

get("payload", SetupFrame::payload).isNotNull().and {
isEqualToPayload(expected.payload!!)
}
}

private val setupFlagsAssertion: FlagsAssertion<SetupFlags> = { expected ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package io.rsocket.tck.frame

import io.netty.buffer.*
import io.netty.buffer.ByteBuf
import io.netty.buffer.ByteBufAllocator
import io.rsocket.tck.frame.shared.*
import kotlin.time.*
import kotlin.time.DurationUnit

fun create(
header: FrameHeader<SetupFlags>,
version: Version,
keepAlive: KeepAlive,
dataMimeType: MimeType
): SetupFrame = SetupFrame(header, version, keepAlive, null, null, dataMimeType, null)

data class SetupFrame(
override val header: FrameHeader<SetupFlags>,
val version: Version,
val keepAlive: KeepAlive,
val resumeToken: ResumeToken?,
val metadataMimeType: MimeType,
val resumeToken: ResumeToken? = null,
val metadataMimeType: MimeType? = null,
val dataMimeType: MimeType,
val payload: Payload
val payload: Payload? = null
) : Frame<SetupFlags>(FrameType.SETUP) {

override fun buffer(allocator: ByteBufAllocator): ByteBuf {
Expand All @@ -23,14 +31,23 @@ data class SetupFrame(
writeShort(it.length.toInt())
it.token.preview { this@headerBuffer.writeBytes(this) }
}
writeByte(metadataMimeType.length.toInt())
writeUtf8(metadataMimeType.text)
if (metadataMimeType != null) {
writeByte(metadataMimeType.length.toInt())
writeUtf8(metadataMimeType.text)
}
writeByte(dataMimeType.length.toInt())
writeUtf8(dataMimeType.text)
payload.metadata?.length?.let(this::writeLength)

payload?.metadata?.length?.let(this::writeLength)
}
return allocator.compose(header, payload)
}

companion object {
fun decode(buffer: ByteBuf): SetupFrame {
return buffer.frame().asSetup()
}
}
}

fun RawFrame.asSetup(): SetupFrame = typed(FrameType.SETUP) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package io.rsocket.tck.frame.shared

import io.netty.buffer.*
import kotlin.time.*
import io.netty.buffer.ByteBuf
import java.util.concurrent.TimeUnit
import kotlin.time.Duration
import kotlin.time.milliseconds
import kotlin.time.toDuration

@Suppress("FunctionName")
fun KeepAlive(interval: Int, maxLifetime: Int): KeepAlive =
KeepAlive(interval.toDuration(TimeUnit.MILLISECONDS), maxLifetime.toDuration(TimeUnit.MILLISECONDS))

data class KeepAlive(
val interval: Duration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ data class PayloadMetadata(
val length: Int = value.readableBytes()
)

fun ByteBufAllocator.compose(header: ByteBuf, payload: Payload): ByteBuf = when (payload.metadata) {
null -> compose(header, payload.data)
else -> compose(header, payload.metadata.value, payload.data)
fun ByteBufAllocator.compose(header: ByteBuf, payload: Payload?): ByteBuf = when (payload) {
null -> header
else -> when (payload.metadata) {
null -> compose(header, payload.data)
else -> compose(header, payload.metadata.value, payload.data)
}
}

fun ByteBuf.readPayloadMetadata(): PayloadMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import io.netty.buffer.*
@Suppress("FunctionName")
fun Version(major: Int, minor: Int): Version = Version((major shl 16) or (minor and 0xFFFF))

inline class Version(val value: Int) {
data class Version(val value: Int) {
val major: Int get() = value shr 16 and 0xFFFF
val minor: Int get() = value and 0xFFFF
override fun toString(): String = "$major.$minor"
Expand Down
79 changes: 0 additions & 79 deletions rsocket-tck-core/src/main/kotlin/io/rsocket/tck/test.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class SetupFrameTest {
get { version }.isEqualTo(Version.Current)
get { keepAlive.interval.inMilliseconds }.isEqualTo(5.0)
get { keepAlive.maxLifetime.inMilliseconds }.isEqualTo(500.0)
get { metadataMimeType.text }.isEqualTo("metadata_type")
get { metadataMimeType?.text }.isEqualTo("metadata_type")
get { dataMimeType.text }.isEqualTo("data_type")
get { resumeToken }.isEqualTo(null)
get { payload.metadata?.value }.isEqualToBuffer(bufferOf(1, 2, 3, 4))
get { payload.data }.isEqualToBuffer(bufferOf(5, 4, 3))
get { payload?.metadata?.value }.isEqualToBuffer(bufferOf(1, 2, 3, 4))
get { payload?.data }.isEqualToBuffer(bufferOf(5, 4, 3))
}
}

Expand All @@ -56,7 +56,7 @@ class SetupFrameTest {

expectThat(newSetup) {
get { resumeToken?.token }.isEqualTo(token)
get { payload.data }.isEqualTo(bufferOf(5, 4, 3))
get { payload?.data }.isEqualTo(bufferOf(5, 4, 3))
}
}
}
31 changes: 31 additions & 0 deletions rsocket-tck-features/features/ConnectionSetup.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# encoding utf-8

Feature: Connection establishment

Scenario: Successful connection establishment
Given server listening to a port
When client sends SETUP frame with
| metadata-flag | 0 |
| resume-flag | 0 |
| lease-flag | 0 |
| major-version | 1 |
| minor-version | 0 |
| mime-type-metadata | message/x.rsocket.composite-metadata.v0 |
| keep-alive | 500 |
| max-life-time | 1500 |
| mime-type-data | text/plain |
| metadata | null |
| data | null |
Then server requires the following SETUP frame content
| stream-id | 0 | 0b0000_0000_0000_0000_0000_0000_0000_0000 |
| frame-type | 1 | 0b0000_01 |
| flags | 0 | 0b00_0000_0000 |
| major-version | 1 | 0b0000_0000_0000_0001 |
| minor-version | 0 | 0b0000_0000_0000_0000 |
| keep-alive | 500 | 0b0000_0000_0000_0000_0000_0001_1111_0100 |
| max-life-time | 1500 | 0b0000_0000_0000_0000_0000_0101_1101_1100 |
| mime-length-metadata | 39 | 0b0010_0111 |
| mime-type-metadata | message/x.rsocket.composite-metadata.v0 | 0x6d_65_73_73_61_67_65_2f_78_2e_72_73_6f_63_6b_65_74_2e_63_6f_6d_70_6f_73_69_74_65_2d_6d_65_74_61_64_61_74_61_2e_76_30 |
| mime-length-data | 10 | 0b0000_1010 |
| mime-type-data | text/plain | 0x74_65_78_74_2f_70_6c_61_69_6e_0a |
And connection is not closed after
Empty file.
4 changes: 4 additions & 0 deletions rsocket-tck-java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Java TCK Tools

This is supportive code to run `cucmber` files under `features` module in
java implementation of RSocket.
28 changes: 28 additions & 0 deletions rsocket-tck-java/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
id 'java'
}

group 'io.rsocket'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
implementation(project(':rsocket-tck-core'))
implementation(project(':rsocket-tck-features'))
implementation("io.projectreactor.netty:reactor-netty:0.9.7.RELEASE")
compile("io.cucumber:cucumber-java8:$cucumber_version")
compile("io.cucumber:cucumber-guice:$cucumber_version")
compile("org.assertj:assertj-core:3.16.0")
implementation("com.google.inject:guice:4.2.0")
implementation("io.netty:netty-all:4.1.48.Final")
implementation("io.rsocket:rsocket-core:1.0.1")
compile("io.rsocket:rsocket-transport-netty:1.0.1")

testRuntimeOnly("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
testCompile("io.cucumber:cucumber-junit:$cucumber_version")
testImplementation("junit:junit:4.12")
testCompile("junit:junit:4.12")
}
Loading