|
@@ -0,0 +1,47 @@
|
|
1
|
+package io.zipcoder;
|
|
2
|
+
|
|
3
|
+import org.junit.Before;
|
|
4
|
+import org.junit.Test;
|
|
5
|
+
|
|
6
|
+import static org.junit.Assert.*;
|
|
7
|
+
|
|
8
|
+public class SafeCopierTest {
|
|
9
|
+
|
|
10
|
+ String introduction;
|
|
11
|
+
|
|
12
|
+ @Before
|
|
13
|
+ public void setUp(){
|
|
14
|
+ introduction = "It was the best of times,\n" +
|
|
15
|
+ "it was the blurst of times,\n" +
|
|
16
|
+ "it was the age of wisdom,\n" +
|
|
17
|
+ "it was the age of foolishness,\n" +
|
|
18
|
+ "it was the epoch of belief,\n" +
|
|
19
|
+ "it was the epoch of incredulity,\n" +
|
|
20
|
+ "it was the season of Light,\n" +
|
|
21
|
+ "it was the season of Darkness,\n" +
|
|
22
|
+ "it was the spring of hope,\n" +
|
|
23
|
+ "it was the winter of despair,\n" +
|
|
24
|
+ "we had everything before us,\n" +
|
|
25
|
+ "we had nothing before us,\n" +
|
|
26
|
+ "we were all going direct to Heaven,\n" +
|
|
27
|
+ "we were all going direct the other way--\n" +
|
|
28
|
+ "in short, the period was so far like the present period, that some of\n" +
|
|
29
|
+ "its noisiest authorities insisted on its being received, for good or for\n" +
|
|
30
|
+ "evil, in the superlative degree of comparison only.";
|
|
31
|
+ }
|
|
32
|
+ @Test
|
|
33
|
+ public void run() {
|
|
34
|
+ SafeCopier safeCopier = new SafeCopier(introduction);
|
|
35
|
+ Thread monkeySafe1 = new Thread(safeCopier);
|
|
36
|
+ Thread monkeySafe2 = new Thread(safeCopier);
|
|
37
|
+ Thread monkeySafe3 = new Thread(safeCopier);
|
|
38
|
+ Thread monkeySafe4 = new Thread(safeCopier);
|
|
39
|
+ Thread monkeySafe5 = new Thread(safeCopier);
|
|
40
|
+
|
|
41
|
+ monkeySafe1.start();
|
|
42
|
+ monkeySafe2.start();
|
|
43
|
+ monkeySafe3.start();
|
|
44
|
+ monkeySafe4.start();
|
|
45
|
+ monkeySafe5.start();
|
|
46
|
+ }
|
|
47
|
+}
|