2015-01-06 17:14:16 +01:00
|
|
|
package com.minres.scviewer.database.test;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
import static org.junit.Assert.fail;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import com.minres.scviewer.database.IWaveformDb;
|
2015-01-10 00:23:46 +01:00
|
|
|
import com.minres.scviewer.database.IWaveformDbLoader;
|
|
|
|
import com.minres.scviewer.database.WaveformDb;
|
2015-01-06 17:14:16 +01:00
|
|
|
|
|
|
|
public class DatabaseServicesTest {
|
|
|
|
|
|
|
|
@Before
|
|
|
|
public void setUp() throws Exception {
|
2015-01-10 00:23:46 +01:00
|
|
|
// Wait for OSGi dependencies
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
if (WaveformDb.getLoaders().size() == 3) // Dependencies fulfilled
|
|
|
|
return;
|
|
|
|
Thread.sleep(1000);
|
|
|
|
}
|
|
|
|
fail("OSGi dependencies unfulfilled");
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@After
|
|
|
|
public void tearDown() throws Exception {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2015-01-10 00:23:46 +01:00
|
|
|
public void testVCD() throws Exception {
|
2015-01-06 17:14:16 +01:00
|
|
|
File f = new File("inputs/my_db.vcd").getAbsoluteFile();
|
|
|
|
assertTrue(f.exists());
|
2015-01-10 00:23:46 +01:00
|
|
|
IWaveformDb database=new WaveformDb();
|
|
|
|
database.load(f);
|
2015-01-06 17:14:16 +01:00
|
|
|
assertNotNull(database);
|
|
|
|
assertEquals(14, database.getAllWaves().size());
|
|
|
|
assertEquals(2, database.getChildNodes().size());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2015-01-10 00:23:46 +01:00
|
|
|
public void testTxSQLite() throws Exception {
|
2015-01-06 17:14:16 +01:00
|
|
|
File f = new File("inputs/my_db.txdb").getAbsoluteFile();
|
|
|
|
assertTrue(f.exists());
|
2015-01-10 00:23:46 +01:00
|
|
|
IWaveformDb database=new WaveformDb();
|
|
|
|
database.load(f);
|
2015-01-06 17:14:16 +01:00
|
|
|
assertNotNull(database);
|
|
|
|
assertEquals(3, database.getAllWaves().size());
|
2015-01-10 00:23:46 +01:00
|
|
|
assertEquals(1, database.getChildNodes().size());
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2015-01-10 00:23:46 +01:00
|
|
|
public void testTxText() throws Exception {
|
2015-01-06 17:14:16 +01:00
|
|
|
File f = new File("inputs/my_db.txlog").getAbsoluteFile();
|
|
|
|
assertTrue(f.exists());
|
2015-01-10 00:23:46 +01:00
|
|
|
IWaveformDb database=new WaveformDb();
|
|
|
|
database.load(f);
|
2015-01-06 17:14:16 +01:00
|
|
|
assertNotNull(database);
|
|
|
|
assertEquals(3, database.getAllWaves().size());
|
2015-01-10 00:23:46 +01:00
|
|
|
assertEquals(1, database.getChildNodes().size());
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|