1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.internal.impl.filter;
20
21 import java.io.IOException;
22 import java.io.UncheckedIOException;
23 import java.nio.file.Files;
24 import java.util.Collections;
25 import java.util.List;
26
27 import org.eclipse.aether.DefaultRepositorySystemSession;
28 import org.eclipse.aether.artifact.Artifact;
29 import org.eclipse.aether.internal.impl.DefaultRepositorySystemLifecycle;
30 import org.eclipse.aether.repository.RemoteRepository;
31 import org.eclipse.aether.resolution.ArtifactRequest;
32 import org.eclipse.aether.resolution.ArtifactResult;
33
34
35
36
37 public class GroupIdRemoteRepositoryFilterSourceTest extends RemoteRepositoryFilterSourceTestSupport {
38 private GroupIdRemoteRepositoryFilterSource groupIdRemoteRepositoryFilterSource;
39
40 @Override
41 protected GroupIdRemoteRepositoryFilterSource getRemoteRepositoryFilterSource(
42 DefaultRepositorySystemSession session, RemoteRepository remoteRepository) {
43 return groupIdRemoteRepositoryFilterSource =
44 new GroupIdRemoteRepositoryFilterSource(new DefaultRepositorySystemLifecycle());
45 }
46
47 @Override
48 protected void enableSource(DefaultRepositorySystemSession session) {
49 session.setConfigProperty(
50 "aether.remoteRepositoryFilter." + GroupIdRemoteRepositoryFilterSource.NAME, Boolean.TRUE.toString());
51 }
52
53 protected void allowArtifact(
54 DefaultRepositorySystemSession session, RemoteRepository remoteRepository, Artifact artifact) {
55 DefaultRepositorySystemSession newSession = new DefaultRepositorySystemSession(session);
56 try {
57 Artifact resolvedArtifact =
58 artifact.setFile(Files.createTempFile("test", "tmp").toFile());
59 ArtifactResult artifactResult = new ArtifactResult(
60 new ArtifactRequest(resolvedArtifact, Collections.singletonList(remoteRepository), "context"));
61 artifactResult.setArtifact(resolvedArtifact);
62 artifactResult.setRepository(remoteRepository);
63 List<ArtifactResult> artifactResults = Collections.singletonList(artifactResult);
64 enableSource(newSession);
65 newSession.setConfigProperty(
66 "aether.remoteRepositoryFilter." + GroupIdRemoteRepositoryFilterSource.NAME + ".record",
67 Boolean.TRUE.toString());
68 groupIdRemoteRepositoryFilterSource.postProcess(newSession, artifactResults);
69 } catch (IOException e) {
70 throw new UncheckedIOException(e);
71 }
72 }
73 }