Source Code Cross Referenced for MediaFormatTest.java in  » J2EE » JOnAS-4.8.6 » com » ibm » emb » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » com.ibm.emb.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.ibm.emb.test;
002:
003:        import java.io.ByteArrayInputStream;
004:        import java.io.File;
005:        import java.io.FileInputStream;
006:        import java.io.FileOutputStream;
007:        import java.io.IOException;
008:        import java.io.InputStream;
009:        import java.net.MalformedURLException;
010:        import java.net.URL;
011:
012:        import javax.emb.ContentTooLargeException;
013:        import javax.emb.FormatFeatureException;
014:        import javax.emb.FormatSyntaxException;
015:        import javax.emb.GenericMediaFormat;
016:        import javax.emb.LinkTranslationException;
017:        import javax.emb.Media;
018:        import javax.emb.MediaException;
019:        import javax.emb.MediaFormat;
020:        import javax.emb.MediaFormatRegistry;
021:        import javax.emb.MediaHeader;
022:        import javax.emb.MediaSegment;
023:
024:        import junit.framework.Test;
025:        import junit.framework.TestSuite;
026:
027:        import org.objectweb.jonas.emb.mfb.formats.image.JpegFormat;
028:
029:        import com.ibm.emb.junit.EMBStaticHelper;
030:        import com.ibm.emb.junit.EMBTestCaseBase;
031:
032:        /**
033:         * <pre>
034:         *
035:         *   Line Item: MFB API
036:         *   Subcategory 1: javax.emb
037:         *   Subcategory 2: MediaFormat
038:         *
039:         *   This abstract class provides test methods for all methods described in the interface
040:         *   MediaFormat.
041:         *   For testing implementations of this interface one needs to create a Tester
042:         *   class which extends this abstract class.
043:         *
044:         * </pre>
045:         */
046:        public abstract class MediaFormatTest extends EMBTestCaseBase {
047:
048:            // constructor
049:            public MediaFormatTest(String name) throws MediaException {
050:                super (name);
051:            }
052:
053:            /**
054:             * stdSuite method of this test class instantiates all tests necesssary to
055:             * for the standard compliance tests
056:             * @param String complete class Name of the implementor of the abstract test
057:             */
058:            public static Test stdSuite(String TestCaseImplementor) {
059:                TestSuite suite = new TestSuite(TestCaseImplementor);
060:                try {
061:                    Class implementorClass = Class.forName(TestCaseImplementor);
062:                    java.lang.reflect.Constructor implementorConstructor = implementorClass
063:                            .getDeclaredConstructor(new Class[] { String.class });
064:                    suite.addTest((Test) implementorConstructor
065:                            .newInstance(new String[] { "testEMB013" }));
066:                    suite.addTest((Test) implementorConstructor
067:                            .newInstance(new String[] { "testEMB014" }));
068:                    suite.addTest((Test) implementorConstructor
069:                            .newInstance(new String[] { "testEMB015" }));
070:                    suite.addTest((Test) implementorConstructor
071:                            .newInstance(new String[] { "testEMB016" }));
072:                    suite.addTest((Test) implementorConstructor
073:                            .newInstance(new String[] { "testEMB017" }));
074:                    suite.addTest((Test) implementorConstructor
075:                            .newInstance(new String[] { "testEMB018" }));
076:                    suite.addTest((Test) implementorConstructor
077:                            .newInstance(new String[] { "testEMB019" }));
078:                } catch (java.lang.reflect.InvocationTargetException ex) {
079:                    String msg = "error dynamically creating "
080:                            + TestCaseImplementor + " " + ex.toString();
081:                    EMBStaticHelper.testTrace(msg);
082:                    throw new RuntimeException(msg);
083:                } catch (ClassNotFoundException ex) {
084:                    String msg = "Class not found " + TestCaseImplementor + " "
085:                            + ex.toString();
086:                    EMBStaticHelper.testTrace(msg);
087:                    throw new RuntimeException(msg);
088:                } catch (NoSuchMethodException ex) {
089:                    String msg = "No such method in " + TestCaseImplementor
090:                            + " " + ex.toString();
091:                    EMBStaticHelper.testTrace(msg);
092:                    throw new RuntimeException(msg);
093:                } catch (InstantiationException ex) {
094:                    String msg = TestCaseImplementor + " " + ex.toString();
095:                    EMBStaticHelper.testTrace(msg);
096:                    throw new RuntimeException(msg);
097:                } catch (IllegalAccessException ex) {
098:                    String msg = TestCaseImplementor + " " + ex.toString();
099:                    EMBStaticHelper.testTrace(msg);
100:                    throw new RuntimeException(msg);
101:                }
102:                return suite;
103:            }
104:
105:            /**
106:             * abstract method to create an instance of MediaFormat this method needs to
107:             * be implemented in the test subclass and will create an instance of the
108:             * concrete implementation of the class under test
109:             */
110:            public abstract MediaFormat createMediaFormat();
111:
112:            /**
113:             * <pre>
114:             *
115:             *  Testcase Name: assembleContent(URL, MediaSegment[])
116:             *  Testcase Number: EMB013
117:             *
118:             *  setup:
119:             *
120:             *  test procedure:
121:             *  1.call assembleContent with null as segment array and null as location
122:             *    expected result: NullPointerException
123:             *
124:             *  2.call assembleContent with empty segment array and null as location
125:             *    expected result: empty byte array result
126:             *
127:             *  3.create 1 element segment array containing a null element
128:             *    call assembleContent with the segment array created and null as location
129:             *    expected result: NullPointerException
130:             *
131:             *  4.create 1 element segment array, fill in random content and null as child location
132:             *    call assembleContent with the segment array created and null as location
133:             *    expected result: content equal to the random content passed with the segment array
134:             *
135:             *  5.create several MediaSegments (combined size=2GB) and store in MediaSegment array
136:             *    call assembleContent
137:             *    expected result: ContentTooLargeException
138:             *
139:             *  6.create 1 element segment array with random content and invalid childLocation
140:             *    call assembleContent with segment array and null location
141:             *    expected result: if (isEmbedded) -&gt; FormatSyntaxException
142:             *  					  if (!isEmbedded) -&gt; LinkTranslationException
143:             *
144:             *  7.crate 2 element segemnt array with random content and null childLocation
145:             *    call assembleContent
146:             *    expected result: if (isEmbedded) -&gt; FormatSyntaxException
147:             *  					  if (!isEmbedded) -&gt; byte array not null
148:             *
149:             *  8.create 1 element array with random content and random childLocation
150:             *    call assembleContent
151:             *    expected result: if (isEmbedded) -&gt; FormatSyntaxException
152:             *  					  if (!isEmbedded) -&gt;byte array not null
153:             *
154:             * </pre>
155:             */
156:            public void testEMB013() throws MediaException, IOException {
157:
158:                // media segment
159:                MediaSegment mediaSegment1 = null;
160:                MediaSegment mediaSegment2 = null;
161:                MediaSegment[] testMediaSegmentArray = null;
162:                // test instance
163:                MediaFormat testInstance = createMediaFormat();
164:                byte[] testByteArray1 = null;
165:                byte[] testByteArray2 = null;
166:                //
167:                // test 1
168:                //
169:                try {
170:                    testInstance.assembleContent(null, null);
171:                    fail("test1: Should throw a NullPointerException");
172:                } catch (NullPointerException e) {
173:                    testTrace("test 1 passed");
174:                } catch (Exception e) {
175:                    fail("test 1: Should throw a NullPointerException but threw "
176:                            + e.toString());
177:                }
178:                //
179:                // test 2
180:                //
181:                testMediaSegmentArray = new MediaSegment[0];
182:                if (this  instanceof  com.ibm.emb.test.mfb.GenericPlayListTest) {
183:                    logProductError("PEMB0067STZ reported only for GenericPlaylistFormat;  ");
184:                }
185:                testByteArray1 = testInstance.assembleContent(null,
186:                        testMediaSegmentArray);
187:                assertEquals("test 2", 0, testByteArray1.length);
188:                testTrace("test 2 passed");
189:                //
190:                // test 3
191:                //
192:                testMediaSegmentArray = new MediaSegment[] { null };
193:                try {
194:                    testInstance.assembleContent(null, testMediaSegmentArray);
195:                    fail("test3: Should throw a NullPointerException");
196:                } catch (NullPointerException e) {
197:                    testTrace("test 3 passed");
198:                } catch (Exception e) {
199:                    fail("test 3: Should throw a NullPointerException but throwed "
200:                            + e.toString());
201:                }
202:                //
203:                // test 4
204:                //
205:                testInstance = createMediaFormat();
206:
207:                testByteArray1 = EMBStaticHelper.createRandomByteArray(1024);
208:                mediaSegment1 = new MediaSegment();
209:                mediaSegment1.setContent(testByteArray1);
210:                testMediaSegmentArray = new MediaSegment[] { mediaSegment1 };
211:                if (this  instanceof  com.ibm.emb.test.mfb.GenericPlayListTest) {
212:                    logProductError("PEMB0067STZ reported only for GenericPlaylistFormat;  ");
213:                }
214:                testByteArray2 = testInstance.assembleContent(null,
215:                        testMediaSegmentArray);
216:                assertTrue("test4", java.util.Arrays.equals(testByteArray1,
217:                        testByteArray2));
218:                testTrace("test 4 passed");
219:                //
220:                // test 5
221:                //
222:                if (embTestConfig.getIncludeLongRunningTest()) {
223:                    int maxSize = Integer.parseInt(embTestConfig
224:                            .getMaxMediaSize());
225:                    if ((maxSize == -1) || (maxSize > Integer.MAX_VALUE)) {
226:                        GenericMediaFormat testMedia = new GenericMediaFormat();
227:                        testByteArray1 = EMBStaticHelper
228:                                .createRandomByteArray(Integer
229:                                        .parseInt(embTestConfig
230:                                                .getMaxMediaSize()) + 1);
231:                        mediaSegment1 = new MediaSegment();
232:                        mediaSegment1.setContent(testByteArray1);
233:                        testMediaSegmentArray = new MediaSegment[] { mediaSegment1 };
234:                        try {
235:                            testMedia.assembleContent(null,
236:                                    testMediaSegmentArray);
237:                            fail("test 5: Should throw a ContentTooLargeException");
238:                        } catch (ContentTooLargeException e) {
239:                            testTrace("test 5 passed");
240:                        } catch (Exception e) {
241:                            fail("test 5: Should throw a ContentTooLargeException but threw "
242:                                    + e.toString());
243:                        }
244:                    }
245:                }
246:                //
247:                // test 6
248:                //
249:                testInstance = createMediaFormat();
250:                testByteArray1 = EMBStaticHelper.createRandomByteArray(1024);
251:                mediaSegment1 = new MediaSegment();
252:                mediaSegment1.setContent(testByteArray1);
253:                try {
254:                    mediaSegment1.setChildLocation(new URL("file://"
255:                            + embTestConfig.getMediaDir() + File.separatorChar
256:                            + "childTestFile.test"));
257:                } catch (MalformedURLException e) {
258:                    System.out
259:                            .println("setChildLocation called with malformed URL");
260:                }
261:                testMediaSegmentArray = new MediaSegment[] { mediaSegment1 };
262:                if (testInstance.isEmbedded()) {
263:                    try {
264:                        testInstance.assembleContent(null,
265:                                testMediaSegmentArray);
266:                        fail("test 6: Should throw a FormatSyntaxException");
267:                    } catch (FormatSyntaxException e) {
268:                        testTrace("test 6 passed");
269:                    } catch (Exception e) {
270:                        fail("test 6: Should throw a FormatSyntaxException but threw "
271:                                + e.toString());
272:                    }
273:                } else {
274:                    try {
275:                        testInstance.assembleContent(null,
276:                                testMediaSegmentArray);
277:                        fail("test 6: Should throw a LinkTranslationException");
278:                    } catch (LinkTranslationException e) {
279:                        testTrace("test 6 passed");
280:                    } catch (Exception e) {
281:                        fail("test 6: Should throw a LinkTranslationException but threw "
282:                                + e.toString());
283:                    }
284:                }
285:                //
286:                // test 7
287:                //
288:                testInstance = createMediaFormat();
289:                testByteArray1 = EMBStaticHelper.createRandomByteArray(1024);
290:                testByteArray2 = EMBStaticHelper.createRandomByteArray(1024);
291:                mediaSegment1 = new MediaSegment();
292:                mediaSegment2 = new MediaSegment();
293:                mediaSegment1.setContent(testByteArray1);
294:                mediaSegment2.setContent(testByteArray2);
295:                testMediaSegmentArray = new MediaSegment[] { mediaSegment1,
296:                        mediaSegment2 };
297:                if (testInstance.isEmbedded()) {
298:                    try {
299:                        testInstance.assembleContent(null,
300:                                testMediaSegmentArray);
301:                        fail("test 7: Should throw a FormatSyntaxException");
302:                    } catch (FormatSyntaxException e) {
303:                        testTrace("test 7 passed");
304:                    } catch (Exception e) {
305:                        fail("test 7: Should throw a FormatSyntaxException but threw "
306:                                + e.toString());
307:                    }
308:                } else {
309:                    testByteArray1 = testInstance.assembleContent(null,
310:                            testMediaSegmentArray);
311:                    assertNotNull("test 7: ", testByteArray1);
312:                }
313:                //
314:                // test 8
315:                //
316:                testInstance = createMediaFormat();
317:                testByteArray1 = EMBStaticHelper.createRandomByteArray(1024);
318:                testByteArray2 = EMBStaticHelper.createRandomByteArray(1024);
319:                String childMediaPath = embTestConfig.getMediaDir()
320:                        + File.separatorChar + "Generated" + File.separatorChar
321:                        + "childMedia.test";
322:                File childMedia = new File(childMediaPath);
323:                childMedia.createNewFile();
324:                FileOutputStream childMediaOutputStream = new FileOutputStream(
325:                        childMedia);
326:                childMediaOutputStream.write(testByteArray2);
327:                childMediaOutputStream.close();
328:                mediaSegment1 = new MediaSegment();
329:                mediaSegment1.setContent(testByteArray1);
330:                mediaSegment1.setChildLocation(new URL("file:///"
331:                        + childMediaPath));
332:
333:                if (testInstance.isEmbedded()) {
334:                    try {
335:                        testInstance.assembleContent(null,
336:                                testMediaSegmentArray);
337:                        fail("test 8: Should throw a FormatSyntaxException");
338:                    } catch (FormatSyntaxException e) {
339:                        testTrace("test 8 passed");
340:                    } catch (Exception e) {
341:                        fail("test 8: Should throw a FormatSyntaxException but threw "
342:                                + e.toString());
343:                    }
344:                } else {
345:                    testByteArray1 = testInstance.assembleContent(null,
346:                            testMediaSegmentArray);
347:                    assertNotNull("test 8: ", testByteArray1);
348:                }
349:
350:                succeed();
351:            }
352:
353:            /**
354:             * <pre>
355:             *
356:             *  Testcase Name: disassembleContent(URL, byte[])
357:             *  Testcase Number: EMB014
358:             *
359:             *  setup:
360:             *
361:             *  test procedure:
362:             *  1.call disassembleContent with null as mediaContent and null as location
363:             *    expected result: NullPointerException
364:             *
365:             *  2.create byte array with random content, call disassembleContent with null location
366:             *    expected result:  if (isEmbedded)
367:             *  						-&gt; 1 element segment array OR
368:             *  						-&gt; FormatSyntaxException
369:             *  					   if (!isEmbedded)
370:             *  						-&gt; multiple element segment array OR
371:             *  						-&gt; FormatSyntaxException OR
372:             *  						-&gt; LinkTranslationException
373:             *
374:             *  3.retrieve property file for nonembedded media
375:             *    use sample media file and call disassembleContent
376:             *    call assembleContent on returned media segment array
377:             *    expected result: returned content should be same format as original
378:             *  	  				  and roughly the same size
379:             *
380:             * </pre>
381:             */
382:            public void testEMB014() throws MediaException, IOException,
383:                    ClassNotFoundException, IllegalAccessException,
384:                    InstantiationException {
385:
386:                // test instance
387:                MediaFormat testInstance = createMediaFormat();
388:                //
389:                // test 1
390:                //
391:                try {
392:                    testInstance.disassembleContent(null, null);
393:                    fail("test1: Should throw a NullPointerException");
394:                } catch (NullPointerException e) {
395:                    testTrace("test 1 passed");
396:                } catch (Exception e) {
397:                    fail("test 1: Should throw a NullPointerException but threw "
398:                            + e.toString());
399:                }
400:                //
401:                // test 2
402:                //
403:                byte[] testByteArray = EMBStaticHelper
404:                        .createRandomByteArray(1024);
405:                if (testInstance.isEmbedded()) {
406:                    try {
407:                        MediaSegment[] testSegmentArray = testInstance
408:                                .disassembleContent(null, testByteArray);
409:                        assertEquals("test 2: ", 1, testSegmentArray.length);
410:                        testTrace("test 2 passed");
411:                    } catch (FormatSyntaxException e) {
412:                        testTrace("test 2 passed: FormatSyntaxException");
413:                    } catch (Exception e) {
414:                        fail("test 2: Should pass or throw FormatSyntaxException but threw "
415:                                + e.toString());
416:                    }
417:                } else {
418:                    try {
419:                        MediaSegment[] testSegmentArray = testInstance
420:                                .disassembleContent(null, testByteArray);
421:                        assertTrue("test 2: ", testSegmentArray.length > 1);
422:                        testTrace("test 2 passed");
423:                    } catch (FormatSyntaxException e) {
424:                        testTrace("test 2 passed: FormatSyntaxException");
425:                    } catch (LinkTranslationException e) {
426:                        testTrace("test 2 passed: LinkTranslationException");
427:                    } catch (Exception e) {
428:                        fail("test 2: Should pass, throw FormatSyntaxException, or throw LinkTranslationException but threw "
429:                                + e.toString());
430:                    }
431:                }
432:                //
433:                // test 3
434:                //
435:                // retrieve non embedded media information
436:                String fullClassName = embTestConfig
437:                        .getNonEmbeddedMediaClassName();
438:                String fileExtension = embTestConfig
439:                        .getNonEmbeddedMediaFileExt();
440:                String nonEmbeddedMediaFile = embTestConfig
441:                        .getNonEmbeddedMediaFile();
442:
443:                // register non embedded media format
444:                javax.emb.MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
445:                formatRegistry.rebind(fileExtension, (MediaFormat) Class
446:                        .forName(fullClassName).newInstance());
447:                testInstance = (MediaFormat) Class.forName(fullClassName)
448:                        .newInstance();
449:
450:                String mediaFullPath = embTestConfig.getMediaDir()
451:                        + File.separatorChar + nonEmbeddedMediaFile;
452:                File mediaFile = new File(mediaFullPath);
453:                FileInputStream mediaFileInputStream = new FileInputStream(
454:                        mediaFile);
455:                byte[] mediaArray = new byte[(int) mediaFile.length()];
456:                mediaFileInputStream.read(mediaArray);
457:                mediaFileInputStream.close();
458:                URL mediaLocation = new URL("file", "localhost",
459:                        File.separatorChar + mediaFile.getAbsolutePath());
460:
461:                MediaSegment[] testSegmentArray = testInstance
462:                        .disassembleContent(mediaLocation, mediaArray);
463:                assertTrue("test 3: ", testSegmentArray.length >= 1);
464:
465:                byte[] testArray = testInstance.assembleContent(mediaLocation,
466:                        testSegmentArray);
467:                assertTrue("test 3: ", (Math.abs(testArray.length
468:                        - mediaArray.length) <= 100));
469:
470:                testTrace("test 3 passed");
471:
472:                succeed();
473:            }
474:
475:            /**
476:             * <pre>
477:             *
478:             *  Testcase Name: extractHeader(InputStream content)
479:             *  Testcase Number: EMB015
480:             *
481:             *  setup:
482:             *
483:             *  test procedure:
484:             *  1.call extractHeader(null)
485:             *    expected result: NullPointerException
486:             *
487:             *  2.create input stream from random content and call extractHeader with input stream
488:             *    possible results:
489:             *  				a) not null...instance of GenericMediaHeader
490:             *  				b) FormatSyntaxException
491:             *  				c) FormatFeatureException
492:             *  				d) fail...
493:             *  &lt;pre&gt;
494:             *
495:             */
496:            public void testEMB015() throws MediaException, IOException {
497:                MediaFormat testInstance = createMediaFormat();
498:                //
499:                // test 1
500:                //
501:                try {
502:                    testInstance.extractHeader(null);
503:                    fail("test 1: Should throw a NullPointerException");
504:                } catch (NullPointerException e) {
505:                    testTrace("test 1 passed");
506:                } catch (Exception e) {
507:                    fail("test 1: Should throw a NullPointerException but threw "
508:                            + e.toString());
509:                }
510:                //
511:                // test 2
512:                //
513:                testInstance = createMediaFormat();
514:                byte[] testByteArray = EMBStaticHelper
515:                        .createRandomByteArray(1024);
516:                InputStream in = new ByteArrayInputStream(testByteArray);
517:                try {
518:                    MediaHeader header = testInstance.extractHeader(in);
519:                    assertTrue("test 2: ",
520:                            header instanceof  javax.emb.GenericMediaHeader);
521:                    testTrace("test 2 passed");
522:                } catch (FormatSyntaxException e) {
523:                    testTrace("test 2 passed: FormatSyntaxException");
524:                } catch (FormatFeatureException e) {
525:                    testTrace("test 2 passed: FormatFeatureException");
526:                } catch (Exception e) {
527:                    fail("test 2: Should pass, throw a FormatSyntaxException, or throw a FormatFeatureException "
528:                            + "but threw " + e.toString());
529:                }
530:                in.close();
531:
532:                succeed();
533:            }
534:
535:            /**
536:             * <pre>
537:             *
538:             *  Testcase Name: extractProxy(InputStream content)
539:             *  Testcase Number: EMB016
540:             *
541:             *  setup:
542:             *
543:             *  test procedure:
544:             *  1.call extractProxy(null)
545:             *    expected result: NullPointerException
546:             *
547:             *  2.create instance of MediaFormat, bind(&quot;jpg&quot;, new JpegFormat())
548:             *    call extractProxy with &quot;test.jpg&quot;
549:             *    expected result: not null
550:             *
551:             * </pre>
552:             */
553:            public void testEMB016() throws MediaException, IOException {
554:                MediaFormat testInstance = createMediaFormat();
555:                MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
556:                formatRegistry.rebind("jpg", new JpegFormat());
557:                //
558:                // test 1
559:                //
560:                try {
561:                    testInstance.extractProxy(null);
562:                    fail("test 1: Should throw a NullPointerException");
563:                } catch (NullPointerException e) {
564:                    testTrace("test 1 passed");
565:                } catch (Exception e) {
566:                    fail("test 1: Should throw a NullPointerException but threw "
567:                            + e.toString());
568:                }
569:                //
570:                // test 2
571:                //
572:                testInstance = createMediaFormat();
573:                byte[] testByteArray = EMBStaticHelper
574:                        .createRandomByteArray(1024);
575:                InputStream in = new ByteArrayInputStream(testByteArray);
576:                Media mediaProxy = testInstance.extractProxy(in);
577:                in.close();
578:                assertNotNull("test 2: ", mediaProxy);
579:                testTrace("test 2 passed");
580:
581:                succeed();
582:            }
583:
584:            /**
585:             * <pre>
586:             *
587:             *  Testcase Name: getDefaultMimeType()
588:             *  Testcase Number: EMB017
589:             *
590:             *  setup:
591:             *
592:             *  test procedure:
593:             *  1.call getDefaultMimeType
594:             *    expected result: result is not null and not an empty string
595:             *
596:             * </pre>
597:             */
598:            public void testEMB017() throws MediaException {
599:
600:                // test instance
601:                MediaFormat testInstance = createMediaFormat();
602:                //
603:                // test 1
604:                //
605:                assertNotNull("test 1", testInstance.getDefaultMimeType());
606:                assertFalse("test 1", testInstance.getDefaultMimeType().equals(
607:                        ""));
608:                testTrace("test 1 passed");
609:
610:                succeed();
611:            }
612:
613:            /**
614:             * <pre>
615:             *
616:             *  Testcase Name: isEmbedded()
617:             *  Testcase Number: EMB018
618:             *
619:             *  setup:
620:             *
621:             *  test procedure:
622:             *  1.create MediaFormat using abstract create method
623:             *    call isEmbedded()
624:             *    expected result: no exeception and result is either true or false
625:             *
626:             * </pre>
627:             */
628:            public void testEMB018() {
629:                MediaFormat testInstance = createMediaFormat();
630:                //
631:                // test 1
632:                //
633:                try {
634:                    boolean result = testInstance.isEmbedded();
635:                    testTrace("test 1 passed");
636:                } catch (Exception e) {
637:                    fail("test 1: Should not throw an Exception but threw "
638:                            + e.toString());
639:                }
640:                succeed();
641:            }
642:
643:            /**
644:             * <pre>
645:             *
646:             *  Testcase Name: isStreamingDesirable()
647:             *  Testcase Number: EMB019
648:             *
649:             *  setup:
650:             *
651:             *  test procedure:
652:             *  1.create MediaFormat using abstract create method
653:             *    call isStreamingDesireable()
654:             *    expected result: no exeception and result is either true or false
655:             *
656:             * </pre>
657:             */
658:            public void testEMB019() {
659:                MediaFormat testInstance = createMediaFormat();
660:                //
661:                // test 1
662:                //
663:                try {
664:                    boolean result = testInstance.isStreamingDesirable();
665:                    testTrace("test 1 passed");
666:                } catch (Exception e) {
667:                    fail("test 1: Should not throw an Exception but threw "
668:                            + e.toString());
669:                }
670:                succeed();
671:            }
672:
673:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.