Source Code Cross Referenced for TransactionTimeoutEventTest.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 java.util.TooManyListenersException;
023:
024:        import javax.sip.ClientTransaction;
025:        import javax.sip.RequestEvent;
026:        import javax.sip.ServerTransaction;
027:        import javax.sip.SipException;
028:        import javax.sip.Timeout;
029:        import javax.sip.TimeoutEvent;
030:        import javax.sip.header.ContactHeader;
031:        import javax.sip.header.ToHeader;
032:        import javax.sip.message.Request;
033:        import javax.sip.message.Response;
034:
035:        import org.apache.log4j.Logger;
036:
037:        import test.tck.TckInternalError;
038:        import test.tck.TiUnexpectedError;
039:
040:        /**
041:         * Timeout test for invite client transactions -- test to see if an timeout
042:         * event is delivered to the listener if the RI refuses to send OK to the INVITE
043:         * Client Tx.
044:         * 
045:         * @author M. Ranganathan
046:         */
047:
048:        public class TransactionTimeoutEventTest extends MessageFlowHarness {
049:            private static Logger logger = Logger
050:                    .getLogger(InviteClientTransactionsStateMachineTest.class);
051:
052:            public TransactionTimeoutEventTest(String name) {
053:                super (name, false); // disable auto-dialog for the RI, else ACKs get
054:                // filtered out
055:            }
056:
057:            // ==================== tests ==============================
058:
059:            /**
060:             * Test if the tx timeout is delivered.
061:             */
062:            public void testClientTransactionTimeout() {
063:                try {
064:                    Request invite = createTiInviteRequest(null, null, null);
065:                    ClientTransaction tran = null;
066:                    try {
067:                        eventCollector.collectRequestEvent(riSipProvider);
068:
069:                        tran = tiSipProvider.getNewClientTransaction(invite);
070:                        tran.sendRequest();
071:                    } catch (SipException ex) {
072:                        throw new TiUnexpectedError(
073:                                "A SipExceptionOccurred while trying to send request!",
074:                                ex);
075:                    } catch (TooManyListenersException ex) {
076:                        throw new TckInternalError(
077:                                "Failed to regiest a SipListener with an RI SipProvider",
078:                                ex);
079:                    }
080:                    waitForMessage();
081:                    RequestEvent inviteReceivedEvent = eventCollector
082:                            .extractCollectedRequestEvent();
083:                    assertNotNull("RequestEvent", inviteReceivedEvent);
084:                    try {
085:                        eventCollector.collectTimeoutEvent(tiSipProvider);
086:                    } catch (TooManyListenersException ex) {
087:                        throw new TiUnexpectedError(
088:                                "Failed to register a SipListener with TI", ex);
089:                    }
090:                    waitForTimeout();
091:                    TimeoutEvent timeoutEvent = eventCollector
092:                            .extractCollectedTimeoutEvent();
093:                    assertNotNull("Timeout event", timeoutEvent);
094:                    assertTrue("Timeout event type ", timeoutEvent.getTimeout()
095:                            .equals(Timeout.TRANSACTION));
096:                } catch (Exception ex) {
097:                    logger.error("unexpected exception ", ex);
098:                    ex.printStackTrace();
099:                    fail("unexpected exception");
100:                }
101:            }
102:
103:            public void testServerTransactionForTimeout() {
104:                try {
105:                    Request invite = createRiInviteRequest(null, null, null);
106:                    ClientTransaction tran = null;
107:                    try {
108:                        eventCollector.collectRequestEvent(tiSipProvider);
109:                        tran = riSipProvider.getNewClientTransaction(invite);
110:                        tran.sendRequest();
111:                    } catch (SipException ex) {
112:                        throw new TiUnexpectedError(
113:                                "A SipExceptionOccurred while trying to send request!",
114:                                ex);
115:                    } catch (TooManyListenersException ex) {
116:                        throw new TckInternalError(
117:                                "Failed to regiest a SipListener with an RI SipProvider",
118:                                ex);
119:                    }
120:                    waitForMessage();
121:                    RequestEvent inviteReceivedEvent = eventCollector
122:                            .extractCollectedRequestEvent();
123:                    assertNotNull("RequestEvent not seen at TI",
124:                            inviteReceivedEvent);
125:                    assertTrue("Server Transaction MUST be null",
126:                            inviteReceivedEvent.getServerTransaction() == null);
127:                    ServerTransaction st = tiSipProvider
128:                            .getNewServerTransaction(inviteReceivedEvent
129:                                    .getRequest());
130:                    Response response = tiMessageFactory.createResponse(
131:                            Response.OK, inviteReceivedEvent.getRequest());
132:                    ToHeader toHeader = (ToHeader) response
133:                            .getHeader(ToHeader.NAME);
134:                    toHeader.setTag("123456");
135:                    ContactHeader contact = super .createTiContact();
136:                    response.setHeader(contact);
137:                    st.sendResponse(response);
138:
139:                    eventCollector.collectTimeoutEvent(tiSipProvider);
140:                    waitForTimeout();
141:                    TimeoutEvent timeoutEvent = eventCollector
142:                            .extractCollectedTimeoutEvent();
143:                    assertNotNull("Timeout event", timeoutEvent);
144:                    assertTrue("Timeout event type must be TRANSACTION ",
145:                            timeoutEvent.getTimeout().equals(
146:                                    Timeout.TRANSACTION));
147:
148:                } catch (Exception ex) {
149:                    logger.error("unexpected exception ", ex);
150:                    ex.printStackTrace();
151:                    fail("unexpected exception");
152:                }
153:            }
154:
155:            public void testServerTransactionForRetransmissionAlerts() {
156:                try {
157:                    Request invite = createRiInviteRequest(null, null, null);
158:                    ClientTransaction tran = null;
159:                    tiSipProvider.setAutomaticDialogSupportEnabled(false);
160:                    try {
161:                        eventCollector.collectRequestEvent(tiSipProvider);
162:                        tran = riSipProvider.getNewClientTransaction(invite);
163:                        tran.sendRequest();
164:                    } catch (SipException ex) {
165:                        throw new TiUnexpectedError(
166:                                "A SipExceptionOccurred while trying to send request!",
167:                                ex);
168:                    } catch (TooManyListenersException ex) {
169:                        throw new TckInternalError(
170:                                "Failed to regiest a SipListener with an RI SipProvider",
171:                                ex);
172:                    }
173:                    waitForMessage();
174:                    RequestEvent inviteReceivedEvent = eventCollector
175:                            .extractCollectedRequestEvent();
176:                    assertNotNull("RequestEvent not seen at TI",
177:                            inviteReceivedEvent);
178:                    assertTrue("Server Transaction MUST be null",
179:                            inviteReceivedEvent.getServerTransaction() == null);
180:                    ServerTransaction st = tiSipProvider
181:                            .getNewServerTransaction(inviteReceivedEvent
182:                                    .getRequest());
183:                    Response response = tiMessageFactory.createResponse(
184:                            Response.OK, inviteReceivedEvent.getRequest());
185:                    ToHeader toHeader = (ToHeader) response
186:                            .getHeader(ToHeader.NAME);
187:                    toHeader.setTag("1234567");
188:                    ContactHeader contact = super .createTiContact();
189:                    response.setHeader(contact);
190:                    st.enableRetransmissionAlerts();
191:                    st.sendResponse(response);
192:                    eventCollector.collectTimeoutEvent(tiSipProvider);
193:                    waitForTimeout();
194:                    TimeoutEvent timeoutEvent = eventCollector
195:                            .extractCollectedTimeoutEvent();
196:                    assertNotNull("Timeout event not found ", timeoutEvent);
197:                    assertTrue("Timeout event type must be retransmit ",
198:                            timeoutEvent.getTimeout()
199:                                    .equals(Timeout.RETRANSMIT));
200:
201:                } catch (Exception ex) {
202:                    logger.error("unexpected exception ", ex);
203:                    ex.printStackTrace();
204:                    fail("unexpected exception");
205:                }
206:            }
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.