001: package com.ibm.emb.test.mfb;
002:
003: // java stuff
004: import java.io.File;
005: import java.io.FileInputStream;
006: import java.io.IOException;
007: import java.io.InputStream;
008:
009: import javax.emb.MediaBean;
010: import javax.emb.MediaException;
011: import javax.emb.MediaFormatRegistry;
012: import javax.emb.MediaHeader;
013:
014: import org.objectweb.jonas.emb.mfb.formats.audio.WavAudioFormat;
015:
016: import com.ibm.emb.junit.EMBTestRunner;
017: import com.ibm.emb.test.MediaHeaderTest;
018:
019: public class WavHeaderTest extends MediaHeaderTest {
020:
021: /**
022: * constructor
023: */
024: public WavHeaderTest(String name) throws MediaException {
025: super (name);
026: }
027:
028: /**
029: * main method
030: */
031: public static void main(String args[]) {
032: EMBTestRunner.run(WavHeaderTest.class);
033: }
034:
035: /**
036: * do initialisation here
037: */
038: protected void setUp() {
039: }
040:
041: /**
042: * freeup resources
043: */
044: protected void tearDown() {
045: }
046:
047: /**
048: * creates an instance of WavHeader with the given Parameters used in super
049: * class of WavHeaderTest
050: */
051: public MediaHeader createMediaHeader() throws MediaException,
052: IOException {
053:
054: // register media format
055: MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
056: formatRegistry.rebind("wav", new WavAudioFormat());
057:
058: // full path of the wav audio sample
059: String mediaWavFullPath = embTestConfig.getMediaDir()
060: + File.separator + embTestConfig.getWavSoundName1();
061:
062: // creates media bean
063: File mediaWavFile = new File(mediaWavFullPath);
064: MediaBean mediaBean = new MediaBean(mediaWavFile, "wav");
065:
066: // creates Wav format
067: InputStream mediaWavInputStream = new FileInputStream(
068: mediaWavFile);
069: WavAudioFormat wavFormat = new WavAudioFormat();
070: MediaHeader wavHeader = wavFormat
071: .extractHeader(mediaWavInputStream);
072: mediaWavInputStream.close();
073: return wavHeader;
074: }
075:
076: /**
077: * <pre>
078: *
079: * Testcase Name: getField(String)
080: * Testcase Number: TEMB0078SBA
081: *
082: * Test 1:
083: * iterate over fieldnames, check for these results:
084: * bandwidth: 44100
085: * blockAlignment: 2
086: * formatChunkSize: 16
087: * formatTag: 1
088: * numberOfChannels: 1
089: * sampleRate: 22050
090: * sampleSize: 16
091: * waveChunkSize: 22136
092: *
093: *
094: * </pre>
095: */
096: public void testTEMB0078SBA() throws MediaException, IOException {
097:
098: //TODO : wavHeader does not exist any more
099: // WavHeader testInstance;
100: // testInstance = (WavHeader) createMediaHeader();
101: //
102: // //
103: // // test 1
104: // //
105: //
106: // assertTrue("test1 : ", testInstance.getField("bandwidth").toString().equals("44100")
107: // && testInstance.getField("blockAlignment").toString().equals("2")
108: // && testInstance.getField("formatChunkSize").toString().equals("16")
109: // && testInstance.getField("formatTag").toString().equals("1")
110: // && testInstance.getField("numberOfChannels").toString().equals("1")
111: // && testInstance.getField("sampleRate").toString().equals("22050")
112: // && testInstance.getField("sampleSize").toString().equals("16")
113: // && testInstance.getField("waveChunkSize").toString().equals("22136"));
114:
115: testTrace("test 1 passed");
116:
117: succeed();
118: }
119:
120: }
|