Skip to content

Commit

Permalink
PSM-1716 Sort
Browse files Browse the repository at this point in the history
  • Loading branch information
nathankooij committed Dec 30, 2022
1 parent 2f9d347 commit 51ac167
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
Expand All @@ -38,12 +39,12 @@ final class DocumentationGeneratorTaskListener implements TaskListener {
this.basePath = path.substring(path.indexOf('=') + 1) + File.separator + "docs";

// XXX: Should we extract this method?
Path docsPath = Paths.get(basePath);
try {
Path docsPath = Paths.get(basePath);
Files.createDirectories(docsPath);
} catch (IOException e) {
} catch (IOException | InvalidPathException e) {
throw new IllegalStateException(
String.format("Error while creating directory '%s'", docsPath), e);
String.format("Error while creating directory with path '%s'", basePath), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,31 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.io.TempDir;

final class DocumentationGeneratorBugPatternTest extends DocumentationGeneratorCompilerBasedTest {
@Test
@EnabledOnOs(WINDOWS)
@Test
void wrongPathFailsWindows() {
wrongPathFails('?');
}

@Test
@DisabledOnOs(WINDOWS)
@Test
void wrongPathFailsOtherOperatingSystems() {
// Strictly speaking we are validating here that we cannot write to a RO FS.
wrongPathFails('/');
}

private void wrongPathFails(char invalidCharacter) {
String invalidPath = invalidCharacter + "wrong-path";
assertThatThrownBy(() -> compile(invalidPath))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Error while creating directory '%s'", Paths.get(invalidPath, "docs"));
.hasMessage(
"Error while creating directory with path '%s'", invalidPath + File.separator + "docs");
}

@Test
Expand Down

0 comments on commit 51ac167

Please sign in to comment.