update standards version
[debian/freetts] / tests / UnitDatabaseTests.java
1 /**
2  * Copyright 2001 Sun Microsystems, Inc.
3  * 
4  * See the file "license.terms" for information on usage and
5  * redistribution of this file, and for a DISCLAIMER OF ALL 
6  * WARRANTIES.
7  */
8 package tests;
9 import junit.framework.*;
10 import java.util.*;
11 import java.io.*;
12 import java.net.URL;
13 import com.sun.speech.freetts.*;
14 import com.sun.speech.freetts.diphone.DiphoneUnitDatabase;
15
16 /**
17  * JUnit Tests for the DiphoneUnitDatabase test. 
18  * 
19  * @version 1.0
20  */
21 public class UnitDatabaseTests extends TestCase {
22     DiphoneUnitDatabase udb;
23     private final static String BINARY_DB =
24     "file:../bld/classes/com/sun/speech/freetts/en/us/cmu_us_kal/cmu_us_kal.bin";
25     private final static String TEXT_DB =
26     "file:../com/sun/speech/freetts/en/us/cmu_us_kal/cmu_us_kal.txt";
27
28     /**
29      * Creates the set of UtteranceTests
30      * 
31      * @param  name the name of the test.
32      */
33     public UnitDatabaseTests(String name) {
34         super(name);
35     }
36
37     /**
38      * Common code run before each test
39      */
40     protected void setUp() {
41         try {
42             udb = new DiphoneUnitDatabase(new
43                     URL(BINARY_DB), true);
44         } catch (IOException ioe) {
45             System.out.println("Can't load db " + ioe);
46         }
47     } 
48
49
50     /**
51      * Checks to make sure that the  binary and text version of the DB
52      * compare.
53      */
54     public void testIdentical() {
55         DiphoneUnitDatabase udbTextVersion = null;
56         try {
57             udbTextVersion = new DiphoneUnitDatabase(
58                     new URL(TEXT_DB), false);
59
60         } catch (IOException ioe) {
61             System.out.println("Can't load text db " + ioe);
62         }
63         assertTrue("db loaded", udb != null);
64         assertTrue("txt db loaded", udbTextVersion != null);
65         assertTrue("DBs identical", udb.compare(udbTextVersion));
66     }
67
68
69
70     /**
71      * Common code run after each test
72      */
73     protected void tearDown() {
74         //utterance = null;
75     } 
76
77
78     /**
79      * Tests to see that we succeed
80      */
81     public void testSuccess() {
82         assertTrue("Should succeed", true);
83     }
84
85
86     /**
87      * Factory method that creates the test suite.
88      * 
89      * @return the test suite.
90      */
91     public static Test suite() {
92         return new TestSuite(UnitDatabaseTests.class);
93     } 
94
95
96
97     /**
98      * Main entry point for this test suite.
99      * 
100      * @param  args    the command line arguments.
101      */
102     public static void main(String[] args) {
103         junit.textui.TestRunner.run(suite());
104     } 
105 }
106
107