Merge branch 'develop' into feature/hg_hooks_over_tcp

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Sebastian Sdorra
2020-11-27 08:57:09 +01:00
68 changed files with 1134 additions and 401 deletions

View File

@@ -59,8 +59,13 @@ class PendingPluginInstallationTest {
}
@Test
void shouldThrowExceptionIfCancelFailed(@TempDir Path directory) {
void shouldThrowExceptionIfCancelFailed(@TempDir Path directory) throws IOException {
Path file = directory.resolve("file");
Files.createDirectory(file);
Path makeFileNotDeletable = file.resolve("not_deletable");
Files.write(makeFileNotDeletable, "42".getBytes());
when(plugin.getDescriptor().getInformation().getName()).thenReturn("scm-awesome-plugin");
PendingPluginInstallation installation = new PendingPluginInstallation(plugin, file);

View File

@@ -48,12 +48,15 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
@@ -239,6 +242,30 @@ class I18nServletTest {
assertJson(json);
}
@Test
void shouldNotHaveInvalidPluginsJsonFiles() throws IOException {
String path = getClass().getClassLoader().getResource("locales/en/plugins.json").getPath();
assertThat(path).isNotNull();
Path filePath = Paths.get(path);
Path translationRootPath = filePath.getParent().getParent();
assertThat(translationRootPath).isDirectoryContaining("glob:**/en");
Files
.list(translationRootPath)
.filter(Files::isDirectory)
.map(localePath -> localePath.resolve("plugins.json"))
.forEach(this::validatePluginsJson);
}
private void validatePluginsJson(Path path) {
try {
new ObjectMapper().readTree(path.toFile());
} catch (IOException e) {
fail("error while parsing translation file " + path, e);
}
}
private void verifyHeaders(HttpServletResponse response) {
verify(response).setCharacterEncoding("UTF-8");
verify(response).setContentType("application/json");