Skip to content

Commit

Permalink
Make tests use commons-codec for Base64 instead of javax.xml.bind.Dat…
Browse files Browse the repository at this point in the history
…atypeConverter

Fixes #466
  • Loading branch information
thesamet committed Jun 26, 2018
1 parent 1690bed commit 2b055be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: scala
sudo: required
dist: trusty
jdk: oraclejdk9

scala:
- 2.10.7
Expand Down
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ lazy val runtime = crossProject(JSPlatform, JVMPlatform, NativePlatform)
name := "scalapb-runtime",
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "fastparse" % "1.0.0",
"com.lihaoyi" %%% "utest" % "0.6.4" % "test"
"com.lihaoyi" %%% "utest" % "0.6.4" % "test",
"commons-codec" % "commons-codec" % "1.11" % "test",
),
testFrameworks += new TestFramework("utest.runner.Framework"),
unmanagedResourceDirectories in Compile += baseDirectory.value / "../../protobuf",
Expand Down
5 changes: 3 additions & 2 deletions scalapb-runtime/jvm/src/test/scala/scalapb/EncodingSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scalapb

import org.scalatest._
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.apache.commons.codec.binary.Base64

class EncodingSpec extends PropSpec with GeneratorDrivenPropertyChecks with Matchers {
property("fromBase64 is the inverse of toBase64") {
Expand All @@ -12,13 +13,13 @@ class EncodingSpec extends PropSpec with GeneratorDrivenPropertyChecks with Matc

property("fromBase64 is compatible with javax.printBase64") {
forAll { b: Array[Byte] =>
Encoding.fromBase64(javax.xml.bind.DatatypeConverter.printBase64Binary(b)) should be(b)
Encoding.fromBase64(Base64.encodeBase64String(b)) should be(b)
}
}

property("toBase64 is compatible with javax.parseBase64") {
forAll { b: Array[Byte] =>
javax.xml.bind.DatatypeConverter.parseBase64Binary(Encoding.toBase64(b)) should be(b)
Base64.decodeBase64(Encoding.toBase64(b)) should be(b)
}
}
}

0 comments on commit 2b055be

Please sign in to comment.