blob: 8521eb6519e62d244e3c34643beb752837d4bd81 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2013, 2017 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.osgi.tests.hooks.framework;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.launch.Framework;
public class ContextFinderTests extends AbstractFrameworkHookTests {
private Map<String, String> configuration;
private Framework framework;
protected void setUp() throws Exception {
super.setUp();
File file = OSGiTestsActivator.getContext().getDataFile(getName());
configuration = new HashMap<String, String>();
configuration.put(Constants.FRAMEWORK_STORAGE, file.getAbsolutePath());
framework = createFramework(configuration);
initAndStart(framework);
}
protected void tearDown() throws Exception {
stopQuietly(framework);
super.tearDown();
}
public void testContextClassLoaderNullLocal() throws InvalidSyntaxException, IOException {
BundleContext bc = framework.getBundleContext();
ClassLoader contextFinder = bc.getService(bc.getServiceReferences(ClassLoader.class, "(equinox.classloader.type=contextClassLoader)").iterator().next());
Enumeration<URL> result = contextFinder.getResources("does/not/exist.txt");
assertNotNull("Null result.", result);
assertFalse("Found unexpected result", result.hasMoreElements());
}
}