FileDocCategorySizeDatePackage
TestMMSOpenClose.javaAPI DocphoneME MR2 API (J2ME)3871Wed May 02 18:00:44 BST 2007com.sun.midp.io.j2me.mms

TestMMSOpenClose

public class TestMMSOpenClose 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
MMS_TO_DEVICE_ID
The device ID ("phone number") of the recipient.
private final String
MMS_TO_APP_ID
The application ID of the recipient.
private final String
MMS_CLIENT_ADDRESS
The MMS client address.
private javax.wireless.messaging.MessageConnection
con
The MMS 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 MMS connection.

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

param
clientAddress The MMS address of the client that will receive the message.


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


        try {

            closeConnection();

            passed = true;
            assertTrue("Indicate that the test 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(MMS_CLIENT_ADDRESS);
        } catch (IOException ioe) {
            System.out.println(TEST_NAME + " set-up failed:");
            ioe.printStackTrace();
        }