/**********************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2013 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
*
* Contributors:
* Bernd Hufmann - Initial API and implementation
+ * Alexandre Montplaisir - Port to JUnit4
**********************************************************************/
+
package org.eclipse.linuxtools.lttng2.ui.tests.control.service;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlService;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlServiceFactory;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.FrameworkUtil;
+
/**
- * The class <code>LTTngControlServiceTest</code> contains test for the class <code>{@link LTTngControlService}</code>.
+ * The class <code>LTTngControlServiceTest</code> contains test for the class
+ * <code>{@link LTTngControlService}</code>.
*/
@SuppressWarnings({"nls", "javadoc"})
-public class LTTngControlServiceTest extends TestCase {
+public class LTTngControlServiceTest {
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM = "LTTngServiceTest.cfg";
// ------------------------------------------------------------------------
// Test data
// ------------------------------------------------------------------------
+
private CommandShellFactory fShellFactory;
private String fTestfile;
private LTTngToolsFileShell fShell;
private ILttngControlService fService;
-
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
-
// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
+
/**
* Perform pre-test initialization.
*
- * @throws Exception if the initialization fails for some reason
- *
+ * @throws Exception
+ * if the initialization fails for some reason
*/
- @Override
+ @Before
public void setUp() throws Exception {
- super.setUp();
fShellFactory = CommandShellFactory.getInstance();
URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
fService = new LTTngControlService(fShell);
}
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() throws Exception {
- }
-
// ------------------------------------------------------------------------
// Test Cases
// ------------------------------------------------------------------------
+ @Test
public void testVersion() {
try {
fShell.setScenario(SCEN_LTTNG_VERSION);
}
}
+ @Test
public void testVersionWithPrompt() {
try {
fShell.setScenario(SCEN_LTTNG_VERSION_WITH_PROMPT);
}
}
+ @Test
public void testUnsupportedVersion() {
try {
fShell.setScenario(SCEN_LTTNG_UNSUPPORTED_VERSION);
}
}
+ @Test
public void testNoVersion() {
try {
fShell.setScenario(SCEN_LTTNG_NO_VERSION);
}
}
+ @Test
public void testLttngNotInstalled() {
try {
fShell.setScenario(SCEN_LTTNG_NOT_INSTALLED);
}
}
+ @Test
public void testGetSessionNames1() {
try {
fShell.setScenario(SCEN_NO_SESSION_AVAILABLE);
}
}
+ @Test
public void testGetSessionNames2() {
try {
fShell.setScenario(SCEN_GET_SESSION_NAMES1);
}
}
+ @Test
public void testGetSessionNotExist() {
try {
fShell.setScenario(SCEN_GET_SESSION_NAME_NOT_EXIST);
}
}
+ @Test
public void testGetSessionNameGarbage() {
try {
fShell.setScenario(SCEN_GET_SESSION_GARBAGE_OUT);
}
}
+ @Test
public void testGetSession1() {
try {
fShell.setScenario(SCEN_GET_SESSION1);
}
}
+ @Test
public void testGetKernelProviderNoKernel1() {
try {
fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL1);
}
}
+ @Test
public void testGetKernelProviderNoKernel2() {
try {
fShell.setScenario(SCEN_LIST_WITH_NO_KERNEL2);
}
}
-
+ @Test
public void testGetUstProvider() {
try {
fShell.setScenario(SCEN_GET_UST_PROVIDER1);
}
}
+ @Test
public void testUstProvider2() {
try {
fShell.setScenario(SCEN_GET_UST_PROVIDER2);
}
}
+ @Test
public void testGetUstProvider3() {
try {
fShell.setScenario(SCEN_GET_UST_PROVIDER3);
}
}
+ @Test
public void testCreateSession() {
try {
fShell.setScenario(SCEN_CREATE_SESSION1);
}
}
+ @Test
public void testCreateSessionWithPrompt() {
try {
// First line has the shell prompt before the command output
}
}
-
+ @Test
public void testCreateSessionVariants() {
fShell.setScenario(SCEN_CREATE_SESSION_VARIANTS);
}
}
+ @Test
public void testDestroySession() {
try {
fShell.setScenario(SCEN_DESTROY_SESSION1);
}
}
+ @Test
public void testCreateChannel() {
try {
}
}
+ @Test
public void testDisableChannel() {
try {
}
}
+ @Test
public void testEnableChannel() {
try {
// }
// }
+ @Test
public void testEnableEvents() {
try {
// 1) session name, channel = null, 3 event names, kernel
}
}
+ @Test
public void testEnableSyscalls() {
try {
// 1) session name, channel = null, 3 event names, kernel
}
}
+ @Test
public void testDynamicProbe() {
try {
// 1) session name, channel = null, 3 event names, kernel
}
}
+ @Test
public void testEnableLogLevel() {
try {
// 1) session name, channel = null, 3 event names, kernel
}
}
+ @Test
public void testAddContext() {
try {
// 1) session name, channel = null, 3 event names, kernel
}
}
+ @Test
public void testAddContextFailure() {
// 1) session name, channel = null, 3 event names, kernel
}
}
+ @Test
public void testCalibrate() {
try {
fShell.setScenario(SCEN_CALIBRATE_HANDLING);
}
}
+ @Test
public void testCalibrateFailure() {
-
try {
fShell.setScenario(SCEN_CALIBRATE_HANDLING);
fService.calibrate(false, new NullProgressMonitor());