use of org.sonatype.aether.test.util.impl.StubMetadata 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.StubMetadata 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.StubMetadata 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