Source Code Cross Referenced for TestSipConnectionNotifier.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 javax.microedition.sip.SipClientConnection;
030:        import gov.nist.microedition.sip.SipClientConnectionImpl;
031:        import javax.microedition.io.Connector;
032:        import java.io.OutputStream;
033:        import java.io.IOException;
034:        import com.sun.midp.i3test.TestCase;
035:
036:        /**
037:         * Tests for SipConnectionNotifier class.
038:         */
039:        public class TestSipConnectionNotifier extends TestCase {
040:
041:            /**
042:             * Body of the test 1.
043:             *
044:             * Try to establish connection with wrong URI format.
045:             */
046:            void Test1() {
047:                SipConnectionNotifier scn = null;
048:                try {
049:                    // try to create SipConnection object with SCTP transport
050:                    scn = (SipConnectionNotifier) Connector
051:                            .open("sip:alice@atlanta.com;transport=sctp");
052:                    fail("IllegalArgumentException wasn't caused");
053:                } catch (SipException e) {
054:                    if (e.getErrorCode() == SipException.TRANSPORT_NOT_SUPPORTED) {
055:                        assertTrue("OK", true);
056:                    } else {
057:                        fail("SipException was caused with wrong parameter");
058:                    }
059:                } catch (Throwable e) {
060:                    fail("" + e + " was caused");
061:                }
062:
063:                try {
064:                    // try to create SipConnection object with wrong URI
065:                    // user part is empty when '@' is present
066:                    scn = (SipConnectionNotifier) Connector
067:                            .open("sip:@www.sun.com");
068:                    fail("IllegalArgumentException wasn't caused");
069:                } catch (java.lang.IllegalArgumentException e) {
070:                    assertTrue("IllegalArgumentException was caused", true);
071:                } catch (Throwable e) {
072:                    fail("" + e + " was caused");
073:                }
074:
075:                try {
076:                    // try to create SipConnection object with wrong URI
077:                    // port format is wrong
078:                    scn = (SipConnectionNotifier) Connector
079:                            .open("sip:user@www.sun.com:abcd");
080:                    fail("IllegalArgumentException wasn't caused");
081:                } catch (java.lang.IllegalArgumentException e) {
082:                    assertTrue("IllegalArgumentException was caused", true);
083:                } catch (Throwable e) {
084:                    fail("" + e + " was caused");
085:                }
086:
087:                try {
088:                    // try to create SipConnection object with wrong URI
089:                    // parameter name is not unique
090:                    scn = (SipConnectionNotifier) Connector
091:                            .open("sip:user@www.sun.com:1234;par1=val1;par1=val1");
092:                    fail("IllegalArgumentException wasn't caused");
093:                } catch (java.lang.IllegalArgumentException e) {
094:                    assertTrue("IllegalArgumentException was caused", true);
095:                } catch (Throwable e) {
096:                    fail("" + e + " was caused");
097:                }
098:            }
099:
100:            /**
101:             * Create a SipConnectionNotifier and get local port and address
102:             */
103:            void Test2() {
104:                SipConnectionNotifier scn = null;
105:                try {
106:                    // Open SIP server connection and listen to port 8888
107:                    scn = (SipConnectionNotifier) Connector.open("sip:8888");
108:                } catch (Exception ex) {
109:                    assertNull("Exception during scn open", scn);
110:                    ex.printStackTrace();
111:                }
112:                assertNotNull("scn is null", scn);
113:
114:                try {
115:                    assertEquals("Local port is incorrect", scn.getLocalPort(),
116:                            8888);
117:                } catch (IOException ioe) {
118:                    fail("IOException in getting local port or address");
119:                }
120:
121:                try {
122:                    scn.close();
123:                } catch (IOException ioe) {
124:                    ioe.printStackTrace();
125:                }
126:            }
127:
128:            /**
129:             * Create a SipConnectionNotifier with "transport=tcp"
130:             */
131:            void Test3() {
132:                SipConnectionNotifier scn = null;
133:                try {
134:                    // Open SIP server connection and listen to port 9999
135:                    scn = (SipConnectionNotifier) Connector
136:                            .open("sip:9999;transport=tcp");
137:                    assertNotNull("scn is null", scn);
138:                    scn.close();
139:                } catch (Exception ex) {
140:                    ex.printStackTrace();
141:                }
142:            }
143:
144:            /**
145:             * Create a SipConnectionNotifier with explicite "transport=udp"
146:             */
147:            void Test4() {
148:                SipConnectionNotifier scn = null;
149:                try {
150:                    // Open SIP server connection and listen to port 4444
151:                    scn = (SipConnectionNotifier) Connector.open("sip:8889");
152:                    assertNotNull("scn is null", scn);
153:                    scn.close();
154:                } catch (Exception ex) {
155:                    ex.printStackTrace();
156:                }
157:            }
158:
159:            /**
160:             * Create a SipConnectionNotifier with explicite "sip:"
161:             */
162:            void Test5() {
163:                SipConnectionNotifier scn = null;
164:                try {
165:                    // Open SIP server connection and listen to port 4444
166:                    scn = (SipConnectionNotifier) Connector.open("sip:");
167:                    assertNotNull("scn is null", scn);
168:                    scn.close();
169:                } catch (Exception ex) {
170:                    ex.printStackTrace();
171:                }
172:            }
173:
174:            /**
175:             * Create a SipConnectionNotifier with explicite "sip:;transport=tcp"
176:             */
177:            void Test6() {
178:                SipConnectionNotifier scn = null;
179:                try {
180:                    // Open SIP server connection and listen to port 4444
181:                    scn = (SipConnectionNotifier) Connector
182:                            .open("sip:;transport=tcp");
183:                    assertNotNull("scn is null", scn);
184:                    scn.close();
185:                } catch (Exception ex) {
186:                    ex.printStackTrace();
187:                }
188:            }
189:
190:            /**
191:             * Tests execute
192:             *
193:             */
194:            public void runTests() {
195:                declare("Wrong URI format");
196:                Test1();
197:                declare("SCN Methods");
198:                Test2();
199:                declare("TCP Transport");
200:                Test3();
201:                declare("UDP Transport");
202:                Test4();
203:                declare("sip:");
204:                Test5();
205:                declare("sip:;transport=tcp");
206:                Test6();
207:            }
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.