1 /**********************************************************************
2 * Copyright (c) 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 * Jonathan Rajotte - Support of machine interface
11 **********************************************************************/
13 package org
.eclipse
.linuxtools
.lttng2
.control
.ui
.tests
.service
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.assertTrue
;
21 import org
.eclipse
.core
.commands
.ExecutionException
;
22 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.SessionInfo
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.service
.ILttngControlService
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlServiceConstants
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlServiceMI
;
35 public class LTTngControlServiceMiTest
extends LTTngControlServiceTest
{
37 private static final String MI_TEST_STREAM
= "LTTngServiceMiTest.cfg";
40 protected ILttngControlService
getControlService() {
42 URL resource
= LTTngControlServiceMI
.class.getResource(LTTngControlServiceConstants
.MI_XSD_FILENAME
);
43 return new LTTngControlServiceMI(getfShell(), resource
);
44 } catch (ExecutionException e
) {
50 public void testGetSessionNameGarbage() {
52 fShell
.setScenario(SCEN_GET_SESSION_GARBAGE_OUT
);
53 fService
.getSessionNames(new NullProgressMonitor());
54 } catch (ExecutionException e
) {
55 // Success. Parsing of garbage result in an ExecutionException
56 // generated by the XML document parser: Unable to parse the xml
62 public void testCreateLiveSession() throws ExecutionException
{
63 fShell
.setScenario(SCEN_CREATE_LIVE_SESSION
);
65 ISessionInfo params
= new SessionInfo("mysession");
67 params
.setStreamedTrace(true);
68 params
.setNetworkUrl("net://127.0.0.1");
69 ISessionInfo sessionInfo
= fService
.createSession(params
, new NullProgressMonitor());
70 assertNotNull(sessionInfo
);
71 assertEquals("mysession", sessionInfo
.getName());
72 assertEquals(TraceSessionState
.INACTIVE
, sessionInfo
.getSessionState());
73 assertTrue(sessionInfo
.isStreamedTrace());
74 assertTrue(sessionInfo
.isLive());
75 assertEquals("tcp4://127.0.0.1:5342/ [data: 5343]", sessionInfo
.getSessionPath());
76 String
[] names
= fService
.getSessionNames(new NullProgressMonitor());
77 assertEquals(names
[0], "mysession");
78 fService
.destroySession("mysession", new NullProgressMonitor());
82 protected String
getTestStream() {
83 return MI_TEST_STREAM
;
87 protected TraceLogLevel
getAllEventTraceLogLevel() {
88 return TraceLogLevel
.TRACE_DEBUG
;
92 public void testGetKernelProviderNoUstVerbose() {
93 // Verbose mode in machine interface is deactivated. This test is
98 public void testCreateSession2_1() {
99 // 2.1 is not supported by mi. This test is ignored.
103 public void testGetKernelProviderNoUst3() {
104 // Verbose mode in machine interface is deactivated. This test is
109 public void testGetKernelProviderNoKernelVerbose() {
110 // Verbose mode in machine interface is deactivated. This test is
115 public void testCreateSessionVerbose2_1() {
116 // Verbose mode in machine interface is deactivated. This test is
121 public void testDestroySessionVerbose() {
122 // Verbose mode in machine interface is deactivated. This test is
127 public void testCreateSessionWithPrompt() {
128 // TODO Investigate if this case can happen in production. If yes than
129 // we need to rethinks the MI fetching and parsing.
133 public void testAddContext() {
134 // TODO This does not use mi feature.And currently the context enabling
139 public void testAddContextFailure() {
140 // TODO This does not use mi feature.And currently the context enabling