You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@toree.apache.org by lb...@apache.org on 2016/01/22 23:07:15 UTC
[07/51] [abbrv] incubator-toree git commit: Moved scala files to new
locations based on new package
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/comm/CommWriterSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/comm/CommWriterSpec.scala b/protocol/src/test/scala/com/ibm/spark/comm/CommWriterSpec.scala
deleted file mode 100644
index 0818da3..0000000
--- a/protocol/src/test/scala/com/ibm/spark/comm/CommWriterSpec.scala
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ibm.spark.comm
-
-import java.util.UUID
-
-import com.ibm.spark.kernel.protocol.v5
-import com.ibm.spark.kernel.protocol.v5._
-import com.ibm.spark.kernel.protocol.v5.content._
-import org.mockito.Matchers.{eq => mockEq, _}
-import org.mockito.Mockito._
-import org.scalatest.mock.MockitoSugar
-import org.scalatest.{FunSpec, BeforeAndAfter, Matchers}
-
-
-class CommWriterSpec extends FunSpec with Matchers with BeforeAndAfter
- with MockitoSugar
-{
- private val TestCommId = UUID.randomUUID().toString
-
- class TestCommWriter extends CommWriter(TestCommId) {
- // Stub this implementation to do nothing
- override protected[comm] def sendCommKernelMessage[
- T <: KernelMessageContent with CommContent
- ](commContent: T): Unit = {}
- }
-
- private var commWriter: CommWriter = _
-
- before {
- commWriter = spy(new TestCommWriter())
- }
-
- describe("CommWriter") {
- describe("#writeOpen") {
- it("should package a CommOpen instance") {
- commWriter.writeOpen("")
-
- verify(commWriter).sendCommKernelMessage(any[CommOpen])
- }
-
- it("should include the comm_id in the message") {
- val expected = TestCommId
- commWriter.writeOpen("")
-
- verify(commWriter).sendCommKernelMessage(
- CommOpen(comm_id = expected, target_name = "", data = MsgData.Empty))
- }
-
- it("should include the target name in the message") {
- val expected = "<TARGET_NAME>"
- commWriter.writeOpen(expected)
-
- verify(commWriter).sendCommKernelMessage(
- CommOpen(
- comm_id = TestCommId, target_name = expected, data = MsgData.Empty
- )
- )
- }
-
- it("should provide empty data in the message if no data is provided") {
- val expected: v5.MsgData = MsgData.Empty
- commWriter.writeOpen("")
-
- verify(commWriter).sendCommKernelMessage(
- CommOpen(comm_id = TestCommId, target_name = "", data = expected))
- }
-
- it("should include the data in the message") {
- val expected = MsgData("message" -> "a", "foo" -> "bar")
- commWriter.writeOpen("", expected)
-
- verify(commWriter).sendCommKernelMessage(
- CommOpen(comm_id = TestCommId, target_name = "", data = expected))
- }
- }
-
- describe("#writeMsg") {
- it("should send a comm_msg message to the relay") {
- commWriter.writeMsg(MsgData.Empty)
-
- verify(commWriter).sendCommKernelMessage(any[CommMsg])
- }
-
- it("should include the comm_id in the message") {
- val expected = TestCommId
- commWriter.writeMsg(MsgData.Empty)
-
- verify(commWriter).sendCommKernelMessage(
- CommMsg(comm_id = expected, data = MsgData.Empty))
- }
-
- it("should fail a require if the data is null") {
- intercept[IllegalArgumentException] {
- commWriter.writeMsg(null)
- }
- }
-
- it("should include the data in the message") {
- val expected = MsgData("message" -> "a")
- commWriter.writeMsg(expected)
-
- verify(commWriter).sendCommKernelMessage(
- CommMsg(comm_id = TestCommId, data = expected))
- }
- }
-
- describe("#writeClose") {
- it("should send a comm_close message to the relay") {
- commWriter.writeClose()
-
- verify(commWriter).sendCommKernelMessage(any[CommClose])
- }
-
- it("should include the comm_id in the message") {
- val expected = TestCommId
- commWriter.writeClose()
-
- verify(commWriter).sendCommKernelMessage(
- CommClose(comm_id = expected, data = MsgData.Empty))
- }
-
- it("should provide empty data in the message if no data is provided") {
- val expected: v5.MsgData = MsgData.Empty
- commWriter.writeClose()
-
- verify(commWriter).sendCommKernelMessage(
- CommClose(comm_id = TestCommId, data = expected))
- }
-
- it("should include the data in the message") {
- val expected = MsgData("message" -> "a")
- commWriter.writeClose(expected)
-
- verify(commWriter).sendCommKernelMessage(
- CommClose(comm_id = TestCommId, data = expected))
- }
- }
-
- describe("#write") {
- it("should send a comm_msg message to the relay") {
- commWriter.write(Array('a'), 0, 1)
-
- verify(commWriter).sendCommKernelMessage(any[CommMsg])
- }
-
- it("should include the comm_id in the message") {
- val expected = TestCommId
- val messageData = MsgData("message" -> "a")
- commWriter.write(Array('a'), 0, 1)
-
- verify(commWriter).sendCommKernelMessage(
- CommMsg(comm_id = expected, data = messageData))
- }
-
- it("should package the string as part of the data with a 'message' key") {
- val expected = MsgData("message" -> "a")
- commWriter.write(Array('a'), 0, 1)
-
- verify(commWriter).sendCommKernelMessage(
- CommMsg(comm_id = TestCommId, data = expected))
- }
- }
-
- describe("#flush") {
- it("should do nothing") {
- // TODO: Is this test necessary? It does nothing.
- commWriter.flush()
- }
- }
-
- describe("#close") {
- it("should send a comm_close message to the relay") {
- commWriter.close()
-
- verify(commWriter).sendCommKernelMessage(any[CommClose])
- }
-
- it("should include the comm_id in the message") {
- val expected = TestCommId
- commWriter.close()
-
- verify(commWriter).sendCommKernelMessage(
- CommClose(comm_id = expected, data = MsgData.Empty))
- }
-
- it("should provide empty data in the message") {
- val expected: v5.MsgData = MsgData.Empty
- commWriter.close()
-
- verify(commWriter).sendCommKernelMessage(
- CommClose(comm_id = TestCommId, data = expected))
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/HeaderBuilderSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/HeaderBuilderSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/HeaderBuilderSpec.scala
deleted file mode 100644
index 2dd9b31..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/HeaderBuilderSpec.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5
-
-import org.scalatest.{Matchers, FunSpec}
-
-class HeaderBuilderSpec extends FunSpec with Matchers {
- describe("HeaderBuilder") {
- describe("#create") {
- it("should set the msg_id field to a unique ID if none is provided") {
- HeaderBuilder.create("").msg_id should not be empty
- }
-
- it("should set the msg_id field to the argument if provided") {
- val expected = "some id"
- HeaderBuilder.create("", expected).msg_id should be (expected)
- }
-
- it("should set the username field to the SparkKernelInfo property") {
- val expected = SparkKernelInfo.username
- HeaderBuilder.create("").username should be (expected)
- }
-
- it("should set the session field to the SparkKernelInfo property") {
- val expected = SparkKernelInfo.session
- HeaderBuilder.create("").session should be (expected)
- }
-
- it("should set the msg_type field to the argument provided") {
- val expected = "some type"
- HeaderBuilder.create(expected).msg_type should be (expected)
- }
-
- it("should set the version field to the SparkKernelInfo property") {
- val expected = SparkKernelInfo.protocolVersion
- HeaderBuilder.create("").version should be (expected)
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/HeaderSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/HeaderSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/HeaderSpec.scala
deleted file mode 100644
index d53d64e..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/HeaderSpec.scala
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5
-
-import org.scalatest.{Matchers, FunSpec}
-import play.api.data.validation.ValidationError
-import play.api.libs.json.{JsPath, Json, JsValue}
-
-class HeaderSpec extends FunSpec with Matchers {
- val headerJson: JsValue = Json.parse("""
- {
- "msg_id": "<UUID>",
- "username": "<STRING>",
- "session": "<UUID>",
- "msg_type": "<STRING>",
- "version": "<FLOAT>"
- }
- """)
-
- val header: Header = Header(
- "<UUID>", "<STRING>", "<UUID>", "<STRING>", "<FLOAT>"
- )
-
- describe("Header") {
- describe("when null") {
- it("should implicitly convert to empty json") {
- val header: Header = null
- Json.toJson(header).toString() should be ("{}")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a header instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- headerJson.as[Header] should be (header)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newHeader = headerJson.asOpt[Header]
-
- newHeader.get should be (header)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val headerResults = headerJson.validate[Header]
-
- headerResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: Header) => valid
- ) should be (header)
- }
-
- it("should implicitly convert from a header instance to valid json") {
- Json.toJson(header) should be (headerJson)
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/KMBuilderSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/KMBuilderSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/KMBuilderSpec.scala
deleted file mode 100644
index cd5116b..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/KMBuilderSpec.scala
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5
-
-import com.ibm.spark.kernel.protocol.v5.content.{CommOpen, StreamContent}
-import org.scalatest.{Matchers, FunSpec}
-import play.api.libs.json._
-
-class KMBuilderSpec extends FunSpec with Matchers {
- describe("KMBuilder") {
- val emptyKM = KernelMessage(
- ids = Seq(),
- signature = "",
- header = HeaderBuilder.empty,
- parentHeader = HeaderBuilder.empty,
- metadata = Metadata(),
- contentString = ""
- )
- val nonEmptyHeader = Header("1", "user", "2", "msg", "version")
-
- describe("constructor") {
- it("should hold an empty KernelMessage when constructed by default") {
- KMBuilder().km should be(emptyKM)
- }
-
- it("should throw an IllegalArgumentException if given a null message") {
- intercept[IllegalArgumentException] {
- KMBuilder(null)
- }
- }
- }
-
- describe("#build"){
- it("should build a KernelMessage") {
- KMBuilder().build.copy(metadata = Metadata()) should be(emptyKM)
- }
-
- class KM2 extends KMBuilder {
- override def metadataDefaults : Metadata = {
- Metadata("foo" -> "bar", "baos" -> "bean")
- }
- }
- it("should include default metadata in built message by default") {
- val builder = new KM2
- val metadata = builder.build.metadata
- builder.metadataDefaults.foreach { case (k, v) =>
- assert (metadata.contains(k) && metadata(k) == v)
- }
- }
-
- it("should not include default metadata in built message if disabled") {
- val builder = new KM2
- val metadata = builder.build(includeDefaultMetadata = false).metadata
- metadata should be(Metadata())
- }
- }
-
- describe("withXYZ"){
- describe("#withIds"){
- it("should produce a KMBuilder with a KernelMessage with ids set") {
- val ids = Seq("baos", "win")
- val builder = KMBuilder().withIds(ids)
- builder.km.ids should be (ids)
- }
- }
-
- describe("#withSignature"){
- it("should produce a KMBuilder with a KernelMessage with signature set") {
- val sig = "beans"
- val builder = KMBuilder().withSignature(sig)
- builder.km.signature should be (sig)
- }
- }
-
- describe("#withHeader"){
- it("should produce a KMBuilder with a KernelMessage with header set," +
- "given a Header") {
- val builder = KMBuilder().withHeader(nonEmptyHeader)
- builder.km.header should be (nonEmptyHeader)
- }
- it("should produce a KMBuilder with a KernelMessage with header set " +
- "to a header for the given message type") {
- val msgType = MessageType.Outgoing.ExecuteResult
- val header = HeaderBuilder.create(msgType.toString).copy(msg_id = "")
- val builder = KMBuilder().withHeader(msgType)
- builder.km.header.copy(msg_id = "") should be (header)
- }
- it("should produce a KMBuilder with a KernelMessage with header set " +
- "to a header for the given string message type") {
- val msgType = CommOpen.toTypeString
- val header = HeaderBuilder.create(msgType).copy(msg_id = "")
- val builder = KMBuilder().withHeader(msgType)
- builder.km.header.copy(msg_id = "") should be (header)
- }
- }
-
- describe("#withParent"){
- it("should produce a KMBuilder with a KernelMessage with " +
- "parentHeader set to the header of the given parent message") {
- val parent = emptyKM.copy(header = nonEmptyHeader)
- val builder = KMBuilder().withParent(parent)
- builder.km.parentHeader should be (parent.header)
- }
- }
-
- describe("#withParentHeader"){
- it("should produce a KMBuilder with a KernelMessage with " +
- "parentHeader set") {
- val builder = KMBuilder().withParentHeader(nonEmptyHeader)
- builder.km.parentHeader should be (nonEmptyHeader)
- }
- }
-
- describe("#withMetadata"){
- it("should produce a KMBuilder with a KernelMessage whose metadata " +
- "contains the given metadata") {
- val metadata = Metadata("foo" -> "bar", "baos" -> "bean")
- val builder = KMBuilder().withMetadata(metadata)
- builder.km.metadata should be (metadata)
- val builtKM = builder.build
- metadata.foreach { case (k, v) =>
- assert (builtKM.metadata.contains(k) && builtKM.metadata(k) == v)
- }
- }
- }
-
- describe("#withContentString"){
- it("should produce a KMBuilder with a KernelMessage with content set") {
- val content = "foo bar"
- val builder = KMBuilder().withContentString(content)
- builder.km.contentString should be (content)
- }
- it("should produce a KMBuilder with a KernelMessage with content" +
- "containing a JSON string of the given object") {
- val sc = StreamContent("foo", "bar")
- val builder = KMBuilder().withContentString(sc)
- builder.km.contentString should be (Json.toJson(sc).toString)
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ClearOutputSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ClearOutputSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ClearOutputSpec.scala
deleted file mode 100644
index 3811314..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ClearOutputSpec.scala
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class ClearOutputSpec extends FunSpec with Matchers {
- val clearOutputJson: JsValue = Json.parse("""
- {
- "wait": true
- }
-""")
-
- val clearOutput = ClearOutput(
- true
- )
-
- describe("ClearOutput") {
- describe("#toTypeString") {
- it("should return correct type") {
- ClearOutput.toTypeString should be ("clear_output")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a ClearOutput instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- clearOutputJson.as[ClearOutput] should be (clearOutput)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteRequest = clearOutputJson.asOpt[ClearOutput]
-
- newCompleteRequest.get should be (clearOutput)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteRequestResults = clearOutputJson.validate[ClearOutput]
-
- CompleteRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ClearOutput) => valid
- ) should be (clearOutput)
- }
-
- it("should implicitly convert from a ClearOutput instance to valid json") {
- Json.toJson(clearOutput) should be (clearOutputJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommCloseSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommCloseSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommCloseSpec.scala
deleted file mode 100644
index 15ba4ed..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommCloseSpec.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import com.ibm.spark.kernel.protocol.v5._
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class CommCloseSpec extends FunSpec with Matchers {
- val commCloseJson: JsValue = Json.parse("""
- {
- "comm_id": "<UUID>",
- "data": {}
- }
- """)
-
- val commClose = CommClose(
- "<UUID>", MsgData.Empty
- )
-
- describe("CommClose") {
- describe("#toTypeString") {
- it("should return correct type") {
- CommClose.toTypeString should be ("comm_close")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a CommClose instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- commCloseJson.as[CommClose] should be (commClose)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteRequest = commCloseJson.asOpt[CommClose]
-
- newCompleteRequest.get should be (commClose)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteRequestResults = commCloseJson.validate[CommClose]
-
- CompleteRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: CommClose) => valid
- ) should be (commClose)
- }
-
- it("should implicitly convert from a CommClose instance to valid json") {
- Json.toJson(commClose) should be (commCloseJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommMsgSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommMsgSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommMsgSpec.scala
deleted file mode 100644
index 74b99fe..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommMsgSpec.scala
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-import com.ibm.spark.kernel.protocol.v5._
-
-class CommMsgSpec extends FunSpec with Matchers {
- val commMsgJson: JsValue = Json.parse("""
- {
- "comm_id": "<UUID>",
- "data": {}
- }
- """)
-
- val commMsgJsonWithData: JsValue = Json.parse(
- """
- {
- "comm_id": "<UUID>",
- "data": {
- "key" : {
- "foo" : "bar",
- "baz" : {
- "qux" : 3
- }
- }
- }
- }
- """.stripMargin)
-
- val commMsg = CommMsg(
- "<UUID>", MsgData.Empty
- )
-
- val commMsgWithData = CommMsg(
- "<UUID>", MsgData("key" -> Json.obj(
- "foo" -> "bar",
- "baz" -> Map("qux" -> 3)
- ))
- )
-
- describe("CommMsg") {
- describe("#toTypeString") {
- it("should return correct type") {
- CommMsg.toTypeString should be ("comm_msg")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a CommMsg instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- commMsgJson.as[CommMsg] should be (commMsg)
- }
-
- it("should implicitly convert json with a non-empty json data field " +
- "to a CommMsg instance") {
- commMsgJsonWithData.as[CommMsg] should be (commMsgWithData)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteRequest = commMsgJson.asOpt[CommMsg]
-
- newCompleteRequest.get should be (commMsg)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteRequestResults = commMsgJson.validate[CommMsg]
-
- CompleteRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: CommMsg) => valid
- ) should be (commMsg)
- }
-
- it("should implicitly convert from a CommMsg instance to valid json") {
- Json.toJson(commMsg) should be (commMsgJson)
- }
-
- it("should implicitly convert a CommMsg instance with non-empty json " +
- "data to valid json") {
- Json.toJson(commMsgWithData) should be (commMsgJsonWithData)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommOpenSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommOpenSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommOpenSpec.scala
deleted file mode 100644
index 3f216e9..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CommOpenSpec.scala
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-import com.ibm.spark.kernel.protocol.v5.MsgData
-
-class CommOpenSpec extends FunSpec with Matchers {
- val commOpenJson: JsValue = Json.parse("""
- {
- "comm_id": "<UUID>",
- "target_name": "<STRING>",
- "data": {}
- }
- """)
-
- val commOpen = CommOpen(
- "<UUID>", "<STRING>", MsgData.Empty
- )
-
- describe("CommOpen") {
- describe("#toTypeString") {
- it("should return correct type") {
- CommOpen.toTypeString should be ("comm_open")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a CommOpen instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- commOpenJson.as[CommOpen] should be (commOpen)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteRequest = commOpenJson.asOpt[CommOpen]
-
- newCompleteRequest.get should be (commOpen)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteRequestResults = commOpenJson.validate[CommOpen]
-
- CompleteRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: CommOpen) => valid
- ) should be (commOpen)
- }
-
- it("should implicitly convert from a CommOpen instance to valid json") {
- Json.toJson(commOpen) should be (commOpenJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplyErrorSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplyErrorSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplyErrorSpec.scala
deleted file mode 100644
index ab41581..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplyErrorSpec.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class CompleteReplyErrorSpec extends FunSpec with Matchers {
- val completeReplyErrorJson: JsValue = Json.parse("""
- {
- "matches": [],
- "cursor_start": 1,
- "cursor_end": 5,
- "metadata": {},
- "status": "error",
- "ename":"<STRING>",
- "evalue": "<STRING>",
- "traceback": []
- }
- """)
-
-
- val completeReplyError: CompleteReplyError = CompleteReplyError(
- List(), 1, 5, Map(), Some("<STRING>"), Some("<STRING>"), Some(List())
- )
-
- describe("CompleteReplyError") {
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a CompleteReplyError instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- completeReplyErrorJson.as[CompleteReplyError] should be (completeReplyError)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteReplyOk = completeReplyErrorJson.asOpt[CompleteReplyError]
-
- newCompleteReplyOk.get should be (completeReplyError)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteReplyOkResults = completeReplyErrorJson.validate[CompleteReplyError]
-
- CompleteReplyOkResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: CompleteReplyError) => valid
- ) should be (completeReplyError)
- }
-
- it("should implicitly convert from a CompleteReplyError instance to valid json") {
- Json.toJson(completeReplyError) should be (completeReplyErrorJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplyOkSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplyOkSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplyOkSpec.scala
deleted file mode 100644
index a3edeec..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplyOkSpec.scala
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class CompleteReplyOkSpec extends FunSpec with Matchers {
- val completeReplyOkJson: JsValue = Json.parse("""
- {
- "matches": [],
- "cursor_start": 1,
- "cursor_end": 5,
- "metadata": {},
- "status": "ok"
- }
- """)
-
-
- val completeReplyOk: CompleteReplyOk = CompleteReplyOk(
- List(), 1, 5, Map()
- )
-
- describe("CompleteReplyOk") {
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a CompleteReplyOk instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- completeReplyOkJson.as[CompleteReplyOk] should be (completeReplyOk)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteReplyOk = completeReplyOkJson.asOpt[CompleteReplyOk]
-
- newCompleteReplyOk.get should be (completeReplyOk)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteReplyOkResults = completeReplyOkJson.validate[CompleteReplyOk]
-
- CompleteReplyOkResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: CompleteReplyOk) => valid
- ) should be (completeReplyOk)
- }
-
- it("should implicitly convert from a CompleteReplyOk instance to valid json") {
- Json.toJson(completeReplyOk) should be (completeReplyOkJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplySpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplySpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplySpec.scala
deleted file mode 100644
index a0e6a27..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteReplySpec.scala
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{Matchers, FunSpec}
-import play.api.data.validation.ValidationError
-import play.api.libs.json.{JsPath, JsValue, Json}
-
-/**
- * Created by Senkwich on 7/24/14.
- */
-class CompleteReplySpec extends FunSpec with Matchers {
-
-
- val completeReplyJson: JsValue = Json.parse("""
- {
- "matches": [],
- "cursor_start": 1,
- "cursor_end": 5,
- "metadata": {},
- "status": "<STRING>"
- }
- """)
-
- val completeReply: CompleteReply = CompleteReply(
- List(), 1, 5, Map(), "<STRING>", None, None, None
- )
-
- describe("CompleteReply") {
- describe("#toTypeString") {
- it("should return correct type") {
- CompleteReply.toTypeString should be ("complete_reply")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a CompleteReply instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- completeReplyJson.as[CompleteReply] should be (completeReply)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteReply = completeReplyJson.asOpt[CompleteReply]
-
- newCompleteReply.get should be (completeReply)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteReplyResults = completeReplyJson.validate[CompleteReply]
-
- CompleteReplyResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: CompleteReply) => valid
- ) should be (completeReply)
- }
-
- it("should implicitly convert from a CompleteReply instance to valid json") {
- Json.toJson(completeReply) should be (completeReplyJson)
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteRequestSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteRequestSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteRequestSpec.scala
deleted file mode 100644
index 3738354..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/CompleteRequestSpec.scala
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class CompleteRequestSpec extends FunSpec with Matchers {
- val completeRequestJson: JsValue = Json.parse("""
- {
- "code": "<STRING>",
- "cursor_pos": 999
- }
- """)
-
- val completeRequest: CompleteRequest = CompleteRequest(
- "<STRING>", 999
- )
-
- describe("CompleteRequest") {
- describe("#toTypeString") {
- it("should return correct type") {
- CompleteRequest.toTypeString should be ("complete_request")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a CompleteRequest instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- completeRequestJson.as[CompleteRequest] should be (completeRequest)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteRequest = completeRequestJson.asOpt[CompleteRequest]
-
- newCompleteRequest.get should be (completeRequest)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteRequestResults = completeRequestJson.validate[CompleteRequest]
-
- CompleteRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: CompleteRequest) => valid
- ) should be (completeRequest)
- }
-
- it("should implicitly convert from a CompleteRequest instance to valid json") {
- Json.toJson(completeRequest) should be (completeRequestJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ConnectReplySpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ConnectReplySpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ConnectReplySpec.scala
deleted file mode 100644
index 7ebfb07..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ConnectReplySpec.scala
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json.{JsPath, JsValue, Json}
-
-/**
- * Created by Senkwich on 7/24/14.
- */
-class ConnectReplySpec extends FunSpec with Matchers {
-
-
- val connectReplyJson: JsValue = Json.parse("""
- {
- "shell_port": 11111,
- "iopub_port": 22222,
- "stdin_port": 33333,
- "hb_port": 44444
- }
- """)
-
- val connectReply: ConnectReply = ConnectReply(11111,22222,33333,44444)
-
- describe("ConnectReply") {
- describe("#toTypeString") {
- it("should return correct type") {
- ConnectReply.toTypeString should be ("connect_reply")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a ConnectReply instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- connectReplyJson.as[ConnectReply] should be (connectReply)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newConnectReply = connectReplyJson.asOpt[ConnectReply]
-
- newConnectReply.get should be (connectReply)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val ConnectReplyResults = connectReplyJson.validate[ConnectReply]
-
- ConnectReplyResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ConnectReply) => valid
- ) should be (connectReply)
- }
-
- it("should implicitly convert from a ConnectReply instance to valid json") {
- Json.toJson(connectReply) should be (connectReplyJson)
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ConnectRequestSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ConnectRequestSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ConnectRequestSpec.scala
deleted file mode 100644
index af64d75..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ConnectRequestSpec.scala
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class ConnectRequestSpec extends FunSpec with Matchers {
- val connectRequestJson: JsValue = Json.parse("""
- {}
- """)
-
- val connectRequest: ConnectRequest = ConnectRequest()
-
- describe("ConnectRequest") {
- describe("#toTypeString") {
- it("should return correct type") {
- ConnectRequest.toTypeString should be ("connect_request")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a ConnectRequest instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- connectRequestJson.as[ConnectRequest] should be (connectRequest)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newConnectRequest = connectRequestJson.asOpt[ConnectRequest]
-
- newConnectRequest.get should be (connectRequest)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val ConnectRequestResults = connectRequestJson.validate[ConnectRequest]
-
- ConnectRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ConnectRequest) => valid
- ) should be (connectRequest)
- }
-
- it("should implicitly convert from a ConnectRequest instance to valid json") {
- Json.toJson(connectRequest) should be (connectRequestJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/DisplayDataSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/DisplayDataSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/DisplayDataSpec.scala
deleted file mode 100644
index 26b03e7..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/DisplayDataSpec.scala
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.FunSuite
-
-import org.scalatest.{Matchers, FunSpec}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-import com.ibm.spark.kernel.protocol.v5._
-
-class DisplayDataSpec extends FunSpec with Matchers {
- val displayDataJson: JsValue = Json.parse("""
- {
- "source": "<STRING>",
- "data": {},
- "metadata": {}
- }
- """)
-
- val displayData: DisplayData = DisplayData(
- "<STRING>", Map(), Map()
- )
-
- describe("DisplayData") {
- describe("#toTypeString") {
- it("should return correct type") {
- DisplayData.toTypeString should be ("display_data")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a displayData instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- displayDataJson.as[DisplayData] should be (displayData)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newDisplayData = displayDataJson.asOpt[DisplayData]
-
- newDisplayData.get should be (displayData)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val displayDataResults = displayDataJson.validate[DisplayData]
-
- displayDataResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: DisplayData) => valid
- ) should be (displayData)
- }
-
- it("should implicitly convert from a displayData instance to valid json") {
- Json.toJson(displayData) should be (displayDataJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ErrorContentSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ErrorContentSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ErrorContentSpec.scala
deleted file mode 100644
index 3321d1e..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ErrorContentSpec.scala
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{Matchers, FunSpec}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class ErrorContentSpec extends FunSpec with Matchers {
- val errorJson: JsValue = Json.parse("""
- {
- "ename": "<STRING>",
- "evalue": "<STRING>",
- "traceback": ["<STRING>"]
- }
- """)
-
- val error = ErrorContent("<STRING>", "<STRING>", List("<STRING>"))
-
- describe("ErrorContent") {
- describe("#toTypeString") {
- it("should return correct type") {
- ErrorContent.toTypeString should be ("error")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a ErrorContent instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- errorJson.as[ErrorContent] should be (error)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteRequest = errorJson.asOpt[ErrorContent]
-
- newCompleteRequest.get should be (error)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteRequestResults = errorJson.validate[ErrorContent]
-
- CompleteRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ErrorContent) => valid
- ) should be (error)
- }
-
- it("should implicitly convert from a ErrorContent instance to valid json") {
- Json.toJson(error) should be (errorJson)
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteInputSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteInputSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteInputSpec.scala
deleted file mode 100644
index 7327785..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteInputSpec.scala
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class ExecuteInputSpec extends FunSpec with Matchers {
- val executeInputJson: JsValue = Json.parse("""
- {
- "code": "<STRING>",
- "execution_count": 42
- }
- """)
-
- val executeInput: ExecuteInput = ExecuteInput(
- "<STRING>", 42
- )
-
- describe("ExecuteInput") {
- describe("#toTypeString") {
- it("should return correct type") {
- ExecuteInput.toTypeString should be ("execute_input")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a executeInput instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- executeInputJson.as[ExecuteInput] should be (executeInput)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newExecuteInput = executeInputJson.asOpt[ExecuteInput]
-
- newExecuteInput.get should be (executeInput)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val executeInputResults = executeInputJson.validate[ExecuteInput]
-
- executeInputResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ExecuteInput) => valid
- ) should be (executeInput)
- }
-
- it("should implicitly convert from a executeInput instance to valid json") {
- Json.toJson(executeInput) should be (executeInputJson)
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyAbortSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyAbortSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyAbortSpec.scala
deleted file mode 100644
index 5241650..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyAbortSpec.scala
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import com.ibm.spark.kernel.protocol.v5._
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class ExecuteReplyAbortSpec extends FunSpec with Matchers {
- val executeReplyAbortJson: JsValue = Json.parse("""
- {
- "status": "abort",
- "execution_count": 999
- }
- """)
-
- val executeReplyAbort: ExecuteReplyAbort = ExecuteReplyAbort(
- 999
- )
-
- describe("ExecuteReplyAbort") {
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a ExecuteReplyAbort instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- executeReplyAbortJson.as[ExecuteReplyAbort] should be (executeReplyAbort)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newExecuteReplyAbort = executeReplyAbortJson.asOpt[ExecuteReplyAbort]
-
- newExecuteReplyAbort.get should be (executeReplyAbort)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val ExecuteReplyAbortResults = executeReplyAbortJson.validate[ExecuteReplyAbort]
-
- ExecuteReplyAbortResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ExecuteReplyAbort) => valid
- ) should be (executeReplyAbort)
- }
-
- it("should implicitly convert from a ExecuteReplyAbort instance to valid json") {
- Json.toJson(executeReplyAbort) should be (executeReplyAbortJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyErrorSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyErrorSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyErrorSpec.scala
deleted file mode 100644
index 9859d5e..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyErrorSpec.scala
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-import com.ibm.spark.kernel.protocol.v5._
-
-class ExecuteReplyErrorSpec extends FunSpec with Matchers {
- val executeReplyErrorJson: JsValue = Json.parse("""
- {
- "status": "error",
- "execution_count": 999,
- "ename": "<STRING>",
- "evalue": "<STRING>",
- "traceback": []
- }
- """)
-
- val executeReplyError: ExecuteReplyError = ExecuteReplyError(
- 999, Some("<STRING>"), Some("<STRING>"), Some(List())
- )
-
- describe("ExecuteReplyError") {
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a ExecuteReplyError instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- executeReplyErrorJson.as[ExecuteReplyError] should be (executeReplyError)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newExecuteReplyError = executeReplyErrorJson.asOpt[ExecuteReplyError]
-
- newExecuteReplyError.get should be (executeReplyError)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val ExecuteReplyErrorResults = executeReplyErrorJson.validate[ExecuteReplyError]
-
- ExecuteReplyErrorResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ExecuteReplyError) => valid
- ) should be (executeReplyError)
- }
-
- it("should implicitly convert from a ExecuteReplyError instance to valid json") {
- Json.toJson(executeReplyError) should be (executeReplyErrorJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyOkSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyOkSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyOkSpec.scala
deleted file mode 100644
index be73811..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplyOkSpec.scala
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-import com.ibm.spark.kernel.protocol.v5._
-
-class ExecuteReplyOkSpec extends FunSpec with Matchers {
- val executeReplyOkJson: JsValue = Json.parse("""
- {
- "status": "ok",
- "execution_count": 999,
- "payload": [],
- "user_expressions": {}
- }
- """)
-
- val executeReplyOk: ExecuteReplyOk = ExecuteReplyOk(
- 999, Some(Payloads()), Some(UserExpressions())
- )
-
- describe("ExecuteReplyOk") {
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a executeReplyOk instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- executeReplyOkJson.as[ExecuteReplyOk] should be (executeReplyOk)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newExecuteReplyOk = executeReplyOkJson.asOpt[ExecuteReplyOk]
-
- newExecuteReplyOk.get should be (executeReplyOk)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val executeReplyOkResults = executeReplyOkJson.validate[ExecuteReplyOk]
-
- executeReplyOkResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ExecuteReplyOk) => valid
- ) should be (executeReplyOk)
- }
-
- it("should implicitly convert from a executeReplyOk instance to valid json") {
- Json.toJson(executeReplyOk) should be (executeReplyOkJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplySpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplySpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplySpec.scala
deleted file mode 100644
index 24af1f2..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteReplySpec.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import com.ibm.spark.kernel.protocol.v5._
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class ExecuteReplySpec extends FunSpec with Matchers {
- val executeReplyJson: JsValue = Json.parse("""
- {
- "status": "<STRING>",
- "execution_count": 999
- }
- """)
-
- val executeReply: ExecuteReply = ExecuteReply(
- "<STRING>", 999, None, None, None, None, None
- )
-
- describe("ExecuteReply") {
- describe("#toTypeString") {
- it("should return correct type") {
- ExecuteReply.toTypeString should be ("execute_reply")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a executeReply instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- executeReplyJson.as[ExecuteReply] should be (executeReply)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newExecuteReply = executeReplyJson.asOpt[ExecuteReply]
-
- newExecuteReply.get should be (executeReply)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val executeReplyResults = executeReplyJson.validate[ExecuteReply]
-
- executeReplyResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ExecuteReply) => valid
- ) should be (executeReply)
- }
-
- it("should implicitly convert from a executeReply instance to valid json") {
- Json.toJson(executeReply) should be (executeReplyJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteRequestSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteRequestSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteRequestSpec.scala
deleted file mode 100644
index bb8cd71..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteRequestSpec.scala
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{Matchers, FunSpec}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-import com.ibm.spark.kernel.protocol.v5._
-
-class ExecuteRequestSpec extends FunSpec with Matchers {
- val executeRequestJson: JsValue = Json.parse("""
- {
- "code": "<STRING>",
- "silent": false,
- "store_history": false,
- "user_expressions": {},
- "allow_stdin": false
- }
- """)
-
- val executeRequest: ExecuteRequest = ExecuteRequest(
- "<STRING>", false, false, UserExpressions(), false
- )
-
- describe("ExecuteRequest") {
- describe("#toTypeString") {
- it("should return correct type") {
- ExecuteRequest.toTypeString should be ("execute_request")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a executeRequest instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- executeRequestJson.as[ExecuteRequest] should be (executeRequest)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newExecuteRequest = executeRequestJson.asOpt[ExecuteRequest]
-
- newExecuteRequest.get should be (executeRequest)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val executeRequestResults = executeRequestJson.validate[ExecuteRequest]
-
- executeRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ExecuteRequest) => valid
- ) should be (executeRequest)
- }
-
- it("should implicitly convert from a executeRequest instance to valid json") {
- Json.toJson(executeRequest) should be (executeRequestJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteResultSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteResultSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteResultSpec.scala
deleted file mode 100644
index fdbe3ca..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/ExecuteResultSpec.scala
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-import com.ibm.spark.kernel.protocol.v5._
-
-class ExecuteResultSpec extends FunSpec with Matchers {
- val executeResultJson: JsValue = Json.parse("""
- {
- "execution_count": 999,
- "data": {"text/plain": "resulty result"},
- "metadata": {}
- }
- """)
-
- val executeResult = ExecuteResult(
- 999, Data("text/plain" -> "resulty result"), Metadata()
- )
-
- describe("ExecuteResult") {
- describe("#toTypeString") {
- it("should return correct type") {
- ExecuteResult.toTypeString should be ("execute_result")
- }
- }
-
- describe("#hasContent") {
- it("should be true when data has a non-empty text/plain field") {
- executeResult.hasContent should be (true)
- }
-
- it("should be false if data is null") {
- val executeResultNoData = ExecuteResult(
- 999, null, Metadata()
- )
- executeResultNoData.hasContent should be (false)
- }
-
- it("should be false when data does not have a text/plain field") {
- val executeResultEmptyData = ExecuteResult(
- 999, Data(), Metadata()
- )
- executeResultEmptyData.hasContent should be (false)
-
- }
-
- it("should be false if text/plain field maps to an empty string") {
- val executeResultEmptyString = ExecuteResult(
- 999, Data("text/plain" -> ""), Metadata()
- )
- executeResultEmptyString.hasContent should be (false)
- }
-
- it("should be false if text/plain maps to null") {
- val executeResultTextPlainNull = ExecuteResult(
- 999, Data("text/plain" -> null), Metadata()
- )
- executeResultTextPlainNull.hasContent should be (false)
- }
- }
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a ExecuteResult instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- executeResultJson.as[ExecuteResult] should be (executeResult)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteRequest = executeResultJson.asOpt[ExecuteResult]
-
- newCompleteRequest.get should be (executeResult)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteRequestResults = executeResultJson.validate[ExecuteResult]
-
- CompleteRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: ExecuteResult) => valid
- ) should be (executeResult)
- }
-
- it("should implicitly convert from a ExecuteResult instance to valid json") {
- Json.toJson(executeResult) should be (executeResultJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/HistoryReplySpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/HistoryReplySpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/HistoryReplySpec.scala
deleted file mode 100644
index 4e69066..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/HistoryReplySpec.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-import com.ibm.spark.kernel.protocol.v5._
-
-class HistoryReplySpec extends FunSpec with Matchers {
- val historyReplyJson: JsValue = Json.parse("""
- {
- "history": ["<STRING>", "<STRING2>", "<STRING3>"]
- }
- """)
-
- val historyReply = HistoryReply(
- List("<STRING>", "<STRING2>", "<STRING3>")
- )
-
- describe("HistoryReply") {
- describe("#toTypeString") {
- it("should return correct type") {
- HistoryReply.toTypeString should be ("history_reply")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a HistoryReply instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- historyReplyJson.as[HistoryReply] should be (historyReply)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteRequest = historyReplyJson.asOpt[HistoryReply]
-
- newCompleteRequest.get should be (historyReply)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteRequestResults = historyReplyJson.validate[HistoryReply]
-
- CompleteRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: HistoryReply) => valid
- ) should be (historyReply)
- }
-
- it("should implicitly convert from a HistoryReply instance to valid json") {
- Json.toJson(historyReply) should be (historyReplyJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/HistoryRequestSpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/HistoryRequestSpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/HistoryRequestSpec.scala
deleted file mode 100644
index dc775fa..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/HistoryRequestSpec.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class HistoryRequestSpec extends FunSpec with Matchers {
- val historyRequestJson: JsValue = Json.parse("""
- {
- "output": true,
- "ras": true,
- "hist_access_type": "<STRING>",
- "session": 1,
- "start": 0,
- "stop": 5,
- "n": 1,
- "pattern": "<STRING>",
- "unique": true
- }
- """)
-
- val historyRequest = HistoryRequest(
- true, true, "<STRING>", 1, 0, 5, 1, "<STRING>", true
- )
-
- describe("HistoryRequest") {
- describe("#toTypeString") {
- it("should return correct type") {
- HistoryRequest.toTypeString should be ("history_request")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a HistoryRequest instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- historyRequestJson.as[HistoryRequest] should be (historyRequest)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteRequest = historyRequestJson.asOpt[HistoryRequest]
-
- newCompleteRequest.get should be (historyRequest)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteRequestResults = historyRequestJson.validate[HistoryRequest]
-
- CompleteRequestResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: HistoryRequest) => valid
- ) should be (historyRequest)
- }
-
- it("should implicitly convert from a HistoryRequest instance to valid json") {
- Json.toJson(historyRequest) should be (historyRequestJson)
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/68f7ddd6/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/InputReplySpec.scala
----------------------------------------------------------------------
diff --git a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/InputReplySpec.scala b/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/InputReplySpec.scala
deleted file mode 100644
index a5d14b1..0000000
--- a/protocol/src/test/scala/com/ibm/spark/kernel/protocol/v5/content/InputReplySpec.scala
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2015 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.spark.kernel.protocol.v5.content
-
-import org.scalatest.{FunSpec, Matchers}
-import play.api.data.validation.ValidationError
-import play.api.libs.json._
-
-class InputReplySpec extends FunSpec with Matchers {
- val inputReplyJson: JsValue = Json.parse("""
- {
- "value": "<STRING>"
- }
- """)
-
- val inputReply = InputReply(
- "<STRING>"
- )
-
- describe("InputReply") {
- describe("#toTypeString") {
- it("should return correct type") {
- InputReply.toTypeString should be ("input_reply")
- }
- }
-
- describe("implicit conversions") {
- it("should implicitly convert from valid json to a InputReply instance") {
- // This is the least safe way to convert as an error is thrown if it fails
- inputReplyJson.as[InputReply] should be (inputReply)
- }
-
- it("should also work with asOpt") {
- // This is safer, but we lose the error information as it returns
- // None if the conversion fails
- val newCompleteReply = inputReplyJson.asOpt[InputReply]
-
- newCompleteReply.get should be (inputReply)
- }
-
- it("should also work with validate") {
- // This is the safest as it collects all error information (not just first error) and reports it
- val CompleteReplyResults = inputReplyJson.validate[InputReply]
-
- CompleteReplyResults.fold(
- (invalid: Seq[(JsPath, Seq[ValidationError])]) => println("Failed!"),
- (valid: InputReply) => valid
- ) should be (inputReply)
- }
-
- it("should implicitly convert from a InputReply instance to valid json") {
- Json.toJson(inputReply) should be (inputReplyJson)
- }
- }
- }
-}
-