Source Code Cross Referenced for MediaSegmentTest.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:        // java stuff
004:        import java.net.MalformedURLException;
005:        import java.net.URL;
006:
007:        import javax.emb.MediaException;
008:        import javax.emb.MediaSegment;
009:
010:        import com.ibm.emb.junit.EMBStaticHelper;
011:        import com.ibm.emb.junit.EMBTestCaseBase;
012:        import com.ibm.emb.junit.EMBTestRunner;
013:
014:        /**
015:         * <pre>
016:         * 
017:         *  Line Item: MFB API 
018:         *  Subcategory 1: javax.emb
019:         *  Subcategory 2: MediaSegment
020:         *  
021:         * </pre>
022:         */
023:        public class MediaSegmentTest extends EMBTestCaseBase {
024:
025:            public MediaSegmentTest(String name) throws MediaException {
026:                super (name);
027:            }
028:
029:            public static void main(String args[]) {
030:                EMBTestRunner.run(MediaSegmentTest.class);
031:            }
032:
033:            /**
034:             * <pre>
035:             * 
036:             *  Testcase Name: getContent()
037:             *  Testcase Number: EMB033
038:             *  
039:             *  setup:
040:             *  
041:             *  test procedure:
042:             *  1.create random content byte array and pass into setContent()
043:             *    call getContent()
044:             *    expected result: content should match original byte array	
045:             *  
046:             *  2.create new media segment and call getContent
047:             *    expected result: empty byte array
048:             *  
049:             * </pre>
050:             */
051:            public void testEMB033() {
052:                //
053:                // test 1
054:                // 
055:                MediaSegment testInstance = new MediaSegment();
056:                byte[] testArray = EMBStaticHelper
057:                        .createRandomByteArray(EMBStaticHelper
058:                                .randomInt(0, 255));
059:                testInstance.setContent(testArray);
060:                assertSame("test 1: ", testArray, testInstance.getContent());
061:                testTrace("test 1 passed");
062:                //
063:                // test 2
064:                //
065:                testInstance = new MediaSegment();
066:                assertEquals("test 2: content is not empty", 0, testInstance
067:                        .getContent().length);
068:                testTrace("test 2 passed");
069:
070:                succeed();
071:            }
072:
073:            /**
074:             * <pre>
075:             * 
076:             *  Testcase Name: getChildLocation()
077:             *  Testcase Number: EMB034
078:             *  
079:             *  setup:
080:             *  
081:             *  test procedure:
082:             *  1.call setChildLoation(null), call getChildLocation()
083:             *    expected result: null
084:             *  
085:             *  2.create random URL with &quot;file&quot; protocol, call setChildLocation with random URL
086:             *    call getChildLocation()
087:             *    expected result: return same URL
088:             *      
089:             * </pre>
090:             */
091:            public void testEMB034() throws MediaException,
092:                    MalformedURLException {
093:                //
094:                // test 1
095:                //
096:                MediaSegment testInstance = new MediaSegment();
097:                testInstance.setChildLocation(null);
098:                assertNull("test 1: ", testInstance.getChildLocation());
099:                testTrace("test 1 passed");
100:                // 
101:                // test 2
102:                //
103:                testInstance = new MediaSegment();
104:                URL testURL = new URL("file", "localhost", "/testfile");
105:                testInstance.setChildLocation(testURL);
106:                assertTrue("test 2: ", testURL.equals(testInstance
107:                        .getChildLocation()));
108:                testTrace("test 2 passed");
109:
110:                succeed();
111:
112:            }
113:
114:            /**
115:             * <pre>
116:             * 
117:             *  Testcase Name: setContent(content)
118:             *  Testcase Number: EMB035
119:             *  
120:             *  setup: 
121:             *  
122:             *  test procedure
123:             *  1.call setContent with null
124:             *    expected result: NullPointerException
125:             *  
126:             *  2.call setContent with random byte array
127:             *    call getContent() 
128:             *    expected result: content equal to the random one passed in
129:             *  
130:             * </pre>
131:             */
132:            public void testEMB035() throws MediaException {
133:                //
134:                // test 1
135:                //
136:                MediaSegment testInstance = new MediaSegment();
137:                try {
138:                    testInstance.setContent(null);
139:                    fail("test 1: Should throw a NullPointerException");
140:                } catch (NullPointerException e) {
141:                    testTrace("test 1 passed");
142:                } catch (Exception e) {
143:                    fail("test 1: Should throw a NullPointerException but threw "
144:                            + e.toString());
145:                }
146:                //
147:                // test 2
148:                //
149:                testInstance = new MediaSegment();
150:                byte[] randomArray = EMBStaticHelper
151:                        .createRandomByteArray(EMBStaticHelper
152:                                .randomInt(0, 255));
153:                testInstance.setContent(randomArray);
154:                assertSame("test 2: ", randomArray, testInstance.getContent());
155:                testTrace("test 2 passed");
156:
157:                succeed();
158:            }
159:
160:            /**
161:             * <pre>
162:             * 
163:             *  Testcase Name: setChildLocation(URL childLocation)
164:             *  Testcase Number: EMB036
165:             *  
166:             *  setup:
167:             *  
168:             *  test procedure:
169:             *  1.call setChildLocation with null
170:             *    expected result: NullPointerException
171:             *  
172:             *  2.call setChildLocation with URL pointing to local machine and protocol type &quot;file&quot;
173:             *    call getChildLocation() 
174:             *    expected result: content equal to the URL passed before
175:             *  
176:             * </pre>
177:             */
178:            public void testEMB038() throws MediaException,
179:                    MalformedURLException {
180:                //
181:                // test 1
182:                //
183:                MediaSegment testInstance = new MediaSegment();
184:                try {
185:                    testInstance.setChildLocation(null);
186:                    testTrace("test 1 passed");
187:                } catch (NullPointerException e) {
188:                    fail("test 1: Should not throw a NullPointerException");
189:                } catch (Exception e) {
190:                    fail("test 1: Should not throw any exception");
191:                }
192:                //
193:                // test 2
194:                //
195:                testInstance = new MediaSegment();
196:                URL testURL = new URL("file", "localhost", "/testfile");
197:                testInstance.setChildLocation(testURL);
198:                assertEquals("test 1: ", testURL.toString(), testInstance
199:                        .getChildLocation().toString());
200:                testTrace("test 2 passed");
201:
202:                succeed();
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.