harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilya Okomin (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-1591) [classlib][awt]Compatibility: awt.Font.getStringBounds() exception order on Harmony differs from RI
Date Tue, 26 Sep 2006 15:11:50 GMT
[classlib][awt]Compatibility: awt.Font.getStringBounds() exception order on Harmony differs
from RI
---------------------------------------------------------------------------------------------------

                 Key: HARMONY-1591
                 URL: http://issues.apache.org/jira/browse/HARMONY-1591
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Ilya Okomin
            Priority: Minor


Methods awt.Font.getStringBounds() when 'string' source parameter is null throws exceptions
in the order that differs from the RI's one.
Spec keeps silence about any exceptions for these cases.

To check this run next test case:

----------------test.java------------------
import junit.framework.TestCase;

import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.text.CharacterIterator;

public class test extends TestCase {

    public static void main(String[] args) {
        junit.textui.TestRunner.run(test.class);
    }

    public void testcase() {
        Font font = new Font("dialog", Font.PLAIN, 12);
        FontRenderContext cnt = new FontRenderContext(null, false, true);
        try{
            font.getStringBounds((char[]) null, -16, 1, cnt);
            System.out.println("Fail: IndexOutOfBoundsException expected!");
        }catch (Exception e) {
            if (e instanceof IndexOutOfBoundsException) {
                System.out.println("Success: " + e);
            } else {
                System.out.println("Fail: " + e);
            }
        }

        try{
            font.getStringBounds((String) null, -16, 1, cnt);
            System.out.println("Fail: NullPointerException expected!");
        }catch (Exception e) {
            if (e instanceof NullPointerException) {
                System.out.println("Success: " + e);
            } else {
                System.out.println("Fail: " + e);
            }
        }

        try{
            font.getStringBounds((CharacterIterator) null, -16, 1, cnt);
            System.out.println("Fail: NullPointerException expected!");
        }catch (Exception e) {
            if (e instanceof NullPointerException) {
                System.out.println("Success: " + e);
            } else {
                System.out.println("Fail: " + e);
            }
        }

        try{
            font.getStringBounds((String) null, cnt);
            System.out.println("Fail: NullPointerException expected!");
        }catch (Exception e) {
            if (e instanceof NullPointerException) {
                System.out.println("Success: " + e);
            } else {
                System.out.println("Fail: " + e);
            }
        }

    }
}
------------------------------------------------

====== Output RI ======
.Success: java.lang.IndexOutOfBoundsException: beginIndex: -16
Success: java.lang.NullPointerException
Success: java.lang.NullPointerException
Success: java.lang.NullPointerException

Time: 0.11

OK (1 test)

======= Output Harmony ======

.Fail: java.lang.NullPointerException
Fail: java.lang.IndexOutOfBoundsException: Wrong start index: -16
Success: java.lang.NullPointerException
Success: java.lang.NullPointerException

Time: 0.01

OK (1 test)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message