{"id":464301,"date":"2025-06-24T21:00:32","date_gmt":"2025-06-24T21:00:32","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=464301"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=464301","title":{"rendered":"<span>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 @TempDir \u0432 Java<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 <code>@TempDir<\/code>\u00a0\u2014 \u043c\u043e\u0449\u043d\u044b\u043c, \u043d\u043e\u00a0\u0447\u0430\u0441\u0442\u043e \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c JUnit 5\u00a0\u0434\u043b\u044f\u00a0\u0440\u0430\u0431\u043e\u0442\u044b \u0441\u00a0\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c\u0438 \u0432\u00a0\u0442\u0435\u0441\u0442\u0430\u0445.<\/p>\n<h4>\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438?<\/h4>\n<p>\u0422\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0438\u0448\u0443\u0442 \u043d\u0430\u00a0\u0434\u0438\u0441\u043a, \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u0441\u043e\u0440\u044f\u044e\u0442 <code>\/tmp<\/code>, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0431\u044b\u043b\u0438 \u043f\u043e\u0434\u0447\u0438\u0441\u0442\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041b\u043e\u043c\u0430\u044e\u0442\u0441\u044f \u0432\u00a0CI, \u043a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u0432\u043e\u0440\u043a\u0435\u0440\u0430 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u00a0\u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442\u00a0\u0436\u0435 \u0444\u0430\u0439\u043b.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0430\u0434\u0430\u044e\u0442 \u043d\u0430\u00a0Windows, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u00ab\u0444\u0430\u0439\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c\u00bb.<\/p>\n<\/li>\n<\/ol>\n<p><code>@TempDir<\/code> \u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0435 \u0442\u0440\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: JUnit \u0441\u043e\u0437\u0434\u0430\u0435\u0442 <strong>\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e<\/strong> \u043f\u0430\u043f\u043a\u0443, \u0438\u043d\u0436\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u0430\u043c <code>Path<\/code>\/<code>File<\/code>, \u0430\u00a0\u043f\u043e\u0442\u043e\u043c\u00a0\u2014 \u043f\u043e\u00a0\u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0432\u044b\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u0430\u00a0\u0441\u043e\u0431\u043e\u0439. <\/p>\n<pre><code class=\"java\">class ReportServiceTest {      @Test     void generatesCsv(@TempDir Path temp) throws IOException {         Path report = temp.resolve(\"users.csv\");         new ReportService().writeCsv(report);          assertLinesMatch(             List.of(\"id,name\", \"1,Alice\", \"2,Bob\"),             Files.readAllLines(report)         );     } }<\/code><\/pre>\n<p>\u0421\u0435\u043a\u0443\u043d\u0434\u043d\u043e\u0435 \u0434\u0435\u043b\u043e: \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0435\u0433\u043e \u0432\u00a0\u043f\u0440\u043e\u0434\u2011\u043a\u043e\u0434, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0437\u0430\u0431\u044b\u043b\u0438. JUnit \u0441\u0430\u043c \u0443\u0434\u0430\u043b\u0438\u0442 \u043f\u0430\u043f\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0442\u0435\u0441\u0442\u0430. <\/p>\n<h4>\u0422\u0440\u0438 \u043b\u0438\u0446\u0430 cleanup: ALWAYS, ON_SUCCESS, NEVER<\/h4>\n<p>\u0423 <code>@TempDir<\/code> \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>cleanup<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0427\u0442\u043e\u00a0\u0434\u0435\u043b\u0430\u0435\u0442<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>ALWAYS<\/code> (\u0434\u0435\u0444\u043e\u043b\u0442)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0447\u0438\u0441\u0442\u0438\u0442 \u0432\u0441\u0435\u0433\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">99% \u044e\u0437\u2011\u043a\u0435\u0439\u0441\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>ON_SUCCESS<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0447\u0438\u0441\u0442\u0438\u0442 <strong>\u0442\u043e\u043b\u044c\u043a\u043e<\/strong> \u043f\u0440\u0438\u00a0\u0437\u0435\u043b\u0435\u043d\u043e\u043c \u0442\u0435\u0441\u0442\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0435\u0431\u0430\u0433 \u0444\u0435\u0439\u043b\u043e\u0432, flaky\u2011\u0430\u0434<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>NEVER<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u043d\u0438\u0447\u0435\u0433\u043e<\/strong> \u043d\u0435\u00a0\u0447\u0438\u0441\u0442\u0438\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0440\u0435\u0434\u043a\u0438\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<pre><code class=\"java\">@Test void debugFailure(         @TempDir(cleanup = ON_SUCCESS) Path temp ) throws Exception {     \/\/ ... }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0441\u044f \u0430\u0441\u0441\u0435\u0440\u0442\u00a0\u2014 \u043f\u0430\u043f\u043a\u0430 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c, \u043c\u043e\u0436\u043d\u043e \u0440\u0443\u043a\u0430\u043c\u0438 \u0437\u0430\u043b\u0435\u0437\u0442\u044c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b. <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0432 <code>junit-platform.properties<\/code><br \/> <code>junit.jupiter.tempdir.cleanup.mode.default=ON_SUCCESS<\/code><\/p>\n<p>\u0421\u00a0JUnit 5.11+ ON_SUCCESS \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 nested\u2011\u0442\u0435\u0441\u0442\u044b \u0438 class\u2011level <code>@TempDir<\/code>.<\/p>\n<h4>CSV-\u0440\u0435\u043f\u043e\u0440\u0442\u044b<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u0447\u0435\u0442 \u0432 <code>Path<\/code>.<\/p>\n<pre><code class=\"java\">public final class ReportService {      public void writeCsv(Path target) {         try (BufferedWriter w = Files.newBufferedWriter(target)) {             w.write(\"id,name\\n\");             users().forEach(u -&gt; IoUtil.safeWrite(w, \"%d,%s\\n\", u.id(), u.name()));         } catch (IOException e) {             throw new UncheckedIOException(e);         }     }      \/* \u2026 business logic \u2026 *\/ }<\/code><\/pre>\n<p>\u0422\u0435\u0441\u0442 \u0441 <code>@TempDir<\/code>\u00a0\u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u0435\u043d (\u0441\u043c. \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440). \u041d\u0435\u00a0\u043d\u0443\u0436\u043d\u043e \u043f\u0430\u0440\u0438\u0442\u044c\u0441\u044f \u043e\u00a0\u043a\u043e\u043b\u043b\u0438\u0437\u0438\u044f\u0445 \u0438\u043c\u0435\u043d: \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439.<\/p>\n<h4>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0438\u0448\u0435\u0442 \u0432 OutputStream<\/h4>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0434\u2011\u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <code>OutputStream<\/code>, \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435: \u043f\u043e\u0434\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c <code>ByteArrayOutputStream<\/code>.<\/p>\n<pre><code class=\"java\">@Test void writesXmlToStream() {     ByteArrayOutputStream out = new ByteArrayOutputStream();     new XmlWriter(out).writeString(\"foo\");      assertThat(out.toString(UTF_8)).isEqualTo(\"&lt;tag&gt;foo&lt;\/tag&gt;\"); }<\/code><\/pre>\n<p>\u0411\u0435\u0437\u00a0\u0434\u0438\u0441\u043a\u0430, \u0431\u0435\u0437\u00a0\u043f\u0440\u0430\u0432 \u043d\u0430\u00a0\u0444\u0430\u0439\u043b\u044b, \u0442\u0435\u0441\u0442 \u0431\u0435\u0436\u0438\u0442 \u0432\u00a0\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b. <\/p>\n<h4>Jimfs \u2014 in-memory FS \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u0430\u0431\u043b<\/h4>\n<p>\u041d\u043e\u00a0\u043a\u0430\u043a\u00a0\u0431\u044b\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u043e\u0434\u00a0\u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0432\u044f\u0437\u0430\u043d \u043d\u0430 <code>Path<\/code> \u0438 \u0434\u0435\u0440\u0433\u0430\u0435\u0442 \u0442\u043e\u043d\u043d\u0443 <code>Files.*<\/code>? \u0412\u00a0\u0431\u043e\u0439 \u043f\u0443\u0441\u043a\u0430\u0435\u043c [Jimfs]\u00a0\u2014 \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432\u00a0\u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<pre><code class=\"java\">FileSystem fs = Jimfs.newFileSystem(Configuration.unix()); Path tmp = fs.getPath(\"\/tmp\");           \/\/ mkdir -p \/tmp Files.createDirectories(tmp); new ReportService().writeCsv(tmp.resolve(\"users.csv\"));<\/code><\/pre>\n<p>\u0421\u00a0JUnit 5.10\u00a0\u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f SPI <code>TempDirFactory<\/code>. \u041f\u0438\u0448\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443:<\/p>\n<pre><code class=\"java\">class JimfsTempDirFactory implements TempDirFactory {     private final FileSystem fs = Jimfs.newFileSystem(Configuration.unix());      @Override     public Path createTempDirectory(Object context) throws IOException {         return Files.createTempDirectory(fs.getPath(\"\/\"), \"junit\");     } }<\/code><\/pre>\n<p>\u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c:<\/p>\n<pre><code class=\"java\">@Test void reportInMemory(         @TempDir(factory = JimfsTempDirFactory.class) Path dir ) { \/* ... *\/ }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0435\u0441\u0442\u044b \u043d\u0435\u00a0\u0442\u0440\u043e\u0433\u0430\u044e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e FS \u0432\u043e\u043e\u0431\u0449\u0435. <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c <code>junit.jupiter.tempdir.factory.default=...JimfsTempDirFactory<\/code>, \u0438 <strong>\u0432\u0441\u0435<\/strong> <code>@TempDir<\/code> \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 Jimfs\u2011\u043e\u0432\u044b\u0435.<\/p>\n<h4>\u041f\u0440\u043e\u0447\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b<\/h4>\n<p><strong>Symlink\u2011\u043b\u043e\u0432\u0443\u0448\u043a\u0438.<\/strong> JUnit 5.12+ \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432\u00a0tmp\u2011\u043f\u0430\u043f\u043a\u0435 \u0435\u0441\u0442\u044c \u0441\u0438\u043c\u043b\u0438\u043d\u043a \u043d\u0430\u0440\u0443\u0436\u0443: \u0441\u0441\u044b\u043b\u043a\u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f, \u0446\u0435\u043b\u044c\u00a0\u2014 \u043d\u0435\u0442. \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435, \u0447\u0435\u043c \u0442\u0443\u043f\u043e\u0435 <code>rm -rf<\/code>. <\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b.<\/strong> \u041a\u0430\u0436\u0434\u044b\u0439 <code>@TempDir<\/code> \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439\u00a0\u2014 \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c <code>junit.jupiter.execution.parallel.enabled=true<\/code>.<\/p>\n<p><strong>Windows\u2011file\u2011locking.<\/strong> \u041d\u0435\u00a0\u0434\u0435\u0440\u0436\u0438\u0442\u0435 <code>FileChannel<\/code> \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0434\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0443\u0436\u043d\u043e. \u0414\u0430\u0436\u0435 <code>@TempDir<\/code> \u0442\u0443\u0442 \u0431\u0435\u0441\u0441\u0438\u043b\u0435\u043d.<\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 Jimfs \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442<\/h4>\n<ul>\n<li>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0435 \u043b\u043e\u0433\u0438\u043a\u0443, \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u00a0ACL\/xattrs.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c work\u2011with\u2011network\u2011share.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 JNI\u2011\u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e <code>fchmod()<\/code>\u00a0\u2014 Jimfs \u044d\u0442\u043e \u043d\u0435\u00a0\u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u00a0\u044d\u0442\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0431\u0435\u0440\u0438\u0442\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0434\u0438\u0441\u043a + <code>@TempDir(cleanup = NEVER)<\/code> \u0438 \u043f\u043e\u0434\u0447\u0438\u0449\u0430\u0439\u0442\u0435 \u0440\u0443\u043a\u0430\u043c\u0438 \u0432 <code>@AfterEach<\/code>.<\/p>\n<hr\/>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432\u00a0\u0442\u0435\u0441\u0442\u0430\u0445, \u043a\u0440\u0443\u0442\u0438\u0442\u0435 <code>deleteOnExit()<\/code> \u0438 \u043d\u0430\u0434\u0435\u0435\u0442\u0435\u0441\u044c, \u0447\u0442\u043e\u00a0CI \u0441\u0430\u043c \u043a\u0430\u043a\u2011\u043d\u0438\u0431\u0443\u0434\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u0442\u0441\u044f\u00a0\u2014 \u043f\u043e\u0440\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f. <code>@TempDir<\/code> \u0432\u00a0JUnit \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u0437\u043e\u043e\u043f\u0430\u0440\u043a \u043e\u0434\u043d\u0438\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u043e\u043c: \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 cleanup, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 in\u2011memory \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u0430\u00a0\u0441 5.10+\u00a0\u2014 \u0435\u0449\u0435 \u0438 \u0442\u043e\u043d\u043a\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0444\u0430\u0431\u0440\u0438\u043a\u0438. <\/p>\n<p>\u041d\u0435\u00a0\u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e <code>cleanup = ON_SUCCESS<\/code>, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u0442\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0444\u0435\u0439\u043b\u044b, \u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u0440\u0436\u0438\u0442\u0435 JUnit \u0432\u00a0\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438: \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 5.11\u20135.12, \u043f\u043e\u0444\u0438\u043a\u0448\u0435\u043d\u044b \u0431\u0430\u0433\u0438 \u0441\u00a0nested\u2011\u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u0441\u0438\u043c\u0432\u043e\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u0438 \u0440\u0430\u043d\u043d\u0438\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439. \u0422\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u044e <code>TempDirFactory<\/code>. \u041f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u0435 \u043e\u0434\u0438\u043d \u0432\u0435\u0447\u0435\u0440\u00a0\u2014 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u0435 \u0441\u043e\u0442\u043d\u0438 \u0432\u00a0\u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<p>\u0412\u00a0\u0446\u0435\u043b\u043e\u043c, \u043b\u044e\u0431\u043e\u0439 \u043a\u043e\u0434, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u00a0\u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439, \u0434\u043e\u043b\u0436\u0435\u043d\u00a0\u0431\u044b\u0442\u044c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d \u0432\u00a0\u0442\u0435\u0441\u0442\u0430\u0445. <code>@TempDir<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442, \u0447\u0438\u0441\u0442\u0438\u0442. \u0412\u0441\u0435, \u0447\u0442\u043e\u00a0\u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u043c\u00a0\u2014 \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443, \u043d\u0435\u00a0\u0434\u0443\u043c\u0430\u044f \u043e\u00a0\u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u0445. <\/p>\n<hr\/>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435\u0440\u044c\u0451\u0437 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441\u00a0\u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0432\u00a0Java\u00a0\u2014 \u0441\u00a0\u0432\u0430\u0441 \u043d\u0438\u043a\u0442\u043e \u043d\u0435\u00a0\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043d\u0430\u0438\u0437\u0443\u0441\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 @TempDir, Jimfs, FileChannel \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0435\u0439. \u041d\u043e\u00a0\u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0433\u0434\u0435 \u0438 \u043a\u0430\u043a\u00a0\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c,\u00a0\u2014 \u0443\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u043b\u044f\u00a0\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0433\u043b\u0443\u0431\u0436\u0435, \u0443\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u00a0\u043b\u043e\u043c\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u00a0CI,\u00a0\u2014 \u0437\u0430\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u0432\u00a0\u043d\u0430\u0448 \u043a\u0443\u0440\u0441 <a href=\"https:\/\/otus.pw\/Hy3V\/\" rel=\"noopener noreferrer nofollow\">\u00abJava Developer. Basic\u00bb<\/a>. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u00a0\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u0435\u0439\u0441\u0430\u0445, \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u0438\u00a0\u2014 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0438\u0437\u00a0\u0438\u043d\u0434\u0443\u0441\u0442\u0440\u0438\u0438.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0443\u00a0\u043d\u0430\u0441 \u043e\u0442\u043a\u0440\u044b\u0442 <a href=\"https:\/\/otus.pw\/TtQiZ\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u043a\u0443\u0440\u0441\u043e\u0432<\/a> OTUS, \u0433\u0434\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u00a0\u0441\u0432\u043e\u0439 \u0441\u0442\u0435\u043a \u0438 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432\u00a0<a href=\"https:\/\/otus.pw\/wHTl\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0443\u0440\u043e\u043a\u043e\u0432<\/a>. \u0422\u0430\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0447\u0442\u043e\u2011\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435\u00a0\u2014 \u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/920200\/\"> https:\/\/habr.com\/ru\/articles\/920200\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 <code>@TempDir<\/code>\u00a0\u2014 \u043c\u043e\u0449\u043d\u044b\u043c, \u043d\u043e\u00a0\u0447\u0430\u0441\u0442\u043e \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c JUnit 5\u00a0\u0434\u043b\u044f\u00a0\u0440\u0430\u0431\u043e\u0442\u044b \u0441\u00a0\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c\u0438 \u0432\u00a0\u0442\u0435\u0441\u0442\u0430\u0445.<\/p>\n<h4>\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438?<\/h4>\n<p>\u0422\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0438\u0448\u0443\u0442 \u043d\u0430\u00a0\u0434\u0438\u0441\u043a, \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u0441\u043e\u0440\u044f\u044e\u0442 <code>\/tmp<\/code>, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0431\u044b\u043b\u0438 \u043f\u043e\u0434\u0447\u0438\u0441\u0442\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041b\u043e\u043c\u0430\u044e\u0442\u0441\u044f \u0432\u00a0CI, \u043a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u0432\u043e\u0440\u043a\u0435\u0440\u0430 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u00a0\u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442\u00a0\u0436\u0435 \u0444\u0430\u0439\u043b.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0430\u0434\u0430\u044e\u0442 \u043d\u0430\u00a0Windows, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u00ab\u0444\u0430\u0439\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c\u00bb.<\/p>\n<\/li>\n<\/ol>\n<p><code>@TempDir<\/code> \u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0435 \u0442\u0440\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: JUnit \u0441\u043e\u0437\u0434\u0430\u0435\u0442 <strong>\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e<\/strong> \u043f\u0430\u043f\u043a\u0443, \u0438\u043d\u0436\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u0430\u043c <code>Path<\/code>\/<code>File<\/code>, \u0430\u00a0\u043f\u043e\u0442\u043e\u043c\u00a0\u2014 \u043f\u043e\u00a0\u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0432\u044b\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u0430\u00a0\u0441\u043e\u0431\u043e\u0439. <\/p>\n<pre><code class=\"java\">class ReportServiceTest {      @Test     void generatesCsv(@TempDir Path temp) throws IOException {         Path report = temp.resolve(\"users.csv\");         new ReportService().writeCsv(report);          assertLinesMatch(             List.of(\"id,name\", \"1,Alice\", \"2,Bob\"),             Files.readAllLines(report)         );     } }<\/code><\/pre>\n<p>\u0421\u0435\u043a\u0443\u043d\u0434\u043d\u043e\u0435 \u0434\u0435\u043b\u043e: \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0435\u0433\u043e \u0432\u00a0\u043f\u0440\u043e\u0434\u2011\u043a\u043e\u0434, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0437\u0430\u0431\u044b\u043b\u0438. JUnit \u0441\u0430\u043c \u0443\u0434\u0430\u043b\u0438\u0442 \u043f\u0430\u043f\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0442\u0435\u0441\u0442\u0430. <\/p>\n<h4>\u0422\u0440\u0438 \u043b\u0438\u0446\u0430 cleanup: ALWAYS, ON_SUCCESS, NEVER<\/h4>\n<p>\u0423 <code>@TempDir<\/code> \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>cleanup<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0427\u0442\u043e\u00a0\u0434\u0435\u043b\u0430\u0435\u0442<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>ALWAYS<\/code> (\u0434\u0435\u0444\u043e\u043b\u0442)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0447\u0438\u0441\u0442\u0438\u0442 \u0432\u0441\u0435\u0433\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">99% \u044e\u0437\u2011\u043a\u0435\u0439\u0441\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>ON_SUCCESS<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0447\u0438\u0441\u0442\u0438\u0442 <strong>\u0442\u043e\u043b\u044c\u043a\u043e<\/strong> \u043f\u0440\u0438\u00a0\u0437\u0435\u043b\u0435\u043d\u043e\u043c \u0442\u0435\u0441\u0442\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0435\u0431\u0430\u0433 \u0444\u0435\u0439\u043b\u043e\u0432, flaky\u2011\u0430\u0434<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>NEVER<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u043d\u0438\u0447\u0435\u0433\u043e<\/strong> \u043d\u0435\u00a0\u0447\u0438\u0441\u0442\u0438\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0440\u0435\u0434\u043a\u0438\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<pre><code class=\"java\">@Test void debugFailure(         @TempDir(cleanup = ON_SUCCESS) Path temp ) throws Exception {     \/\/ ... }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0441\u044f \u0430\u0441\u0441\u0435\u0440\u0442\u00a0\u2014 \u043f\u0430\u043f\u043a\u0430 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c, \u043c\u043e\u0436\u043d\u043e \u0440\u0443\u043a\u0430\u043c\u0438 \u0437\u0430\u043b\u0435\u0437\u0442\u044c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b. <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0432 <code>junit-platform.properties<\/code><br \/> <code>junit.jupiter.tempdir.cleanup.mode.default=ON_SUCCESS<\/code><\/p>\n<p>\u0421\u00a0JUnit 5.11+ ON_SUCCESS \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 nested\u2011\u0442\u0435\u0441\u0442\u044b \u0438 class\u2011level <code>@TempDir<\/code>.<\/p>\n<h4>CSV-\u0440\u0435\u043f\u043e\u0440\u0442\u044b<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u0447\u0435\u0442 \u0432 <code>Path<\/code>.<\/p>\n<pre><code class=\"java\">public final class ReportService {      public void writeCsv(Path target) {         try (BufferedWriter w = Files.newBufferedWriter(target)) {             w.write(\"id,name\\n\");             users().forEach(u -&gt; IoUtil.safeWrite(w, \"%d,%s\\n\", u.id(), u.name()));         } catch (IOException e) {             throw new UncheckedIOException(e);         }     }      \/* \u2026 business logic \u2026 *\/ }<\/code><\/pre>\n<p>\u0422\u0435\u0441\u0442 \u0441 <code>@TempDir<\/code>\u00a0\u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u0435\u043d (\u0441\u043c. \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440). \u041d\u0435\u00a0\u043d\u0443\u0436\u043d\u043e \u043f\u0430\u0440\u0438\u0442\u044c\u0441\u044f \u043e\u00a0\u043a\u043e\u043b\u043b\u0438\u0437\u0438\u044f\u0445 \u0438\u043c\u0435\u043d: \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439.<\/p>\n<h4>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0438\u0448\u0435\u0442 \u0432 OutputStream<\/h4>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0434\u2011\u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <code>OutputStream<\/code>, \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435: \u043f\u043e\u0434\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c <code>ByteArrayOutputStream<\/code>.<\/p>\n<pre><code class=\"java\">@Test void writesXmlToStream() {     ByteArrayOutputStream out = new ByteArrayOutputStream();     new XmlWriter(out).writeString(\"foo\");      assertThat(out.toString(UTF_8)).isEqualTo(\"&lt;tag&gt;foo&lt;\/tag&gt;\"); }<\/code><\/pre>\n<p>\u0411\u0435\u0437\u00a0\u0434\u0438\u0441\u043a\u0430, \u0431\u0435\u0437\u00a0\u043f\u0440\u0430\u0432 \u043d\u0430\u00a0\u0444\u0430\u0439\u043b\u044b, \u0442\u0435\u0441\u0442 \u0431\u0435\u0436\u0438\u0442 \u0432\u00a0\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b. <\/p>\n<h4>Jimfs \u2014 in-memory FS \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u0430\u0431\u043b<\/h4>\n<p>\u041d\u043e\u00a0\u043a\u0430\u043a\u00a0\u0431\u044b\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u043e\u0434\u00a0\u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0432\u044f\u0437\u0430\u043d \u043d\u0430 <code>Path<\/code> \u0438 \u0434\u0435\u0440\u0433\u0430\u0435\u0442 \u0442\u043e\u043d\u043d\u0443 <code>Files.*<\/code>? \u0412\u00a0\u0431\u043e\u0439 \u043f\u0443\u0441\u043a\u0430\u0435\u043c [Jimfs]\u00a0\u2014 \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432\u00a0\u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<pre><code class=\"java\">FileSystem fs = Jimfs.newFileSystem(Configuration.unix()); Path tmp = fs.getPath(\"\/tmp\");           \/\/ mkdir -p \/tmp Files.createDirectories(tmp); new ReportService().writeCsv(tmp.resolve(\"users.csv\"));<\/code><\/pre>\n<p>\u0421\u00a0JUnit 5.10\u00a0\u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f SPI <code>TempDirFactory<\/code>. \u041f\u0438\u0448\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443:<\/p>\n<pre><code class=\"java\">class JimfsTempDirFactory implements TempDirFactory {     private final FileSystem fs = Jimfs.newFileSystem(Configuration.unix());      @Override     public Path createTempDirectory(Object context) throws IOException {         return Files.createTempDirectory(fs.getPath(\"\/\"), \"junit\");     } }<\/code><\/pre>\n<p>\u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c:<\/p>\n<pre><code class=\"java\">@Test void reportInMemory(         @TempDir(factory = JimfsTempDirFactory.class) Path dir ) { \/* ... *\/ }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0435\u0441\u0442\u044b \u043d\u0435\u00a0\u0442\u0440\u043e\u0433\u0430\u044e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e FS \u0432\u043e\u043e\u0431\u0449\u0435. <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c <code>junit.jupiter.tempdir.factory.default=...JimfsTempDirFactory<\/code>, \u0438 <strong>\u0432\u0441\u0435<\/strong> <code>@TempDir<\/code> \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 Jimfs\u2011\u043e\u0432\u044b\u0435.<\/p>\n<h4>\u041f\u0440\u043e\u0447\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b<\/h4>\n<p><strong>Symlink\u2011\u043b\u043e\u0432\u0443\u0448\u043a\u0438.<\/strong> JUnit 5.12+ \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432\u00a0tmp\u2011\u043f\u0430\u043f\u043a\u0435 \u0435\u0441\u0442\u044c \u0441\u0438\u043c\u043b\u0438\u043d\u043a \u043d\u0430\u0440\u0443\u0436\u0443: \u0441\u0441\u044b\u043b\u043a\u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f, \u0446\u0435\u043b\u044c\u00a0\u2014 \u043d\u0435\u0442. \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435, \u0447\u0435\u043c \u0442\u0443\u043f\u043e\u0435 <code>rm -rf<\/code>. <\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b.<\/strong> \u041a\u0430\u0436\u0434\u044b\u0439 <code>@TempDir<\/code> \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439\u00a0\u2014 \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c <code>junit.jupiter.execution.parallel.enabled=true<\/code>.<\/p>\n<p><strong>Windows\u2011file\u2011locking.<\/strong> \u041d\u0435\u00a0\u0434\u0435\u0440\u0436\u0438\u0442\u0435 <code>FileChannel<\/code> \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0434\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0443\u0436\u043d\u043e. \u0414\u0430\u0436\u0435 <code>@TempDir<\/code> \u0442\u0443\u0442 \u0431\u0435\u0441\u0441\u0438\u043b\u0435\u043d.<\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 Jimfs \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442<\/h4>\n<ul>\n<li>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0435 \u043b\u043e\u0433\u0438\u043a\u0443, \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u00a0ACL\/xattrs.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c work\u2011with\u2011network\u2011share.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 JNI\u2011\u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e <code>fchmod()<\/code>\u00a0\u2014 Jimfs \u044d\u0442\u043e \u043d\u0435\u00a0\u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u00a0\u044d\u0442\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0431\u0435\u0440\u0438\u0442\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0434\u0438\u0441\u043a + <code>@TempDir(cleanup = NEVER)<\/code> \u0438 \u043f\u043e\u0434\u0447\u0438\u0449\u0430\u0439\u0442\u0435 \u0440\u0443\u043a\u0430\u043c\u0438 \u0432 <code>@AfterEach<\/code>.<\/p>\n<hr\/>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432\u00a0\u0442\u0435\u0441\u0442\u0430\u0445, \u043a\u0440\u0443\u0442\u0438\u0442\u0435 <code>deleteOnExit()<\/code> \u0438 \u043d\u0430\u0434\u0435\u0435\u0442\u0435\u0441\u044c, \u0447\u0442\u043e\u00a0CI \u0441\u0430\u043c \u043a\u0430\u043a\u2011\u043d\u0438\u0431\u0443\u0434\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u0442\u0441\u044f\u00a0\u2014 \u043f\u043e\u0440\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f. <code>@TempDir<\/code> \u0432\u00a0JUnit \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u0437\u043e\u043e\u043f\u0430\u0440\u043a \u043e\u0434\u043d\u0438\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u043e\u043c: \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 cleanup, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 in\u2011memory \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u0430\u00a0\u0441 5.10+\u00a0\u2014 \u0435\u0449\u0435 \u0438 \u0442\u043e\u043d\u043a\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0444\u0430\u0431\u0440\u0438\u043a\u0438. <\/p>\n<p>\u041d\u0435\u00a0\u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e <code>cleanup = ON_SUCCESS<\/code>, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u0442\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0444\u0435\u0439\u043b\u044b, \u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u0440\u0436\u0438\u0442\u0435 JUnit \u0432\u00a0\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438: \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 5.11\u20135.12, \u043f\u043e\u0444\u0438\u043a\u0448\u0435\u043d\u044b \u0431\u0430\u0433\u0438 \u0441\u00a0nested\u2011\u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u0441\u0438\u043c\u0432\u043e\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u0438 \u0440\u0430\u043d\u043d\u0438\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439. \u0422\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u044e <code>TempDirFactory<\/code>. \u041f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u0435 \u043e\u0434\u0438\u043d \u0432\u0435\u0447\u0435\u0440\u00a0\u2014 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u0435 \u0441\u043e\u0442\u043d\u0438 \u0432\u00a0\u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<p>\u0412\u00a0\u0446\u0435\u043b\u043e\u043c, \u043b\u044e\u0431\u043e\u0439 \u043a\u043e\u0434, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u00a0\u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439, \u0434\u043e\u043b\u0436\u0435\u043d\u00a0\u0431\u044b\u0442\u044c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d \u0432\u00a0\u0442\u0435\u0441\u0442\u0430\u0445. <code>@TempDir<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442, \u0447\u0438\u0441\u0442\u0438\u0442. \u0412\u0441\u0435, \u0447\u0442\u043e\u00a0\u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u043c\u00a0\u2014 \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443, \u043d\u0435\u00a0\u0434\u0443\u043c\u0430\u044f \u043e\u00a0\u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u0445. <\/p>\n<hr\/>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435\u0440\u044c\u0451\u0437 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441\u00a0\u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0432\u00a0Java\u00a0\u2014 \u0441\u00a0\u0432\u0430\u0441 \u043d\u0438\u043a\u0442\u043e \u043d\u0435\u00a0\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043d\u0430\u0438\u0437\u0443\u0441\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 @TempDir, Jimfs, FileChannel \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0435\u0439. \u041d\u043e\u00a0\u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0433\u0434\u0435 \u0438 \u043a\u0430\u043a\u00a0\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c,\u00a0\u2014 \u0443\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u043b\u044f\u00a0\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0433\u043b\u0443\u0431\u0436\u0435, \u0443\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u00a0\u043b\u043e\u043c\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u00a0CI,\u00a0\u2014 \u0437\u0430\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u0432\u00a0\u043d\u0430\u0448 \u043a\u0443\u0440\u0441 <a href=\"https:\/\/otus.pw\/Hy3V\/\" rel=\"noopener noreferrer nofollow\">\u00abJava Developer. Basic\u00bb<\/a>. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u00a0\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u0435\u0439\u0441\u0430\u0445, \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u0438\u00a0\u2014 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0438\u0437\u00a0\u0438\u043d\u0434\u0443\u0441\u0442\u0440\u0438\u0438.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0443\u00a0\u043d\u0430\u0441 \u043e\u0442\u043a\u0440\u044b\u0442 <a href=\"https:\/\/otus.pw\/TtQiZ\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u043a\u0443\u0440\u0441\u043e\u0432<\/a> OTUS, \u0433\u0434\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u00a0\u0441\u0432\u043e\u0439 \u0441\u0442\u0435\u043a \u0438 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432\u00a0<a href=\"https:\/\/otus.pw\/wHTl\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0443\u0440\u043e\u043a\u043e\u0432<\/a>. \u0422\u0430\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0447\u0442\u043e\u2011\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435\u00a0\u2014 \u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/920200\/\"> https:\/\/habr.com\/ru\/articles\/920200\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-464301","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/464301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=464301"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/464301\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=464301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=464301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=464301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}