1
2
3
4
5 package com.qulice.maven;
6
7 import com.qulice.spi.ResourceValidator;
8 import com.qulice.spi.Violation;
9 import java.io.File;
10 import java.util.Collection;
11 import java.util.Collections;
12 import java.util.concurrent.CountDownLatch;
13 import java.util.concurrent.atomic.AtomicInteger;
14
15
16
17
18
19
20
21
22
23
24
25
26
27 final class BlockedValidator implements ResourceValidator {
28
29
30
31
32 private final AtomicInteger cnt;
33
34
35
36
37 private final CountDownLatch latch;
38
39 BlockedValidator() {
40 this.cnt = new AtomicInteger(0);
41 this.latch = new CountDownLatch(1);
42 }
43
44 @Override
45 public Collection<Violation> validate(final Collection<File> ignore) {
46 this.cnt.incrementAndGet();
47 this.latch.countDown();
48 try {
49 Thread.sleep(Long.MAX_VALUE);
50 } catch (final InterruptedException ex) {
51 Thread.currentThread().interrupt();
52 }
53 return Collections.emptyList();
54 }
55
56 @Override
57 public String name() {
58 return "blocked forever";
59 }
60
61 @Override
62 public int rules() {
63 return 0;
64 }
65
66 int count() {
67 return this.cnt.get();
68 }
69
70 void await() {
71 try {
72 this.latch.await();
73 } catch (final InterruptedException ex) {
74 Thread.currentThread().interrupt();
75 }
76 }
77 }