I'm unit testing some Java code that must parse an input String
as a path-name. I'm using Java 7, so the parsed value is a Path
object.
The Paths.get
method will throw an InvalidPathException
if the path string cannot be converted to a Path
So, to check my parsing code is robust I need a test value that will cause Paths.get
to throw that exception. That is, a String
value that is not a valid path. What constitutes a valid path is system (even file-system) dependent, so I am specifically interested in a String
that is not a valid POSIX path, or (failing that) not a valid Linux path.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…