1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.artifact.resolver;
20
21 import javax.inject.Inject;
22
23 import java.util.Collections;
24
25 import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
26 import org.apache.maven.artifact.Artifact;
27 import org.junit.jupiter.api.BeforeEach;
28 import org.junit.jupiter.api.Test;
29
30 import static org.junit.jupiter.api.Assertions.assertTrue;
31
32 @Deprecated
33 class DefaultArtifactResolverTest extends AbstractArtifactComponentTestCase {
34 @Inject
35 private ArtifactResolver artifactResolver;
36
37 private Artifact projectArtifact;
38
39 @BeforeEach
40 @Override
41 public void setUp() throws Exception {
42 super.setUp();
43 projectArtifact = createLocalArtifact("project", "3.0");
44 }
45
46 @Override
47 protected String component() {
48 return "resolver";
49 }
50
51 @Test
52 void testMNG4738() throws Exception {
53 Artifact g = createLocalArtifact("g", "1.0");
54 createLocalArtifact("h", "1.0");
55 artifactResolver.resolveTransitively(
56 Collections.singleton(g), projectArtifact, remoteRepositories(), localRepository(), null);
57
58
59 ThreadGroup tg = Thread.currentThread().getThreadGroup();
60 while (tg.getParent() == null) {
61 tg = tg.getParent();
62 }
63
64 ThreadGroup[] tgList = new ThreadGroup[tg.activeGroupCount()];
65 tg.enumerate(tgList);
66
67 boolean seen = false;
68
69 for (ThreadGroup aTgList : tgList) {
70 if (!aTgList.getName().equals(DefaultArtifactResolver.DaemonThreadCreator.THREADGROUP_NAME)) {
71 continue;
72 }
73
74 seen = true;
75
76 tg = aTgList;
77 Thread[] ts = new Thread[tg.activeCount()];
78 tg.enumerate(ts);
79
80 for (Thread active : ts) {
81 String name = active.getName();
82 boolean daemon = active.isDaemon();
83 assertTrue(daemon, name + " is no daemon Thread.");
84 }
85 }
86
87 assertTrue(seen, "Could not find ThreadGroup: " + DefaultArtifactResolver.DaemonThreadCreator.THREADGROUP_NAME);
88 }
89
90 @Test
91 void testLookup() throws Exception {
92 ArtifactResolver resolver = getContainer().lookup(ArtifactResolver.class, "default");
93 }
94 }