use of org.sonatype.aether.spi.connector.ArtifactUpload in project sonatype-aether by sonatype.
the class RecordingRepositoryConnector method put.
public void put(Collection<? extends ArtifactUpload> artifactUploads, Collection<? extends MetadataUpload> metadataUploads) {
if (artifactUploads != null) {
for (ArtifactUpload artifactUpload : artifactUploads) {
// mimic "real" connector
artifactUpload.setState(State.ACTIVE);
if (artifactUpload.getFile() == null) {
artifactUpload.setException(new ArtifactTransferException(artifactUpload.getArtifact(), null, "no file"));
}
this.actualPut.add(artifactUpload.getArtifact());
artifactUpload.setState(State.DONE);
}
}
if (metadataUploads != null) {
for (MetadataUpload metadataUpload : metadataUploads) {
// mimic "real" connector
metadataUpload.setState(State.ACTIVE);
if (metadataUpload.getFile() == null) {
metadataUpload.setException(new MetadataTransferException(metadataUpload.getMetadata(), null, "no file"));
}
this.actualPutMD.add(metadataUpload.getMetadata());
metadataUpload.setState(State.DONE);
}
}
}
use of org.sonatype.aether.spi.connector.ArtifactUpload in project sonatype-aether by sonatype.
the class PutTest method testArtifactUpload.
@Test
public void testArtifactUpload() throws Exception {
addExpectation("gid/aid/version/aid-version-classifier.extension", "artifact");
addExpectation("gid/aid/version/aid-version-classifier.extension.sha1", sha1("artifact"));
addExpectation("gid/aid/version/aid-version-classifier.extension.md5", md5("artifact"));
Artifact artifact = artifact("artifact");
ArtifactUpload up = new ArtifactUpload(artifact, artifact.getFile());
List<ArtifactUpload> uploads = Arrays.asList(up);
connector().put(uploads, null);
ArtifactTransferException ex = up.getException();
assertNull(ex != null ? ex.getMessage() : "", ex);
assertExpectations();
}
use of org.sonatype.aether.spi.connector.ArtifactUpload in project sonatype-aether by sonatype.
the class PutTest method testArtifactWithZeroBytesFile.
@Test
@Ignore("https://issues.sonatype.org/browse/AHC-5")
public void testArtifactWithZeroBytesFile() throws Exception {
String content = "";
addExpectation("gid/aid/version/aid-version-classifier.extension", content);
addExpectation("gid/aid/version/aid-version-classifier.extension.sha1", sha1(content));
addExpectation("gid/aid/version/aid-version-classifier.extension.md5", md5(content));
Artifact artifact = artifact(content);
ArtifactUpload up = new ArtifactUpload(artifact, artifact.getFile());
List<ArtifactUpload> uploads = Arrays.asList(up);
connector().put(uploads, null);
ArtifactTransferException ex = up.getException();
assertNull(ex != null ? ex.getMessage() : "", ex);
assertExpectations();
}
Aggregations