Improve error message further.

This commit is contained in:
Josh Suereth 2014-06-03 13:57:27 -04:00
parent 2c3f40eb02
commit 87306524a8
1 changed files with 6 additions and 1 deletions

View File

@ -15,12 +15,17 @@ object ConcurrentCache extends Properties("ClassLoaderCache concurrent access")
else None
}
private def showCp(cp: ClassLoader): String = cp match {
case u: java.net.URLClassLoader => u.getURLs.mkString("UrlClassLoader(", ", ", ")")
case _ => cp.toString
}
property("Same class loader for same classpaths concurrently processed") = forAll { (names: List[String], concurrent: Int) =>
withcp(names.distinct) { files =>
val cache = new ClassLoaderCache(null)
val loaders = (1 to concurrent).par.map(_ => cache(files)).toList
loaders match {
case DifferentClassloader(left, right) => false :| s"$left != $right"
case DifferentClassloader(left, right) => false :| s"${showCp(left)} != ${showCp(right)}"
case _ => true :| ""
}
}