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-1465) [classlib][awt]compatibility:awt.Font.getLineMetrics() for null FontRenderContext returns LineMetrics instanse on Harmony and throws NPE on RI
Date Thu, 14 Sep 2006 14:45:22 GMT
[classlib][awt]compatibility:awt.Font.getLineMetrics() for null FontRenderContext returns LineMetrics
instanse on Harmony and throws NPE on RI
----------------------------------------------------------------------------------------------------------------------------------------------

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


There is nothing written in the spec about the exceptions but if the FontRenderContext parameter
is null awt.Font.getLineMetrics()  returns LineMetrics instanse on Harmony while NPE is thrown
on RI.
Next test case passes on RI and fails on Harmony:
-------------------------test.java------------------------------------
import junit.framework.TestCase;

import java.awt.Font;
import java.awt.font.*;

import java.text.AttributedString;
import java.text.AttributedCharacterIterator.Attribute;
import java.util.*;

public class test extends TestCase {

    private final Font f = new Font("dialog", Font.PLAIN, 12);
    
    public static void main(String[] args) {
    }

    public void testFontgetLineMetricsWithNullFRC(){
        final String str = "test";
        try{
            f.getLineMetrics(str, null);
            fail("NullPointerException expected but wasn't thrown!");
        }catch (NullPointerException e) {
            // as expected
        }

        try{
            f.getLineMetrics(str, 1, 3, null);
            fail("NullPointerException expected but wasn't thrown!");
        }catch (NullPointerException e) {
            // as expected
        }

        try{
            f.getLineMetrics(str.toCharArray(), 1, 3, null);
            fail("NullPointerException expected but wasn't thrown!");
        }catch (NullPointerException e) {
            // as expected
        }

        try{
            AttributedString as = new AttributedString("test");
            as.addAttribute(TextAttribute.FONT, f, 0, 2 );

            f.getLineMetrics(as.getIterator(), 1, 3, null);
            fail("NullPointerException expected but wasn't thrown!");
        }catch (NullPointerException e) {
            // as expected
        }
        
    }
  
}
---------------------------------------------------------------

-- 
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