blob: 016b3e62c78c19ea7ab7f81d31b6f0a231caa32c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package org.eclipse.equinox.p2.tests.artifact.repository;
import java.io.ByteArrayOutputStream;
import java.io.File;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.osgi.framework.Version;
public class MD5Tests extends AbstractProvisioningTest {
File testRepo = null;
IArtifactRepository repo = null;
protected void setUp() throws Exception {
super.setUp();
testRepo = getTestData("Repository with MD5", "testData/artifactRepo/simpleWithMD5");
repo = getArtifactRepositoryManager().loadRepository(testRepo.toURI(), new NullProgressMonitor());
assertNotNull("1.0", repo);
}
public void testCheckMD5() {
IArtifactKey[] keys = repo.getArtifactKeys();
for (int i = 0; i < keys.length; i++) {
IArtifactDescriptor[] desc = repo.getArtifactDescriptors(keys[i]);
for (int j = 0; j < desc.length; j++) {
IStatus status = repo.getArtifact(desc[j], new ByteArrayOutputStream(500), new NullProgressMonitor());
//All artifacts that are expected to fail MD5 check are those whose id starts with bogus
if (desc[j].getArtifactKey().getId().startsWith("bogus")) {
assertNotOK(status);
continue;
}
assertOK("2.1 " + desc[j], status);
}
}
}
public void testBug249035_ArtifactIdentity() {
//MD5 sum should not affect the identity of the artifact
ArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", new Version("1.0.0")));
descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_MD5, "42");
try {
repo.getOutputStream(descriptor);
fail("3.1 - Expected Artifact exists exception did not occur.");
} catch (ProvisionException e) {
assertTrue("3.2", e.getMessage().contains("The artifact is already available in the repository"));
}
}
protected void tearDown() throws Exception {
getArtifactRepositoryManager().removeRepository(testRepo.toURI());
super.tearDown();
}
}
|