test/jdk/sun/java2d/cmm/ColorConvertOp/ConstructorsNullTest/ConstructorsNullTest.java
changeset 54231 e4813eded7cb
parent 50834 9cf279436b9d
equal deleted inserted replaced
54230:d9d9655bb077 54231:e4813eded7cb
    18  *
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
       
    23 
    23 /*
    24 /*
    24   test
    25   @test
    25   @bug 4185854
    26   @bug 4185854
    26   @summary Checks that constructors do not accept nulls and throw NPE
    27   @summary Checks that constructors do not accept nulls and throw NPE
    27   @run applet ConstructorsNullTest.html
    28   @run main ConstructorsNullTest
    28 */
    29 */
    29 
    30 
    30 // Note there is no @ in front of test above.  This is so that the
    31 import java.awt.RenderingHints;
    31 //  harness will not mistake this file as a test file.  It should
    32 import java.awt.color.ColorSpace;
    32 //  only see the html file as a test file. (the harness runs all
    33 import java.awt.color.ICC_Profile;
    33 //  valid test files, so it would run this test twice if this file
    34 import java.awt.image.ColorConvertOp;
    34 //  were valid as well as the html file.)
       
    35 // Also, note the area= after Your Name in the author tag.  Here, you
       
    36 //  should put which functional area the test falls in.  See the
       
    37 //  AWT-core home page -> test areas and/or -> AWT team  for a list of
       
    38 //  areas.
       
    39 // Note also the 'ConstructorsNullTest.html' in the run tag.  This should
       
    40 //  be changed to the name of the test.
       
    41 
    35 
       
    36 public class ConstructorsNullTest {
    42 
    37 
    43 /**
    38     public static void main(final String[] args) {
    44  * ConstructorsNullTest.java
       
    45  *
       
    46  * summary:
       
    47  */
       
    48 
       
    49 import java.applet.Applet;
       
    50 import java.awt.*;
       
    51 import java.awt.image.*;
       
    52 import java.awt.color.*;
       
    53 
       
    54 
       
    55 //Automated tests should run as applet tests if possible because they
       
    56 // get their environments cleaned up, including AWT threads, any
       
    57 // test created threads, and any system resources used by the test
       
    58 // such as file descriptors.  (This is normally not a problem as
       
    59 // main tests usually run in a separate VM, however on some platforms
       
    60 // such as the Mac, separate VMs are not possible and non-applet
       
    61 // tests will cause problems).  Also, you don't have to worry about
       
    62 // synchronisation stuff in Applet tests they way you do in main
       
    63 // tests...
       
    64 
       
    65 
       
    66 public class ConstructorsNullTest extends Applet
       
    67  {
       
    68    //Declare things used in the test, like buttons and labels here
       
    69 
       
    70    public void init()
       
    71     {
       
    72       //Create instructions for the user here, as well as set up
       
    73       // the environment -- set the layout manager, add buttons,
       
    74       // etc.
       
    75 
       
    76       this.setLayout (new BorderLayout ());
       
    77 
       
    78     }//End  init()
       
    79 
       
    80    public void start ()
       
    81     {
       
    82       //Get things going.  Request focus, set size, et cetera
       
    83       setSize (200,200);
       
    84       show();
       
    85 
       
    86       ColorConvertOp gp;
    39       ColorConvertOp gp;
    87       boolean passed = false;
    40       boolean passed = false;
    88       try {
    41       try {
    89           gp = new ColorConvertOp((ColorSpace)null, (RenderingHints)null);
    42           gp = new ColorConvertOp((ColorSpace)null, (RenderingHints)null);
    90       } catch (NullPointerException e) {
    43       } catch (NullPointerException e) {
   102       if (!passed) {
    55       if (!passed) {
   103           System.out.println("Test FAILED: one of constructors didn't throw NullPointerException.");
    56           System.out.println("Test FAILED: one of constructors didn't throw NullPointerException.");
   104           throw new RuntimeException("Test FAILED: one of constructors didn't throw NullPointerException.");
    57           throw new RuntimeException("Test FAILED: one of constructors didn't throw NullPointerException.");
   105       }
    58       }
   106       System.out.println("Test PASSED: all constructors threw NullPointerException.");
    59       System.out.println("Test PASSED: all constructors threw NullPointerException.");
   107 
    60     }
   108       //What would normally go into main() will probably go here.
    61 }// class ConstructorsNullTest
   109       //Use System.out.println for diagnostic messages that you want
       
   110       //to read after the test is done.
       
   111       //Use System.out.println for messages you want the tester to read.
       
   112 
       
   113     }// start()
       
   114 
       
   115  }// class ConstructorsNullTest