mas01mj@725
|
1 import junit.framework.*;
|
mas01mj@725
|
2 import java.io.File;
|
mas01mj@725
|
3 import org.omras2.*;
|
mas01mj@725
|
4
|
mas01mj@725
|
5 public class TestInsert extends TestCase
|
mas01mj@725
|
6 {
|
mas01mj@725
|
7 File testDBFile;
|
mas01mj@725
|
8 File testFeatureFile;
|
mas01mj@725
|
9 protected void setUp()
|
mas01mj@725
|
10 {
|
mas01mj@725
|
11 testDBFile = new File("testfiles/test.adb");
|
mas01mj@725
|
12 testFeatureFile = new File("testfiles/testfeature");
|
mas01mj@725
|
13 if(testDBFile.exists())
|
mas01mj@725
|
14 testDBFile.delete();
|
mas01mj@725
|
15 }
|
mas01mj@725
|
16
|
mas01mj@725
|
17 public void testInsertFile()
|
mas01mj@725
|
18 {
|
mas01mj@725
|
19 AudioDB testDB = new AudioDB(testDBFile);
|
mas01mj@725
|
20 assertTrue("DB created", testDB.create(1, 1, 1));
|
mas01mj@725
|
21 testDB.open(AudioDB.Mode.O_RDWR);
|
mas01mj@725
|
22 assertTrue("Insert feature file", testDB.insert(testFeatureFile));
|
mas01mj@725
|
23 Status status = testDB.getStatus();
|
mas01mj@725
|
24 assertEquals("One feature in db", 1, status.getNumFiles());
|
mas01mj@725
|
25 assertEquals("1D Feature", 1, status.getDim());
|
mas01mj@725
|
26 }
|
mas01mj@725
|
27
|
mas01mj@725
|
28 public void testInsertFileReadOnly()
|
mas01mj@725
|
29 {
|
mas01mj@725
|
30 AudioDB testDB = new AudioDB(testDBFile);
|
mas01mj@725
|
31 assertTrue("DB created", testDB.create(1, 1, 1));
|
mas01mj@725
|
32 testDB.open(AudioDB.Mode.O_RDONLY);
|
mas01mj@725
|
33 assertFalse("Insert feature file", testDB.insert(testFeatureFile));
|
mas01mj@725
|
34 }
|
mas01mj@728
|
35
|
mas01mj@728
|
36 public void testInsertData()
|
mas01mj@728
|
37 {
|
mas01mj@728
|
38 AudioDB testDB = new AudioDB(testDBFile);
|
mas01mj@728
|
39 assertTrue("DB created", testDB.create(100, 100, 1));
|
mas01mj@728
|
40 testDB.open(AudioDB.Mode.O_RDWR);
|
mas01mj@728
|
41 Status status = testDB.getStatus();
|
mas01mj@728
|
42 assertTrue("Insert feature 1", testDB.insert("feature1", 5, 1, new double[] { 1, 2, 3, 4, 5 }));
|
mas01mj@728
|
43 assertTrue("Insert feature 2", testDB.insert("feature2", 5, 1, new double[] { 1, 2, 3, 4, 5 }));
|
mas01mj@728
|
44 assertTrue("Insert feature 3", testDB.insert("feature3", 5, 1, new double[] { 5, 4, 3, 2, 1 }));
|
mas01mj@728
|
45 assertFalse("Insert feature 3 again", testDB.insert("feature3", 5, 1, new double[] { 5, 4, 3, 2, 1 }));
|
mas01mj@728
|
46 assertFalse("Insert bad feature", testDB.insert("feature4", 1, 3, new double[] { 5, 4, 3 }));
|
mas01mj@728
|
47 assertEquals("3 features in db", 3, testDB.getStatus().getNumFiles());
|
mas01mj@728
|
48 }
|
mas01mj@725
|
49 }
|