Skip to main content
summaryrefslogtreecommitdiffstats
blob: a58ccfffed4401724ab3cfd317151c5b4a636b84 (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
/*******************************************************************************
 * Copyright (c) 2008, 2017 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.frameworkadmin.tests;

import java.io.File;
import java.io.IOException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
import org.osgi.framework.BundleException;

public class RemovingABundle extends FwkAdminAndSimpleConfiguratorTest {

	public RemovingABundle(String name) {
		super(name);
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		Manipulator manipulator = createMinimalConfiguration(RemovingABundle.class.getName());
		manipulator.getConfigData().addBundle(new BundleInfo("bundle_1", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 4, false));
		manipulator.save(false);

		File fooINI = new File(getInstallFolder(), getLauncherName() +".ini");
		assertEquals(fooINI.exists(), true);
		assertContent(getBundleTxt(), "bundle_1");
	}
	
	public void testRemoveBundleWithoutURL() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException {
		Manipulator m2 = getEquinoxFrameworkAdmin().getManipulator();

		LauncherData launcherData2 = m2.getLauncherData();
		launcherData2.setFwConfigLocation(getConfigurationFolder());
		launcherData2.setLauncher(new File(getInstallFolder(), "eclipse"));

		try {
			m2.load();
		} catch (IllegalStateException e) {
			//TODO We ignore the framework JAR location not set exception
		}
		BundleInfo info = new BundleInfo("bundle_1", "1.0.0", null, 0, false);
		m2.getConfigData().removeBundle(info);
		m2.save(false);

		assertNotContent(getBundleTxt(), "bundle_1");
	}
}

Back to the top