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.video.MpegVideoFormat;
016:
017: import com.ibm.emb.junit.EMBTestRunner;
018:
019: public class MpegVideoFormatTest extends EmbeddedMediaFormatTest {
020:
021: /**
022: * constructor
023: */
024: public MpegVideoFormatTest(String name) throws MediaException {
025: super (name);
026: }
027:
028: /**
029: * main method
030: */
031: public static void main(String args[]) {
032: EMBTestRunner.run(MpegVideoFormatTest.class);
033: }
034:
035: /**
036: * creates an instance of MpegVideoFormat with the given Parameters used in
037: * super class of MpegVideoFormatTest
038: */
039: public MediaFormat createMediaFormat() {
040: return new MpegVideoFormat();
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: * Testcase Name: extractHeader(Media)
059: * Testcase Number: TEMB0086SBA
060: *
061: * Test 1:
062: * call extractHeader passing suitable MPEG video
063: * --> check result to be an instance of com.ibm.emb.meb.MpegVideoHeader
064: *
065: * </pre>
066: */
067: public void testTEMB0086SBA() throws MediaException, IOException {
068:
069: //
070: // test 1
071: //
072:
073: // register media format
074: MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
075: formatRegistry.rebind("mpeg", new MpegVideoFormat());
076:
077: // full path of the mpeg video sample
078: String mediaMpegFullPath = embTestConfig.getMediaDir()
079: + File.separator + embTestConfig.getMpegMovieName1();
080:
081: // creates media bean
082: File mediaMpegFile = new File(mediaMpegFullPath);
083: MediaBean mediaBean = new MediaBean(mediaMpegFile, "mpeg");
084:
085: // creates mpeg video format
086: MpegVideoFormat mpegVideoFormat = new MpegVideoFormat();
087:
088: // creates mpegVideoHeader
089:
090: // TODO : MpegHeader does not exist any more
091: // InputStream mediaMpegInputStream = new FileInputStream(mediaMpegFile);
092: // MpegVideoHeader mpegVideoHeader = (MpegVideoHeader) mpegVideoFormat.extractHeader(mediaMpegInputStream);
093: // mediaMpegInputStream.close();
094: //
095: // // test
096: // assertTrue("test 1", mpegVideoHeader instanceof MpegVideoHeader);
097:
098: testTrace("test 1 passed");
099:
100: succeed();
101: }
102:
103: /**
104: * <pre>
105: *
106: * Testcase Name: extractSurrogate(Media)
107: * Testcase Number: TEMB0087SBA
108: *
109: * Test 1:
110: * call extractSurrogate passing suitable MPEG video.
111: * check result to be an instance of Media
112: * access the content of the resulting media ----> to verify it is accessible
113: *
114: * </pre>
115: */
116: public void testTEMB0087SBA() throws MediaException, IOException {
117: //
118: // test 1
119: //
120:
121: // register media format
122: MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
123: formatRegistry.rebind("mpg", new MpegVideoFormat());
124:
125: // full path of the mpeg video sample
126: String mediaMpegFullPath = embTestConfig.getMediaDir()
127: + File.separator + embTestConfig.getMpegMovieName1();
128:
129: // creates media bean
130: File mediaMpegFile = new File(mediaMpegFullPath);
131: MediaBean mediaBean = new MediaBean(mediaMpegFile, "mpeg");
132:
133: InputStream mediaMpegInputStream = new FileInputStream(
134: mediaMpegFile);
135: // creates mpeg video format
136: MpegVideoFormat mpegVideoFormat = new MpegVideoFormat();
137: // gets surrogate
138: MediaBean mediaBeanSurrogate = (MediaBean) mpegVideoFormat
139: .extractProxy(mediaMpegInputStream);
140: mediaMpegInputStream.close();
141:
142: // check access to content and check format
143: byte[] content = mediaBeanSurrogate.getContent();
144: byte[] content_ = new byte[content.length];
145: System.arraycopy(content, 0, content_, 0, content.length);
146:
147: assertTrue("test 1", mediaBeanSurrogate instanceof Media);
148: testTrace("test 1 passed");
149:
150: succeed();
151: }
152:
153: /**
154: * <pre>
155: *
156: * Testcase Name: getDefaultMimeType()
157: * Testcase Number: TEMB0088SBA
158: *
159: * Test 1:
160: * call getDefaultMimeType
161: * --->check if result equals "video/mpeg"
162: *
163: * </pre>
164: */
165: public void testTEMB0088SBA() throws MediaException {
166: //
167: // test 1
168: //
169:
170: // creates mpeg video format
171: MpegVideoFormat mpegVideoFormat = new MpegVideoFormat();
172:
173: assertEquals("test 1: ", "video/mpeg", mpegVideoFormat
174: .getDefaultMimeType());
175: testTrace("test 1 passed");
176:
177: succeed();
178: }
179:
180: /**
181: * <pre>
182: *
183: * Testcase Name: isStreamingDesirable()
184: * Testcase Number: TEMB0089SBA
185: *
186: * Test 1:
187: * call isStreamingDesirable
188: * --->check if result is true
189: *
190: * </pre>
191: */
192: public void testTEMB0089SBA() throws MediaException {
193: //
194: // test 1
195: //
196:
197: // creates mpeg video format
198: MpegVideoFormat mpegVideoFormat = new MpegVideoFormat();
199:
200: assertTrue("test 1: ", mpegVideoFormat.isStreamingDesirable());
201: testTrace("test 1 passed");
202:
203: succeed();
204: }
205:
206: }
|