forked from marceloverdijk/lesscss-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultithreadedIT.java
More file actions
70 lines (62 loc) · 1.81 KB
/
MultithreadedIT.java
File metadata and controls
70 lines (62 loc) · 1.81 KB
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
package integration;
import java.io.File;
import java.util.Arrays;
import org.apache.commons.io.FileUtils;
import org.jodah.concurrentunit.Waiter;
import org.junit.Before;
import org.junit.Test;
public class MultithreadedIT extends AbstractCompileIT {
final Waiter waiter = new Waiter();
@Before
public void setUp() throws Exception {
super.setUp();
lessCompiler.setCustomJs(Arrays.asList(
toURL("compatibility/custom.math.js"),
toURL("compatibility/custom.color.js"),
toURL("compatibility/custom.process.title.js")));
}
@Test
public void testMultithreaded() throws Throwable {
final String[] filenames = new String[]{
"colors",
"comments",
"css-3",
"css-escapes",
"css",
"functions",
"ie-filters",
"import_custom",
"import_custom",
"javascript",
"lazy-eval",
"media",
"mixins-args",
"mixins-closure",
"mixins-guards"
};
final int ITERATIONS = 5;
for(int i=0;i<ITERATIONS;i++){
for(final String filename : filenames){
new Thread(new Runnable() {
public void run() {
try{
testCompile(filename);
waiter.resume();
}catch(Throwable t){
waiter.fail(t);
}
}
}).start();
}
}
waiter.await(60*1000, ITERATIONS * filenames.length);
}
private void testCompile(String filename) throws Exception {
testCompile(toFile("compatibility/less/" + filename + ".less"), toFile("compatibility/css/" + filename + ".css"));
}
protected void testCompile(File lessFile, File cssFile) throws Exception {
String expected = FileUtils.readFileToString(cssFile);
String actual = lessCompiler.compile(lessFile);
waiter.assertEquals(expected.replace("\r\n", "\n"), actual);
}
}