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.Media;
010: import javax.emb.MediaBean;
011: import javax.emb.MediaException;
012: import javax.emb.MediaFormat;
013: import javax.emb.MediaFormatRegistry;
014:
015: import org.objectweb.jonas.emb.mfb.formats.audio.WavAudioFormat;
016:
017: import com.ibm.emb.junit.EMBTestRunner;
018:
019: public class WavFormatTest extends EmbeddedMediaFormatTest {
020:
021: /**
022: * constructor
023: */
024: public WavFormatTest(String name) throws MediaException {
025: super (name);
026: }
027:
028: /**
029: * main method
030: */
031: public static void main(String args[]) {
032: EMBTestRunner.run(WavFormatTest.class);
033: }
034:
035: /**
036: * creates an instance of BmpFormat with the given Parameters used in super
037: * class of BmpFormatTest
038: */
039: public MediaFormat createMediaFormat() {
040: return new WavAudioFormat();
041: }
042:
043: /**
044: * do initialisation here
045: */
046: protected void setUp() {
047: }
048:
049: /**
050: * freeup resources
051: */
052: protected void tearDown() {
053: }
054:
055: /**
056: * <pre>
057: *
058: *
059: *
060: * Testcase Name: extractHeader(Media)
061: * Testcase Number: TEMB0074SBA
062: *
063: * Test 1:
064: * call extractHeader passing a wav-audio media
065: * --> check result to be an instance of com.ibm.emb.meb.WavHeader
066: *
067: *
068: *
069: * </pre>
070: */
071: public void testTEMB0074SBA() throws MediaException, IOException {
072:
073: //
074: // test 1
075: //
076:
077: // register media format
078: MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
079: formatRegistry.rebind("wav", new WavAudioFormat());
080:
081: // full path of the mpeg video sample
082: String mediaWavFullPath = embTestConfig.getMediaDir()
083: + File.separator + embTestConfig.getWavSoundName1();
084:
085: // creates media bean
086: File mediaWavFile = new File(mediaWavFullPath);
087: MediaBean mediaBean = new MediaBean(mediaWavFile, "wav");
088:
089: // creates wav audio format
090: WavAudioFormat wavFormat = new WavAudioFormat();
091:
092: // creates mpegAudioHeader
093: // TODO : wavHeader does not exist any more
094: // InputStream mediaWavInputStream = new FileInputStream(mediaWavFile);
095: // WavHeader wavHeader = (WavHeader) wavFormat.extractHeader(mediaWavInputStream);
096: // mediaWavInputStream.close();
097: // // test
098: // assertTrue("test 1", wavHeader instanceof WavHeader);
099:
100: testTrace("test 1 passed");
101:
102: succeed();
103: }
104:
105: /**
106: * <pre>
107: *
108: *
109: *
110: * Testcase Name: extractSurrogate(Media)
111: * Testcase Number: TEMB0057SBA
112: *
113: * Test 1:
114: * call extractSurrogate passing a wav audio media
115: * check result to be an instance of Media
116: * access the content of the resulting media ----> to verify it is accessible
117: *
118: *
119: *
120: * </pre>
121: */
122: public void testTEMB0057SBA() throws MediaException, IOException {
123: //
124: // test 1
125: //
126:
127: // register media format
128: MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
129: formatRegistry.rebind("wav", new WavAudioFormat());
130:
131: // full path of the wav audio sample
132: String mediaWavFullPath = embTestConfig.getMediaDir()
133: + File.separator + embTestConfig.getWavSoundName1();
134:
135: // creates media bean
136: File mediaWavFile = new File(mediaWavFullPath);
137: MediaBean mediaBean = new MediaBean(mediaWavFile, "wav");
138:
139: InputStream mediaWavInputStream = new FileInputStream(
140: mediaWavFile);
141: // creates wav audio format
142: WavAudioFormat wavFormat = new WavAudioFormat();
143: // gets surrogate
144: MediaBean mediaBeanSurrogate = (MediaBean) wavFormat
145: .extractProxy(mediaWavInputStream);
146: mediaWavInputStream.close();
147:
148: // check access to content and check format
149: byte[] content = mediaBeanSurrogate.getContent();
150: byte[] content_ = new byte[content.length];
151: System.arraycopy(content, 0, content_, 0, content.length);
152:
153: assertTrue("test 1", mediaBeanSurrogate instanceof Media);
154: testTrace("test 1 passed");
155:
156: succeed();
157: }
158:
159: /**
160: * <pre>
161: *
162: *
163: *
164: * Testcase Name: getDefaultMimeType()
165: * Testcase Number: TEMB0075SBA
166: *
167: * Test 1:
168: * call getDefaultMimeType
169: * --->check if result equals "audio/x-pn-wav"
170: *
171: *
172: *
173: * </pre>
174: */
175: public void testTEMB0075SBA() throws MediaException {
176: //
177: // test 1
178: //
179:
180: // creates mpeg video format
181: WavAudioFormat wavFormat = new WavAudioFormat();
182:
183: assertEquals("test 1: ", "audio/x-pn-wav", wavFormat
184: .getDefaultMimeType());
185: testTrace("test 1 passed");
186:
187: succeed();
188: }
189:
190: /**
191: * <pre>
192: *
193: *
194: *
195: * Testcase Name: isStreamingDesirable()
196: * Testcase Number: TEMB0076SBA
197: *
198: * Test 1:
199: * call isStreamingDesirable
200: * --->check if result is true
201: *
202: *
203: *
204: * </pre>
205: */
206: public void testTEMB0076SBA() throws MediaException {
207: //
208: // test 1
209: //
210:
211: // creates mpeg video format
212: WavAudioFormat wavFormat = new WavAudioFormat();
213:
214: assertTrue("test 1: ", wavFormat.isStreamingDesirable());
215: testTrace("test 1 passed");
216:
217: succeed();
218: }
219:
220: }
|