2015-01-21 21:58:35 +01:00
|
|
|
/*******************************************************************************
|
2015-10-22 00:25:12 +02:00
|
|
|
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
2015-01-21 21:58:35 +01:00
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* MINRES Technologies GmbH - initial API and implementation
|
|
|
|
*******************************************************************************/
|
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 java.io.File;
|
|
|
|
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import com.minres.scviewer.database.IWaveformDb;
|
2015-10-24 23:15:07 +02:00
|
|
|
import com.minres.scviewer.database.IWaveformDbFactory;
|
2015-01-06 17:14:16 +01:00
|
|
|
|
|
|
|
public class DatabaseServicesTest {
|
|
|
|
|
2015-10-24 23:15:07 +02:00
|
|
|
|
|
|
|
private static IWaveformDbFactory waveformDbFactory;
|
|
|
|
|
|
|
|
private IWaveformDb waveformDb;
|
|
|
|
|
|
|
|
public synchronized void setFactory(IWaveformDbFactory service) {
|
|
|
|
waveformDbFactory = service;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void unsetFactory(IWaveformDbFactory service) {
|
|
|
|
if (waveformDbFactory == service) {
|
|
|
|
waveformDbFactory = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-06 17:14:16 +01:00
|
|
|
@Before
|
|
|
|
public void setUp() throws Exception {
|
2015-10-24 23:15:07 +02:00
|
|
|
waveformDb=waveformDbFactory.getDatabase();
|
2015-01-10 00:23:46 +01:00
|
|
|
// Wait for OSGi dependencies
|
2015-10-24 23:15:07 +02:00
|
|
|
// for (int i = 0; i < 10; i++) {
|
|
|
|
// if (waveformDb.size() == 3) // Dependencies fulfilled
|
|
|
|
// return;
|
|
|
|
// Thread.sleep(1000);
|
|
|
|
// }
|
|
|
|
// assertEquals("OSGi dependencies unfulfilled", 3, WaveformDb.getLoaders().size());
|
|
|
|
}
|
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-10-24 23:15:07 +02:00
|
|
|
waveformDb.load(f);
|
|
|
|
assertNotNull(waveformDb);
|
|
|
|
assertEquals(14, waveformDb.getAllWaves().size());
|
|
|
|
assertEquals(2, waveformDb.getChildNodes().size());
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@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-10-24 23:15:07 +02:00
|
|
|
waveformDb.load(f);
|
|
|
|
assertNotNull(waveformDb);
|
|
|
|
assertEquals(3, waveformDb.getAllWaves().size());
|
|
|
|
assertEquals(1, waveformDb.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-10-24 23:15:07 +02:00
|
|
|
waveformDb.load(f);
|
|
|
|
assertNotNull(waveformDb);
|
|
|
|
assertEquals(3, waveformDb.getAllWaves().size());
|
|
|
|
assertEquals(1, waveformDb.getChildNodes().size());
|
2015-01-06 17:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|