Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 114791 Details for
Bug 249996
[artifact] MirrorApplication does not mirror properly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fixes test cases
249996TestsPatch.txt (text/plain), 10.48 KB, created by
Andrew Cattle
on 2008-10-10 09:46:13 EDT
(
hide
)
Description:
Fixes test cases
Filename:
MIME Type:
Creator:
Andrew Cattle
Created:
2008-10-10 09:46:13 EDT
Size:
10.48 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.tests >Index: src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java,v >retrieving revision 1.67 >diff -u -r1.67 AbstractProvisioningTest.java >--- src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java 9 Oct 2008 03:22:36 -0000 1.67 >+++ src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java 10 Oct 2008 13:43:13 -0000 >@@ -1007,7 +1007,9 @@ > //this implicitly verifies the keys are present > > IArtifactDescriptor[] sourceDescriptors = sourceRepo.getArtifactDescriptors(sourceKeys[i]); >- assertEquals(message, sourceDescriptors, destinationDescriptors); >+ >+ //TODO call to temporary method for verifying descriptors >+ assertContains(message, sourceDescriptors, destinationDescriptors, false); //order doesn't matter > } > } > >@@ -1074,4 +1076,46 @@ > assertEquals(message, expected.get(expectedArray[i]), actual.get(expectedArray[i])); > } > } >+ >+ //TODO Temporary solution. Not biconditional. >+ protected static void assertContains(String message, IArtifactDescriptor[] expected, IArtifactDescriptor[] actual, boolean orderImportant) { >+ // if the order in the array must match exactly, then call the other method >+ if (orderImportant) { >+ assertEquals(message, expected, actual); >+ return; >+ } >+ // otherwise use this method and check that the arrays are equal in any order >+ if (expected == null && actual == null) >+ return; >+ if (expected == actual) >+ return; >+ if (expected == null || actual == null) >+ assertTrue(message + ".1", false); >+ if (expected.length > actual.length) >+ assertTrue(message + ".2", false); >+ boolean[] found = new boolean[expected.length]; >+ for (int i = 0; i < expected.length; i++) { >+ for (int j = 0; j < actual.length; j++) { >+ if (!found[i] && isEqual(expected[i], actual[j])) >+ found[i] = true; >+ } >+ } >+ for (int i = 0; i < found.length; i++) >+ if (!found[i]) >+ assertTrue(message + ".3." + i, false); >+ } >+ >+ //TODO Temporary solution >+ protected static boolean isEqual(IArtifactDescriptor expected, IArtifactDescriptor actual) { >+ if (expected == null && actual == null) >+ return true; >+ if (expected == actual) >+ return true; >+ if (expected == null || actual == null) >+ return false; >+ if (!expected.getArtifactKey().equals(actual.getArtifactKey())) >+ return false; >+ >+ return Arrays.equals(expected.getProcessingSteps(), actual.getProcessingSteps()); >+ } > } >Index: src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java,v >retrieving revision 1.4 >diff -u -r1.4 MetadataMirrorApplicationTest.java >--- src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java 9 Oct 2008 03:22:36 -0000 1.4 >+++ src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java 10 Oct 2008 13:43:13 -0000 >@@ -11,7 +11,6 @@ > package org.eclipse.equinox.p2.tests.mirror; > > import java.io.File; >-import java.net.MalformedURLException; > import java.net.URI; > import java.util.HashMap; > import java.util.Map; >@@ -698,12 +697,8 @@ > */ > public void testArtifactMirrorNullSource() { > String[] args = null; >- try { >- //create arguments without a "-source" >- args = new String[] {"-destination", destRepoLocation.toURL().toExternalForm()}; >- } catch (MalformedURLException e) { >- fail("21.0", e); >- } >+ //create arguments without a "-source" >+ args = new String[] {"-destination", destRepoLocation.toURI().toString()}; > > try { > runMirrorApplication("21.1", args); >@@ -721,12 +716,8 @@ > */ > public void testArtifactMirrorNullDestination() { > String[] args = null; >- try { >- //create arguments without a "-destination" >- args = new String[] {"-source", sourceRepoLocation.toURL().toExternalForm()}; >- } catch (MalformedURLException e) { >- fail("22.0", e); >- } >+ //create arguments without a "-destination" >+ args = new String[] {"-source", sourceRepoLocation.toURI().toString()}; > > try { > runMirrorApplication("22.1", args); >Index: src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java,v >retrieving revision 1.4 >diff -u -r1.4 ArtifactMirrorApplicationTest.java >--- src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java 9 Oct 2008 03:22:36 -0000 1.4 >+++ src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java 10 Oct 2008 13:43:13 -0000 >@@ -11,16 +11,15 @@ > package org.eclipse.equinox.p2.tests.mirror; > > import java.io.File; >-import java.net.MalformedURLException; > import java.net.URI; >-import java.util.HashMap; >-import java.util.Map; >+import java.util.*; > import org.eclipse.equinox.app.IApplicationContext; > import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication; >+import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; > import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; >-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; >-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; >+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.eclipse.equinox.p2.tests.TestActivator; > import org.osgi.framework.Bundle; >@@ -290,6 +289,39 @@ > } > > /** >+ * ensures that all files with entries in the repo have corresponding files on disk. >+ * Not Biconditional. >+ */ >+ private void assertFileSizes(String message, SimpleArtifactRepository expected, SimpleArtifactRepository actual) { >+ IArtifactKey[] expectedKeys = expected.getArtifactKeys(); >+ >+ for (int i = 0; i < expectedKeys.length; i++) { >+ IArtifactDescriptor[] expectedDescriptors = expected.getArtifactDescriptors(expectedKeys[i]); >+ IArtifactDescriptor[] actualDescriptors = actual.getArtifactDescriptors(expectedKeys[i]); >+ >+ if (expectedDescriptors == null || actualDescriptors == null) >+ if (!(expectedDescriptors == null && actualDescriptors == null)) >+ fail(message + " missing key " + expectedKeys[i]); >+ >+ top: for (int j = 0; j < expectedDescriptors.length; j++) { >+ for (int k = 0; k < actualDescriptors.length; k++) { >+ if (Arrays.equals(expectedDescriptors[j].getProcessingSteps(), actualDescriptors[k].getProcessingSteps())) { >+ File expectedFile = expected.getArtifactFile(expectedDescriptors[j]); >+ File actualFile = actual.getArtifactFile(actualDescriptors[k]); >+ if (expectedFile == null || actualFile == null) >+ fail(message + " descriptor mismatch"); >+ if (!(expectedFile.exists() && actualFile.exists())) >+ fail(message + " file does not exist"); >+ assertTrue(expectedFile.length() == actualFile.length()); >+ continue top; >+ } >+ } >+ fail(message + "Missing expected descriptor" + expectedDescriptors[j]); >+ } >+ } >+ } >+ >+ /** > * Tests mirroring all artifacts in a repository to an empty repository with "-append" > * Source contains A, B > * Target contains >@@ -522,7 +554,7 @@ > */ > public void testArtifactMirrorToInvalid() { > try { >- //Setup: create a URL pointing to an unmodifiable place >+ //Setup: create a URI pointing to an unmodifiable place > URI invalidDestRepository = new URI("http://foobar.com/abcdefg"); > > //run the application with the modifiable destination >@@ -546,7 +578,7 @@ > delete(invalidRepository); > > try { >- //Setup: create a URL pointing to an unmodifiable place >+ //Setup: create a URI pointing to an unmodifiable place > URI invalidDestRepository = new URI("http://foobar.com/abcdefg"); > basicRunMirrorApplication("15.1", invalidRepository.toURI(), invalidDestRepository, true); > //We expect the ProvisionException to be thrown >@@ -675,12 +707,9 @@ > */ > public void testArtifactMirrorNullSource() { > String[] args = null; >- try { >- //create arguments without a "-source" >- args = new String[] {"-destination", destRepoLocation.toURL().toExternalForm()}; >- } catch (MalformedURLException e) { >- fail("21.0", e); >- } >+ >+ //create arguments without a "-source" >+ args = new String[] {"-destination", destRepoLocation.toURI().toString()}; > > try { > runMirrorApplication("21.1", args); >@@ -698,12 +727,9 @@ > */ > public void testArtifactMirrorNullDestination() { > String[] args = null; >- try { >- //create arguments without a "-destination" >- args = new String[] {"-source", sourceRepoLocation.toURL().toExternalForm()}; >- } catch (MalformedURLException e) { >- fail("22.0", e); >- } >+ >+ //create arguments without a "-destination" >+ args = new String[] {"-source", sourceRepoLocation.toURI().toString()}; > > try { > runMirrorApplication("22.1", args); >@@ -776,4 +802,27 @@ > fail("25.5", e); > } > } >+ >+ /** >+ * Verifies that the mirror application copies files (including packed files) correctly >+ */ >+ public void testArtifactFileCopying() { >+ //Setup: load the repository containing packed data >+ File packedRepoLocation = getTestData("26.0", "/testData/mirror/mirrorPackedRepo"); >+ >+ try { >+ basicRunMirrorApplication("26.1", packedRepoLocation.toURI(), destRepoLocation.toURI(), false); >+ } catch (Exception e) { >+ fail("26.3", e); >+ } >+ >+ try { >+ //Verify Contents >+ assertContentEquals("26.4", getManager().loadRepository(packedRepoLocation.toURI(), null), getManager().loadRepository(destRepoLocation.toURI(), null)); >+ //Verify files on disk >+ assertFileSizes("26.5", (SimpleArtifactRepository) getManager().loadRepository(packedRepoLocation.toURI(), null), (SimpleArtifactRepository) getManager().loadRepository(destRepoLocation.toURI(), null)); >+ } catch (ProvisionException e) { >+ fail("26.6", e); >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 249996
:
114472
|
114540
|
114593
|
114594
|
114791
|
115034