Merge pull request #59 from das7pad/tests/cleanup-resources

[tests] cleanup resources
This commit is contained in:
Shane Kilkelly 2019-08-01 16:26:51 +01:00 committed by GitHub
commit 3fac2cc825
5 changed files with 81 additions and 97 deletions

View file

@ -47,6 +47,14 @@ public class MockSnapshotServer {
port = ((NetworkConnector) server.getConnectors()[0]).getLocalPort();
}
public void stop() {
try {
server.stop();
} catch (Exception e) {
Log.warn("Exception when trying to stop server", e);
}
}
public void setState(SnapshotAPIState state) {
responseBuilder.setState(state);
}

View file

@ -5,6 +5,7 @@ import org.apache.commons.io.IOUtils;
import static org.asynchttpclient.Dsl.*;
import org.asynchttpclient.*;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -137,6 +138,8 @@ public class WLGitBridgeIntegrationTest {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
private MockSnapshotServer server;
private GitBridgeApp wlgb;
private File dir;
@Before
@ -144,6 +147,12 @@ public class WLGitBridgeIntegrationTest {
dir = folder.newFolder();
}
@After
public void tearDown() {
server.stop();
wlgb.stop();
}
private void gitConfig(File dir) throws IOException, InterruptedException {
assertEquals(0, runtime.exec(
"git config user.name TEST", null, dir
@ -224,40 +233,38 @@ public class WLGitBridgeIntegrationTest {
@Test
public void canCloneARepository() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3857, getResource("/canCloneARepository").toFile());
server = new MockSnapshotServer(3857, getResource("/canCloneARepository").toFile());
server.start();
server.setState(states.get("canCloneARepository").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33857, 3857)
});
wlgb.run();
File testprojDir = gitClone("testproj", 33857, dir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canCloneARepository/state/testproj"), testprojDir.toPath()));
}
@Test
public void canCloneMultipleRepositories() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3858, getResource("/canCloneMultipleRepositories").toFile());
server = new MockSnapshotServer(3858, getResource("/canCloneMultipleRepositories").toFile());
server.start();
server.setState(states.get("canCloneMultipleRepositories").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33858, 3858)
});
wlgb.run();
File testproj1Dir = gitClone("testproj1", 33858, dir);
File testproj2Dir = gitClone("testproj2", 33858, dir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canCloneMultipleRepositories/state/testproj1"), testproj1Dir.toPath()));
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canCloneMultipleRepositories/state/testproj2"), testproj2Dir.toPath()));
}
@Test
public void canPullAModifiedTexFile() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3859, getResource("/canPullAModifiedTexFile").toFile());
server = new MockSnapshotServer(3859, getResource("/canPullAModifiedTexFile").toFile());
server.start();
server.setState(states.get("canPullAModifiedTexFile").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33859, 3859)
});
wlgb.run();
@ -265,16 +272,15 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedTexFile/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullAModifiedTexFile").get("withModifiedTexFile"));
gitPull(testprojDir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedTexFile/withModifiedTexFile/testproj"), testprojDir.toPath()));
}
@Test
public void canPullADeletedTexFile() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3860, getResource("/canPullADeletedTexFile").toFile());
server = new MockSnapshotServer(3860, getResource("/canPullADeletedTexFile").toFile());
server.start();
server.setState(states.get("canPullADeletedTexFile").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33860, 3860)
});
wlgb.run();
@ -282,16 +288,15 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADeletedTexFile/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullADeletedTexFile").get("withDeletedTexFile"));
gitPull(testprojDir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADeletedTexFile/withDeletedTexFile/testproj"), testprojDir.toPath()));
}
@Test
public void canPullAModifiedBinaryFile() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3862, getResource("/canPullAModifiedBinaryFile").toFile());
server = new MockSnapshotServer(3862, getResource("/canPullAModifiedBinaryFile").toFile());
server.start();
server.setState(states.get("canPullAModifiedBinaryFile").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33862, 3862)
});
wlgb.run();
@ -299,16 +304,15 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedBinaryFile/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullAModifiedBinaryFile").get("withModifiedBinaryFile"));
gitPull(testprojDir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedBinaryFile/withModifiedBinaryFile/testproj"), testprojDir.toPath()));
}
@Test
public void canPullADeletedBinaryFile() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3863, getResource("/canPullADeletedBinaryFile").toFile());
server = new MockSnapshotServer(3863, getResource("/canPullADeletedBinaryFile").toFile());
server.start();
server.setState(states.get("canPullADeletedBinaryFile").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33863, 3863)
});
wlgb.run();
@ -316,16 +320,15 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADeletedBinaryFile/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullADeletedBinaryFile").get("withDeletedBinaryFile"));
gitPull(testprojDir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADeletedBinaryFile/withDeletedBinaryFile/testproj"), testprojDir.toPath()));
}
@Test
public void canPullADuplicateBinaryFile() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(4001, getResource("/canPullADuplicateBinaryFile").toFile());
server = new MockSnapshotServer(4001, getResource("/canPullADuplicateBinaryFile").toFile());
server.start();
server.setState(states.get("canPullADuplicateBinaryFile").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(44001, 4001)
});
wlgb.run();
@ -333,30 +336,28 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADuplicateBinaryFile/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullADuplicateBinaryFile").get("withDuplicateBinaryFile"));
gitPull(testprojDir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADuplicateBinaryFile/withDuplicateBinaryFile/testproj"), testprojDir.toPath()));
}
@Test
public void canCloneDuplicateBinaryFiles() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(4002, getResource("/canCloneDuplicateBinaryFiles").toFile());
server = new MockSnapshotServer(4002, getResource("/canCloneDuplicateBinaryFiles").toFile());
server.start();
server.setState(states.get("canCloneDuplicateBinaryFiles").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(44002, 4002)
});
wlgb.run();
File testprojDir = gitClone("testproj", 44002, dir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canCloneDuplicateBinaryFiles/state/testproj"), testprojDir.toPath()));
}
@Test
public void canPullUpdatedBinaryFiles() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(4003, getResource("/canPullUpdatedBinaryFiles").toFile());
server = new MockSnapshotServer(4003, getResource("/canPullUpdatedBinaryFiles").toFile());
server.start();
server.setState(states.get("canPullUpdatedBinaryFiles").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(44003, 4003)
});
wlgb.run();
@ -364,16 +365,15 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullUpdatedBinaryFiles/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullUpdatedBinaryFiles").get("withUpdatedBinaryFiles"));
gitPull(testprojDir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullUpdatedBinaryFiles/withUpdatedBinaryFiles/testproj"), testprojDir.toPath()));
}
@Test
public void canPullAModifiedNestedFile() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3864, getResource("/canPullAModifiedNestedFile").toFile());
server = new MockSnapshotServer(3864, getResource("/canPullAModifiedNestedFile").toFile());
server.start();
server.setState(states.get("canPullAModifiedNestedFile").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33864, 3864)
});
wlgb.run();
@ -381,16 +381,15 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedNestedFile/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullAModifiedNestedFile").get("withModifiedNestedFile"));
gitPull(testprojDir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedNestedFile/withModifiedNestedFile/testproj"), testprojDir.toPath()));
}
@Test
public void canPullDeletedNestedFiles() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3865, getResource("/canPullDeletedNestedFiles").toFile());
server = new MockSnapshotServer(3865, getResource("/canPullDeletedNestedFiles").toFile());
server.start();
server.setState(states.get("canPullDeletedNestedFiles").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33865, 3865)
});
wlgb.run();
@ -398,15 +397,14 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullDeletedNestedFiles/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullDeletedNestedFiles").get("withDeletedNestedFiles"));
gitPull(testprojDir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj"), testprojDir.toPath()));
}
@Test
public void canPushFilesSuccessfully() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3866, getResource("/canPushFilesSuccessfully").toFile());
server = new MockSnapshotServer(3866, getResource("/canPushFilesSuccessfully").toFile());
server.start();
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33866, 3866)
});
wlgb.run();
@ -417,7 +415,6 @@ public class WLGitBridgeIntegrationTest {
gitAdd(testprojDir);
gitCommit(testprojDir, "push");
gitPush(testprojDir);
wlgb.stop();
}
private static final String EXPECTED_OUT_PUSH_OUT_OF_DATE_FIRST =
@ -429,10 +426,10 @@ public class WLGitBridgeIntegrationTest {
@Test
public void pushFailsOnFirstStageOutOfDate() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3867, getResource("/pushFailsOnFirstStageOutOfDate").toFile());
server = new MockSnapshotServer(3867, getResource("/pushFailsOnFirstStageOutOfDate").toFile());
server.start();
server.setState(states.get("pushFailsOnFirstStageOutOfDate").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33867, 3867)
});
wlgb.run();
@ -442,7 +439,6 @@ public class WLGitBridgeIntegrationTest {
gitAdd(testprojDir);
gitCommit(testprojDir, "push");
Process push = gitPush(testprojDir, 1);
wlgb.stop();
assertEquals(EXPECTED_OUT_PUSH_OUT_OF_DATE_FIRST, Util.fromStream(push.getErrorStream(), 2));
}
@ -455,10 +451,10 @@ public class WLGitBridgeIntegrationTest {
@Test
public void pushFailsOnSecondStageOutOfDate() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3868, getResource("/pushFailsOnSecondStageOutOfDate").toFile());
server = new MockSnapshotServer(3868, getResource("/pushFailsOnSecondStageOutOfDate").toFile());
server.start();
server.setState(states.get("pushFailsOnSecondStageOutOfDate").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33868, 3868)
});
wlgb.run();
@ -468,7 +464,6 @@ public class WLGitBridgeIntegrationTest {
gitAdd(testprojDir);
gitCommit(testprojDir, "push");
Process push = gitPush(testprojDir, 1);
wlgb.stop();
assertEquals(EXPECTED_OUT_PUSH_OUT_OF_DATE_SECOND, Util.fromStream(push.getErrorStream(), 2));
}
@ -485,10 +480,10 @@ public class WLGitBridgeIntegrationTest {
@Test
public void pushFailsOnInvalidFiles() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3869, getResource("/pushFailsOnInvalidFiles").toFile());
server = new MockSnapshotServer(3869, getResource("/pushFailsOnInvalidFiles").toFile());
server.start();
server.setState(states.get("pushFailsOnInvalidFiles").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33869, 3869)
});
wlgb.run();
@ -498,7 +493,6 @@ public class WLGitBridgeIntegrationTest {
gitAdd(testprojDir);
gitCommit(testprojDir, "push");
Process push = gitPush(testprojDir, 1);
wlgb.stop();
List<String> actual = Util.linesFromStream(push.getErrorStream(), 2, "[K");
assertEquals(EXPECTED_OUT_PUSH_INVALID_FILES, actual);
}
@ -513,10 +507,10 @@ public class WLGitBridgeIntegrationTest {
@Test
public void pushFailsOnInvalidProject() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3870, getResource("/pushFailsOnInvalidProject").toFile());
server = new MockSnapshotServer(3870, getResource("/pushFailsOnInvalidProject").toFile());
server.start();
server.setState(states.get("pushFailsOnInvalidProject").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33870, 3870)
});
wlgb.run();
@ -526,7 +520,6 @@ public class WLGitBridgeIntegrationTest {
gitAdd(testprojDir);
gitCommit(testprojDir, "push");
Process push = gitPush(testprojDir, 1);
wlgb.stop();
List<String> actual = Util.linesFromStream(push.getErrorStream(), 2, "[K");
assertEquals(EXPECTED_OUT_PUSH_INVALID_PROJECT, actual);
}
@ -542,10 +535,10 @@ public class WLGitBridgeIntegrationTest {
/* this one prints a stack trace */
@Test
public void pushFailsOnUnexpectedError() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3871, getResource("/pushFailsOnUnexpectedError").toFile());
server = new MockSnapshotServer(3871, getResource("/pushFailsOnUnexpectedError").toFile());
server.start();
server.setState(states.get("pushFailsOnUnexpectedError").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33871, 3871)
});
wlgb.run();
@ -555,7 +548,6 @@ public class WLGitBridgeIntegrationTest {
gitAdd(testprojDir);
gitCommit(testprojDir, "push");
Process push = gitPush(testprojDir, 1);
wlgb.stop();
List<String> actual = Util.linesFromStream(push.getErrorStream(), 2, "[K");
assertEquals(EXPECTED_OUT_PUSH_UNEXPECTED_ERROR, actual);
}
@ -572,10 +564,10 @@ public class WLGitBridgeIntegrationTest {
@Test
public void pushSucceedsAfterRemovingInvalidFiles() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3872, getResource("/pushSucceedsAfterRemovingInvalidFiles").toFile());
server = new MockSnapshotServer(3872, getResource("/pushSucceedsAfterRemovingInvalidFiles").toFile());
server.start();
server.setState(states.get("pushSucceedsAfterRemovingInvalidFiles").get("invalidState"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33872, 3872)
});
wlgb.run();
@ -595,7 +587,6 @@ public class WLGitBridgeIntegrationTest {
gitCommit(testprojDir, "remove_invalid_file");
server.setState(states.get("pushSucceedsAfterRemovingInvalidFiles").get("validState"));
gitPush(testprojDir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/pushSucceedsAfterRemovingInvalidFiles/validState/testproj"), testprojDir.toPath()));
}
@ -609,12 +600,12 @@ public class WLGitBridgeIntegrationTest {
int gitBridgePort = 33873;
int mockServerPort = 3873;
MockSnapshotServer server = new MockSnapshotServer(
server = new MockSnapshotServer(
mockServerPort, getResource("/canServePushedFiles").toFile());
server.start();
server.setState(states.get("canServePushedFiles").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(gitBridgePort, mockServerPort)
});
wlgb.run();
@ -646,19 +637,18 @@ public class WLGitBridgeIntegrationTest {
response = asyncHttpClient().prepareGet(url).execute().get();
assertEquals(404, response.getStatusCode());
wlgb.stop();
}
@Test
public void wlgbCanSwapProjects(
) throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(
server = new MockSnapshotServer(
3874,
getResource("/wlgbCanSwapProjects").toFile()
);
server.start();
server.setState(states.get("wlgbCanSwapProjects").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33874, 3874, new SwapJobConfig(1, 0, 0, 250))
});
wlgb.run();
@ -677,7 +667,6 @@ public class WLGitBridgeIntegrationTest {
while (testProj2ServerDir.exists());
assertTrue(testProj1ServerDir.exists());
assertFalse(testProj2ServerDir.exists());
wlgb.stop();
}
private static final List<String> EXPECTED_OUT_PUSH_SUBMODULE = Arrays.asList(
@ -691,10 +680,10 @@ public class WLGitBridgeIntegrationTest {
@Test
public void pushSubmoduleFailsWithInvalidGitRepo() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3875, getResource("/pushSubmoduleFailsWithInvalidGitRepo").toFile());
server = new MockSnapshotServer(3875, getResource("/pushSubmoduleFailsWithInvalidGitRepo").toFile());
server.start();
server.setState(states.get("pushSubmoduleFailsWithInvalidGitRepo").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33875, 3875)
});
wlgb.run();
@ -708,10 +697,8 @@ public class WLGitBridgeIntegrationTest {
gitAdd(testprojDir);
gitCommit(testprojDir, "push");
Process push = gitPush(testprojDir, 1);
wlgb.stop();
List<String> actual = Util.linesFromStream(push.getErrorStream(), 2, "[K");
assertEquals(EXPECTED_OUT_PUSH_SUBMODULE, actual);
wlgb.stop();
}
@Test
@ -721,12 +708,12 @@ public class WLGitBridgeIntegrationTest {
int gitBridgePort = 33873;
int mockServerPort = 3873;
MockSnapshotServer server = new MockSnapshotServer(
server = new MockSnapshotServer(
mockServerPort, getResource("/canServePushedFiles").toFile());
server.start();
server.setState(states.get("canServePushedFiles").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(gitBridgePort, mockServerPort)
});
wlgb.run();
@ -744,8 +731,6 @@ public class WLGitBridgeIntegrationTest {
response = asyncHttpClient().prepareGet(url).execute().get();
assertEquals(500, response.getStatusCode());
assertEquals("{\"message\":\"HTTP error 500\"}", response.getResponseBody());
wlgb.stop();
}
@Test
@ -753,16 +738,15 @@ public class WLGitBridgeIntegrationTest {
int gitBridgePort = 33883;
int mockServerPort = 3883;
MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/cannotCloneAProtectedProjectWithoutAuthentication").toFile());
server = new MockSnapshotServer(mockServerPort, getResource("/cannotCloneAProtectedProjectWithoutAuthentication").toFile());
server.start();
server.setState(states.get("cannotCloneAProtectedProjectWithoutAuthentication").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(gitBridgePort, mockServerPort)
});
wlgb.run();
Process gitProcess = runtime.exec("git clone http://127.0.0.1:" + gitBridgePort + "/testproj.git", null, dir);
wlgb.stop();
assertNotEquals(0, gitProcess.waitFor());
}
@ -771,16 +755,15 @@ public class WLGitBridgeIntegrationTest {
int gitBridgePort = 33879;
int mockServerPort = 3879;
MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/cannotCloneA4xxProject").toFile());
server = new MockSnapshotServer(mockServerPort, getResource("/cannotCloneA4xxProject").toFile());
server.start();
server.setState(states.get("cannotCloneA4xxProject").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(gitBridgePort, mockServerPort)
});
wlgb.run();
Process gitProcess = runtime.exec("git clone http://127.0.0.1:" + gitBridgePort + "/testproj.git", null, dir);
wlgb.stop();
assertNotEquals(0, gitProcess.waitFor());
}
@ -789,16 +772,15 @@ public class WLGitBridgeIntegrationTest {
int gitBridgePort = 33880;
int mockServerPort = 3880;
MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/cannotCloneAMissingProject").toFile());
server = new MockSnapshotServer(mockServerPort, getResource("/cannotCloneAMissingProject").toFile());
server.start();
server.setState(states.get("cannotCloneAMissingProject").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(gitBridgePort, mockServerPort)
});
wlgb.run();
Process gitProcess = runtime.exec("git clone http://127.0.0.1:" + gitBridgePort + "/testproj.git", null, dir);
wlgb.stop();
assertNotEquals(0, gitProcess.waitFor());
}
@ -806,17 +788,15 @@ public class WLGitBridgeIntegrationTest {
public void canMigrateRepository() throws IOException, GitAPIException, InterruptedException {
int gitBridgePort = 33881;
int mockServerPort = 3881;
MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/canMigrateRepository").toFile());
server = new MockSnapshotServer(mockServerPort, getResource("/canMigrateRepository").toFile());
server.start();
server.setState(states.get("canMigrateRepository").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(gitBridgePort, mockServerPort)
});
wlgb.run();
File testprojDir = gitClone("testproj", gitBridgePort, dir);
File testprojDir2 = gitClone("testproj2", gitBridgePort, dir);
wlgb.stop();
// Second project content is equal to content of the first
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canMigrateRepository/state/testproj"), testprojDir2.toPath()));
}
@ -825,17 +805,15 @@ public class WLGitBridgeIntegrationTest {
public void skipMigrationWhenMigratedFromMissing() throws IOException, GitAPIException, InterruptedException {
int gitBridgePort = 33882;
int mockServerPort = 3882;
MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/skipMigrationWhenMigratedFromMissing").toFile());
server = new MockSnapshotServer(mockServerPort, getResource("/skipMigrationWhenMigratedFromMissing").toFile());
server.start();
server.setState(states.get("skipMigrationWhenMigratedFromMissing").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(gitBridgePort, mockServerPort)
});
wlgb.run();
// don't clone the source project first
File testprojDir2 = gitClone("testproj2", gitBridgePort, dir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/skipMigrationWhenMigratedFromMissing/state/testproj2"), testprojDir2.toPath()));
}
@ -843,15 +821,14 @@ public class WLGitBridgeIntegrationTest {
public void canCloneAMigratedRepositoryWithoutChanges() throws IOException, GitAPIException, InterruptedException {
int gitBridgePort = 33883;
int mockServerPort = 3883;
MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/canCloneAMigratedRepositoryWithoutChanges").toFile());
server = new MockSnapshotServer(mockServerPort, getResource("/canCloneAMigratedRepositoryWithoutChanges").toFile());
server.start();
server.setState(states.get("canCloneAMigratedRepositoryWithoutChanges").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(gitBridgePort, mockServerPort)
});
wlgb.run();
File testprojDir = gitClone("testproj_no_change", gitBridgePort, dir);
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canCloneAMigratedRepositoryWithoutChanges/state/testproj_no_change"), testprojDir.toPath()));
}
@ -859,15 +836,14 @@ public class WLGitBridgeIntegrationTest {
public void rejectV1Repository() throws IOException, GitAPIException, InterruptedException {
int gitBridgePort = 33884;
int mockServerPort = 3884;
MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/rejectV1Repository").toFile());
server = new MockSnapshotServer(mockServerPort, getResource("/rejectV1Repository").toFile());
server.start();
server.setState(states.get("rejectV1Repository").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
wlgb = new GitBridgeApp(new String[] {
makeConfigFile(gitBridgePort, mockServerPort)
});
wlgb.run();
Process gitProcess = runtime.exec("git clone http://127.0.0.1:" + gitBridgePort + "/1234bbccddff.git", null, dir);
wlgb.stop();
assertNotEquals(0, gitProcess.waitFor());
}

View file

@ -24,7 +24,7 @@
],
"atts": [
{
"url": "http://127.0.0.1:3857/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
"url": "http://127.0.0.1:3881/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
"path": "min_mean_wait_evm_7_eps_150dpi.png"
}
]
@ -68,7 +68,7 @@
],
"atts": [
{
"url": "http://127.0.0.1:3857/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
"url": "http://127.0.0.1:3881/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
"path": "min_mean_wait_evm_7_eps_150dpi.png"
}
]

View file

@ -31,7 +31,7 @@
],
"atts": [
{
"url": "http://127.0.0.1:3857/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
"url": "http://127.0.0.1:3884/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
"path": "min_mean_wait_evm_7_eps_150dpi.png"
}
]

View file

@ -24,7 +24,7 @@
],
"atts": [
{
"url": "http://127.0.0.1:3857/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
"url": "http://127.0.0.1:3882/state/testproj2/min_mean_wait_evm_7_eps_150dpi.png",
"path": "min_mean_wait_evm_7_eps_150dpi.png"
}
]