Bug 448058: Replace RSE by org.eclipse.remote
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.ui.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / tests / model / component / TraceControlPropertiesTest.java
CommitLineData
06b9339e 1/**********************************************************************
b732adaa 2 * Copyright (c) 2012, 2014 Ericsson
cfdb727a 3 *
06b9339e
BH
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
cfdb727a
AM
8 *
9 * Contributors:
06b9339e 10 * Bernd Hufmann - Initial API and implementation
2ba3d0a1 11 * Alexandre Montplaisir - Port to JUnit4
b732adaa 12 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
06b9339e 13 **********************************************************************/
2ba3d0a1 14
9bc60be7 15package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component;
06b9339e 16
b732adaa
MS
17import static org.junit.Assert.assertEquals;
18import static org.junit.Assert.assertFalse;
19import static org.junit.Assert.assertNotNull;
20import static org.junit.Assert.assertNull;
21import static org.junit.Assert.assertTrue;
2ba3d0a1 22
d132bcc7
BH
23import java.io.File;
24import java.net.URL;
25
d132bcc7
BH
26import org.eclipse.core.runtime.FileLocator;
27import org.eclipse.core.runtime.Path;
b732adaa
MS
28import org.eclipse.remote.core.IRemoteConnection;
29import org.eclipse.remote.core.IRemoteConnectionManager;
30import org.eclipse.remote.core.RemoteServices;
9bc60be7
AM
31import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
32import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
33import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement;
34import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEventType;
35import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
36import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
37import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BufferType;
38import org.eclipse.tracecompass.internal.lttng2.control.stubs.service.TestRemoteSystemProxy;
39import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
40import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.BaseEventComponent;
41import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.KernelProviderComponent;
42import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
43import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceChannelComponent;
44import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceDomainComponent;
45import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceEventComponent;
46import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceProbeEventComponent;
47import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
48import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.UstProviderComponent;
49import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.BaseEventPropertySource;
50import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.KernelProviderPropertySource;
51import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TargetNodePropertySource;
52import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceChannelPropertySource;
53import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceDomainPropertySource;
54import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceEventPropertySource;
55import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceProbeEventPropertySource;
56import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceSessionPropertySource;
57import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.UstProviderPropertySource;
06b9339e
BH
58import org.eclipse.ui.views.properties.IPropertySource;
59import org.junit.After;
2ba3d0a1 60import org.junit.Test;
9269df72 61import org.osgi.framework.FrameworkUtil;
06b9339e
BH
62
63/**
2ba3d0a1
AM
64 * The class <code>TraceControlPropertiesTest</code> contains tests for the all
65 * property class</code>.
06b9339e 66 */
2ba3d0a1 67public class TraceControlPropertiesTest {
d132bcc7
BH
68
69 // ------------------------------------------------------------------------
70 // Constants
71 // ------------------------------------------------------------------------
2ba3d0a1 72
d132bcc7
BH
73 private static final String DIRECTORY = "testfiles";
74 private static final String TEST_STREAM = "ListInfoTest.cfg";
75 private static final String SCEN_LIST_INFO_TEST = "ListInfoTest";
76
06b9339e
BH
77 // ------------------------------------------------------------------------
78 // Housekeeping
79 // ------------------------------------------------------------------------
80
06b9339e
BH
81 /**
82 * Perform post-test clean-up.
06b9339e 83 */
06b9339e 84 @After
2ba3d0a1 85 public void tearDown() {
b957fb8c 86 TraceControlTestFacility.getInstance().waitForJobs();
06b9339e 87 }
cfdb727a 88
06b9339e
BH
89 /**
90 * Run the TraceControlComponent.
cfdb727a
AM
91 *
92 * @throws Exception
93 * This will fail the test
06b9339e 94 */
2ba3d0a1 95 @Test
a26d90be 96 public void testComponentProperties() throws Exception {
cfdb727a 97
06b9339e
BH
98 TestRemoteSystemProxy proxy = new TestRemoteSystemProxy();
99
9269df72 100 URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
d132bcc7
BH
101 File testfile = new File(FileLocator.toFileURL(location).toURI());
102 proxy.setTestFile(testfile.getAbsolutePath());
103 proxy.setScenario(SCEN_LIST_INFO_TEST);
cfdb727a 104
06b9339e
BH
105 ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
106
b732adaa
MS
107 IRemoteConnectionManager cm = RemoteServices.getLocalServices().getConnectionManager();
108 IRemoteConnection host = cm.getConnection(IRemoteConnectionManager.LOCAL_CONNECTION_NAME);
06b9339e
BH
109
110 TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, proxy);
111
112 root.addChild(node);
113 node.connect();
114
b732adaa 115 TraceControlTestFacility.getInstance().waitForConnect(node);
06b9339e
BH
116 TraceControlTestFacility.getInstance().waitForJobs();
117
118 // ------------------------------------------------------------------------
119 // Verify Node Properties (adapter)
120 // ------------------------------------------------------------------------
121 Object adapter = node.getAdapter(IPropertySource.class);
122 assertNotNull(adapter);
123 assertTrue(adapter instanceof TargetNodePropertySource);
124
125 TargetNodePropertySource source = (TargetNodePropertySource)adapter;
126
127 assertNull(source.getEditableValue());
128 assertFalse(source.isPropertySet(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID));
129 assertNotNull(source.getPropertyDescriptors());
130
131 assertEquals("myNode", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID));
b732adaa 132 assertEquals("localhost", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_ADDRESS_PROPERTY_ID));
06b9339e 133 assertEquals(TargetNodeState.CONNECTED.name(), source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_STATE_PROPERTY_ID));
d4514365 134 assertEquals("2.1.0", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_VERSION_PROPERTY_ID));
06b9339e
BH
135 assertNull(source.getPropertyValue("test"));
136
137 adapter = node.getAdapter(IChannelInfo.class);
138 assertNull(adapter);
cfdb727a 139
06b9339e
BH
140 ITraceControlComponent[] groups = node.getChildren();
141 assertNotNull(groups);
142 assertEquals(2, groups.length);
cfdb727a 143
06b9339e
BH
144 ITraceControlComponent[] providers = groups[0].getChildren();
145
146 assertNotNull(providers);
147 assertEquals(3, providers.length);
148
149 // ------------------------------------------------------------------------
150 // Verify Kernel Provider Properties (adapter)
151 // ------------------------------------------------------------------------
152 KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0];
cfdb727a 153
06b9339e
BH
154 adapter = kernelProvider.getAdapter(IPropertySource.class);
155 assertNotNull(adapter);
156 assertTrue(adapter instanceof KernelProviderPropertySource);
157
158 KernelProviderPropertySource kernelSource = (KernelProviderPropertySource)adapter;
159 assertNotNull(kernelSource.getPropertyDescriptors());
160
161 assertEquals("Kernel", kernelSource.getPropertyValue(KernelProviderPropertySource.KERNEL_PROVIDER_NAME_PROPERTY_ID));
162
163 // ------------------------------------------------------------------------
164 // Verify UST Provider Properties (adapter)
165 // ------------------------------------------------------------------------
166 UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
cfdb727a 167
06b9339e
BH
168 adapter = ustProvider.getAdapter(IPropertySource.class);
169 assertNotNull(adapter);
170 assertTrue(adapter instanceof UstProviderPropertySource);
171
172 UstProviderPropertySource ustSource = (UstProviderPropertySource)adapter;
173 assertNotNull(ustSource.getPropertyDescriptors());
174
2e74131b 175 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello [PID=9379]", ustSource.getPropertyValue(UstProviderPropertySource.UST_PROVIDER_NAME_PROPERTY_ID));
06b9339e
BH
176 assertEquals(String.valueOf(9379), ustSource.getPropertyValue(UstProviderPropertySource.UST_PROVIDER_PID_PROPERTY_ID));
177
178 // ------------------------------------------------------------------------
179 // Verify Base Event Properties (adapter)
180 // ------------------------------------------------------------------------
181 ITraceControlComponent[] events = ustProvider.getChildren();
182 assertNotNull(events);
183 assertEquals(2, events.length);
184
185 BaseEventComponent baseEventInfo = (BaseEventComponent) events[0];
186 assertNotNull(baseEventInfo);
cfdb727a 187
06b9339e
BH
188 adapter = baseEventInfo.getAdapter(IPropertySource.class);
189 assertNotNull(adapter);
190 assertTrue(adapter instanceof BaseEventPropertySource);
191
192 BaseEventPropertySource baseSource = (BaseEventPropertySource)adapter;
193 assertNotNull(baseSource.getPropertyDescriptors());
194
195 assertEquals("ust_tests_hello:tptest_sighandler", baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_NAME_PROPERTY_ID));
196 assertEquals(TraceEventType.TRACEPOINT.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_TYPE_PROPERTY_ID));
4775bcbf 197 assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_LOGLEVEL_PROPERTY_ID));
06b9339e 198
d4514365
BH
199 baseEventInfo = (BaseEventComponent) events[1];
200 assertNotNull(baseEventInfo);
201
202 adapter = baseEventInfo.getAdapter(IPropertySource.class);
203 assertNotNull(adapter);
204 assertTrue(adapter instanceof BaseEventPropertySource);
205 baseSource = (BaseEventPropertySource)adapter;
206 assertNotNull(baseSource.getPropertyDescriptors());
207 assertEquals("doublefield=float;floatfield=float;stringfield=string", baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_FIELDS_PROPERTY_ID));
208
06b9339e
BH
209 // ------------------------------------------------------------------------
210 // Verify Session Properties (adapter)
211 // ------------------------------------------------------------------------
212 ITraceControlComponent[] sessions = groups[1].getChildren();
213 assertNotNull(sessions);
214 assertEquals(2, sessions.length);
215
216 TraceSessionComponent session = (TraceSessionComponent)sessions[1];
217
218 adapter = session.getAdapter(IPropertySource.class);
219 assertNotNull(adapter);
220 assertTrue(adapter instanceof TraceSessionPropertySource);
221
222 TraceSessionPropertySource sessionSource = (TraceSessionPropertySource)adapter;
223 assertNotNull(sessionSource.getPropertyDescriptors());
224
225 assertEquals("mysession", sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_NAME_PROPERTY_ID));
226 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_PATH_PROPERTY_ID));
227 assertEquals(TraceSessionState.ACTIVE.name(), sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_STATE_PROPERTY_ID));
228
229 // ------------------------------------------------------------------------
230 // Verify Domain Provider Properties (adapter)
231 // ------------------------------------------------------------------------
232 ITraceControlComponent[] domains = session.getChildren();
233 assertNotNull(domains);
234 assertEquals(2, domains.length);
235
236 TraceDomainComponent domain = (TraceDomainComponent) domains[0];
237 adapter = domain.getAdapter(IPropertySource.class);
238 assertNotNull(adapter);
239 assertTrue(adapter instanceof TraceDomainPropertySource);
240
241 TraceDomainPropertySource domainSource = (TraceDomainPropertySource)adapter;
242 assertNotNull(domainSource.getPropertyDescriptors());
243
244 assertEquals("Kernel", domainSource.getPropertyValue(TraceDomainPropertySource.TRACE_DOMAIN_NAME_PROPERTY_ID));
83051fc3 245 assertEquals(BufferType.BUFFER_SHARED.getInName(), domainSource.getPropertyValue(TraceDomainPropertySource.BUFFER_TYPE_PROPERTY_ID));
cfdb727a 246
06b9339e
BH
247 ITraceControlComponent[] channels = domains[0].getChildren();
248 assertNotNull(channels);
249 assertEquals(2, channels.length);
250
251 // ------------------------------------------------------------------------
252 // Verify Channel Properties (adapter)
253 // ------------------------------------------------------------------------
254 assertTrue(channels[0] instanceof TraceChannelComponent);
255 TraceChannelComponent channel = (TraceChannelComponent) channels[0];
cfdb727a 256
06b9339e
BH
257 adapter = channel.getAdapter(IPropertySource.class);
258 assertNotNull(adapter);
259 assertTrue(adapter instanceof TraceChannelPropertySource);
260
261 TraceChannelPropertySource channelSource = (TraceChannelPropertySource)adapter;
262 assertNotNull(channelSource.getPropertyDescriptors());
263
264 assertEquals("channel0", channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_NAME_PROPERTY_ID));
265 assertEquals(String.valueOf(4), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID));
266 assertEquals(TraceEnablement.ENABLED.name(), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_STATE_PROPERTY_ID));
267 assertEquals(String.valueOf(false), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID));
268 assertEquals("splice()", channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID));
269 assertEquals(String.valueOf(200), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_READ_TIMER_PROPERTY_ID));
270 assertEquals(String.valueOf(262144), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID));
271 assertEquals(String.valueOf(0), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID));
cfdb727a 272
06b9339e
BH
273 // ------------------------------------------------------------------------
274 // Verify Event Properties (adapter)
275 // ------------------------------------------------------------------------
276 ITraceControlComponent[] channel0Events = channel.getChildren();
277 assertNotNull(channel0Events);
d132bcc7 278 assertEquals(5, channel0Events.length);
06b9339e 279 assertTrue(channel0Events[0] instanceof TraceEventComponent);
cfdb727a 280
06b9339e 281 TraceEventComponent event = (TraceEventComponent) channel0Events[0];
cfdb727a 282
06b9339e
BH
283 adapter = event.getAdapter(IPropertySource.class);
284 assertNotNull(adapter);
285 assertTrue(adapter instanceof TraceEventPropertySource);
286
287 TraceEventPropertySource eventSource = (TraceEventPropertySource)adapter;
288 assertNotNull(eventSource.getPropertyDescriptors());
cfdb727a 289
06b9339e
BH
290 assertEquals("block_rq_remap", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
291 assertEquals(TraceLogLevel.TRACE_EMERG.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
292 assertEquals(TraceEventType.TRACEPOINT.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
293 assertEquals(TraceEnablement.ENABLED.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
cfdb727a 294
d132bcc7
BH
295 // ------------------------------------------------------------------------
296 // Verify Probe Event Properties (adapter)
297 // ------------------------------------------------------------------------
298 assertTrue(channel0Events[2] instanceof TraceProbeEventComponent);
cfdb727a 299
d132bcc7 300 TraceProbeEventComponent probeEvent = (TraceProbeEventComponent) channel0Events[2];
cfdb727a 301
d132bcc7
BH
302 adapter = probeEvent.getAdapter(IPropertySource.class);
303 assertNotNull(adapter);
304 assertTrue(adapter instanceof TraceProbeEventPropertySource);
305
306 TraceProbeEventPropertySource probeEventSource = (TraceProbeEventPropertySource)adapter;
307 assertNotNull(probeEventSource.getPropertyDescriptors());
308 assertEquals(4, probeEventSource.getPropertyDescriptors().length);
cfdb727a 309
d132bcc7
BH
310 assertEquals("myevent2", probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
311 assertEquals(TraceEventType.PROBE.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
312 assertEquals(TraceEnablement.ENABLED.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
313 assertEquals("0xc0101340", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID));
cfdb727a 314
d132bcc7 315 assertTrue(channel0Events[3] instanceof TraceProbeEventComponent);
cfdb727a 316
d132bcc7 317 probeEvent = (TraceProbeEventComponent) channel0Events[3];
cfdb727a 318
d132bcc7
BH
319 adapter = probeEvent.getAdapter(IPropertySource.class);
320 assertNotNull(adapter);
321 assertTrue(adapter instanceof TraceProbeEventPropertySource);
322
323 probeEventSource = (TraceProbeEventPropertySource)adapter;
324 assertNotNull(probeEventSource.getPropertyDescriptors());
325 assertEquals(5, probeEventSource.getPropertyDescriptors().length);
cfdb727a 326
d132bcc7
BH
327 assertEquals("myevent0", probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
328 assertEquals(TraceEventType.PROBE.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
329 assertEquals(TraceEnablement.ENABLED.name(), probeEventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
330 assertEquals("0x0", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID));
331 assertEquals("init_post", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID));
cfdb727a 332
d4514365
BH
333 //-------------------------------------------------------------------------
334 // Verify Filter of UST event
335 //-------------------------------------------------------------------------
336 event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[0];
337 adapter = event.getAdapter(IPropertySource.class);
338 assertEquals("with filter", event.getFilterExpression());
339
54f2dcc0
BH
340 //-------------------------------------------------------------------------
341 // Verify Log Level Type of UST events (> LTTng 2.4)
342 //-------------------------------------------------------------------------
343 event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[0];
344 adapter = event.getAdapter(IPropertySource.class);
345 eventSource = (TraceEventPropertySource) adapter;
346 assertEquals("== TRACE_DEBUG_LINE", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
347
348 event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[1];
349 adapter = event.getAdapter(IPropertySource.class);
350 eventSource = (TraceEventPropertySource) adapter;
351 assertEquals("<= TRACE_INFO", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
352
353 event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[2];
354 adapter = event.getAdapter(IPropertySource.class);
355 eventSource = (TraceEventPropertySource) adapter;
356 assertEquals("TRACE_DEBUG_SYSTEM", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
357
a26d90be
BH
358 //-------------------------------------------------------------------------
359 // Delete node
360 //-------------------------------------------------------------------------
361 node.disconnect();
362 node.getParent().removeChild(node);
06b9339e 363 }
f3b33d40 364}
This page took 0.07898 seconds and 5 git commands to generate.