Source Code Cross Referenced for MpegAudioFormatTest.java in  » J2EE » JOnAS-4.8.6 » com » ibm » emb » test » mfb » 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.mfb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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