annotate bindings/java/test/TestInsert.java @ 725:7e1fa27b67ee
* Full status support
* Insert support (not fully tested)
* Unit tests for create + initial insert
author |
mas01mj |
date |
Wed, 21 Jul 2010 14:27:07 +0000 |
parents |
|
children |
4d9e4ff0a9cd |
rev |
line source |
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 System.out.println(status.hasReferences());
|
mas01mj@725
|
27 System.out.println(status.isL2Normed());
|
mas01mj@725
|
28 System.out.println(status.hasPower());
|
mas01mj@725
|
29 System.out.println(status.hasTimes());
|
mas01mj@725
|
30 }
|
mas01mj@725
|
31
|
mas01mj@725
|
32 public void testInsertFileReadOnly()
|
mas01mj@725
|
33 {
|
mas01mj@725
|
34 AudioDB testDB = new AudioDB(testDBFile);
|
mas01mj@725
|
35 assertTrue("DB created", testDB.create(1, 1, 1));
|
mas01mj@725
|
36 testDB.open(AudioDB.Mode.O_RDONLY);
|
mas01mj@725
|
37 assertFalse("Insert feature file", testDB.insert(testFeatureFile));
|
mas01mj@725
|
38 }
|
mas01mj@725
|
39 }
|