Guest User

Untitled

a guest
Aug 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1.  
  2. /**
  3. * Created by IntelliJ IDEA.
  4. * User: mike
  5. * Date: 11/11/05
  6. * Time: 15:34
  7. * To change this template use File | Settings | File Templates.
  8. */
  9. import static groovyx.gpars.GParsPool.*;
  10.  
  11. def path = '/Users/mike/IdeaProjects/GradleSlowTest/src/test/java/orz/mikeneck/gradle/slow/test'
  12. def packagePath = path.replace('/Users/mike/IdeaProjects/GradleSlowTest/src/test/java/', '')
  13.  
  14. assert new File(path).isDirectory()
  15.  
  16. def head = $/package orz.mikeneck.gradle.slow.test;
  17. import org.junit.Before;
  18. import org.junit.Test;
  19. import java.util.List;
  20. import java.util.ArrayList;
  21. import static org.hamcrest.CoreMatchers.*;
  22. import static org.junit.Assert.*;
  23. /$
  24.  
  25. def body =$/
  26. public static final int SIZE = 100;
  27. private List<Integer> intList;
  28. @Test
  29. public void test() throws InterruptedException {
  30. int number = 0;
  31. for (Integer i : intList) {
  32. assertThat(i, is(number++));
  33. Thread.sleep(10);
  34. }
  35. }
  36. @Before
  37. public void setUp() {
  38. intList = new ArrayList<Integer>();
  39. for (int i = 0; i <= SIZE; i++ ) {
  40. intList.add(i);
  41. }
  42. }
  43. }
  44. /$
  45.  
  46. def tests = []
  47. (1..100).each {
  48. tests << it
  49. }
  50.  
  51. withPool {
  52. tests.collectParallel {test ->
  53. def className = "GradleTest${test}"
  54. def name = "${className}.java"
  55. def fileName = "${path}/${name}"
  56. def define = "public class ${className} {"
  57. def contents = new StringWriter()
  58. contents << head
  59. contents << define
  60. contents << body
  61. println '----'
  62. println "creating ${fileName}"
  63. new File(fileName).write(contents.toString(), 'UTF-8')
  64. assert new File(fileName).exists()
  65. }
  66. }
Add Comment
Please, Sign In to add comment