Skip to content

Instantly share code, notes, and snippets.

@hanxue
Created June 26, 2014 06:17
Show Gist options
  • Select an option

  • Save hanxue/a3fbe15fb4179f7bc6f4 to your computer and use it in GitHub Desktop.

Select an option

Save hanxue/a3fbe15fb4179f7bc6f4 to your computer and use it in GitHub Desktop.
Scalatest exception hexBinary needs to be even-length
hexBinary needs to be even-length: WRONG
java.lang.IllegalArgumentException: hexBinary needs to be even-length: WRONG
at javax.xml.bind.DatatypeConverterImpl.parseHexBinary(DatatypeConverterImpl.java:442)
at javax.xml.bind.DatatypeConverter.parseHexBinary(DatatypeConverter.java:357)
at net.entrypass.simulator.TestP1Library.randomBytes(TestP1Library.scala:67)
at net.entrypass.simulator.TestP1Library$$anonfun$7.apply$mcV$sp(TestP1Library.scala:41)
at net.entrypass.simulator.TestP1Library$$anonfun$7.apply(TestP1Library.scala:41)
at net.entrypass.simulator.TestP1Library$$anonfun$7.apply(TestP1Library.scala:41)
at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
at org.scalatest.Transformer.apply(Transformer.scala:22)
at org.scalatest.Transformer.apply(Transformer.scala:20)
at org.scalatest.FlatSpecLike$$anon$1.apply(FlatSpecLike.scala:1639)
at org.scalatest.Suite$class.withFixture(Suite.scala:1121)
at org.scalatest.FlatSpec.withFixture(FlatSpec.scala:1683)
at org.scalatest.FlatSpecLike$class.invokeWithFixture$1(FlatSpecLike.scala:1636)
at org.scalatest.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:1648)
at org.scalatest.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:1648)
at org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)
at org.scalatest.FlatSpecLike$class.runTest(FlatSpecLike.scala:1648)
at org.scalatest.FlatSpec.runTest(FlatSpec.scala:1683)
at org.scalatest.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:1706)
at org.scalatest.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:1706)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:413)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
at scala.collection.immutable.List.foreach(List.scala:383)
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:390)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:427)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
at scala.collection.immutable.List.foreach(List.scala:383)
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:396)
at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:483)
at org.scalatest.FlatSpecLike$class.runTests(FlatSpecLike.scala:1706)
at org.scalatest.FlatSpec.runTests(FlatSpec.scala:1683)
at org.scalatest.Suite$class.run(Suite.scala:1423)
at org.scalatest.FlatSpec.org$scalatest$FlatSpecLike$$super$run(FlatSpec.scala:1683)
at org.scalatest.FlatSpecLike$$anonfun$run$1.apply(FlatSpecLike.scala:1752)
at org.scalatest.FlatSpecLike$$anonfun$run$1.apply(FlatSpecLike.scala:1752)
at org.scalatest.SuperEngine.runImpl(Engine.scala:545)
at org.scalatest.FlatSpecLike$class.run(FlatSpecLike.scala:1752)
at org.scalatest.FlatSpec.run(FlatSpec.scala:1683)
at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:55)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2563)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2557)
at scala.collection.immutable.List.foreach(List.scala:383)
at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:2557)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1044)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1043)
at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:2722)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1043)
at org.scalatest.tools.Runner$.run(Runner.scala:883)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:141)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
import javax.xml.bind.DatatypeConverter
class Scalatest extends UnitSpec{
val expectedIp = "192.168.1.196"
val localIp = java.net.InetAddress.getLocalHost.getHostAddress
assume(localIp == expectedIp, "Currently P1Test is hardcoded to run from " + expectedIp)
"Correct heartbeat" should "return 1" in {
1.toByte should be (P1Test.sendAndReceive(P1Test.heartbeat)._1)
}
"Correct heartbeat with status result" should "return 1" in {
1.toByte should be (P1Test.sendAndReceive(P1Test.heartbeatStatus)._1)
}
"Correct Door Is Open result" should "return 3"in {
3.toByte should be (P1Test.sendAndReceive(P1Test.doorIsOpen)._1)
}
"Correct Door Is Closed result" should "return 3" in {
3.toByte should be (P1Test.sendAndReceive(P1Test.doorIsClosed)._1)
}
"Correct Door Forced Open result" should "return 3" in {
3.toByte should be (P1Test.sendAndReceive(P1Test.doorForcedOpen)._1)
}
"Correct Valid Card Entry result" should "return 5" in {
5.toByte should be (P1Test.sendAndReceive(P1Test.validCardEntry)._1)
}
"Incorrect heartbeat result" should "return 0" in {
0.toByte should be (P1Test.sendAndReceive(randomBytes)._1)
}
"Incorrect heartbeat with status result" should "return 0" in {
0.toByte should be (P1Test.sendAndReceive(randomBytes)._1)
}
"Incorrect Door Is Open result" should "return 2" in {
2.toByte should be (P1Test.sendAndReceive(randomBytes)._1)
}
"Incorrect Door Is Closed result" should "return 2" in {
2.toByte should be (P1Test.sendAndReceive(randomBytes)._1)
}
"Incorrect Door Forced Open result" should "return 2" in {
2.toByte should be (P1Test.sendAndReceive(randomBytes)._1)
}
"Incorrect Valid Card Entry result" should "return 4" in {
4.toByte should be (P1Test.sendAndReceive(randomBytes)._1)
}
def randomBytes: Array[Byte] = {
val bytes = new Array[Byte](20)
scala.util.Random.nextBytes(bytes)
Array.concat(DatatypeConverter.parseHexBinary("WRONG"), bytes)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment