-
Notifications
You must be signed in to change notification settings - Fork 52
/
AddMultipleFilesTest.java
94 lines (73 loc) · 2.96 KB
/
AddMultipleFilesTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package saros.stf.test.consistency;
import static org.junit.Assert.assertTrue;
import static saros.stf.client.tester.SarosTester.ALICE;
import static saros.stf.client.tester.SarosTester.BOB;
import org.junit.BeforeClass;
import org.junit.Test;
import saros.stf.client.StfTestCase;
import saros.stf.client.util.EclipseTestThread;
import saros.stf.client.util.Util;
public class AddMultipleFilesTest extends StfTestCase {
@BeforeClass
public static void selectTesters() throws Exception {
select(ALICE, BOB);
}
private EclipseTestThread alice;
private EclipseTestThread bob;
/*
* So what is going wrong here ? Alice sends a big file, that is now
* processed in the SharedResourceManager which ACCIDENTLY locks out all
* threads. While we are writing the big file in the SWT GUI thread, we
* adding more files from the RMI thread. The SharedResourceManager is
* locked and so refused to process the newly generated files. Found this
* bug while playing around with Saros Light. This test simulates are real
* scenario: multiple users add files per drag and drop at the same time.
*/
@Test
public void testAddMultipleFilesSimultaneouslyTest() throws Exception {
Util.setUpSessionWithProjectAndFile("foo", "main", "main", ALICE, BOB);
BOB.superBot().views().packageExplorerView().waitUntilResourceIsShared("foo/main");
EclipseTestThread.Runnable aliceFileTask =
new EclipseTestThread.Runnable() {
@Override
public void run() throws Exception {
for (int i = 0; i < 10; i++) {
if (Thread.currentThread().isInterrupted()) break;
ALICE.superBot().internal().createFile("foo", "bigfile" + i, 10 * 1024 * 1024, true);
}
}
};
EclipseTestThread.Runnable bobFileTask =
new EclipseTestThread.Runnable() {
@Override
public void run() throws Exception {
for (int i = 0; i < 1000; i++) {
if (Thread.currentThread().isInterrupted()) break;
BOB.superBot().internal().createFile("foo", "smallfile" + i, 100 * 1024, true);
}
}
};
alice = createTestThread(aliceFileTask);
bob = createTestThread(bobFileTask);
bob.start();
alice.start();
Util.joinAll(2 * 60 * 1000, alice, bob);
alice.verify();
bob.verify();
BOB.controlBot()
.getNetworkManipulator()
.synchronizeOnActivityQueue(ALICE.getJID(), 2 * 60 * 1000);
ALICE
.controlBot()
.getNetworkManipulator()
.synchronizeOnActivityQueue(BOB.getJID(), 2 * 60 * 1000);
for (int i = 0; i < 1000; i++) {
assertTrue(
"file " + "foo/smallfile" + i + " does not exist on ALICEs side",
ALICE.superBot().internal().existsResource("foo/smallfile" + i));
assertTrue(
"file " + "foo/smallfile" + i + " does not exist on BOBs side",
BOB.superBot().internal().existsResource("foo/smallfile" + i));
}
}
}