1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.resource.maven.repository;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.containsString;
20 import static org.hamcrest.Matchers.equalTo;
21 import static org.hamcrest.Matchers.is;
22
23 import java.io.File;
24 import java.util.List;
25
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.sonatype.aether.RepositorySystemSession;
29 import org.sonatype.aether.artifact.Artifact;
30 import org.sonatype.aether.resolution.DependencyResolutionException;
31 import org.sonatype.aether.util.artifact.DefaultArtifact;
32
33 import de.smartics.properties.resource.domain.ArtifactRef;
34 import de.smartics.properties.resource.domain.ClassPathEnvironment;
35 import de.smartics.testdoc.annotations.Uut;
36 import de.smartics.util.test.io.FileTestUtils;
37
38
39
40
41 public class ResourceRepositoryTest
42 {
43
44
45
46
47
48
49 @Uut
50 private MavenRepository uut;
51
52 private RepositorySystemSession session;
53
54
55
56
57
58
59
60 @Before
61 public void setUp()
62 {
63 final File repoDir = FileTestUtils.getFileFromResource("repository");
64 uut = new MavenRepository(null,
65
66 repoDir.getAbsolutePath());
67 session = uut.createSession();
68 }
69
70
71
72
73
74 @Test
75 public void resolvesLocalFiles() throws DependencyResolutionException
76 {
77 final Artifact artifact =
78 new DefaultArtifact("de.smartics.test", "single-project", "jar",
79 "1.2.3");
80 final ClassPathEnvironment resources = uut.resolve(session, artifact);
81
82 final List<ArtifactRef> refs = resources.getArtifactRefs();
83 assertThat(refs.size(), is(equalTo(1)));
84 assertThat(
85 refs.get(0).getUrl().toExternalForm(),
86 containsString("repository/de/smartics/test/single-project/1.2.3/single-project-1.2.3.jar"));
87 }
88 }