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