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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*******************************************************************************
* Copyright (c) 2010 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.net.URI;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.updatesite.CategoryXMLAction;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.tests.*;
/**
*
*/
public class CategoryIUXMLActionTest extends AbstractProvisioningTest {
private TestMetadataRepository metadataRepository;
private IPublisherResult actionResult;
private URI siteLocation;
@Override
protected void setUp() throws Exception {
super.setUp();
actionResult = new PublisherResult();
PublisherInfo info = new PublisherInfo();
metadataRepository = new TestMetadataRepository(getAgent(), new IInstallableUnit[0]);
info.setMetadataRepository(metadataRepository);
siteLocation = TestData.getFile("updatesite", "CategoryXMLActionTest/" + getName() + ".xml").toURI();
FeaturesAction featuresAction = new FeaturesAction(new File[] {TestData.getFile("updatesite", "CategoryXMLActionTest")});
featuresAction.perform(info, actionResult, new NullProgressMonitor());
CategoryXMLAction action = new CategoryXMLAction(siteLocation, null);
action.perform(info, actionResult, getMonitor());
}
public void testIUCategoryCreation01() throws Exception {
doCategorySetTest();
}
public void testIUCategoryCreation02() throws Exception {
doCategorySetTest();
}
public void testIUCategoryCreation03() throws Exception {
doCategorySetTest();
}
public void testIUCategoryCreation04() throws Exception {
doCategoryNotSetTest();
}
public void testIUCategoryCreation05() throws Exception {
doCategoryNotSetTest();
}
public void testIUCategoryCreation06() throws Exception {
doCategoryNotSetTest();
}
private void doCategorySetTest() {
IQueryResult result = actionResult.query(QueryUtil.createIUCategoryQuery(), new NullProgressMonitor());
assertEquals("1.0", 1, queryResultSize(result));
IInstallableUnit iu = (IInstallableUnit) result.iterator().next();
assertEquals("1.1", "Test Category Label", iu.getProperty(IInstallableUnit.PROP_NAME));
}
private void doCategoryNotSetTest() {
IQueryResult result = actionResult.query(QueryUtil.createIUCategoryQuery(), new NullProgressMonitor());
assertEquals("1.0", 0, queryResultSize(result));
}
}
|