### 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.62 diff -u -r1.62 AbstractProvisioningTest.java --- src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java 30 Sep 2008 21:02:50 -0000 1.62 +++ src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java 3 Oct 2008 14:21:01 -0000 @@ -1056,4 +1056,23 @@ } return true; } + + /** + * Ensures 2 inputed Maps representing repository properties are equivalent + * A special assert is needed as the time stamp is expected to change + */ + protected static void assertRepositoryProperties(String message, Map expected, Map actual) { + if ((expected == null) && (actual == null)) + return; + if ((expected == null) || (actual == null)) + fail(); + + Object[] expectedArray = expected.keySet().toArray(); + + for (int i = 0; i < expectedArray.length; i++) { + assertTrue(actual.containsKey(expectedArray[i])); //Ensure the key exists + if (!expectedArray[i].equals("p2.timestamp")) //time stamp value is expected to change + assertEquals(expected.get(expectedArray[i]), actual.get(expectedArray[i])); + } + } } 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.2 diff -u -r1.2 MetadataMirrorApplicationTest.java --- src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java 2 Oct 2008 21:08:08 -0000 1.2 +++ src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java 3 Oct 2008 14:21:01 -0000 @@ -828,4 +828,50 @@ fail("23.1", e); } } + + /** + * Ensures that a repository created by the mirror application is a copy of the source + */ + public void testNewArtifactRepoProperties() { + //run mirror application with source not preexisting + metadataMirrorToEmpty("24.0", true); + + try { + assertEquals("24.1", getManager().loadRepository(sourceRepoLocation.toURL(), null).getName(), getManager().loadRepository(destRepoLocation.toURL(), null).getName()); + assertRepositoryProperties("24.2", getManager().loadRepository(sourceRepoLocation.toURL(), null).getProperties(), getManager().loadRepository(destRepoLocation.toURL(), null).getProperties()); + } catch (ProvisionException e) { + fail("24.3", e); + } catch (MalformedURLException e) { + fail("24.4", e); + } + } + + /** + * Ensures that a repository created before the mirror application is run does not have its properties changed + */ + public void testExistingArtifactRepoProperties() { + //Setup: create the destination + String name = "Destination Name"; + Map properties = null; //default properties + try { + //create the repository and get the resulting properties + properties = getManager().createRepository(destRepoLocation.toURL(), name, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties).getProperties(); + } catch (ProvisionException e) { + fail("25.0", e); + } catch (MalformedURLException e) { + fail("25.1", e); + } + + //run the mirror application + metadataMirrorToEmpty("25.2", true); + + try { + assertEquals("25.3", name, getManager().loadRepository(destRepoLocation.toURL(), null).getName()); + assertRepositoryProperties("25.4", properties, getManager().loadRepository(destRepoLocation.toURL(), null).getProperties()); + } catch (ProvisionException e) { + fail("25.5", e); + } catch (MalformedURLException e) { + fail("25.6", e); + } + } } 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.2 diff -u -r1.2 ArtifactMirrorApplicationTest.java --- src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java 2 Oct 2008 21:08:08 -0000 1.2 +++ src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java 3 Oct 2008 14:21:01 -0000 @@ -34,7 +34,7 @@ protected File sourceRepo3Location; //helloworldfeature + yetanotherfeature protected File sourceRepo4Location; //helloworldfeature v1.0.1 - private IArtifactRepositoryManager getArtifactRepositoryManager() { + private IArtifactRepositoryManager getManager() { return (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName()); } @@ -59,11 +59,11 @@ */ protected void tearDown() throws Exception { //remove all the repositories - getArtifactRepositoryManager().removeRepository(destRepoLocation.toURL()); - getArtifactRepositoryManager().removeRepository(sourceRepoLocation.toURL()); - getArtifactRepositoryManager().removeRepository(sourceRepo2Location.toURL()); - getArtifactRepositoryManager().removeRepository(sourceRepo3Location.toURL()); - getArtifactRepositoryManager().removeRepository(sourceRepo4Location.toURL()); + getManager().removeRepository(destRepoLocation.toURL()); + getManager().removeRepository(sourceRepoLocation.toURL()); + getManager().removeRepository(sourceRepo2Location.toURL()); + getManager().removeRepository(sourceRepo3Location.toURL()); + getManager().removeRepository(sourceRepo4Location.toURL()); //delete the destination location (no left over files for the next test) delete(destRepoLocation); @@ -156,7 +156,7 @@ try { //Setup ensure setup completes successfully - assertContentEquals(message + ".1", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals(message + ".1", getManager().loadRepository(sourceRepo2Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail(message + ".2", e); } catch (MalformedURLException e) { @@ -178,7 +178,7 @@ try { //Setup: verify contents - assertContentEquals(message + ".1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals(message + ".1", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail(message + ".2", e); } catch (MalformedURLException e) { @@ -200,7 +200,7 @@ try { //Setup: verify contents - assertContentEquals(message + ".1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals(message + ".1", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail(message + ".2", e); } catch (MalformedURLException e) { @@ -222,7 +222,7 @@ try { //Setup: verify - assertContentEquals(message + ".1", getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals(message + ".1", getManager().loadRepository(sourceRepo3Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail(message + ".2", e); } catch (MalformedURLException e) { @@ -244,7 +244,7 @@ try { //Setup: verify - assertContentEquals(message + ".1", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals(message + ".1", getManager().loadRepository(sourceRepo2Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail(message + ".2", e); } catch (MalformedURLException e) { @@ -256,8 +256,8 @@ try { //Setup: verify - assertContains(message + ".5", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); - assertContains(message + ".6", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContains(message + ".5", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); + assertContains(message + ".6", getManager().loadRepository(sourceRepo2Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail(message + ".7", e); } catch (MalformedURLException e) { @@ -277,14 +277,14 @@ File emptyRepository = new File(getTempFolder(), getUniqueString()); try { //Setup: remove repository if it exists - getArtifactRepositoryManager().removeRepository(emptyRepository.toURL()); + getManager().removeRepository(emptyRepository.toURL()); } catch (MalformedURLException e1) { fail(message + ".0", e1); } //Setup: delete any data that may be in the folder delete(emptyRepository); try { - getArtifactRepositoryManager().createRepository(emptyRepository.toURL(), "Empty Repository", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, null); + getManager().createRepository(emptyRepository.toURL(), "Empty Repository", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, null); } catch (ProvisionException e) { fail(message + ".1", e); } catch (MalformedURLException e) { @@ -317,7 +317,7 @@ try { //verify destination's content - assertContentEquals("1.1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("1.1", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("1.2", e); } catch (MalformedURLException e) { @@ -336,7 +336,7 @@ try { //verify destination's content - assertContentEquals("2.1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("2.1", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("2.2", e); } catch (MalformedURLException e) { @@ -355,7 +355,7 @@ try { //verify destination's content - assertContentEquals("3.1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("3.1", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("3.2", e); } catch (MalformedURLException e) { @@ -374,7 +374,7 @@ try { //verify destination's content - assertContentEquals("4.1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("4.1", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("4.2", e); } catch (MalformedURLException e) { @@ -393,10 +393,10 @@ try { //verify destination's content - assertContains("5.1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); - assertContains("5.2", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContains("5.1", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); + assertContains("5.2", getManager().loadRepository(sourceRepo2Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("5.3", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURL(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null).getArtifactKeys().length); + assertEquals("5.3", getManager().loadRepository(sourceRepoLocation.toURL(), null).getArtifactKeys().length + getManager().loadRepository(sourceRepo2Location.toURL(), null).getArtifactKeys().length, getManager().loadRepository(destRepoLocation.toURL(), null).getArtifactKeys().length); } catch (ProvisionException e) { fail("5.4", e); } catch (MalformedURLException e) { @@ -415,7 +415,7 @@ try { //verify destination's content - assertContentEquals("6.1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("6.1", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("6.2", e); } catch (MalformedURLException e) { @@ -434,7 +434,7 @@ try { //verify destination's content - assertContentEquals("7.1", getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("7.1", getManager().loadRepository(sourceRepo3Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("7.2", e); } catch (MalformedURLException e) { @@ -453,7 +453,7 @@ try { //verify destination's content - assertContentEquals("8.1", getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("8.1", getManager().loadRepository(sourceRepo3Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("8.2", e); } catch (MalformedURLException e) { @@ -472,7 +472,7 @@ try { //verify destination's content - assertContentEquals("9.1", getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("9.1", getManager().loadRepository(sourceRepo3Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("9.2", e); } catch (MalformedURLException e) { @@ -491,7 +491,7 @@ try { //verify destination's content - assertContentEquals("10.1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("10.1", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("10.2", e); } catch (MalformedURLException e) { @@ -510,10 +510,10 @@ try { //verify destination's content - assertContains("11.1", getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); - assertContains("11.2", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContains("11.1", getManager().loadRepository(sourceRepo3Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); + assertContains("11.2", getManager().loadRepository(sourceRepo2Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("11.3", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURL(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURL(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null).getArtifactKeys().length); + assertEquals("11.3", getManager().loadRepository(sourceRepo2Location.toURL(), null).getArtifactKeys().length + getManager().loadRepository(sourceRepo3Location.toURL(), null).getArtifactKeys().length, getManager().loadRepository(destRepoLocation.toURL(), null).getArtifactKeys().length); } catch (ProvisionException e) { fail("11.4", e); } catch (MalformedURLException e) { @@ -532,7 +532,7 @@ try { //verify destination's content - assertContentEquals("12.1", getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("12.1", getManager().loadRepository(sourceRepo3Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("12.2", e); } catch (MalformedURLException e) { @@ -590,9 +590,9 @@ //Setup: create a URL pointing to an unmodifiable place URL invalidDestRepository = new URL("http://foobar.com/abcdefg"); basicRunMirrorApplication("15.1", invalidRepository.toURL(), invalidDestRepository, true); - //We expect the UnsupportedOperationException to be thrown - fail("15.0 UnsupportedOperationException not thrown"); - } catch (UnsupportedOperationException e) { + //We expect the ProvisionException to be thrown + fail("15.0 ProvisionException not thrown"); + } catch (ProvisionException e) { return; //correct type of exception was thrown } catch (Exception e) { fail("15.2", e); @@ -610,7 +610,7 @@ try { //verify destination's content - assertContentEquals("16.1", getArtifactRepositoryManager().loadRepository(emptyRepository.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("16.1", getManager().loadRepository(emptyRepository.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("16.2", e); } catch (MalformedURLException e) { @@ -620,7 +620,7 @@ //Cleanup try { //remove the emptyRepository - getArtifactRepositoryManager().removeRepository(emptyRepository.toURL()); + getManager().removeRepository(emptyRepository.toURL()); } catch (MalformedURLException e1) { //delete any leftover data delete(emptyRepository); @@ -641,8 +641,8 @@ try { //verify destination's content - assertContains("17.1", getArtifactRepositoryManager().loadRepository(emptyRepository.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); - assertContentEquals("17.2", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContains("17.1", getManager().loadRepository(emptyRepository.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("17.2", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("17.3", e); } catch (MalformedURLException e) { @@ -652,7 +652,7 @@ //Cleanup try { //remove the empty repository - getArtifactRepositoryManager().removeRepository(emptyRepository.toURL()); + getManager().removeRepository(emptyRepository.toURL()); } catch (MalformedURLException e1) { //delete any leftover data delete(emptyRepository); @@ -673,7 +673,7 @@ try { //verify destination's content - assertContentEquals("18.1", getArtifactRepositoryManager().loadRepository(emptyRepository.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("18.1", getManager().loadRepository(emptyRepository.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("18.2", e); } catch (MalformedURLException e) { @@ -683,7 +683,7 @@ //Cleanup try { //remove the empty repository - getArtifactRepositoryManager().removeRepository(emptyRepository.toURL()); + getManager().removeRepository(emptyRepository.toURL()); } catch (MalformedURLException e1) { //delete any leftover data delete(emptyRepository); @@ -708,7 +708,7 @@ try { //verify destination's content - assertContentEquals("19.2", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContentEquals("19.2", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); } catch (ProvisionException e) { fail("19.3", e); } catch (MalformedURLException e) { @@ -731,10 +731,10 @@ try { //verify destination's content - assertContains("20.2", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); - assertContains("20.3", getArtifactRepositoryManager().loadRepository(sourceRepo4Location.toURL(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null)); + assertContains("20.2", getManager().loadRepository(sourceRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); + assertContains("20.3", getManager().loadRepository(sourceRepo4Location.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("20.4", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURL(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo4Location.toURL(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURL(), null).getArtifactKeys().length); + assertEquals("20.4", getManager().loadRepository(sourceRepoLocation.toURL(), null).getArtifactKeys().length + getManager().loadRepository(sourceRepo4Location.toURL(), null).getArtifactKeys().length, getManager().loadRepository(destRepoLocation.toURL(), null).getArtifactKeys().length); } catch (ProvisionException e) { fail("20.5", e); } catch (MalformedURLException e) { @@ -805,4 +805,50 @@ fail("23.1", e); } } + + /** + * Ensures that a repository created by the mirror application is a copy of the source + */ + public void testNewArtifactRepoProperties() { + //run mirror application with source not preexisting + artifactMirrorToEmpty("24.0", true); + + try { + assertEquals("24.1", getManager().loadRepository(sourceRepoLocation.toURL(), null).getName(), getManager().loadRepository(destRepoLocation.toURL(), null).getName()); + assertRepositoryProperties("24.2", getManager().loadRepository(sourceRepoLocation.toURL(), null).getProperties(), getManager().loadRepository(destRepoLocation.toURL(), null).getProperties()); + } catch (ProvisionException e) { + fail("24.3", e); + } catch (MalformedURLException e) { + fail("24.4", e); + } + } + + /** + * Ensures that a repository created before the mirror application is run does not have its properties changed + */ + public void testExistingArtifactRepoProperties() { + //Setup: create the destination + String name = "Destination Name"; + Map properties = null; //default properties + try { + //create the repository and get the resulting properties + properties = getManager().createRepository(destRepoLocation.toURL(), name, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties).getProperties(); + } catch (ProvisionException e) { + fail("25.0", e); + } catch (MalformedURLException e) { + fail("25.1", e); + } + + //run the mirror application + artifactMirrorToEmpty("25.2", true); + + try { + assertEquals("25.3", name, getManager().loadRepository(destRepoLocation.toURL(), null).getName()); + assertRepositoryProperties("25.4", properties, getManager().loadRepository(destRepoLocation.toURL(), null).getProperties()); + } catch (ProvisionException e) { + fail("25.5", e); + } catch (MalformedURLException e) { + fail("25.6", e); + } + } } #P org.eclipse.equinox.p2.artifact.repository Index: src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java,v retrieving revision 1.13 diff -u -r1.13 MirrorApplication.java --- src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java 2 Oct 2008 21:08:09 -0000 1.13 +++ src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java 3 Oct 2008 14:21:02 -0000 @@ -82,14 +82,14 @@ //TODO modify the contains statement once the API is available destinationLoaded = getManager().contains(destinationLocation); - destination = initializeDestination(); + //must execute before initializeDestination is called source = getManager().loadRepository(sourceLocation, null); + destination = initializeDestination(); } private IArtifactRepository initializeDestination() throws ProvisionException { - IArtifactRepositoryManager manager = getManager(); try { - IArtifactRepository repository = manager.loadRepository(destinationLocation, null); + IArtifactRepository repository = getManager().loadRepository(destinationLocation, null); if (!repository.isModifiable()) throw new IllegalArgumentException("Artifact repository not modifiable: " + destinationLocation); //$NON-NLS-1$ if (!append) @@ -98,10 +98,10 @@ } catch (ProvisionException e) { //fall through and create a new repository below } - // the given repo location is not an existing repo so we have to create something + //This code assumes source has been successfully loaded before this point + //No existing repository; create a new repository at destinationLocation but with source's attributes. // TODO for now create a Simple repo by default. - String repositoryName = destinationLocation + " - artifacts"; //$NON-NLS-1$ - return manager.createRepository(destinationLocation, repositoryName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, null); + return getManager().createRepository(destinationLocation, source.getName(), IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, source.getProperties()); } /* (non-Javadoc) #P org.eclipse.equinox.p2.metadata.repository Index: src/org/eclipse/equinox/internal/p2/metadata/mirror/MirrorApplication.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/MirrorApplication.java,v retrieving revision 1.5 diff -u -r1.5 MirrorApplication.java --- src/org/eclipse/equinox/internal/p2/metadata/mirror/MirrorApplication.java 1 Oct 2008 15:19:37 -0000 1.5 +++ src/org/eclipse/equinox/internal/p2/metadata/mirror/MirrorApplication.java 3 Oct 2008 14:21:05 -0000 @@ -82,8 +82,9 @@ //TODO modify the contains statement once the API is available destinationLoaded = getManager().contains(destinationLocation); - destination = initializeDestination(); + //must execute before initializeDestination is called source = getManager().loadRepository(sourceLocation, null); + destination = initializeDestination(); } /* @@ -116,8 +117,10 @@ } catch (ProvisionException e) { //fall through and create repo } - String repositoryName = destinationLocation + " - metadata"; //$NON-NLS-1$ - return getManager().createRepository(destinationLocation, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, null); + //This code assumes source has been successfully loaded before this point + //No existing repository; create a new repository at destinationLocation but with source's attributes. + // TODO for now create a Simple repo by default. + return getManager().createRepository(destinationLocation, source.getName(), IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, source.getProperties()); } /* (non-Javadoc)