|
Lines 27-32
Link Here
|
| 27 |
import org.eclipse.equinox.p2.tests.TestActivator; |
27 |
import org.eclipse.equinox.p2.tests.TestActivator; |
| 28 |
|
28 |
|
| 29 |
public class SimpleArtifactRepositoryTest extends TestCase { |
29 |
public class SimpleArtifactRepositoryTest extends TestCase { |
|
|
30 |
//artifact repository to remove on tear down |
| 31 |
private File repositoryFile = null; |
| 32 |
private URL repositoryURL = null; |
| 33 |
|
| 34 |
protected void tearDown() throws Exception { |
| 35 |
super.tearDown(); |
| 36 |
//repository location is not used by all tests |
| 37 |
if (repositoryURL != null) { |
| 38 |
getArtifactRepositoryManager().removeRepository(repositoryURL); |
| 39 |
repositoryURL = null; |
| 40 |
} |
| 41 |
if (repositoryFile != null) { |
| 42 |
delete(repositoryFile); |
| 43 |
repositoryFile = null; |
| 44 |
} |
| 45 |
} |
| 30 |
|
46 |
|
| 31 |
public void testGetActualLocation1() throws MalformedURLException { |
47 |
public void testGetActualLocation1() throws MalformedURLException { |
| 32 |
URL base = new URL("http://localhost/artifactRepository"); |
48 |
URL base = new URL("http://localhost/artifactRepository"); |
|
Lines 65-83
Link Here
|
| 65 |
public void testCompressedRepository() throws MalformedURLException, ProvisionException { |
81 |
public void testCompressedRepository() throws MalformedURLException, ProvisionException { |
| 66 |
IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); |
82 |
IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); |
| 67 |
String tempDir = System.getProperty("java.io.tmpdir"); |
83 |
String tempDir = System.getProperty("java.io.tmpdir"); |
| 68 |
File repoLocation = new File(tempDir, "SimpleArtifactRepositoryTest"); |
84 |
repositoryFile = new File(tempDir, "SimpleArtifactRepositoryTest"); |
|
|
85 |
delete(repositoryFile); |
| 86 |
repositoryURL = repositoryFile.toURL(); |
| 69 |
Map properties = new HashMap(); |
87 |
Map properties = new HashMap(); |
| 70 |
properties.put(IRepository.PROP_COMPRESSED, "true"); |
88 |
properties.put(IRepository.PROP_COMPRESSED, "true"); |
| 71 |
IArtifactRepository repo = artifactRepositoryManager.createRepository(repoLocation.toURL(), "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); |
89 |
IArtifactRepository repo = artifactRepositoryManager.createRepository(repositoryURL, "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); |
| 72 |
artifactRepositoryManager.addRepository(repo.getLocation()); |
|
|
| 73 |
EclipseInstallGeneratorInfoProvider provider = new EclipseInstallGeneratorInfoProvider(); |
90 |
EclipseInstallGeneratorInfoProvider provider = new EclipseInstallGeneratorInfoProvider(); |
| 74 |
provider.setArtifactRepository(repo); |
91 |
provider.setArtifactRepository(repo); |
| 75 |
provider.initialize(repoLocation); |
92 |
provider.initialize(repositoryFile); |
| 76 |
provider.setRootVersion("3.3"); |
93 |
provider.setRootVersion("3.3"); |
| 77 |
provider.setRootId("sdk"); |
94 |
provider.setRootId("sdk"); |
| 78 |
provider.setFlavor("tooling"); |
95 |
provider.setFlavor("tooling"); |
| 79 |
new Generator(provider).generate(); |
96 |
new Generator(provider).generate(); |
| 80 |
File files[] = repoLocation.listFiles(); |
97 |
File files[] = repositoryFile.listFiles(); |
| 81 |
boolean jarFilePresent = false; |
98 |
boolean jarFilePresent = false; |
| 82 |
boolean artifactFilePresent = false; |
99 |
boolean artifactFilePresent = false; |
| 83 |
for (int i = 0; i < files.length; i++) { |
100 |
for (int i = 0; i < files.length; i++) { |
|
Lines 92-116
Link Here
|
| 92 |
fail("Repository should create JAR for artifact.xml"); |
109 |
fail("Repository should create JAR for artifact.xml"); |
| 93 |
if (artifactFilePresent) |
110 |
if (artifactFilePresent) |
| 94 |
fail("Repository should not create artifact.xml"); |
111 |
fail("Repository should not create artifact.xml"); |
| 95 |
delete(repoLocation); |
|
|
| 96 |
} |
112 |
} |
| 97 |
|
113 |
|
| 98 |
public void testUncompressedRepository() throws MalformedURLException, ProvisionException { |
114 |
public void testUncompressedRepository() throws MalformedURLException, ProvisionException { |
| 99 |
IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); |
115 |
IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); |
| 100 |
String tempDir = System.getProperty("java.io.tmpdir"); |
116 |
String tempDir = System.getProperty("java.io.tmpdir"); |
| 101 |
File repoLocation = new File(tempDir, "SimpleArtifactRepositoryTest"); |
117 |
repositoryFile = new File(tempDir, "SimpleArtifactRepositoryTest"); |
|
|
118 |
delete(repositoryFile); |
| 119 |
repositoryURL = repositoryFile.toURL(); |
| 102 |
Map properties = new HashMap(); |
120 |
Map properties = new HashMap(); |
| 103 |
properties.put(IRepository.PROP_COMPRESSED, "false"); |
121 |
properties.put(IRepository.PROP_COMPRESSED, "false"); |
| 104 |
IArtifactRepository repo = artifactRepositoryManager.createRepository(repoLocation.toURL(), "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); |
122 |
IArtifactRepository repo = artifactRepositoryManager.createRepository(repositoryURL, "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); |
| 105 |
artifactRepositoryManager.addRepository(repo.getLocation()); |
|
|
| 106 |
EclipseInstallGeneratorInfoProvider provider = new EclipseInstallGeneratorInfoProvider(); |
123 |
EclipseInstallGeneratorInfoProvider provider = new EclipseInstallGeneratorInfoProvider(); |
| 107 |
provider.setArtifactRepository(repo); |
124 |
provider.setArtifactRepository(repo); |
| 108 |
provider.initialize(repoLocation); |
125 |
provider.initialize(repositoryFile); |
| 109 |
provider.setRootVersion("3.3"); |
126 |
provider.setRootVersion("3.3"); |
| 110 |
provider.setRootId("sdk"); |
127 |
provider.setRootId("sdk"); |
| 111 |
provider.setFlavor("tooling"); |
128 |
provider.setFlavor("tooling"); |
| 112 |
new Generator(provider).generate(); |
129 |
new Generator(provider).generate(); |
| 113 |
File files[] = repoLocation.listFiles(); |
130 |
File files[] = repositoryFile.listFiles(); |
| 114 |
boolean jarFilePresent = false; |
131 |
boolean jarFilePresent = false; |
| 115 |
boolean artifactFilePresent = false; |
132 |
boolean artifactFilePresent = false; |
| 116 |
for (int i = 0; i < files.length; i++) { |
133 |
for (int i = 0; i < files.length; i++) { |
|
Lines 125-131
Link Here
|
| 125 |
fail("Repository should not create JAR for artifact.xml"); |
142 |
fail("Repository should not create JAR for artifact.xml"); |
| 126 |
if (!artifactFilePresent) |
143 |
if (!artifactFilePresent) |
| 127 |
fail("Repository should create artifact.xml"); |
144 |
fail("Repository should create artifact.xml"); |
| 128 |
delete(repoLocation); |
|
|
| 129 |
} |
145 |
} |
| 130 |
|
146 |
|
| 131 |
private boolean delete(File file) { |
147 |
private boolean delete(File file) { |