Source Code Cross Referenced for BmpFormatTest.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.BmpFormat;
015:        import org.objectweb.jonas.emb.mfb.formats.image.BmpHeader;
016:
017:        import com.ibm.emb.junit.EMBTestRunner;
018:
019:        public class BmpFormatTest extends EmbeddedMediaFormatTest {
020:
021:            /**
022:             * constructor
023:             */
024:            public BmpFormatTest(String name) throws MediaException {
025:                super (name);
026:            }
027:
028:            /**
029:             * main method
030:             */
031:            public static void main(String args[]) {
032:                EMBTestRunner.run(BmpFormatTest.class);
033:            }
034:
035:            /**
036:             * creates an instance of BmpFormat with the given Parameters used in super
037:             * class of BmpFormatTest
038:             */
039:            public MediaFormat createMediaFormat() {
040:                return new BmpFormat();
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: TEMB0056SBA  
060:             *      
061:             *      Test 1:
062:             *      call extractHeader passing a bmp media
063:             *      --&gt; check result to be an instance of com.ibm.emb.meb.BmpHeader
064:             *      
065:             * </pre>
066:             */
067:            public void testTEMB0056SBA() throws MediaException, IOException {
068:
069:                //
070:                // test 1
071:                //
072:
073:                // register media format
074:                MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
075:                formatRegistry.rebind("bmp", new BmpFormat());
076:
077:                // name of a bmp sample
078:                String mediaBmp = embTestConfig.getBmpPictureName1();
079:
080:                // full path of the bmp sample
081:                String mediaBmpFullPath = embTestConfig.getMediaDir()
082:                        + File.separator + mediaBmp;
083:
084:                // creates media bean
085:                File mediaBmpFile = new File(mediaBmpFullPath);
086:                MediaBean mediaBean = new MediaBean(mediaBmpFile, "bmp");
087:
088:                // creates bmp format
089:                BmpFormat bmpFormat = new BmpFormat();
090:
091:                // creates bmpHeader
092:                InputStream mediaBmpInputStream = new FileInputStream(
093:                        mediaBmpFile);
094:                BmpHeader bmpHeader = (BmpHeader) bmpFormat
095:                        .extractHeader(mediaBmpInputStream);
096:                mediaBmpInputStream.close();
097:
098:                // test
099:                assertTrue("test 1", bmpHeader instanceof  BmpHeader);
100:
101:                testTrace("test 1 passed");
102:
103:                succeed();
104:
105:            }
106:
107:            /**
108:             * <pre>
109:             * 
110:             *      Testcase Name: extractSurrogate(Media)
111:             *      Testcase Number: TEMB0085SBA  
112:             *      
113:             *      Test 1:
114:             *      call extractSurrogate passing a bmp media
115:             *      check result to be an instance of Media
116:             *      access the content of the resulting media ----&gt;  to verify it is accessible
117:             *      check if format of result is an instance of com.ibm.emb.meb.BmpFormat
118:             *      
119:             *      
120:             * </pre>
121:             */
122:            public void testTEMB0085SBA() throws MediaException, IOException {
123:                //
124:                // test 1
125:                //
126:
127:                // register media format
128:                MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
129:                formatRegistry.rebind("bmp", new BmpFormat());
130:
131:                // name of a bmp sample
132:                String mediaBmp = embTestConfig.getBmpPictureName1();
133:
134:                // full path of the bmp sample
135:                String mediaBmpFullPath = embTestConfig.getMediaDir()
136:                        + File.separator + mediaBmp;
137:
138:                // creates media bean
139:                File mediaBmpFile = new File(mediaBmpFullPath);
140:                MediaBean mediaBean = new MediaBean(mediaBmpFile, "bmp");
141:
142:                // creates bmp format
143:                BmpFormat bmpFormat = new BmpFormat();
144:
145:                // error report
146:                logProductError("reported error PEMB0052RMD, invalid bmp header data");
147:
148:                // gets surrogate
149:                InputStream mediaBmpInputStream = new FileInputStream(
150:                        mediaBmpFile);
151:                MediaBean mediaBeanSurrogate = (MediaBean) bmpFormat
152:                        .extractProxy(mediaBmpInputStream);
153:                mediaBmpInputStream.close();
154:
155:                // check access to content and check format
156:                byte[] content = mediaBeanSurrogate.getContent();
157:                byte[] content_ = new byte[content.length];
158:                System.arraycopy(content, 0, content_, 0, content.length);
159:
160:                BmpFormat bmpFormat1 = (BmpFormat) mediaBeanSurrogate
161:                        .getFormat();
162:
163:                assertTrue("test 1", bmpFormat1 instanceof  BmpFormat
164:                        && mediaBeanSurrogate.getMimeType().equals("image/gif"));
165:                testTrace("test 1 passed");
166:
167:                succeed();
168:
169:            }
170:
171:            /**
172:             * <pre>
173:             * 
174:             *      Testcase Name: getDefaultMimeType()
175:             *      Testcase Number: TEMB0058SBA  
176:             *      
177:             *      Test 1:
178:             *      call getDefaultMimeType
179:             *      ---&gt;check if result equals &quot;image/bmp&quot;
180:             *      
181:             *      
182:             * </pre>
183:             */
184:            public void testTEMB0058SBA() throws MediaException {
185:                //
186:                // test 1
187:                //
188:
189:                // creates bmp format
190:                BmpFormat bmpFormat = new BmpFormat();
191:                assertEquals("test 1", "image/bmp", bmpFormat
192:                        .getDefaultMimeType());
193:
194:                testTrace("test 1 passed");
195:
196:                succeed();
197:
198:            }
199:
200:            /**
201:             * <pre>
202:             * 
203:             *      Testcase Name: isStreamingDesirable()
204:             *      Testcase Number: TEMB0060SBA  
205:             *      
206:             *      Test 1:
207:             *      call isStreamingDesirable
208:             *      ---&gt;check if result is false
209:             *      
210:             *      
211:             * </pre>
212:             */
213:            public void testTEMB0060SBA() throws MediaException {
214:                //
215:                // test 1
216:                //
217:
218:                // creates bmp format
219:                BmpFormat bmpFormat = new BmpFormat();
220:                assertTrue("test 1", !bmpFormat.isStreamingDesirable());
221:
222:                testTrace("test 1 passed");
223:
224:                succeed();
225:
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.