FileDocCategorySizeDatePackage
TestSMSOpenClose.javaAPI DocphoneME MR2 API (J2ME)3808Wed May 02 18:00:32 BST 2007com.sun.midp.io.j2me.sms

TestSMSOpenClose

public class TestSMSOpenClose extends com.sun.midp.i3test.TestCase implements Runnable
Tests if an MMS connection can simply be open and closed without sending or receiving any messages.

Fields Summary
private final String
TEST_NAME
The fully qualified name of this test.
private final String
SMS_CLIENT_DEVICE_ID
The device ID ("phone number") of the recipient.
private final int
SMS_CLIENT_PORT
The application ID of the recipient.
private final String
SMS_CLIENT_ADDRESS
The SMS client address.
private javax.wireless.messaging.MessageConnection
con
The SMS connection.
private boolean
passed
Test passed/failed flag.
Constructors Summary
Methods Summary
voidcleanUp()
Provide clean-up services, following the run of this test.

        closeConnection();
    
private voidcloseConnection()
Close the SMS connection.

        try {
            con.close();
        } catch (IOException ioe) {
            // Fail silently.
        } catch (Exception e) {
            // Fail silently.
        }
    
private voidcreateClientConnection(java.lang.String clientAddress)
Create and open an SMS connection.

param
clientAddress The SMS address of the client.


        con = (MessageConnection)Connector.open(clientAddress);
    
public voidrun()
Simply close the open connection. If successful, this test passes.


        try {

            closeConnection();

            /*
             * Close connection again. This is allowed by the spec
             * and shouldn't cause any exceptions to be thrown.
             */ 
            closeConnection();

            passed = true;
            assertTrue("This indicates we passed.", passed);

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
        }
    
public voidrunTests()
Main entry point.


        setUp();

        declare(TEST_NAME);

        run();

        cleanUp();
    
voidsetUp()
Set up the physical connection.



              
      

        try {
            createClientConnection(SMS_CLIENT_ADDRESS);
        } catch (IOException ioe) {
            System.out.println(TEST_NAME + " set-up failed:");
            ioe.printStackTrace();
        }