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 101386 Details for
Bug 231642
[ui] [repo] I can add the same repo twice
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix v01
patch.txt (text/plain), 9.47 KB, created by
John Arthorne
on 2008-05-21 16:53:23 EDT
(
hide
)
Description:
Fix v01
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2008-05-21 16:53:23 EDT
Size:
9.47 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.tests >Index: src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java,v >retrieving revision 1.8 >diff -u -r1.8 SimpleArtifactRepositoryTest.java >--- src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java 18 Apr 2008 21:35:33 -0000 1.8 >+++ src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java 21 May 2008 20:50:32 -0000 >@@ -27,6 +27,22 @@ > import org.eclipse.equinox.p2.tests.TestActivator; > > public class SimpleArtifactRepositoryTest extends TestCase { >+ //artifact repository to remove on tear down >+ private File repositoryFile = null; >+ private URL repositoryURL = null; >+ >+ protected void tearDown() throws Exception { >+ super.tearDown(); >+ //repository location is not used by all tests >+ if (repositoryURL != null) { >+ getArtifactRepositoryManager().removeRepository(repositoryURL); >+ repositoryURL = null; >+ } >+ if (repositoryFile != null) { >+ delete(repositoryFile); >+ repositoryFile = null; >+ } >+ } > > public void testGetActualLocation1() throws MalformedURLException { > URL base = new URL("http://localhost/artifactRepository"); >@@ -65,19 +81,20 @@ > public void testCompressedRepository() throws MalformedURLException, ProvisionException { > IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); > String tempDir = System.getProperty("java.io.tmpdir"); >- File repoLocation = new File(tempDir, "SimpleArtifactRepositoryTest"); >+ repositoryFile = new File(tempDir, "SimpleArtifactRepositoryTest"); >+ delete(repositoryFile); >+ repositoryURL = repositoryFile.toURL(); > Map properties = new HashMap(); > properties.put(IRepository.PROP_COMPRESSED, "true"); >- IArtifactRepository repo = artifactRepositoryManager.createRepository(repoLocation.toURL(), "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); >- artifactRepositoryManager.addRepository(repo.getLocation()); >+ IArtifactRepository repo = artifactRepositoryManager.createRepository(repositoryURL, "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); > EclipseInstallGeneratorInfoProvider provider = new EclipseInstallGeneratorInfoProvider(); > provider.setArtifactRepository(repo); >- provider.initialize(repoLocation); >+ provider.initialize(repositoryFile); > provider.setRootVersion("3.3"); > provider.setRootId("sdk"); > provider.setFlavor("tooling"); > new Generator(provider).generate(); >- File files[] = repoLocation.listFiles(); >+ File files[] = repositoryFile.listFiles(); > boolean jarFilePresent = false; > boolean artifactFilePresent = false; > for (int i = 0; i < files.length; i++) { >@@ -92,25 +109,25 @@ > fail("Repository should create JAR for artifact.xml"); > if (artifactFilePresent) > fail("Repository should not create artifact.xml"); >- delete(repoLocation); > } > > public void testUncompressedRepository() throws MalformedURLException, ProvisionException { > IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); > String tempDir = System.getProperty("java.io.tmpdir"); >- File repoLocation = new File(tempDir, "SimpleArtifactRepositoryTest"); >+ repositoryFile = new File(tempDir, "SimpleArtifactRepositoryTest"); >+ delete(repositoryFile); >+ repositoryURL = repositoryFile.toURL(); > Map properties = new HashMap(); > properties.put(IRepository.PROP_COMPRESSED, "false"); >- IArtifactRepository repo = artifactRepositoryManager.createRepository(repoLocation.toURL(), "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); >- artifactRepositoryManager.addRepository(repo.getLocation()); >+ IArtifactRepository repo = artifactRepositoryManager.createRepository(repositoryURL, "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); > EclipseInstallGeneratorInfoProvider provider = new EclipseInstallGeneratorInfoProvider(); > provider.setArtifactRepository(repo); >- provider.initialize(repoLocation); >+ provider.initialize(repositoryFile); > provider.setRootVersion("3.3"); > provider.setRootId("sdk"); > provider.setFlavor("tooling"); > new Generator(provider).generate(); >- File files[] = repoLocation.listFiles(); >+ File files[] = repositoryFile.listFiles(); > boolean jarFilePresent = false; > boolean artifactFilePresent = false; > for (int i = 0; i < files.length; i++) { >@@ -125,7 +142,6 @@ > fail("Repository should not create JAR for artifact.xml"); > if (!artifactFilePresent) > fail("Repository should create artifact.xml"); >- delete(repoLocation); > } > > private boolean delete(File file) { >Index: src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java,v >retrieving revision 1.16 >diff -u -r1.16 MetadataRepositoryManagerTest.java >--- src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java 2 May 2008 20:10:58 -0000 1.16 >+++ src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java 21 May 2008 20:50:32 -0000 >@@ -166,13 +166,13 @@ > // modify the last modified date to be older than the remote file > cacheFile.setLastModified(0); > // reload the repository and check that the cache was updated >- manager.addRepository(repoLocation); >+ manager.removeRepository(repoLocation); > manager.loadRepository(repoLocation, null); > long lastModified = cacheFile.lastModified(); > assertTrue(0 != lastModified); > > // reload the repository and check that the cache was not updated >- manager.addRepository(repoLocation); >+ manager.removeRepository(repoLocation); > manager.loadRepository(repoLocation, null); > assertEquals(lastModified, cacheFile.lastModified()); > >#P org.eclipse.equinox.p2.metadata.repository >Index: src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java,v >retrieving revision 1.45 >diff -u -r1.45 MetadataRepositoryManager.java >--- src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java 20 May 2008 22:08:10 -0000 1.45 >+++ src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java 21 May 2008 20:50:32 -0000 >@@ -131,6 +131,8 @@ > synchronized (repositoryLock) { > if (repositories == null) > restoreRepositories(); >+ if (contains(location)) >+ return; > added = repositories.put(getKey(location), info) == null; > } > // save the given repository in the preferences. >@@ -176,6 +178,23 @@ > } > } > >+ private boolean contains(URL location) { >+ synchronized (repositoryLock) { >+ if (repositories == null) >+ restoreRepositories(); >+ String key = getKey(location); >+ if (repositories.containsKey(key)) >+ return true; >+ //try alternate key with different trailing slash >+ int len = key.length(); >+ if (key.charAt(len - 1) == '_') >+ key = key.substring(0, len - 1); >+ else >+ key = key + '_'; >+ return repositories.containsKey(key); >+ } >+ } >+ > /** > * Returns the executable extension, or <code>null</code> if there > * was no corresponding extension, or an error occurred loading it >#P org.eclipse.equinox.p2.artifact.repository >Index: src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java,v >retrieving revision 1.42 >diff -u -r1.42 ArtifactRepositoryManager.java >--- src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java 20 May 2008 22:08:09 -0000 1.42 >+++ src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java 21 May 2008 20:50:33 -0000 >@@ -125,6 +125,8 @@ > synchronized (repositoryLock) { > if (repositories == null) > restoreRepositories(); >+ if (contains(location)) >+ return; > added = repositories.put(getKey(location), info) == null; > } > // save the given repository in the preferences. >@@ -161,6 +163,23 @@ > } > } > >+ boolean contains(URL location) { >+ synchronized (repositoryLock) { >+ if (repositories == null) >+ restoreRepositories(); >+ String key = getKey(location); >+ if (repositories.containsKey(key)) >+ return true; >+ //try alternate key with different trailing slash >+ int len = key.length(); >+ if (key.charAt(len - 1) == '_') >+ key = key.substring(0, len - 1); >+ else >+ key = key + '_'; >+ return repositories.containsKey(key); >+ } >+ } >+ > public IArtifactRequest createDownloadRequest(IArtifactKey key, IPath destination) { > return new FileDownloadRequest(key, destination); > }
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 231642
: 101386