1 /**********************************************************************
2 * Copyright (c) 2012, 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 * Bernd Hufmann - Initial API and implementation
11 * Alexandre Montplaisir - Port to JUnit4
12 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
13 **********************************************************************/
15 package org
.eclipse
.tracecompass
.lttng2
.control
.ui
.tests
.model
.component
;
17 import static org
.junit
.Assert
.assertEquals
;
18 import static org
.junit
.Assert
.assertFalse
;
19 import static org
.junit
.Assert
.assertNotNull
;
20 import static org
.junit
.Assert
.assertNotSame
;
21 import static org
.junit
.Assert
.assertTrue
;
26 import org
.eclipse
.core
.runtime
.FileLocator
;
27 import org
.eclipse
.core
.runtime
.Path
;
28 import org
.eclipse
.remote
.core
.IRemoteConnection
;
29 import org
.eclipse
.remote
.core
.IRemoteConnectionManager
;
30 import org
.eclipse
.remote
.core
.RemoteServices
;
31 import org
.eclipse
.swt
.graphics
.Image
;
32 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TargetNodeState
;
33 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.stubs
.service
.TestRemoteSystemProxy
;
34 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
35 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
36 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceProviderGroup
;
37 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionGroup
;
38 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.UstProviderComponent
;
39 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.ILttngControlService
;
40 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlService
;
41 import org
.junit
.After
;
42 import org
.junit
.Before
;
43 import org
.junit
.Test
;
44 import org
.osgi
.framework
.FrameworkUtil
;
47 * The class <code>TraceControlTreeModelNoProvidersTest</code> verifies that the
48 * Tracer Control can handle the case where no kernel provider and only UST
49 * provider are available.
51 public class TraceControlTreeModelNoProvidersTest
{
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
57 private static final String TEST_STREAM
= "ListInfoTest.cfg";
58 private static final String SCEN_LIST_INFO_TEST
= "ListInfoTestNoKernel";
59 private static final String TARGET_NODE_NAME
= "myNode";
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
65 private TestRemoteSystemProxy fProxy
;
66 private String fTestFile
;
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
73 * Perform pre-test initialization.
76 * if the initialization fails for some reason
79 public void setUp() throws Exception
{
80 fProxy
= new TestRemoteSystemProxy();
81 URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(TraceControlTestFacility
.DIRECTORY
+ File
.separator
+ TEST_STREAM
), null);
82 File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
83 fTestFile
= testfile
.getAbsolutePath();
87 * Perform post-test clean-up.
90 public void tearDown() {
91 TraceControlTestFacility
.getInstance().waitForJobs();
95 * Run the TraceControlComponent.
98 public void testTraceControlComponents() {
100 fProxy
.setTestFile(fTestFile
);
101 fProxy
.setScenario(SCEN_LIST_INFO_TEST
);
103 ITraceControlComponent root
= TraceControlTestFacility
.getInstance().getControlView().getTraceControlRoot();
105 IRemoteConnectionManager cm
= RemoteServices
.getLocalServices().getConnectionManager();
106 IRemoteConnection host
= cm
.getConnection(IRemoteConnectionManager
.LOCAL_CONNECTION_NAME
);
108 TargetNodeComponent node
= new TargetNodeComponent(TARGET_NODE_NAME
, root
, host
, fProxy
);
113 TraceControlTestFacility
.getInstance().waitForConnect(node
);
114 TraceControlTestFacility
.getInstance().waitForJobs();
116 // ------------------------------------------------------------------------
117 // Verify Parameters of TargetNodeComponent
118 // ------------------------------------------------------------------------
119 assertEquals("localhost", node
.getRemoteConnection().getAddress()); // assigned in createLocalHost() above
120 assertEquals("Local", node
.getToolTip()); // assigned in createLocalHost() above
121 Image connectedImage
= node
.getImage();
122 assertNotNull(connectedImage
);
123 assertEquals(TargetNodeState
.CONNECTED
, node
.getTargetNodeState());
124 assertNotNull(node
.getControlService());
125 ILttngControlService service
= node
.getControlService();
126 assertTrue(service
instanceof LTTngControlService
);
127 node
.setControlService(service
);
128 assertTrue(node
.getControlService() instanceof LTTngControlService
);
130 // ------------------------------------------------------------------------
131 // Verify Children of TargetNodeComponent
132 // ------------------------------------------------------------------------
133 ITraceControlComponent
[] groups
= node
.getChildren();
134 assertNotNull(groups
);
135 assertEquals(2, groups
.length
);
137 assertTrue(groups
[0] instanceof TraceProviderGroup
);
138 assertTrue(groups
[1] instanceof TraceSessionGroup
);
140 // Check for kernel provider
141 TraceProviderGroup providerGroup
= (TraceProviderGroup
) groups
[0];
142 assertFalse(providerGroup
.hasKernelProvider());
144 assertEquals("Provider", providerGroup
.getName());
145 assertEquals("Sessions", groups
[1].getName());
147 // ------------------------------------------------------------------------
148 // Verify TraceProviderGroup
149 // ------------------------------------------------------------------------
150 ITraceControlComponent
[] providers
= groups
[0].getChildren();
152 assertNotNull(providers
);
153 assertEquals(1, providers
.length
);
154 assertTrue(providers
[0] instanceof UstProviderComponent
);
158 assertEquals(TargetNodeState
.DISCONNECTED
, node
.getTargetNodeState());
159 assertNotNull(node
.getImage());
160 assertNotSame(connectedImage
, node
.getImage());
162 node
.getParent().removeChild(node
);