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
|
package org.eclipse.equinox.p2.tests.artifact.repository;
import java.io.File;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class LocationTest extends AbstractProvisioningTest {
private static final String testDataLocation = "testData/artifactRepo/packedSiblingsWithUUID";
private File targetLocation;
private IArtifactRepository targetRepository, sourceRepository;
public void setUp() throws Exception {
super.setUp();
targetLocation = File.createTempFile("target", ".repo");
targetLocation.delete();
targetLocation.mkdirs();
targetRepository = new SimpleArtifactRepository(getAgent(), "TargetRepo", targetLocation.toURI(), null);
IArtifactRepositoryManager mgr = getArtifactRepositoryManager();
sourceRepository = mgr.loadRepository((getTestData("EmptyJar repo", testDataLocation).toURI()), null);
}
protected void tearDown() throws Exception {
getArtifactRepositoryManager().removeRepository(targetLocation.toURI());
getArtifactRepositoryManager().removeRepository(sourceRepository.getLocation());
AbstractProvisioningTest.delete(targetLocation);
super.tearDown();
}
public void testLocation() throws Exception {
IArtifactKey key = new ArtifactKey("osgi.bundle", "org.springframework.ide.eclipse", Version.parseVersion("2.3.2.201003220227-RELEASE"));
assertTrue(sourceRepository.contains(key));
MirrorRequest req = new MirrorRequest(key, targetRepository, null, null, getTransport());
req.perform(sourceRepository, new NullProgressMonitor());
IStatus status = req.getResult();
assertTrue(status.getMessage(), status.isOK());
}
}
|