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 gov.nist.microedition.sip;
028:
029: import javax.microedition.sip.*;
030: import java.io.OutputStream;
031: import gov.nist.microedition.sip.SipConnectionNotifierImpl;
032: import gov.nist.microedition.sip.SipClientConnectionImpl;
033: import gov.nist.siplite.SipStack;
034: import gov.nist.siplite.message.Request;
035: import gov.nist.siplite.message.Response;
036: import gov.nist.siplite.header.WWWAuthenticateHeader;
037: import gov.nist.siplite.header.AuthenticationHeader;
038: import gov.nist.siplite.stack.ClientTransaction;
039: import gov.nist.siplite.stack.MessageChannel;
040: import gov.nist.siplite.stack.Dialog;
041: import gov.nist.siplite.stack.Transaction;
042: import gov.nist.siplite.stack.SIPServerResponseInterface;
043: import gov.nist.siplite.stack.SIPStackMessageFactory;
044: import gov.nist.siplite.stack.GetSipServerResponse;
045: import gov.nist.siplite.address.Address;
046: import gov.nist.siplite.header.ToHeader;
047: import gov.nist.siplite.header.CallIdHeader;
048: import gov.nist.siplite.header.FromHeader;
049: import gov.nist.siplite.header.ContactHeader;
050: import gov.nist.siplite.header.ExpiresHeader;
051: import gov.nist.siplite.address.URI;
052: import gov.nist.siplite.address.SipURI;
053: import gov.nist.core.ParseException;
054: import javax.microedition.io.*;
055: import com.sun.midp.i3test.TestCase;
056: import java.io.*;
057:
058: /**
059: * Tests for SipConnection class.
060: *
061: */
062: public class TestSipClientInitNotifyReq extends TestCase {
063:
064: /**
065: * Body of the test 1.
066: *
067: * Try to initialization NOTIFY request out of dialog.
068: * @param transport the name of transport protocol
069: */
070: void Test1(String transport) {
071: String method = "NOTIFY";
072: /** Client connection. */
073: SipClientConnection sc = null;
074: try {
075: // Open SIP client connection to the local SIP server
076: sc = (SipClientConnection) Connector
077: .open("sip:sippy.tester@localhost:5060;transport="
078: + transport);
079: } catch (Exception ex) {
080: assertNull("Exception during sc open", sc);
081: ex.printStackTrace();
082: }
083: assertNotNull("sc is null", sc);
084:
085: // Move to INITIALIZED state
086: try {
087: sc.initRequest(method, null);
088: fail("IllegalArgumentException was not caused");
089: } catch (IllegalArgumentException e) {
090: assertTrue("OK", true);
091: } catch (Throwable e) {
092: fail("INITIALIZED " + e + " was caused");
093: }
094:
095: // close connection
096: try {
097: sc.close();
098: } catch (Throwable e) {
099: fail("" + e + " was caused");
100: }
101: }
102:
103: /**
104: * Tests execute
105: *
106: */
107: public void runTests() {
108: String arrProt[] = { "UDP", "TCP" };
109: declare("Initialization NOTIFY request out of dialog");
110: for (int i = 0; i < arrProt.length; i++) {
111: Test1(arrProt[i]);
112: }
113: }
114:
115: }
|