use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.
the class ConnectorTestSuite method testProgressEventsDataBuffer.
@Test
public void testProgressEventsDataBuffer() throws UnsupportedEncodingException, IOException, NoSuchAlgorithmException, NoRepositoryConnectorException {
byte[] bytes = "These are the test contents.\n".getBytes("UTF-8");
int count = 120000;
MessageDigest digest = MessageDigest.getInstance("SHA-1");
for (int i = 0; i < count; i++) {
digest.update(bytes);
}
byte[] hash = digest.digest();
File file = TestFileUtils.createTempFile(bytes, count);
Artifact artifact = new StubArtifact("gid:aid:ext:ver");
ArtifactUpload upA = new ArtifactUpload(artifact, file);
File dir = TestFileUtils.createTempDir("con-test");
File downAFile = new File(dir, "downA.file");
downAFile.deleteOnExit();
ArtifactDownload downA = new ArtifactDownload(artifact, "", downAFile, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
Metadata metadata = new StubMetadata("gid", "aid", "ver", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT);
MetadataUpload upM = new MetadataUpload(metadata, file);
File downMFile = new File(dir, "downM.file");
downMFile.deleteOnExit();
MetadataDownload downM = new MetadataDownload(metadata, "", downMFile, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
DigestingTransferListener listener = new DigestingTransferListener();
session.setTransferListener(listener);
RepositoryConnector connector = factory().newInstance(session, repository);
connector.put(Arrays.asList(upA), null);
assertArrayEquals(hash, listener.getHash());
listener.rewind();
connector.put(null, Arrays.asList(upM));
assertArrayEquals(hash, listener.getHash());
listener.rewind();
connector.get(Arrays.asList(downA), null);
assertArrayEquals(hash, listener.getHash());
listener.rewind();
connector.get(null, Arrays.asList(downM));
assertArrayEquals(hash, listener.getHash());
listener.rewind();
connector.close();
}
use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.
the class IniArtifactDescriptorReaderTest method testMissingDescriptor.
@Test(expected = ArtifactDescriptorException.class)
public void testMissingDescriptor() throws ArtifactDescriptorException {
StubArtifact art = new StubArtifact("missing:aid:ver:ext");
ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(art, null, "");
reader.readArtifactDescriptor(session, request);
}
use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.
the class IniArtifactDescriptorReaderTest method testLookup.
@Test
public void testLookup() throws ArtifactDescriptorException {
StubArtifact art = new StubArtifact("gid:aid:ext:ver");
ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(art, null, "");
ArtifactDescriptorResult description = reader.readArtifactDescriptor(session, request);
assertEquals(request, description.getRequest());
assertEquals(art, description.getArtifact());
assertEquals(1, description.getRelocations().size());
Artifact artifact = description.getRelocations().get(0);
assertEquals("gid", artifact.getGroupId());
assertEquals("aid", artifact.getArtifactId());
assertEquals("ver", artifact.getVersion());
assertEquals("ext", artifact.getExtension());
assertEquals(1, description.getRepositories().size());
RemoteRepository repo = description.getRepositories().get(0);
assertEquals("id", repo.getId());
assertEquals("type", repo.getContentType());
assertEquals("protocol://some/url?for=testing", repo.getUrl());
assertDependencies(description.getDependencies());
assertDependencies(description.getManagedDependencies());
}
use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.
the class DefaultUpdateCheckManagerTest method setup.
@Before
public void setup() throws Exception {
File dir = TestFileUtils.createTempFile("");
TestFileUtils.delete(dir);
File metadataFile = new File(dir, "metadata.txt");
TestFileUtils.write("metadata", metadataFile);
File artifactFile = new File(dir, "artifact.txt");
TestFileUtils.write("artifact", artifactFile);
session = new TestRepositorySystemSession();
repository = new RemoteRepository("id", "default", TestFileUtils.createTempDir().toURL().toString());
manager = new DefaultUpdateCheckManager();
metadata = new StubMetadata("gid", "aid", "ver", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT, metadataFile);
artifact = new StubArtifact("gid", "aid", "", "ext", "ver").setFile(artifactFile);
}
use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.
the class AsyncConnectorSuiteConfiguration method before.
@Override
@Before
public void before() throws Exception {
super.before();
this.factory = new AsyncRepositoryConnectorFactory(NullLogger.INSTANCE, new TestFileProcessor());
this.session = new TestRepositorySystemSession();
this.repository = new RemoteRepository("async-test-repo", "default", url("repo"));
this.artifact = new StubArtifact("gid", "aid", "classifier", "extension", "version", null);
this.metadata = new StubMetadata("gid", "aid", "version", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT, null);
connector = null;
}
Aggregations