Skip to content

Commit

Permalink
Fix style in test code (eclipse-tycho#2938)
Browse files Browse the repository at this point in the history
Improve variable locality.
Make error log assertion first, to facilitate investigation of
non-network failures.
  • Loading branch information
basilevs committed Oct 22, 2023
1 parent 5d5c11b commit a0121a4
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -68,26 +68,26 @@ 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
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
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
Expand All @@ -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) {
Expand Down

0 comments on commit a0121a4

Please sign in to comment.