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.MpegAudioFormat;
015:
016: import com.ibm.emb.junit.EMBTestRunner;
017: import com.ibm.emb.test.MediaHeaderTest;
018:
019: public class MpegAudioHeaderTest extends MediaHeaderTest {
020:
021: /**
022: * constructor
023: */
024: public MpegAudioHeaderTest(String name) throws MediaException {
025: super (name);
026: }
027:
028: /**
029: * main method
030: */
031: public static void main(String args[]) {
032: EMBTestRunner.run(MpegAudioHeaderTest.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 MpegAudioHeader with the given Parameters used in
049: * super class of MpegAudioHeaderTest
050: */
051: public MediaHeader createMediaHeader() throws MediaException,
052: IOException {
053:
054: // register media format
055: MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
056: formatRegistry.rebind("mp3", new MpegAudioFormat());
057:
058: // full path of the mp3 media sample
059: String mediaMp3FullPath = embTestConfig.getMediaDir()
060: + File.separator + embTestConfig.getMp3SoundName1();
061:
062: // creates media bean
063: File mediaMp3File = new File(mediaMp3FullPath);
064: MediaBean mediaBean = new MediaBean(mediaMp3File, "mp3");
065:
066: // creates jpeg format
067: InputStream mediaMp3InputStream = new FileInputStream(
068: mediaMp3File);
069: MpegAudioFormat mp3Format = new MpegAudioFormat();
070: MediaHeader mp3Header = mp3Format
071: .extractHeader(mediaMp3InputStream);
072: mediaMp3InputStream.close();
073: return mp3Header;
074: }
075:
076: /**
077: * <pre>
078: *
079: *
080: *
081: * Testcase Name: getField(String)
082: * Testcase Number: TEMB0091SBA
083: *
084: * Test 1:
085: * iterate over fieldnames, check results:
086: * bitrate: 128
087: * emphasisIndex: 0
088: * layer: 3
089: * modeExtensionIndex: 0
090: * modeIndex: 0
091: * samplingFrequency: 22050
092: * version: 2.0
093: *
094: *
095: *
096: * </pre>
097: */
098: public void testTEMB0091SBA() throws MediaException, IOException {
099:
100: // MpegAudioHeader testInstance;
101: // testInstance = (MpegAudioHeader) createMediaHeader();
102: //
103: // //
104: // // test 1
105: // //
106: //
107: // assertTrue("test1 : ", testInstance.getField("bitrate").toString().equals("128")
108: // && testInstance.getField("emphasisIndex").toString().equals("0")
109: // && testInstance.getField("layer").toString().equals("3")
110: // && testInstance.getField("modeExtensionIndex").toString().equals("0")
111: // && testInstance.getField("modeIndex").toString().equals("0")
112: // && testInstance.getField("samplingFrequency").toString().equals("22050")
113: // && testInstance.getField("version").toString().equals("2.0"));
114: // testTrace("test 1 passed");
115:
116: succeed();
117: }
118: }
|