Package javax.microedition.jcrmi

Examples of javax.microedition.jcrmi.JavaCardRMIConnection


    /**
     * Tests exception handling.
     */
    public void testException()
            throws java.io.IOException, CardDeviceException {
        JavaCardRMIConnection con = null;
        Remote1 rem;
        boolean stub_flag = false;
       
        try {
            SlotFactory.init();
        }
        catch (CardDeviceException e) {
            if (e.getMessage().equals("stub")) {
                stub_flag = true;
            } else {
                throw e;
            }
        }
       
        if (!stub_flag) {
            con = (JavaCardRMIConnection)
                new com.sun.midp.io.j2me.jcrmi.Protocol();
            ((com.sun.midp.io.j2me.jcrmi.Protocol)con)
                .openPrim(appletURL, 0, false);
            rem = (Remote1)con.getInitialReference();
            assertNotNull("Initial reference", rem);
           
            try {
                rem.throwException((short)12);
            }
            catch (java.rmi.RemoteException e) {
                assertTrue("proper exception", true);
            }
            catch (Throwable e1) {
                assertTrue("improper exception: " + e1, false);
            }
           
            try {
                rem.throwException((short)22);
            }
            catch (javacard.framework.service.ServiceException e) {
                assertTrue("proper exception", true);
            }
            catch (Throwable e1) {
                assertTrue("improper exception: " + e1, false);
            }
           
            try {
                rem.throwException((short)11);
            }
            catch (java.io.IOException e) {
                assertTrue("proper exception", true);
            }
            catch (Throwable e1) {
                assertTrue("improper exception: " + e1, false);
            }
           
            try {
                rem.throwSubclass((short)11);
            }
            catch (java.io.IOException e) {
                assertTrue("proper exception", true);
            }
            catch (Throwable e1) {
                assertTrue("improper exception: " + e1, false);
            }
           
            con.close();
        } else {
            assertTrue(true);
        }
    }
View Full Code Here

TOP

Related Classes of javax.microedition.jcrmi.JavaCardRMIConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.