/
sazonovim
/
init-spring
Обзор
Документация
Войти
/
sazonovim
/
init-spring
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/test/java/pro/nikolaev/initspring/util/FilesUtilsTest.java
73 строки
3 KB
Nikolaev Ilya V
added custom TreeCellRenderer for Tree nodes to use actual checkboxes instead of icons for more consistent ui. code clean up and formatting
04 янв 2026, 00:12
04 янв 2026, 00:12
6cdae1c
Код
Авторство
О чём код?
/* * Copyright 2025 Ilya Nikolaev * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package pro.nikolaev.initspring.util; import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; class FilesUtilsTest { /** * src/test/resources/test-archive.zip contains test-archive directory, which contains a tree of files * This test checks if contents of test-archive directory are successfully uncompressed * to a temporary directory * <p> * test-archive directory itself should not appear inside temporary directory * */ @Test void unzipArchive() throws IOException { URL archiveUrl = getClass().getClassLoader().getResource("test-archive.zip"); URL originUrl = getClass().getClassLoader().getResource("test-archive"); Path tmpDir = Files.createTempDirectory(null); FilesUtils.unzipArchive(new File(archiveUrl.getFile()), tmpDir.toFile()); Path originRoot = new File(originUrl.getPath()).toPath(); final List<Path> originFiles; try (Stream<Path> it = Files.walk(originRoot)) { originFiles = it.toList(); } for (Path origin : originFiles) { Path originTail = originRoot.relativize(origin); Path uncompressed = tmpDir.resolve(originTail); assertTrue(Files.exists(uncompressed), () -> "There is no corresponding file for '" + origin + "' . " + " There should exist '" + originTail + "' among uncompressed files. " + " Full path for non existent file: '" + uncompressed + "'" ); if (Files.isRegularFile(uncompressed)) { assertEquals(-1, Files.mismatch(uncompressed, origin), () -> "Files '" + uncompressed + "' and " + "'" + origin + "'" + "are supposed to be identical, but they are not" ); } } } }