Skip to content

Commit

Permalink
merged TCK projects and renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
xytosis committed Jul 19, 2016
1 parent 7646540 commit 2a30f7c
Show file tree
Hide file tree
Showing 20 changed files with 119 additions and 342 deletions.
12 changes: 7 additions & 5 deletions README.md
Expand Up @@ -14,9 +14,9 @@ This allows implementers of the Reactive Socket protocol to be able to write the

The DSLs are designed to be human readable as well, and should require very little documentation to understand. Here is an example of the client side DSL
```
object clienttest extends ClientDSL {
object clienttest extends RequesterDSL {
def main(args: Array[String]) {
Tests.runTests(this, this.writer)
RequesterTests.runTests(this, this.writer)
}
@Test
Expand Down Expand Up @@ -76,9 +76,9 @@ that have already be started.
## Responder DSL
The responder DSL example is the dual to the above requester DSL.
```
object servertest extends MarbleDSL {
object servertest extends ResponderDSL {
def main(args: Array[String]) {
Tests.runTests(this, this.writer)
ResponderTests.runTests(this, this.writer)
}
@Test
Expand Down Expand Up @@ -135,7 +135,9 @@ to send an initial payload, while handle tells the server to expect an initial p
at least one additional element than we request.

## Run Instructions
This project is managed with sbt. Simply navigate to the root directory with build.sbt and run `sbt assembly`. There is currently no way to run this in the command line, but support will come soon.
This project is managed with sbt. Simply navigate to the root directory with build.sbt and run `sbt assembly`.
You can generate a script by first creating an object that extends either `RequesterDSL` or `ResponderDSL` (depending on if you want to generate a requester script or a responder script). Then, follow the examples above to start writing your scripts.
When you want to generate the script, compile again with `sbt assembly` and then use the run script `./run object-name`, where `object-name` is the name of the Scala object containing the tests.

## Documentation
Documentation for both the DSL and the script it generates will come soon, as well as suggestions on the process of building a driver for it.
Expand Down
2 changes: 1 addition & 1 deletion test_client/build.sbt → build.sbt
@@ -1,7 +1,7 @@

import AssemblyKeys._

name := "test_client"
name := "tck"

version := "1.0"

Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions run
@@ -0,0 +1,7 @@
#!/bin/bash

if [ ! -z $1 ]; then
java -cp target/scala-2.11/tck-assembly-*.jar io.reactivesocket.tck.$1
else
echo "Usage: ./run <object name>"
fi
Expand Up @@ -15,7 +15,7 @@ package io.reactivesocket.tck

import java.io.{File, PrintWriter}

class ClientDSL {
class RequesterDSL {

var writer: PrintWriter = new PrintWriter(new File(this.getClass.getSimpleName + ".txt"))

Expand Down
Expand Up @@ -17,11 +17,11 @@ import java.io.{File, PrintWriter}

import scala.collection.immutable.Queue

class MarbleDSL {
class ResponderDSL {

import org.json4s._
import org.json4s.native.Serialization._
import org.json4s.native.Serialization
import org.json4s.native.Serialization._
implicit val formats = Serialization.formats(NoTypeHints)

var writer: PrintWriter = new PrintWriter(new File(this.getClass.getSimpleName + ".txt"))
Expand Down
Expand Up @@ -13,9 +13,9 @@

package io.reactivesocket.tck

object clienttest extends ClientDSL {
object clienttest extends RequesterDSL {
def main(args: Array[String]) {
Tests.runTests(this, this.writer)
ClientTests.runTests(this, this.writer)
}

/* @Test
Expand Down Expand Up @@ -177,3 +177,85 @@ object clienttest extends ClientDSL {


}

object servertest extends ResponderDSL {
def main(args: Array[String]) {
ServerTests.runTests(this, this.writer)
}

@Test
def handleEcho() : Unit = {
// not really a test... more like set up a behavior
requestEchoChannel handle("e", "f")
}

@Test
def handleRequestResponse() : Unit = {
requestResponse handle("a", "b") using(Map("x" -> ("hello", "goodbye")), pause(3), emit('x'),
pause(4), pause(5), complete)

requestResponse handle("c", "d") using(Map("x" -> ("ding", "dong")), pause(10), emit('x'),
pause(10), complete)

requestResponse handle("e", "f") using(pause(10), error)

requestResponse handle("g", "h") using("-")
}

@Test
def handleRequestStream() : Unit = {
requestStream handle("a", "b") using(Map("a" -> ("a", "b"), "b" -> ("c", "d"), "c" -> ("e", "f")),
"---a-----b-----c-----d--e--f---|")
requestStream handle("c", "d") using(Map("a" -> ("a", "b"), "b" -> ("c", "d"), "c" -> ("e", "f")),
"---a-----b-----c-----d--e--f---|")
}

@Test
def handleRequestSubscription() : Unit = {
requestSubscription handle("a", "b") using("abcdefghijklmnop")
}

@Test
def handleRequestChannel() : Unit = {
requestChannel handle("a", "b") asFollows(() => {
val s1 = channelSubscriber()
respond("---x---")
s1 request 1
s1 awaitAtLeast(2, 1000)
s1 assertReceivedCount 2
s1 assertReceived List(("a", "b"), ("a", "a"))
s1 request 5
s1 awaitAtLeast(7, 1000)
respond("a---b---c")
s1 request 5
s1 awaitAtLeast(12, 1000) // there's an implicit request 1 in the beginning
respond("d--e---f-")
respond("|")
s1 awaitTerminal()
s1 assertCompleted()
})
}

@Test
def handleRequestChannel2() : Unit = {
requestChannel handle("c", "d") asFollows(() => {
val s1 = channelSubscriber()
respond("---x---")
s1 request 1
s1 awaitAtLeast(2, 1000)
s1 assertReceivedCount 2
s1 assertReceived List(("c", "d"), ("a", "a"))
s1 request 5
s1 awaitAtLeast(7, 1000)
respond("a---b---c")
s1 request 5
s1 awaitAtLeast(12, 1000) // there's an implicit request 1 in the beginning
respond("d--e---f-")
respond("|")
s1 awaitTerminal()
s1 assertCompleted()
s1 awaitNoAdditionalEvents 1000
})
}

}
Expand Up @@ -17,7 +17,7 @@ import java.io.PrintWriter
import java.nio.file.Files
import java.nio.file.Paths

object Tests extends ClientDSL {
object RequesterTests extends RequesterDSL {
def runTests(cls : Any, writer: PrintWriter) : Unit = {
this.writer = writer;

Expand All @@ -30,6 +30,21 @@ object Tests extends ClientDSL {
}
}
end
Files.deleteIfExists(Paths.get("Tests$.txt"))
Files.deleteIfExists(Paths.get("RequesterTests$.txt"))
}
}

object ResponderTests extends ResponderDSL {
def runTests(cls : Any, writer: PrintWriter) : Unit = {
this.writer = writer;

val methods = cls.getClass.getDeclaredMethods
for (method <- methods) {
if (method.getDeclaredAnnotations.length > 0 && method.getDeclaredAnnotations()(0).isInstanceOf[Test]) {
method.invoke(cls)
}
}
end
Files.deleteIfExists(Paths.get("ResponderTests.txt"))
}
}
3 changes: 0 additions & 3 deletions test_client/run

This file was deleted.

43 changes: 0 additions & 43 deletions test_server/build.sbt

This file was deleted.

10 changes: 0 additions & 10 deletions test_server/project/plugins.sbt

This file was deleted.

3 changes: 0 additions & 3 deletions test_server/run

This file was deleted.

24 changes: 0 additions & 24 deletions test_server/src/main/java/io/reactivesocket/tck/Test.java

This file was deleted.

This file was deleted.

0 comments on commit 2a30f7c

Please sign in to comment.