diff options
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ContextFinderTests.java')
-rw-r--r-- | bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ContextFinderTests.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ContextFinderTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ContextFinderTests.java new file mode 100644 index 000000000..8521eb651 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ContextFinderTests.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * 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()); + } + +} |