Lines 13-26
Link Here
|
13 |
import java.io.File; |
13 |
import java.io.File; |
14 |
import java.net.MalformedURLException; |
14 |
import java.net.MalformedURLException; |
15 |
import java.net.URL; |
15 |
import java.net.URL; |
16 |
import java.util.HashMap; |
16 |
import java.util.*; |
17 |
import java.util.Map; |
|
|
18 |
import org.eclipse.equinox.app.IApplicationContext; |
17 |
import org.eclipse.equinox.app.IApplicationContext; |
19 |
import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication; |
18 |
import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication; |
|
|
19 |
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; |
20 |
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; |
20 |
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; |
21 |
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; |
21 |
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; |
22 |
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; |
|
|
23 |
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; |
22 |
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; |
|
|
23 |
import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; |
24 |
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; |
24 |
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; |
25 |
import org.eclipse.equinox.p2.tests.TestActivator; |
25 |
import org.eclipse.equinox.p2.tests.TestActivator; |
26 |
import org.osgi.framework.Bundle; |
26 |
import org.osgi.framework.Bundle; |
Lines 308-313
Link Here
|
308 |
} |
308 |
} |
309 |
|
309 |
|
310 |
/** |
310 |
/** |
|
|
311 |
* ensures that all files with entries in the repo have corresponding files on disk. |
312 |
*/ |
313 |
private void assertFileSizes(String message, SimpleArtifactRepository expected, SimpleArtifactRepository actual) { |
314 |
IArtifactKey[] expectedKeys = expected.getArtifactKeys(); |
315 |
for (int i = 0; i < expectedKeys.length; i++) { |
316 |
IArtifactDescriptor[] expectedDescriptors = expected.getArtifactDescriptors(expectedKeys[i]); |
317 |
IArtifactDescriptor[] actualDescriptors = actual.getArtifactDescriptors(expectedKeys[i]); |
318 |
|
319 |
top: for (int j = 0; j < expectedDescriptors.length; j++) { |
320 |
for (int j2 = 0; j2 < actualDescriptors.length; j2++) { |
321 |
if (Arrays.equals(expectedDescriptors[j].getProcessingSteps(), actualDescriptors[j2].getProcessingSteps())) { |
322 |
File expectedFile = expected.getArtifactFile(expectedDescriptors[j]); |
323 |
File actualFile = actual.getArtifactFile(actualDescriptors[j2]); |
324 |
if (expectedFile == null || actualFile == null) |
325 |
fail(message + " descriptor mismatch"); |
326 |
if (!(expectedFile.exists() && actualFile.exists())) |
327 |
fail(message + " file does not exist"); |
328 |
assertTrue(expectedFile.length() == actualFile.length()); |
329 |
continue top; |
330 |
} |
331 |
} |
332 |
fail(message + "Missing expected descriptor" + expectedDescriptors[j]); |
333 |
} |
334 |
} |
335 |
} |
336 |
|
337 |
/** |
311 |
* Tests mirroring all artifacts in a repository to an empty repository with "-append" |
338 |
* Tests mirroring all artifacts in a repository to an empty repository with "-append" |
312 |
* Source contains A, B |
339 |
* Source contains A, B |
313 |
* Target contains |
340 |
* Target contains |
Lines 855-858
Link Here
|
855 |
fail("25.6", e); |
882 |
fail("25.6", e); |
856 |
} |
883 |
} |
857 |
} |
884 |
} |
|
|
885 |
|
886 |
/** |
887 |
* Verifies that the mirror application copies files (including packed files) correctly |
888 |
*/ |
889 |
public void testArtifactFileCopying() { |
890 |
//Setup: load the repository containing packed data |
891 |
File packedRepoLocation = getTestData("26.0", "/testData/mirror/mirrorPackedRepo"); |
892 |
|
893 |
try { |
894 |
basicRunMirrorApplication("26.1", packedRepoLocation.toURL(), destRepoLocation.toURL(), false); |
895 |
} catch (MalformedURLException e) { |
896 |
fail("26.2", e); |
897 |
} catch (Exception e) { |
898 |
fail("26.3", e); |
899 |
} |
900 |
|
901 |
try { |
902 |
//Verify Contents |
903 |
assertContentEquals("26.4", getManager().loadRepository(packedRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); |
904 |
//Verify files on disk |
905 |
assertFileSizes("26.5", (SimpleArtifactRepository) getManager().loadRepository(packedRepoLocation.toURL(), null), (SimpleArtifactRepository) getManager().loadRepository(destRepoLocation.toURL(), null)); |
906 |
} catch (ProvisionException e) { |
907 |
fail("26.6", e); |
908 |
} catch (MalformedURLException e) { |
909 |
fail("26.7", e); |
910 |
} |
911 |
} |
858 |
} |
912 |
} |