mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-25 00:31:38 +00:00
Add tests that reproduce #1384.
This commit is contained in:
parent
08f3497a9e
commit
bb619bfaf1
1 changed files with 41 additions and 0 deletions
|
@ -0,0 +1,41 @@
|
|||
package uk.ac.ic.wlgitbridge.snapshot.push;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import uk.ac.ic.wlgitbridge.snapshot.push.exception.InternalErrorException;
|
||||
import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
|
||||
import uk.ac.ic.wlgitbridge.snapshot.push.exception.UnexpectedPostbackException;
|
||||
|
||||
/**
|
||||
* Created by winston on 05/04/2016.
|
||||
*/
|
||||
public class PostbackManagerTest {
|
||||
|
||||
private final PostbackManager postbackManager = new PostbackManager();
|
||||
|
||||
@Test
|
||||
public void testRaceWithVersionId()
|
||||
throws UnexpectedPostbackException,
|
||||
SnapshotPostException {
|
||||
String key = postbackManager.makeKeyForProject("proj");
|
||||
postbackManager.postVersionIDForProject("proj", 1, key);
|
||||
int versionId = postbackManager.waitForVersionIdOrThrow("proj");
|
||||
Assert.assertEquals("Version id didn't match posted", 1, versionId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRaceWithException() throws UnexpectedPostbackException,
|
||||
SnapshotPostException {
|
||||
String key = postbackManager.makeKeyForProject("proj");
|
||||
InternalErrorException ex = new InternalErrorException();
|
||||
postbackManager.postExceptionForProject("proj", ex, key);
|
||||
try {
|
||||
postbackManager.waitForVersionIdOrThrow("proj");
|
||||
} catch (InternalErrorException e) {
|
||||
Assert.assertSame("Wrong exception was thrown", ex, e);
|
||||
return;
|
||||
}
|
||||
Assert.fail("Exception wasn't thrown as required");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue