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 int count() {
62 return this.cnt.get();
63 }
64
65 void await() {
66 try {
67 this.latch.await();
68 } catch (final InterruptedException ex) {
69 Thread.currentThread().interrupt();
70 }
71 }
72 }