implement server handshake test

This commit is contained in:
Eugene Yokota 2017-09-11 00:34:14 -04:00
parent 2e4873c7fb
commit 6b8e716428
4 changed files with 55 additions and 1 deletions

View File

@ -26,7 +26,7 @@ env:
- SBT_CMD="scripted dependency-management/*4of4"
- SBT_CMD="scripted java/* package/* reporter/* run/* project-load/*"
- SBT_CMD="scripted project/*1of2"
- SBT_CMD="scripted project/*2of2"
- SBT_CMD="scripted project/*2of2 server/*"
- SBT_CMD="scripted source-dependencies/*1of3"
- SBT_CMD="scripted source-dependencies/*2of3"
- SBT_CMD="scripted source-dependencies/*3of3"

View File

@ -0,0 +1,35 @@
package example
import java.net.{ URI, Socket, InetAddress, SocketException }
import sbt.io._
import sbt.io.syntax._
import java.io.File
object Client extends App {
val host = "127.0.0.1"
val port = 5123
val delimiter: Byte = '\n'.toByte
println("hello")
Thread.sleep(1000)
val connection = getConnection
val out = connection.getOutputStream
val in = connection.getInputStream
out.write("""{ "type": "ExecCommand", "commandLine": "exit" }""".getBytes("utf-8"))
out.write(delimiter.toInt)
out.flush
val baseDirectory = new File(args(0))
IO.write(baseDirectory / "ok.txt", "ok")
def getConnection: Socket =
try {
new Socket(InetAddress.getByName(host), port)
} catch {
case _ =>
Thread.sleep(1000)
getConnection
}
}

View File

@ -0,0 +1,13 @@
lazy val runClient = taskKey[Unit]("")
lazy val root = (project in file("."))
.settings(
scalaVersion := "2.12.3",
serverPort in Global := 5123,
libraryDependencies += "org.scala-sbt" %% "io" % "1.0.1",
runClient := (Def.taskDyn {
val b = baseDirectory.value
(bgRun in Compile).toTask(s""" $b""")
}).value
)

View File

@ -0,0 +1,6 @@
> show serverPort
> runClient
-> shell
$ sleep 1000
$ exists ok.txt