Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2008-05-21 23:09:26 +0000
committerJohn Arthorne2008-05-21 23:09:26 +0000
commit12e0f97b02e27a25dcfcdbac24ce7cd3d486e693 (patch)
tree60c25f6a3d7fb3fa0b53334c5b69c8403fe49e96 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
parentedec76b14c13faeb7189471a28a84671854d3add (diff)
downloadrt.equinox.p2-12e0f97b02e27a25dcfcdbac24ce7cd3d486e693.tar.gz
rt.equinox.p2-12e0f97b02e27a25dcfcdbac24ce7cd3d486e693.tar.xz
rt.equinox.p2-12e0f97b02e27a25dcfcdbac24ce7cd3d486e693.zip
Bug 231642 [ui] [repo] I can add the same repo twicev20080521-1955
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java40
1 files changed, 28 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
index 84fba33e0..a0eac7f5b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
@@ -27,6 +27,22 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.generator.Generator;
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 class SimpleArtifactRepositoryTest extends TestCase {
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 @@ public class SimpleArtifactRepositoryTest extends TestCase {
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 @@ public class SimpleArtifactRepositoryTest extends TestCase {
fail("Repository should not create JAR for artifact.xml");
if (!artifactFilePresent)
fail("Repository should create artifact.xml");
- delete(repoLocation);
}
private boolean delete(File file) {

Back to the top