Commit | Line | Data |
---|---|---|
e5e5b3db JRJ |
1 | /********************************************************************** |
2 | * Copyright (c) 2014 Ericsson | |
3 | * | |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Jonathan Rajotte - Support of machine interface | |
11 | **********************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.lttng2.control.ui.tests.service; | |
14 | ||
15 | import static org.junit.Assert.assertEquals; | |
16 | import static org.junit.Assert.assertNotNull; | |
17 | import static org.junit.Assert.assertTrue; | |
18 | ||
19 | import java.net.URL; | |
20 | ||
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; | |
30 | ||
31 | /** | |
32 | * @author ejorajo | |
33 | * | |
34 | */ | |
35 | public class LTTngControlServiceMiTest extends LTTngControlServiceTest { | |
36 | ||
37 | private static final String MI_TEST_STREAM = "LTTngServiceMiTest.cfg"; | |
38 | ||
39 | @Override | |
40 | protected ILttngControlService getControlService() { | |
41 | try { | |
42 | URL resource = LTTngControlServiceMI.class.getResource(LTTngControlServiceConstants.MI_XSD_FILENAME); | |
43 | return new LTTngControlServiceMI(getfShell(), resource); | |
44 | } catch (ExecutionException e) { | |
45 | return null; | |
46 | } | |
47 | } | |
48 | ||
49 | @Override | |
50 | public void testGetSessionNameGarbage() { | |
51 | try { | |
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 | |
57 | // document. | |
58 | } | |
59 | } | |
60 | ||
61 | @Override | |
62 | public void testCreateLiveSession() throws ExecutionException { | |
63 | fShell.setScenario(SCEN_CREATE_LIVE_SESSION); | |
64 | ||
65 | ISessionInfo params = new SessionInfo("mysession"); | |
66 | params.setLive(true); | |
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()); | |
79 | } | |
80 | ||
81 | @Override | |
82 | protected String getTestStream() { | |
83 | return MI_TEST_STREAM; | |
84 | } | |
85 | ||
86 | @Override | |
87 | protected TraceLogLevel getAllEventTraceLogLevel() { | |
88 | return TraceLogLevel.TRACE_DEBUG; | |
89 | } | |
90 | ||
91 | @Override | |
92 | public void testGetKernelProviderNoUstVerbose() { | |
93 | // Verbose mode in machine interface is deactivated. This test is | |
94 | // ignored. | |
95 | } | |
96 | ||
97 | @Override | |
98 | public void testCreateSession2_1() { | |
99 | // 2.1 is not supported by mi. This test is ignored. | |
100 | } | |
101 | ||
102 | @Override | |
103 | public void testGetKernelProviderNoUst3() { | |
104 | // Verbose mode in machine interface is deactivated. This test is | |
105 | // ignored. | |
106 | } | |
107 | ||
108 | @Override | |
109 | public void testGetKernelProviderNoKernelVerbose() { | |
110 | // Verbose mode in machine interface is deactivated. This test is | |
111 | // ignored. | |
112 | } | |
113 | ||
114 | @Override | |
115 | public void testCreateSessionVerbose2_1() { | |
116 | // Verbose mode in machine interface is deactivated. This test is | |
117 | // ignored. | |
118 | } | |
119 | ||
120 | @Override | |
121 | public void testDestroySessionVerbose() { | |
122 | // Verbose mode in machine interface is deactivated. This test is | |
123 | // ignored. | |
124 | } | |
125 | ||
126 | @Override | |
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. | |
130 | } | |
131 | ||
132 | @Override | |
133 | public void testAddContext() { | |
134 | // TODO This does not use mi feature.And currently the context enabling | |
135 | // is wrong for 2.6. | |
136 | } | |
137 | ||
138 | @Override | |
139 | public void testAddContextFailure() { | |
140 | // TODO This does not use mi feature.And currently the context enabling | |
141 | // is wrong for 2.6. | |
142 | } | |
ad311f36 BH |
143 | |
144 | @Override | |
145 | public void testCreateSnapshotSession2_5() { | |
146 | // not applicable for MI | |
147 | } | |
e5e5b3db | 148 | } |