Created
September 26, 2017 08:01
-
-
Save Yasushi/3d3cc79719fafc8fb893fde9256e748d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io._ | |
import com.googlecode.sardine.SardineFactory | |
import scala.util.control.Exception._ | |
object Main extends App { | |
val log = new PrintWriter("output", "UTF-8") | |
val u = "http://172.16.10.52:10080/webdav/" | |
val contents = "a".getBytes("UTF-8") | |
def printResult(c: String, i: Int, r: Either[Throwable, Unit]) { | |
r match { | |
case Left(t) => | |
println("category %s length %d failed".format(c, i)) | |
log.println("category %s length %d failed.| %s".format(c, i, t.toString)) | |
case _ => | |
println("category %s length %d success".format(c, i)) | |
} | |
} | |
try { | |
val s = SardineFactory.begin | |
s.setCredentials("davuser", "davuser") | |
s.delete(u+"a") | |
s.delete(u+"j") | |
s.createDirectory(u+"a") | |
s.createDirectory(u+"j") | |
/* | |
for{ | |
i <- (80 to 255) | |
afn <- Some(i).map(u + "a/" + "a"*_) | |
jfn <- Some(i).map(u + "j/" + "あ"*_) | |
} yield { | |
//printResult("a", i, allCatch either s.put(afn, contents, "text/plain")) | |
printResult("j", i, allCatch either s.put(jfn, contents, "text/plain")) | |
} | |
*/ | |
printResult("c", 84, allCatch either s.put(u + "j/a" + "あ"*84, contents, "text/plain")) | |
printResult("c", 84, allCatch either s.put(u + "j/aa" + "あ"*84, contents, "text/plain")) | |
printResult("c", 84, allCatch either s.put(u + "j/aaa" + "あ"*84, contents, "text/plain")) | |
// failed | |
printResult("c", 84, allCatch either s.put(u + "j/aaaa" + "あ"*84, contents, "text/plain")) | |
printResult("c", 84, allCatch either s.put(u + "j/aaaaa" + "あ"*84, contents, "text/plain")) | |
printResult("c", 84, allCatch either s.put(u + "j/aaaaaa" + "あ"*84, contents, "text/plain")) | |
printResult("c", 85, allCatch either s.put(u + "j/a" + "あ"*85, contents, "text/plain")) | |
printResult("c", 86, allCatch either s.put(u + "j/a" + "あ"*86, contents, "text/plain")) | |
} finally { | |
log.close | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment