Expect the unexpected

Be sure to protect clients from passing invalid inputs.

public void open(String path) {
  if(path == null) {
    throw new IllegalArgumentException("path may not be null");
  }
  if(path.trim().length() == 0) {
    throw new IllegalArgumentException("path may not be blank");
  }
}

Here's a handy tip to test exceptions from the Google Java Style Guide.

try {
  open(null);
  fail();
} catch (IllegalArgumentException expected) {
}

If you need to verify the right kind of error is thrown, AssertJ has you covered.

try {
  open("  ");
  fail();
} catch (IllegalArgumentException expected) {
  assertThat(expected).hasMessage("path may not be blank");
}