Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 56286d16b579d735c0510cea39689828ecc5d78f (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
/*******************************************************************************
 * Copyright (c) 2007, 2008 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.frameworkadmin.tests;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
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 SimpleConfiguratorComingAndGoing extends FwkAdminAndSimpleConfiguratorTest {
	Manipulator m = null;

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

	protected void setUp() throws Exception {
		super.setUp();
		m = createMinimalConfiguration(SimpleConfiguratorComingAndGoing.class.getName());
	}

	public void testWithMutipleBundles() throws IOException, BundleException, URISyntaxException {
		BundleInfo bi = new BundleInfo(URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, false);
		m.getConfigData().addBundle(bi);
		m.save(false);

		BundleInfo[] bis = m.getConfigData().getBundles();
		for (int i = 0; i < bis.length; i++) {
			if (bis[i].getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator"))
				m.getConfigData().removeBundle(bis[i]);
		}
		m.save(false);

		assertNothing(getBundleTxt());
		assertContent(getConfigIni(), "bundle_1");
		assertContent(getConfigIni(), "org.eclipse.osgi");

		FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin();
		Manipulator newManipulator = fwkAdmin.getManipulator();

		LauncherData launcherData = newManipulator.getLauncherData();
		launcherData.setFwConfigLocation(getConfigurationFolder());
		launcherData.setLauncher(new File(getInstallFolder(), getLauncherName()));
		try {
			newManipulator.load();
		} catch (IllegalStateException e) {
			//TODO We ignore the framework JAR location not set exception
		}

		newManipulator.getConfigData().addBundle(new BundleInfo(URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true));
		newManipulator.save(false);

		assertContent(getBundleTxt(), "org.eclipse.osgi");
		assertContent(getBundleTxt(), "bundle_1");
		assertContent(getBundleTxt(), "org.eclipse.equinox.simpleconfigurator");
	}
}

Back to the top