Source Code Cross Referenced for TestCSeqHeader.java in  » 6.0-JDK-Modules » j2me » javax » microedition » sip » 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 » 6.0 JDK Modules » j2me » javax.microedition.sip 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package javax.microedition.sip;
028:
029:        import com.sun.midp.i3test.TestCase;
030:
031:        import javax.microedition.io.Connector;
032:        import java.io.IOException;
033:
034:        /**
035:         * RFC3261, p. 38; BNF: p. 229
036:         *
037:         * CSeq = "CSeq" HCOLON 1*DIGIT LWS Method
038:         *
039:         * The CSeq header field serves as a way to identify and order
040:         * transactions.  It consists of a sequence number and a method.  The
041:         * method MUST match that of the request.  For non-REGISTER requests
042:         * outside of a dialog, the sequence number value is arbitrary.  The
043:         * sequence number value MUST be expressible as a 32-bit unsigned
044:         * integer and MUST be less than 2**31.  As long as it follows the above
045:         * guidelines, a client may use any mechanism it would like to select
046:         * CSeq header field values.
047:         *
048:         * Section 12.2.1.1 discusses construction of the CSeq for requests
049:         * within a dialog.
050:         *
051:         * Example:
052:         *
053:         *    CSeq: 4711 INVITE
054:         *
055:         */
056:
057:        public class TestCSeqHeader extends SipHeaderBaseTest {
058:
059:            /** A name of the header that will be tested */
060:            private final String headerName = "CSeq";
061:
062:            /**
063:             * Body of the test 1.
064:             *
065:             * Test for CSeq header field: setName()/getName().
066:             */
067:            void Test1() {
068:                // DEBUG:        System.out.println("");
069:                // DEBUG:        System.out.println("*** Test1 started ***");
070:
071:                SipHeader sh;
072:
073:                // Test the constructor.
074:                /*
075:                try {
076:                    sh = new SipHeader(headerName, "Invalid INVITE");
077:                    fail("Constructor: IAE was not thrown!");
078:                } catch (IllegalArgumentException iae) {
079:                }
080:                 */
081:
082:                sh = createSipHeader(headerName, "4711 INVITE");
083:
084:                if (sh == null) {
085:                    return;
086:                }
087:
088:                // Testing getName()...
089:                String ret_name = sh.getName();
090:                assertTrue("Invalid header value: " + ret_name, ret_name
091:                        .equals(headerName));
092:
093:                // Testing setName()...
094:                try {
095:                    sh.setName(headerName);
096:                } catch (java.lang.IllegalArgumentException e) {
097:                    fail("setName(" + headerName + ") failed (IAE): " + e);
098:                } catch (Throwable e) {
099:                    fail("setName(" + headerName + ") failed: " + e);
100:                }
101:            }
102:
103:            /**
104:             * Body of the test 2.
105:             *
106:             * Test for CSeq header field: getValue()/getHeaderValue().
107:             */
108:            void Test2() {
109:                String val;
110:                String headerValue = "4711 INVITE";
111:
112:                // DEBUG:        System.out.println("");
113:                // DEBUG:        System.out.println("*** Test2 started ***");
114:
115:                SipHeader sh = createSipHeader(headerName, headerValue);
116:
117:                if (sh != null) {
118:                    val = sh.getValue();
119:                    assertTrue("getValue() returned invalid value: '" + val
120:                            + "'", val.equals(headerValue));
121:
122:                    val = sh.getHeaderValue();
123:                    assertTrue("(1) getHeaderValue() returned invalid "
124:                            + "value: '" + val + "'", val.equals(headerValue));
125:
126:                    // Test if the value can be changed.
127:                    headerValue = "12345 REGISTER";
128:                    sh.setValue(headerValue);
129:
130:                    val = sh.getHeaderValue();
131:                    assertTrue("(2) getHeaderValue() returned invalid "
132:                            + "value: '" + val + "'", val.equals(headerValue));
133:                }
134:            }
135:
136:            /**
137:             * Body of the test 4.
138:             *
139:             * Test for CSeq header field: getParameterNames()/getParameter().
140:             */
141:            void Test4() {
142:                // DEBUG:        System.out.println("");
143:                // DEBUG:        System.out.println("*** Test4 started ***");
144:
145:                SipHeader sh = createSipHeader(headerName, "4711 INVITE");
146:
147:                if (sh == null) {
148:                    return;
149:                }
150:
151:                // Testing getParameterNames()...
152:                String[] paramList = sh.getParameterNames();
153:
154:                if (paramList != null) {
155:                    fail("getParameterNames() should return null!");
156:                }
157:
158:                // Testing getParameter()...
159:                String paramVal = sh.getParameter("ttl");
160:                assertTrue("getParameter() returned '" + paramVal
161:                        + "' for the parameter 'ttl' that doesn't exist.",
162:                        paramVal == null);
163:            }
164:
165:            /**
166:             * Body of the test 5.
167:             *
168:             * Test for CSeq header field: setParameter()/removeParameter().
169:             */
170:            void Test5() {
171:                // DEBUG:        System.out.println("");
172:                // DEBUG:        System.out.println("*** Test5 started ***");
173:
174:                SipHeader sh = createSipHeader(headerName, "4711 INVITE");
175:
176:                if (sh == null) {
177:                    return;
178:                }
179:
180:                // Testing setParameter()...
181:                try {
182:                    sh.setParameter("test", "192.0.0.1");
183:                } catch (Exception e) {
184:                    fail(e + " was thrown.");
185:                }
186:
187:                try {
188:                    sh.removeParameter("test");
189:                } catch (Exception e) {
190:                    fail("removeParameter(): " + e + " was thrown!");
191:                }
192:
193:                assertTrue(true); // to avoid error message from the test framework
194:            }
195:
196:            /**
197:             * Run the tests
198:             */
199:            public void runTests() {
200:                declare("setName()/getName()");
201:                Test1();
202:
203:                declare("getValue()/getHeaderValue()");
204:                Test2();
205:
206:                declare("setValue()");
207:                testSetValue(headerName, "4711 INVITE");
208:
209:                declare("getParameterNames()/getParameter()");
210:                Test4();
211:
212:                declare("setParameter()/removeParameter()");
213:                Test5();
214:
215:                declare("toString()");
216:                testToString(headerName, "4711 INVITE");
217:            }
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.