1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*******************************************************************************
* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* EclipseSource - initial API and implementation
******************************************************************************/
package org.eclipse.equinox.p2.tests.updatesite;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.updatesite.UpdateSitePublisherApplication;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.IUPropertyQuery;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.internal.provisional.p2.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.query.Query;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestData;
public class LocalUpdatesiteTest extends AbstractProvisioningTest {
protected File repoLocation;
protected void setUp() throws Exception {
super.setUp();
String tempDir = System.getProperty("java.io.tmpdir");
repoLocation = new File(tempDir, "LocalMetadataRepositoryTest");
AbstractProvisioningTest.delete(repoLocation);
repoLocation.mkdir();
}
protected void tearDown() throws Exception {
getMetadataRepositoryManager().removeRepository(repoLocation.toURI());
delete(repoLocation);
super.tearDown();
}
public void testCategoryQualifier() throws IOException, ProvisionException {
Query categoryQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_CATEGORY, Boolean.toString(true));
File siteSource = TestData.getFile("updatesite", "SiteXMLActionTest");
UpdateSitePublisherApplication application = new UpdateSitePublisherApplication();
try {
application.run(new String[] {"-metadataRepository", repoLocation.toURI().toString(), "-source", siteSource.toString(), "-categoryQualifier", "fooQualifier"});
} catch (Exception e) {
fail("0.99");
}
IMetadataRepository repository = getMetadataRepositoryManager().loadRepository(repoLocation.toURI(), new NullProgressMonitor());
Collector results = repository.query(categoryQuery, new Collector(), new NullProgressMonitor());
assertEquals("1.0", 1, results.size());
Iterator iter = results.iterator();
while (iter.hasNext()) {
IInstallableUnit unit = (IInstallableUnit) iter.next();
assertTrue("2.0", unit.getId().startsWith("fooQualifier"));
assertEquals("3.0", "Test Category Label", unit.getProperty(IInstallableUnit.PROP_NAME));
}
}
}
|