1) Added @Ignore annotation to AnalyzerUtil tests.
These test now all fail as tested functionality is not yet implemented so
they must be ignored.
2) Fixed org.tizen.dynamicanalyzer.ui.file.data tests
Changed hardcoded pathes to Tizen-SDK to current directory with following
deletion of all created files in cleanup. For that purpose Apache Commons IO
library was added to 'test/lib' (same version as in org.tizen.common).
Added calls of SqlConnectionManager.releaseResultSet() to FileApiDBTest.
Without it test hung on SqlConnectionManager.closeConnection().
3) Fixed FileChartBoardTest from org.tizen.dynamicanalyzer.ui.file
Injected FileDataMaker mock object into FileChartBoard object to avoid
NullPointerException.
Marked test with @Ignore as it does not test anything now.
4) Fixed ExecutionCallbackManagerTest
This test relied on tests execution order which was changed in later JUnit
versions.
Tests verified number of executions of methods from the same objects. This
resulted in doubled numbers in the second test.
5) Fixed FileDataMakerTest
Changed database path to relative to current directory with cleanup after
all tests.
Change-Id: I0ffb803f1e12fdd799aa7494a99335dd27d4970c
package org.tizen.dynamicanalyzer.common;
-
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.tizen.dynamicanalyzer.callback.ExecutionCallbackManager;
import org.tizen.dynamicanalyzer.callback.IExecutionCallback;
import org.tizen.dynamicanalyzer.unittest.UnitTestUtil;
-
public class ExecutionCallbackManagerTest {
public class PostWindowOpenCallback implements IExecutionCallback {
public void execute() {
}
-
+
public void execute(String[] msg) {
execute();
}
}
-
- public static final String TEST_CALLBACK_NAME1 = "Test.CallBack";
- public static final String TEST_CALLBACK_NAME3 = "Test.CallBack3";
- private static IExecutionCallback exeCallback1 = mock(IExecutionCallback.class);
- private static IExecutionCallback exeCallback2 = mock(PostWindowOpenCallback.class);
- private static IExecutionCallback exeCallback3 = mock(IExecutionCallback.class);
-
- public ExecutionCallbackManagerTest() {
+ public static final String TEST_CALLBACK_NAME1 = "Test.CallBack";
+ public static final String TEST_CALLBACK_NAME2 = "Test.CallBack2";
+
+ public static IExecutionCallback exeCallback1;
+ public static IExecutionCallback exeCallback2;
+ public static IExecutionCallback exeCallback3;
+
+ @Before
+ public void setUp() {
+ exeCallback1 = mock(IExecutionCallback.class);
+ exeCallback2 = mock(PostWindowOpenCallback.class);
+ exeCallback3 = mock(IExecutionCallback.class);
+
ExecutionCallbackManager.createCallbackList(TEST_CALLBACK_NAME1);
- ExecutionCallbackManager.createCallbackList(TEST_CALLBACK_NAME3);
+ ExecutionCallbackManager.createCallbackList(TEST_CALLBACK_NAME2);
+
ExecutionCallbackManager.registerCallback(TEST_CALLBACK_NAME1, exeCallback1);
ExecutionCallbackManager.registerCallback(TEST_CALLBACK_NAME1, exeCallback2);
- ExecutionCallbackManager.registerCallback(TEST_CALLBACK_NAME3, exeCallback2);
- ExecutionCallbackManager.registerCallback(TEST_CALLBACK_NAME3, exeCallback3);
- boolean failed = ExecutionCallbackManager.registerCallback("UNKNOWN", exeCallback3);
+ ExecutionCallbackManager.registerCallback(TEST_CALLBACK_NAME2, exeCallback2);
+ ExecutionCallbackManager.registerCallback(TEST_CALLBACK_NAME2, exeCallback3);
+ ExecutionCallbackManager.registerCallback("UNKNOWN", exeCallback3);
}
-
+
@Test
public void testExecuteCallbackString() {
ExecutionCallbackManager.executeCallback(TEST_CALLBACK_NAME1);
- ExecutionCallbackManager.executeCallback(TEST_CALLBACK_NAME3);
+ ExecutionCallbackManager.executeCallback(TEST_CALLBACK_NAME2);
ExecutionCallbackManager.executeCallback("UNKNOWN");
- verify(exeCallback1, atLeastOnce()).execute();
+ verify(exeCallback1, times(1)).execute();
verify(exeCallback2, times(2)).execute();
- verify(exeCallback3, atLeast(1)).execute();
+ verify(exeCallback3, times(1)).execute();
}
@Test
testArrayString[2] = anyString();
ExecutionCallbackManager.executeCallback(TEST_CALLBACK_NAME1, testArrayString);
- ExecutionCallbackManager.executeCallback(TEST_CALLBACK_NAME3, testArrayString);
+ ExecutionCallbackManager.executeCallback(TEST_CALLBACK_NAME2, testArrayString);
ExecutionCallbackManager.executeCallback("UNKNOWN", testArrayString);
- verify(exeCallback1, times(2)).execute(testArrayString);
- verify(exeCallback2, times(4)).execute(testArrayString);
- verify(exeCallback3, atMost(3)).execute(testArrayString);
+ verify(exeCallback1, times(1)).execute(testArrayString);
+ verify(exeCallback2, times(2)).execute(testArrayString);
+ verify(exeCallback3, times(1)).execute(testArrayString);
}
}
import static org.mockito.Mockito.mock;
+import org.junit.Ignore;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
import org.powermock.reflect.Whitebox;
+import org.tizen.dynamicanalyzer.ui.file.manager.FileDataMaker;
+@Ignore("Not implemented")
+@RunWith(MockitoJUnitRunner.class)
public class FileChartBoardTest {
+ @Mock private FileDataMaker dataMake;
+ @InjectMocks private FileChartBoard chartBoard = mock(FileChartBoard.class);
+
@Test
public void testAddNewFileChartRows() throws Exception {
- FileChartBoard chartBoard = mock(org.tizen.dynamicanalyzer.ui.file.FileChartBoard.class);
Whitebox.invokeMethod(chartBoard,"addNewFileChartRows");
}
-
-
-
}
import java.util.List;
import java.util.Set;
+import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class FileAccessDBTest {
static FileAccessDB accessDB = null;
static FileAccess access = null;
+ static String path = null;
@BeforeClass
public static void initDB() throws Exception {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("_yyyy-MM-dd-HH-mm-ss");
- String path = "/home/kim/tizen-sdk-data/dynamic-analyzer/temp/app"
- + format.format(date);
+ path = "app" + format.format(date);
SqlConnectionManager.establishConnection(path + File.separator
+ AnalyzerConstants.DATABASE_NAME);
@AfterClass
public static void done() throws Exception {
SqlConnectionManager.closeConnection();
+ FileUtils.deleteDirectory(new File(path));
}
}
import java.util.List;
import java.util.Set;
+import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class FileAccessorDBTest {
static FileAccessorDB accessorDB = null;
static FileAccessor accessor = null;
+ static String path = null;
@BeforeClass
public static void initDB() throws Exception {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("_yyyy-MM-dd-HH-mm-ss");
- String path = "/home/kim/tizen-sdk-data/dynamic-analyzer/temp/app"
- + format.format(date);
+ path = "app" + format.format(date);
SqlConnectionManager.establishConnection(path + File.separator
+ AnalyzerConstants.DATABASE_NAME);
@AfterClass
public static void done() throws Exception {
SqlConnectionManager.closeConnection();
+ FileUtils.deleteDirectory(new File(path));
}
}
import java.util.List;
import java.util.Set;
+import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
static FileEvent event = null;
static FileAccessorDB accessorDB = null;
static FileAccessor accessor = null;
+ static String path = null;
ArrayList<List<Object>> fileApiList = new ArrayList<List<Object>>();
@BeforeClass
public static void initDB() throws Exception {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("_yyyy-MM-dd-HH-mm-ss");
- String path = "/home/kim/tizen-sdk-data/dynamic-analyzer/temp/app"
- + format.format(date);
+ path = "app" + format.format(date);
SqlConnectionManager.establishConnection(path + File.separator
+ AnalyzerConstants.DATABASE_NAME);
new Long(27), new Long(6), null, null, 0 );
}
-
+
@Test
public final void testSelectAPI() {
ArrayList<List<Object>> fileApiList = new ArrayList<List<Object>>();
}
} catch (SQLException e) {
Logger.exception(e);
+ } finally {
+ SqlConnectionManager.releaseResultSet(rs);
}
}
}
}
} catch (SQLException e) {
Logger.exception(e);
- }
+ } finally {
+ SqlConnectionManager.releaseResultSet(rs);
+ }
}
}
-
+
@AfterClass
public static void done() throws Exception {
SqlConnectionManager.closeConnection();
+ FileUtils.deleteDirectory(new File(path));
}
}
import java.util.List;
import java.util.Set;
+import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
static FileStatusDB statusDB = null;
static FileStatus status = null;
+ static String path = null;
@BeforeClass
public static void initDB() throws Exception {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("_yyyy-MM-dd-HH-mm-ss");
- String path = "/home/kim/tizen-sdk-data/dynamic-analyzer/temp/app"
- + format.format(date);
+ path = "app" + format.format(date);
SqlConnectionManager.establishConnection(path + File.separator
+ AnalyzerConstants.DATABASE_NAME);
@AfterClass
public static void done() throws Exception {
SqlConnectionManager.closeConnection();
+ FileUtils.deleteDirectory(new File(path));
}
}
import java.util.Date;
import java.util.List;
import java.util.Random;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
static FileDataManager fileManager = FileDataManager.getInstance();;
static FileDataMaker dataMaker = new FileDataMaker();
static String filePath = "/tmp/test1.txt";
+ static String path;
@BeforeClass
public static void setUp() throws Exception {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("_yyyy-MM-dd-HH-mm-ss");
- String path = "/home/kim/tizen-sdk-data/dynamic-analyzer/temp/app" + format.format(date);
+ path = "app" + format.format(date);
SqlConnectionManager.closeConnection();
SqlConnectionManager.establishConnection(path + File.separator
makeRandomObjects();
}
-
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ FileUtils.deleteDirectory(new File(path));
+ }
public FileDataMakerTest(FileEvent event1, FileEvent event2, FileEvent event3, FileEvent event4,
FileEvent event5, FileEvent event6, FileEvent event7, FileEvent event8, FileEvent event9,
import static org.junit.Assert.fail;
+import org.junit.Ignore;
import org.junit.Test;
public class AnalyzerUtilTest {
+ @Ignore
@Test
public void testGetTimelineComposite() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testSetTimelineComposite() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testCopyFile() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testCopyDirectory() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testExecuteCommand() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetDirs() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetFilesString() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetFilesStringString() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testSaveTraceImage() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testSetFontSize() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testDeleteFile() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testSetCenterShell() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testSetCenterShellShell() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testChangePage() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetTabPage() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetMainTab() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetView() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testCheckLogs() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testAddrToLong() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testPrintHexdecimal() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testToHexdecimal() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetProcessLocalBinaryPath() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetBinarySourcePath() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testIsPieBuild() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetTargetPathKey() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testTranslateSecToMicroSec() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testGetProcessName() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testIsInteger() {
fail("Not yet implemented");
}
+ @Ignore
@Test
public void testIsLong() {
fail("Not yet implemented");