1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.tests
;
15 import java
.io
.IOException
;
18 import org
.eclipse
.core
.runtime
.FileLocator
;
19 import org
.eclipse
.core
.runtime
.IPath
;
20 import org
.eclipse
.core
.runtime
.Path
;
21 import org
.eclipse
.core
.runtime
.Plugin
;
22 import org
.eclipse
.jdt
.annotation
.NonNull
;
23 import org
.eclipse
.tracecompass
.internal
.tmf
.core
.TmfCoreTracer
;
24 import org
.osgi
.framework
.BundleContext
;
27 * <b><u>TmfTestPlugin</u></b>
29 * The activator class controls the plug-in life cycle
31 public class TmfCoreTestPlugin
extends Plugin
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
38 @SuppressWarnings("javadoc")
39 public static final String PLUGIN_ID
= "org.eclipse.tracecompass.tmf.tests";
41 // The shared instance
42 private static TmfCoreTestPlugin fPlugin
;
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
51 public TmfCoreTestPlugin() {
55 // ------------------------------------------------------------------------
57 // ------------------------------------------------------------------------
60 * @return the shared instance
62 public static TmfCoreTestPlugin
getDefault() {
67 * @param plugin the shared instance
69 private static void setDefault(TmfCoreTestPlugin plugin
) {
73 // ------------------------------------------------------------------------
75 // ------------------------------------------------------------------------
78 public void start(BundleContext context
) throws Exception
{
85 public void stop(BundleContext context
) throws Exception
{
92 * Return a path to a file relative to this plugin's base directory
95 * The path relative to the plugin's root directory
96 * @return The path corresponding to the relative path in parameter
98 public static @NonNull IPath
getAbsoluteFilePath(String relativePath
) {
99 Plugin plugin
= TmfCoreTestPlugin
.getDefault();
100 if (plugin
== null) {
102 * Shouldn't happen but at least throw something to get the test to
105 throw new IllegalStateException();
107 URL location
= FileLocator
.find(plugin
.getBundle(), new Path(relativePath
), null);
109 return new Path(FileLocator
.toFileURL(location
).getPath());
110 } catch (IOException e
) {
111 throw new IllegalStateException();