blob: 1fbca5b5ab86ed8622eb6317f1e5acf3fca12897 (
plain) (
blame)
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
|
/*******************************************************************************
* Copyright (c) 2008, 2009 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
import java.io.File;
import java.net.MalformedURLException;
import org.eclipse.equinox.internal.p2.engine.ActionManager;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
/**
* Simple test of the engine API.
*/
public class ActionManagerTest extends AbstractProvisioningTest {
public ActionManagerTest(String name) {
super(name);
}
public ActionManagerTest() {
super("");
}
public void testGetTouchpointQualifiedActionId() {
ActionManager manager = new ActionManager();
assertNotNull(manager.getTouchpointQualifiedActionId("test", MetadataFactory.createTouchpointType("phaseTest", new Version("1"))));
}
public void testGetActionWithVersion() {
ActionManager manager = new ActionManager();
assertNotNull(manager.getAction("test1.test", new VersionRange("1.0.0")));
}
public void testGetActionWithNullVersion() {
ActionManager manager = new ActionManager();
assertNotNull(manager.getAction("test1.test", null));
}
public void testDynamicAction() throws MalformedURLException, BundleException, InterruptedException {
ActionManager manager = new ActionManager();
assertNull(manager.getAction("dummy.touchpointAndAction.dummy", new VersionRange("1.0.0")));
File dummy = getTestData("0.1", "/testData/engineTest/dummy.touchpointAndAction_1.0.0.jar");
Bundle bundle = TestActivator.getContext().installBundle(dummy.toURL().toString());
bundle.start(); //force resolve
int maxTries = 20;
int current = 0;
while (true) {
if (null != manager.getAction("dummy.touchpointAndAction.dummy", new VersionRange("1.0.0")))
break;
if (++current == maxTries)
fail("dummy action not added");
Thread.sleep(100);
}
bundle.uninstall();
current = 0;
while (true) {
if (null == manager.getAction("dummy.touchpointAndAction.dummy", new VersionRange("1.0.0")))
break;
if (++current == maxTries)
fail("dummy action not removed");
Thread.sleep(100);
}
}
}
|