use of org.sonatype.aether.test.impl.TestRepositorySystemSession in project sonatype-aether by sonatype.
the class DefaultArtifactResolverTest method testResolveFromWorkspace.
@Test
public void testResolveFromWorkspace() throws IOException, ArtifactResolutionException {
session = new TestRepositorySystemSession() {
@Override
public WorkspaceReader getWorkspaceReader() {
return new WorkspaceReader() {
public WorkspaceRepository getRepository() {
return new WorkspaceRepository("default");
}
public List<String> findVersions(Artifact artifact) {
return Arrays.asList(artifact.getVersion());
}
public File findArtifact(Artifact artifact) {
try {
return TestFileUtils.createTempFile(artifact.toString());
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
};
}
};
ArtifactRequest request = new ArtifactRequest(artifact, null, "");
request.addRepository(new RemoteRepository("id", "default", "file:///"));
ArtifactResult result = resolver.resolveArtifact(session, request);
assertTrue(result.getExceptions().isEmpty());
Artifact resolved = result.getArtifact();
assertNotNull(resolved.getFile());
byte[] expected = resolved.toString().getBytes("UTF-8");
TestFileUtils.assertContent(expected, resolved.getFile());
resolved = resolved.setFile(null);
assertEquals(artifact, resolved);
connector.assertSeenExpected();
}
use of org.sonatype.aether.test.impl.TestRepositorySystemSession in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method setup.
@Before
public void setup() throws IOException {
session = new TestRepositorySystemSession();
collector = new DefaultDependencyCollector();
collector.setArtifactDescriptorReader(new IniArtifactDescriptorReader("artifact-descriptions/"));
collector.setVersionRangeResolver(new StubVersionRangeResolver());
collector.setRemoteRepositoryManager(new StubRemoteRepositoryManager());
parser = new DependencyGraphParser("artifact-descriptions/");
repository = new RemoteRepository("id", "default", "file:///");
}
use of org.sonatype.aether.test.impl.TestRepositorySystemSession in project sonatype-aether by sonatype.
the class DefaultMetadataResolverTest method setup.
@Before
public void setup() throws Exception {
session = new TestRepositorySystemSession();
// session.setLocalRepositoryManager( new EnhancedLocalRepositoryManager( TestFileUtils.createTempDir() ) );
lrm = (TestLocalRepositoryManager) session.getLocalRepositoryManager();
manager = new StubRemoteRepositoryManager();
resolver = new DefaultMetadataResolver();
resolver.setUpdateCheckManager(new StaticUpdateCheckManager(true));
resolver.setRepositoryEventDispatcher(new StubRepositoryEventDispatcher());
resolver.setRemoteRepositoryManager(manager);
resolver.setSyncContextFactory(new StubSyncContextFactory());
repository = new RemoteRepository("test-DMRT", "default", TestFileUtils.createTempDir().toURI().toURL().toString());
metadata = new StubMetadata("gid", "aid", "ver", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT);
connector = new RecordingRepositoryConnector();
manager.setConnector(connector);
}
use of org.sonatype.aether.test.impl.TestRepositorySystemSession in project sonatype-aether by sonatype.
the class DefaultRepositoryEventDispatcherTest method testDispatchHandlesAllEventTypes.
@Test
public void testDispatchHandlesAllEventTypes() throws Exception {
DefaultRepositoryEventDispatcher dispatcher = new DefaultRepositoryEventDispatcher();
ListenerHandler handler = new ListenerHandler();
RepositoryListener listener = (RepositoryListener) Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[] { RepositoryListener.class }, handler);
TestRepositorySystemSession session = new TestRepositorySystemSession();
session.setRepositoryListener(listener);
for (RepositoryEvent.EventType type : RepositoryEvent.EventType.values()) {
DefaultRepositoryEvent event = new DefaultRepositoryEvent(type, session, null);
handler.methodName = null;
dispatcher.dispatch(event);
assertNotNull("not handled: " + type, handler.methodName);
assertEquals("badly handled: " + type, type.name().replace("_", "").toLowerCase(Locale.ENGLISH), handler.methodName.toLowerCase(Locale.ENGLISH));
}
}
use of org.sonatype.aether.test.impl.TestRepositorySystemSession in project sonatype-aether by sonatype.
the class EnhancedLocalRepositoryManagerTest method setup.
@Before
public void setup() throws Exception {
repository = new RemoteRepository("enhanced-remote-repo", "default", TestFileUtils.createTempDir("enhanced-remote-repo").toURI().toURL().toString());
repository.setRepositoryManager(true);
artifact = new DefaultArtifact("gid", "aid", "", "jar", "1-test", Collections.<String, String>emptyMap(), TestFileUtils.createTempFile("artifact"));
metadata = new DefaultMetadata("gid", "aid", "1-test", "maven-metadata.xml", Nature.RELEASE, TestFileUtils.createTempFile("metadata"));
noVerMetadata = new DefaultMetadata("gid", "aid", null, "maven-metadata.xml", Nature.RELEASE, TestFileUtils.createTempFile("metadata"));
basedir = TestFileUtils.createTempDir("enhanced-repo");
manager = new EnhancedLocalRepositoryManager(basedir);
artifactFile = new File(basedir, manager.getPathForLocalArtifact(artifact));
session = new TestRepositorySystemSession();
}
Aggregations