blob: c145c1c03387b9cddb034e4587a58fbede5262c4 (
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
79
|
/*******************************************************************************
* 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.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
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", Version.create("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));
}
// temporarily disabling this test until API is done
public void DISABLED_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);
}
}
}
|