Source Code Cross Referenced for ClientTransactionTest.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » test » tck » msgflow » 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 » Java Advanced Imaging » test.tck.msgflow 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Conditions Of Use 
003:         * 
004:         * This software was developed by employees of the National Institute of
005:         * Standards and Technology (NIST), and others. 
006:         * This software is has been contributed to the public domain. 
007:         * As a result, a formal license is not needed to use the software.
008:         * 
009:         * This software is provided "AS IS."  
010:         * NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
011:         * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
012:         * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
013:         * AND DATA ACCURACY.  NIST does not warrant or make any representations
014:         * regarding the use of the software or the results thereof, including but
015:         * not limited to the correctness, accuracy, reliability or usefulness of
016:         * the software.
017:         * 
018:         * 
019:         */
020:        package test.tck.msgflow;
021:
022:        import junit.framework.*;
023:
024:        import javax.sip.*;
025:        import javax.sip.message.*;
026:        import javax.sip.header.*;
027:        import java.util.*;
028:        import java.text.*;
029:        import test.tck.*;
030:
031:        /**
032:         * <p>Title: TCK</p>
033:         * <p>Description: JAIN SIP 1.1 Technology Compatibility Kit</p>
034:         * @author Emil Ivov
035:         *         Network Research Team, Louis Pasteur University, Strasbourg, France
036:         * This  code is in the public domain.
037:         * @version 1.0
038:         */
039:
040:        public class ClientTransactionTest extends MessageFlowHarness {
041:
042:            public ClientTransactionTest(String name) {
043:                super (name);
044:            }
045:
046:            //==================== tests ==============================
047:
048:            /**
049:             * Creates an invite request using the Tested Implementation and then
050:             * tests creating a cancel for the same invite request.
051:             */
052:            public void testCreateCancel() {
053:                try {
054:                    Request invite = createTiInviteRequest(null, null, null);
055:                    ClientTransaction tran = null;
056:                    try {
057:                        tran = tiSipProvider.getNewClientTransaction(invite);
058:                    } catch (TransactionUnavailableException exc) {
059:                        throw new TiUnexpectedError(
060:                                "A TransactionUnavailableException was thrown while trying to "
061:                                        + "create a new client transaction",
062:                                exc);
063:                    }
064:
065:                    // see if creating a dialog matters
066:                    tran.getDialog();
067:
068:                    Request cancel = null;
069:                    try {
070:                        cancel = tran.createCancel();
071:                    } catch (SipException ex) {
072:                        ex.printStackTrace();
073:                        fail("Failed to create cancel request!");
074:                    }
075:                    assertEquals(
076:                            "The created request did not have a CANCEL method.",
077:                            cancel.getMethod(), Request.CANCEL);
078:                    assertEquals(
079:                            "Request-URIs of the original and the cancel request do not match",
080:                            cancel.getRequestURI(), invite.getRequestURI());
081:                    assertEquals(
082:                            "Call-IDs of the original and the cancel request do not match",
083:                            cancel.getHeader(CallIdHeader.NAME), invite
084:                                    .getHeader(CallIdHeader.NAME));
085:                    assertEquals(
086:                            "ToHeaders of the original and the cancel request do not match",
087:                            cancel.getHeader(ToHeader.NAME), invite
088:                                    .getHeader(ToHeader.NAME));
089:                    assertTrue(
090:                            "The CSeqHeader's sequence number of the original and "
091:                                    + "the cancel request do not match",
092:                            ((CSeqHeader) cancel.getHeader(CSeqHeader.NAME))
093:                                    .getSeqNumber() == ((CSeqHeader) invite
094:                                    .getHeader(CSeqHeader.NAME)).getSeqNumber());
095:                    assertEquals(
096:                            "The CSeqHeader's method of the cancel request was not CANCEL",
097:                            ((CSeqHeader) cancel.getHeader(CSeqHeader.NAME))
098:                                    .getMethod(), Request.CANCEL);
099:                    assertTrue("There was no ViaHeader in the cancel request",
100:                            cancel.getHeaders(ViaHeader.NAME).hasNext());
101:                    Iterator cancelVias = cancel.getHeaders(ViaHeader.NAME);
102:                    ViaHeader cancelVia = ((ViaHeader) cancelVias.next());
103:                    ViaHeader inviteVia = ((ViaHeader) invite.getHeaders(
104:                            ViaHeader.NAME).next());
105:                    assertEquals(
106:                            "ViaHeaders of the original and the cancel request do not match!",
107:                            cancelVia, inviteVia);
108:                    assertFalse("Cancel request had more than one ViaHeader.",
109:                            cancelVias.hasNext());
110:
111:                    assertEquals("To tags must match", ((ToHeader) invite
112:                            .getHeader("to")).getTag(), ((ToHeader) cancel
113:                            .getHeader("to")).getTag());
114:
115:                    assertEquals("From tags must match", ((FromHeader) invite
116:                            .getHeader("from")).getTag(), ((FromHeader) cancel
117:                            .getHeader("from")).getTag());
118:
119:                    assertEquals("Max-Forwards must match", invite
120:                            .getHeader(MaxForwardsHeader.NAME), cancel
121:                            .getHeader(MaxForwardsHeader.NAME));
122:
123:                } catch (Throwable exc) {
124:                    exc.printStackTrace();
125:                    fail(exc.getClass().getName() + ": " + exc.getMessage());
126:                }
127:
128:                assertTrue(new Exception().getStackTrace()[0].toString(), true);
129:
130:            }
131:
132:            /**
133:             * Tests sending a request from a ClientTransaction.
134:             */
135:            public void testSendRequest() {
136:                try {
137:                    Request invite = createTiInviteRequest(null, null, null);
138:                    RequestEvent receivedRequestEvent = null;
139:                    ClientTransaction tran = null;
140:                    try {
141:                        tran = tiSipProvider.getNewClientTransaction(invite);
142:                        eventCollector.collectRequestEvent(riSipProvider);
143:                        tran.sendRequest();
144:                        waitForMessage();
145:                        receivedRequestEvent = eventCollector
146:                                .extractCollectedRequestEvent();
147:                        assertNotNull(
148:                                "The sent request was not received by the RI!",
149:                                receivedRequestEvent);
150:                        assertNotNull(
151:                                "The sent request was not received by the RI!",
152:                                receivedRequestEvent.getRequest());
153:                    } catch (TransactionUnavailableException exc) {
154:                        throw new TiUnexpectedError(
155:                                "A TransactionUnavailableException was thrown while trying to "
156:                                        + "create a new client transaction",
157:                                exc);
158:                    } catch (SipException exc) {
159:                        exc.printStackTrace();
160:                        fail("The SipException was thrown while trying to send the request.");
161:                    } catch (TooManyListenersException exc) {
162:                        throw new TckInternalError(
163:                                "A  TooManyListenersException was thrown while trying "
164:                                        + "to add a SipListener to an RI SipProvider",
165:                                exc);
166:                    }
167:                } catch (Throwable exc) {
168:                    exc.printStackTrace();
169:                    fail(exc.getClass().getName() + ": " + exc.getMessage());
170:                }
171:
172:                assertTrue(new Exception().getStackTrace()[0].toString(), true);
173:
174:            }
175:
176:            //mranga: removed testCreateAck -- should not test for deprecated functionality
177:            // in the TCK.
178:
179:            //==================== end of tests
180:
181:            //====== STATIC JUNIT ==========
182:            public static Test suite() {
183:                return new TestSuite(ClientTransactionTest.class);
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.