Source Code Cross Referenced for GenericMediaFormatTest.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.IOException;
005:        import java.io.InputStream;
006:        import java.net.MalformedURLException;
007:        import java.net.URL;
008:
009:        import javax.emb.FormatSyntaxException;
010:        import javax.emb.GenericMediaFormat;
011:        import javax.emb.Media;
012:        import javax.emb.MediaException;
013:        import javax.emb.MediaFormat;
014:        import javax.emb.MediaHeader;
015:        import javax.emb.MediaSegment;
016:
017:        import com.ibm.emb.junit.EMBStaticHelper;
018:        import com.ibm.emb.junit.EMBTestRunner;
019:
020:        /**
021:         * <pre>
022:         * 
023:         *  
024:         *   
025:         *     Line Item: MFB API 
026:         *     Subcategory 1: javax.emb
027:         *     Subcategory 2: GenericMediaFormat
028:         *    
029:         *     Test class for javax.emb.GenericMediaFormat which extends the
030:         *     super class MediaFormatTest.  These tests are more specific
031:         *     to the GenericMediaFormat
032:         *    
033:         *   
034:         *  
035:         * </pre>
036:         */
037:        public class GenericMediaFormatTest extends MediaFormatTest {
038:
039:            public GenericMediaFormatTest(String name) throws MediaException {
040:                super (name);
041:            }
042:
043:            public static void main(String args[]) {
044:                EMBTestRunner.run(GenericMediaFormatTest.class);
045:            }
046:
047:            public MediaFormat createMediaFormat() {
048:                return new GenericMediaFormat();
049:            }
050:
051:            /**
052:             * <pre>
053:             * 
054:             *  
055:             *   
056:             *    Testcase Name: assembleContent(URL mediaLocation, MediaSegment[] mediaSegments)
057:             *    Testcase Number: EMB020
058:             *    
059:             *    setup:
060:             *    
061:             *    test procedure:
062:             *    1.create 2 element segment array
063:             *      call assembleContent with the segment array created and null as location
064:             *      expected result: FormatSyntaxException
065:             *    
066:             *    2.create 0 element segment array
067:             *      call assembleContent with the segment array created and null as location
068:             *      expected result: empty byte array
069:             *    
070:             *    3.create 1 element segment array, fill in random content and valid random child location
071:             *      call assembleContent with the segment array created and null as location
072:             *      expected result: FormatSyntaxException
073:             *    
074:             *    4.call assembleContent with null as segment array and null as location
075:             *      expected result: NullPointerException
076:             *    
077:             *    5.create 1 element segment array with null as element
078:             *      call assembleContent with the segment array created and null as location
079:             *      expected result: NullPointerException
080:             *    
081:             *    6.create 1 element segment array, fill in random content null as child location
082:             *      call assembleContent with the segment array created and null as location
083:             *      expected result: content equal to the random content passed with the segment array
084:             *    
085:             *   
086:             *  
087:             * </pre>
088:             */
089:            public void testEMB020() throws MediaException,
090:                    MalformedURLException {
091:                byte[] testByteArray = null;
092:                //
093:                // test 1
094:                //
095:                MediaSegment mediaSegment1 = new MediaSegment();
096:                mediaSegment1.setContent(EMBStaticHelper
097:                        .createRandomByteArray(2048));
098:                MediaSegment mediaSegment2 = new MediaSegment();
099:                mediaSegment2.setContent(EMBStaticHelper
100:                        .createRandomByteArray(2048));
101:                MediaSegment[] testMediaSegmentArray = new MediaSegment[] {
102:                        mediaSegment1, mediaSegment2 };
103:
104:                MediaFormat testInstance = createMediaFormat();
105:                try {
106:                    testInstance.assembleContent(null, testMediaSegmentArray);
107:                    fail("test 1: Should throw a FormatSyntaxException");
108:                } catch (FormatSyntaxException e) {
109:                    testTrace("test 1 passed");
110:                } catch (Exception e) {
111:                    fail("test 1: Should throw a FormatSyntaxException but threw "
112:                            + e.toString());
113:                }
114:                //
115:                // test 2
116:                //
117:                testMediaSegmentArray = new MediaSegment[0];
118:                testByteArray = testInstance.assembleContent(null,
119:                        testMediaSegmentArray);
120:                assertEquals("test 2", 0, testByteArray.length);
121:                testTrace("test 2 passed");
122:                //
123:                // test 3
124:                //
125:                mediaSegment1.setChildLocation(new URL("file", embTestConfig
126:                        .getTestClient(), "/testURL"));
127:                testMediaSegmentArray = new MediaSegment[] { mediaSegment1 };
128:                testInstance = createMediaFormat();
129:
130:                try {
131:                    testInstance.assembleContent(null, testMediaSegmentArray);
132:                    fail("test 3: Should throw a FormatSyntaxException");
133:                } catch (FormatSyntaxException e) {
134:                    testTrace("test 3 passed");
135:                } catch (Exception e) {
136:                    fail("test 3: Should throw a FormatSyntaxException but threw "
137:                            + e.toString());
138:                }
139:                //
140:                // test 4
141:                //
142:                testInstance = createMediaFormat();
143:                try {
144:                    testInstance.assembleContent(null, null);
145:                    fail("test 4: Should throw a NullPointerException");
146:                } catch (NullPointerException e) {
147:                    testTrace("test 4 passed");
148:                } catch (Exception e) {
149:                    fail("test 4: Should throw a NullPointerExceptin but threw "
150:                            + e.toString());
151:                }
152:                //
153:                // test 5
154:                //
155:                testMediaSegmentArray = new MediaSegment[1];
156:                testMediaSegmentArray[0] = null;
157:                testInstance = createMediaFormat();
158:                try {
159:                    testInstance.assembleContent(null, testMediaSegmentArray);
160:                    fail("test 5: Should throw a NullPointerException");
161:                } catch (NullPointerException e) {
162:                    testTrace("test 5 passed");
163:                } catch (Exception e) {
164:                    fail("test 5: Should throw a NullPointerException but threw "
165:                            + e.toString());
166:                }
167:                //
168:                // test 6
169:                //
170:                mediaSegment1 = new MediaSegment();
171:                mediaSegment1.setContent(EMBStaticHelper
172:                        .createRandomByteArray(1024));
173:                testMediaSegmentArray = new MediaSegment[] { mediaSegment1 };
174:                testByteArray = testInstance.assembleContent(null,
175:                        testMediaSegmentArray);
176:                assertTrue("test 6: ", java.util.Arrays.equals(testByteArray,
177:                        mediaSegment1.getContent()));
178:
179:                succeed();
180:            }
181:
182:            /**
183:             * <pre>
184:             * 
185:             *  
186:             *   
187:             *    Testcase Name: disassembleContent(URL mediaLocation, byte[] mediaContent)
188:             *    Testcase Number: EMB021
189:             *    
190:             *    setup:
191:             *    
192:             *    test procedure:
193:             *    1.call disassembleContent with null as mediaContent and null as location
194:             *      expected result: NullPointerException
195:             *    
196:             *    2.create random content byte array
197:             *      call disassembleContent with the random media content created and null as location
198:             *      expected result: 1 element segment array containing content equal to random content and null childLocation
199:             *    
200:             *   
201:             *  
202:             * </pre>
203:             */
204:            public void testEMB021() throws MediaException {
205:                //
206:                // test 1
207:                //
208:                MediaFormat testInstance = createMediaFormat();
209:                try {
210:                    testInstance.disassembleContent(null, null);
211:                    fail("test 1: Should throw a NullPointerException");
212:                } catch (NullPointerException e) {
213:                    testTrace("test 1 passed");
214:                } catch (Exception e) {
215:                    fail("test 1: Should throw a NullPointerException but threw "
216:                            + e.toString());
217:                }
218:                //
219:                // test 2
220:                //
221:                testInstance = createMediaFormat();
222:                byte[] testArray = EMBStaticHelper.createRandomByteArray(2048);
223:                MediaSegment[] testSegment = testInstance.disassembleContent(
224:                        null, testArray);
225:                assertEquals("test 2: ", 1, testSegment.length);
226:                assertSame("test 2: ", testArray, testSegment[0].getContent());
227:                assertEquals("test 2: ", null, testSegment[0]
228:                        .getChildLocation());
229:                testTrace("test 2 passed");
230:
231:                succeed();
232:            }
233:
234:            /**
235:             * <pre>
236:             * 
237:             *  
238:             *   
239:             *    Testcase Name: extractHeader(Media media)
240:             *    Testcase Number: EMB022
241:             *    
242:             *    setup:
243:             *    
244:             *    test procedure:
245:             *    1.call extractHeader(null)
246:             *      expected result: NullPointerException
247:             *   
248:             *    2.create random content, call extractHeader with input stream
249:             *      expected result: instance of GenericMediaHeader
250:             *    
251:             *   
252:             *  
253:             * </pre>
254:             */
255:            public void testEMB022() throws MediaException, IOException {
256:                //
257:                // test 1
258:                //
259:                MediaFormat testInstance = createMediaFormat();
260:                try {
261:                    MediaHeader testTemp = testInstance.extractHeader(null);
262:                    fail("test 1: Should throw a NullPointerException");
263:                } catch (NullPointerException e) {
264:                    testTrace("test 1 passed");
265:                } catch (Exception e) {
266:                    fail("test 1: Should throw a NullPointerException but threw "
267:                            + e.toString());
268:                }
269:                //
270:                // test 2
271:                //
272:                testInstance = createMediaFormat();
273:                byte[] testByteArray = EMBStaticHelper
274:                        .createRandomByteArray(1024);
275:                InputStream in = new ByteArrayInputStream(testByteArray);
276:                MediaHeader header = testInstance.extractHeader(in);
277:                assertTrue("test 2: ",
278:                        header instanceof  javax.emb.GenericMediaHeader);
279:                testTrace("test 2 passed");
280:                in.close();
281:
282:                succeed();
283:            }
284:
285:            /**
286:             * <pre>
287:             * 
288:             *  
289:             *   
290:             *    Testcase Name: extractProxy(Media media)
291:             *    Testcase Number: EMB023
292:             *    
293:             *    setup:
294:             *    
295:             *    test procedure:
296:             *    1.call extractProxy passing null
297:             *      expected result: NullPointerException
298:             *    
299:             *    2.create random content, call extractProxy with input stream
300:             *      expected result: instance of Media
301:             *    
302:             *   
303:             *  
304:             * </pre>
305:             */
306:            public void testEMB023() throws MediaException, IOException {
307:                //
308:                // test 1
309:                //
310:                MediaFormat testInstance = createMediaFormat();
311:                try {
312:                    Media testTemp = testInstance.extractProxy(null);
313:                    fail("test 1: Should throw a NullPointerException");
314:                } catch (NullPointerException e) {
315:                    testTrace("test 1 passed");
316:                } catch (Exception e) {
317:                    fail("test 1: Should throw a NullPointerException but threw "
318:                            + e.toString());
319:                }
320:                //
321:                // test 2
322:                //
323:                testInstance = createMediaFormat();
324:                byte[] testByteArray = EMBStaticHelper
325:                        .createRandomByteArray(1024);
326:                InputStream in = new ByteArrayInputStream(testByteArray);
327:                Media mediaProxy = testInstance.extractProxy(in);
328:                assertNotNull("test 2: proxy is null", mediaProxy);
329:                assertTrue("test 2: ", mediaProxy instanceof  javax.emb.Media);
330:                testTrace("test 2 passed");
331:                in.close();
332:
333:                succeed();
334:            }
335:
336:            /**
337:             * <pre>
338:             * 
339:             *  
340:             *   
341:             *    Testcase Name: getDefaultMimeType()
342:             *    Testcase Number: EMB024
343:             *    
344:             *    setup:
345:             *    
346:             *    test procedure: 
347:             *    1.call getDefaultMimeType
348:             *      expected result: Media.MIME_TYPE_UNKNOWN	
349:             *    
350:             *   
351:             *  
352:             * </pre>
353:             */
354:            public void testEMB024() {
355:                //
356:                // test 1
357:                //
358:                MediaFormat testInstance = createMediaFormat();
359:                assertSame("test 1: ", Media.MIME_TYPE_UNKNOWN, testInstance
360:                        .getDefaultMimeType());
361:                testTrace("test 1 passed");
362:                succeed();
363:            }
364:
365:            /**
366:             * <pre>
367:             * 
368:             *  
369:             *   
370:             *    Testcase Name: isEmbedded()
371:             *    Testcase Number: EMB025
372:             *    
373:             *    setup:
374:             *    
375:             *    test procedure: 
376:             *    1.call isEmbedded
377:             *      expected result: true
378:             *    
379:             *   
380:             *  
381:             * </pre>
382:             */
383:            public void testEMB025() {
384:                //
385:                // test 1
386:                //
387:                MediaFormat testInstance = createMediaFormat();
388:                assertTrue("test 1: ", testInstance.isEmbedded());
389:                testTrace("test 1 passed");
390:                succeed();
391:            }
392:
393:            /**
394:             * <pre>
395:             * 
396:             *  
397:             *   
398:             *    Testcase Name: isStreamingDesirable()
399:             *    Testcase Number: EMB026
400:             *    
401:             *    setup:
402:             *    
403:             *    test procedure:
404:             *    1.call isStreamingDesirable
405:             *      expected result: false
406:             *    
407:             *   
408:             *  
409:             * </pre>
410:             */
411:            public void testEMB026() {
412:                //
413:                // test 1
414:                //
415:                MediaFormat testInstance = createMediaFormat();
416:                assertTrue("test 1: ", !testInstance.isStreamingDesirable());
417:                testTrace("test 1 passed");
418:                succeed();
419:            }
420:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.