Skip to content

Commit

Permalink
rename json files to avoid strange file names and not look like php
Browse files Browse the repository at this point in the history
  • Loading branch information
squito committed May 6, 2015
1 parent 735bc3d commit 863ef64
Show file tree
Hide file tree
Showing 34 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class HistoryServerSuite extends FunSuite with BeforeAndAfter with Matchers with
errOpt should be (None)
val json = jsonOpt.get
val exp = IOUtils.toString(new FileInputStream(
new File(expRoot, path + "/json_expectation")))
new File(expRoot, HistoryServerSuite.sanitizePath(path) + "/expectation.json")))
// compare the ASTs so formatting differences don't cause failures
import org.json4s._
import org.json4s.jackson.JsonMethods._
Expand Down Expand Up @@ -204,9 +204,9 @@ class HistoryServerSuite extends FunSuite with BeforeAndAfter with Matchers with

def generateExpectation(path: String): Unit = {
val json = getUrl(path)
val dir = new File(expRoot, path)
val dir = new File(expRoot, HistoryServerSuite.sanitizePath(path))
dir.mkdirs()
val out = new FileWriter(new File(dir, "json_expectation"))
val out = new FileWriter(new File(dir, "expectation.json"))
out.write(json)
out.close()
}
Expand Down Expand Up @@ -237,19 +237,29 @@ object HistoryServerSuite {
val code = connection.getResponseCode()
val inString = try {
val in = Option(connection.getInputStream())
in.map{IOUtils.toString}
in.map {
IOUtils.toString
}
} catch {
case io: IOException => None
}
val errString = try {
val err = Option(connection.getErrorStream())
err.map{IOUtils.toString}
err.map {
IOUtils.toString
}
} catch {
case io: IOException => None
}
(code, inString, errString)
}


def sanitizePath(path: String): String = {
// this doesn't need to be perfect, just good enough to avoid collisions
path.replaceAll("""\?""", "__q__").replaceAll("=","__e__")
}

def getUrl(path: URL): String = {
val (code, resultOpt, error) = getContentAndCode(path)
if (code == 200) {
Expand Down

0 comments on commit 863ef64

Please sign in to comment.