From a0121a44ca242a13f63d5a50138ef884b2a3ad3a Mon Sep 17 00:00:00 2001 From: Vasili Gulevich Date: Sun, 22 Oct 2023 11:17:22 +0400 Subject: [PATCH] Fix style in test code (#2938) Improve variable locality. Make error log assertion first, to facilitate investigation of non-network failures. --- .../tycho/test/tycho2938/ContentJarTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/tycho2938/ContentJarTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/tycho2938/ContentJarTest.java index 2d3f93b2b1..467924882f 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/tycho2938/ContentJarTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/tycho2938/ContentJarTest.java @@ -49,12 +49,12 @@ public class ContentJarTest extends AbstractTychoIntegrationTest { @Before public void startServer() throws Exception { server = HttpServer.startServer(); + File repositoryRoot = temporaryFolder.getRoot(); + this.mainRepoUrl = server.addServer("repoA", repositoryRoot); File originalResource = ResourceUtil.resolveTestResource("repositories/content_jar"); - FileUtils.copyDirectory(originalResource, temporaryFolder.getRoot()); + FileUtils.copyDirectory(originalResource, repositoryRoot); verifier = getVerifier("target.content_jar", false); verifier.deleteArtifacts("p2.org.eclipse.update.feature", "issue_2938_reproducer", "1.0.0.202310211419"); - File repositoryRoot = temporaryFolder.getRoot(); - this.mainRepoUrl = server.addServer("repoA", repositoryRoot); } @After @@ -68,8 +68,8 @@ public void stopServer() throws Exception { public void noRedirect() throws Exception { configureRepositoryInTargetDefinition(mainRepoUrl); verifier.executeGoal("package"); - assertVisited(TARGET_FEATURE_PATH); verifier.verifyErrorFreeLog(); + assertVisited(TARGET_FEATURE_PATH); } @Test @@ -77,8 +77,8 @@ public void redirectKeepFilename() throws Exception { String redirectedUrl = server.addRedirect("repoB", originalPath -> mainRepoUrl + originalPath); configureRepositoryInTargetDefinition(redirectedUrl); verifier.executeGoal("package"); - assertVisited(TARGET_FEATURE_PATH); verifier.verifyErrorFreeLog(); + assertVisited(TARGET_FEATURE_PATH); } @Test @@ -86,8 +86,8 @@ public void redirectToBadLocation() throws Exception { String redirectedUrl = server.addRedirect("repoB", originalPath -> mainRepoUrl + originalPath + "_invalid"); configureRepositoryInTargetDefinition(redirectedUrl); Assert.assertThrows(VerificationException.class, () -> verifier.executeGoal("package")); - assertVisited("/content.jar_invalid"); verifier.verifyTextInLog("No repository found at " + redirectedUrl); + assertVisited("/content.jar_invalid"); } @Test @@ -101,9 +101,9 @@ public void redirectToMangledLocations() throws Exception { configureRepositoryInTargetDefinition(redirectedUrl); verifier.executeGoal("package"); + verifier.verifyErrorFreeLog(); assertVisited("/content.jar_invalid"); assertVisited(TARGET_FEATURE_PATH + "_invalid"); - verifier.verifyErrorFreeLog(); } private void assertVisited(String path) {