--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests;
+
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceMI;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The plug-in ID
+ */
+ public static final String PLUGIN_ID = "org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests";
+
+ // The shared instance
+ private static Activator fPlugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ setDefault(this);
+ }
+
+ /**
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return fPlugin;
+ }
+
+ /**
+ * @param plugin the shared instance
+ */
+ private static void setDefault(Activator plugin) {
+ fPlugin = plugin;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ setDefault(this);
+ String systemProperty = System.getProperty(LTTngControlServiceMI.MI_SCHEMA_VALIDATION_KEY);
+ if (systemProperty == null) {
+ System.setProperty(LTTngControlServiceMI.MI_SCHEMA_VALIDATION_KEY, Boolean.TRUE.toString());
+ }
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ setDefault(null);
+ super.stop(context);
+ }
+
+}
org.eclipse.tracecompass.lttng2.control.ui.tests;x-friends:="org.eclipse.tracecompass.alltests",
org.eclipse.tracecompass.lttng2.control.ui.tests.model.component;x-internal:=true,
org.eclipse.tracecompass.lttng2.control.ui.tests.service;x-internal:=true
+Bundle-Activator: org.eclipse.tracecompass.lttng2.control.ui.tests.Activator
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.control.ui.tests;
+
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceMI;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The plug-in ID
+ */
+ public static final String PLUGIN_ID = "org.eclipse.tracecompass.lttng2.control.ui.tests";
+
+ // The shared instance
+ private static Activator fPlugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ setDefault(this);
+ }
+
+ /**
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return fPlugin;
+ }
+
+ /**
+ * @param plugin the shared instance
+ */
+ private static void setDefault(Activator plugin) {
+ fPlugin = plugin;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ setDefault(this);
+ String systemProperty = System.getProperty(LTTngControlServiceMI.MI_SCHEMA_VALIDATION_KEY);
+ if (systemProperty == null) {
+ System.setProperty(LTTngControlServiceMI.MI_SCHEMA_VALIDATION_KEY, Boolean.TRUE.toString());
+ }
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ setDefault(null);
+ super.stop(context);
+ }
+
+}
--- /dev/null
+org.eclipse.tracecompass.lttng2.control.ui/mi/schema-validation=false
org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests",
org.eclipse.tracecompass.internal.lttng2.control.ui.views.preferences;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests",
org.eclipse.tracecompass.internal.lttng2.control.ui.views.property;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests",
- org.eclipse.tracecompass.internal.lttng2.control.ui.views.service;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests"
+ org.eclipse.tracecompass.internal.lttng2.control.ui.views.service;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests"
Import-Package: com.google.common.collect
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SessionInfo;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SnapshotInfo;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.UstProviderInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers.XmlMiValidationErrorHandler;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput;
*/
public class LTTngControlServiceMI extends LTTngControlService {
+ /**
+ * The tracing key (.options) and System property to control whether or not schema validation should be used.
+ */
+ public static final String MI_SCHEMA_VALIDATION_KEY = Activator.PLUGIN_ID + "/mi/schema-validation"; //$NON-NLS-1$
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setValidating(false);
- // Validate XSD schema
- if (xsdUrl != null) {
- SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- try {
- docBuilderFactory.setSchema(schemaFactory.newSchema(xsdUrl));
- } catch (SAXException e) {
- throw new ExecutionException(Messages.TraceControl_InvalidSchemaError, e);
+ if (isSchemaValidationEnabled()) {
+ // Validate XSD schema
+ if (xsdUrl != null) {
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ try {
+ docBuilderFactory.setSchema(schemaFactory.newSchema(xsdUrl));
+ } catch (SAXException e) {
+ throw new ExecutionException(Messages.TraceControl_InvalidSchemaError, e);
+ }
}
}
}
+ private static boolean isSchemaValidationEnabled() {
+ String schemaValidationKey = Platform.getDebugOption(MI_SCHEMA_VALIDATION_KEY);
+ String systemProperty = System.getProperty(MI_SCHEMA_VALIDATION_KEY);
+ return schemaValidationKey != null && Boolean.parseBoolean(schemaValidationKey) || systemProperty != null && Boolean.parseBoolean(systemProperty);
+ }
+
/**
* Generate a Document object from an list of Strings.
*