test/java/awt/Toolkit/Headless/ExceptionContract/ExceptionContract.java

Print this page




  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
  21  * questions.
  22  */
  23 
  24 /*
  25   @test
  26   @bug 7040577
  27   @library ../../../regtesthelpers
  28   @build Sysout
  29   @summary Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
  30   @author andrei dmitriev: area=awt.headless
  31   @run main/othervm -Djava.awt.headless=true ExceptionContract
  32 */
  33 
  34 import java.awt.*;
  35 import java.util.Properties;
  36 import test.java.awt.regtesthelpers.Sysout;
  37 
  38 import java.awt.datatransfer.Clipboard;
  39 import java.awt.dnd.*;
  40 import java.awt.dnd.peer.DragSourceContextPeer;
  41 import java.awt.font.TextAttribute;
  42 import java.awt.im.InputMethodHighlight;
  43 import java.awt.image.*;
  44 import java.awt.peer.*;
  45 import java.net.URL;
  46 import java.util.Map;
  47 import java.util.Properties;
  48 
  49 public class ExceptionContract {
  50 
  51     private static boolean passed = false;
  52     public static void main(String[] args)  {
  53         //Case1
  54         try{
  55             new _Toolkit().getLockingKeyState(1);
  56         } catch (HeadlessException he){
  57             passed = true;
  58         }
  59         if (!passed){
  60             throw new RuntimeException("Tk.getLockingKeyState() didn't throw HeadlessException while in the headless mode.");
  61         }
  62 
  63         passed = false;
  64         //Case2


  95         }
  96 
  97 
  98         @Override
  99         public void setLockingKeyState(int keyCode, boolean on) throws UnsupportedOperationException {
 100             super.setLockingKeyState(keyCode, on);
 101         }
 102 
 103         @Override
 104         public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
 105             return super.getLockingKeyState(keyCode);
 106         }
 107 
 108 
 109         @Override
 110         public void loadSystemColors(int[] systemColors) throws HeadlessException {
 111             return;
 112         }
 113 
 114         @Override
 115         protected DesktopPeer createDesktopPeer(Desktop target) throws HeadlessException {
 116             return null;
 117         }
 118 
 119         @Override
 120         protected ButtonPeer createButton(Button target) throws HeadlessException {
 121             return null;
 122         }
 123 
 124         @Override
 125         protected TextFieldPeer createTextField(TextField target) throws HeadlessException {
 126             return null;
 127         }
 128 
 129         @Override
 130         protected LabelPeer createLabel(Label target) throws HeadlessException {
 131             return null;
 132         }
 133 
 134         @Override
 135         protected ListPeer createList(List target) throws HeadlessException {
 136             return null;
 137         }
 138 
 139         @Override
 140         protected CheckboxPeer createCheckbox(Checkbox target) throws HeadlessException {
 141             return null;
 142         }
 143 
 144         @Override
 145         protected ScrollbarPeer createScrollbar(Scrollbar target) throws HeadlessException {
 146             return null;
 147         }
 148 
 149         @Override
 150         protected ScrollPanePeer createScrollPane(ScrollPane target) throws HeadlessException {
 151             return null;
 152         }
 153 
 154         @Override
 155         protected TextAreaPeer createTextArea(TextArea target) throws HeadlessException {
 156             return null;
 157         }
 158 
 159         @Override
 160         protected ChoicePeer createChoice(Choice target) throws HeadlessException {
 161             return null;
 162         }
 163 
 164         @Override
 165         protected FramePeer createFrame(Frame target) throws HeadlessException {
 166             return null;
 167         }
 168 
 169         @Override
 170         protected CanvasPeer createCanvas(Canvas target) {
 171             return null;
 172         }
 173 
 174         @Override
 175         protected PanelPeer createPanel(Panel target) {
 176             return null;
 177         }
 178 
 179         @Override
 180         protected WindowPeer createWindow(Window target) throws HeadlessException {
 181             return null;
 182         }
 183 
 184         @Override
 185         protected DialogPeer createDialog(Dialog target) throws HeadlessException {
 186             return null;
 187         }
 188 
 189         @Override
 190         protected MenuBarPeer createMenuBar(MenuBar target) throws HeadlessException {
 191             return null;
 192         }
 193 
 194         @Override
 195         protected MenuPeer createMenu(Menu target) throws HeadlessException {
 196             return null;
 197         }
 198 
 199         @Override
 200         protected PopupMenuPeer createPopupMenu(PopupMenu target) throws HeadlessException {
 201             return null;
 202         }
 203 
 204         @Override
 205         protected MenuItemPeer createMenuItem(MenuItem target) throws HeadlessException {
 206             return null;
 207         }
 208 
 209         @Override
 210         protected FileDialogPeer createFileDialog(FileDialog target) throws HeadlessException {
 211             return null;
 212         }
 213 
 214         @Override
 215         protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) throws HeadlessException {
 216             return null;
 217         }
 218 
 219         @Override
 220         protected FontPeer getFontPeer(String name, int style) {
 221             return null;
 222         }
 223 
 224         @Override
 225         public Dimension getScreenSize() throws HeadlessException {
 226             return null;
 227         }
 228 
 229         @Override
 230         public int getScreenResolution() throws HeadlessException {
 231             return 0;
 232         }
 233 
 234         @Override
 235         public ColorModel getColorModel() throws HeadlessException {
 236             return null;
 237         }
 238 
 239         @Override
 240         public String[] getFontList() {
 241             return new String[0];
 242         }
 243 
 244         @Override


 295         public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props) {
 296             return null;
 297         }
 298 
 299         @Override
 300         public void beep() {
 301 
 302         }
 303 
 304         @Override
 305         public Clipboard getSystemClipboard() throws HeadlessException {
 306             return null;
 307         }
 308 
 309         @Override
 310         protected EventQueue getSystemEventQueueImpl() {
 311             return null;
 312         }
 313 
 314         @Override
 315         public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
 316             return null;
 317         }
 318 
 319         @Override
 320         public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
 321             return false;
 322         }
 323 
 324         @Override
 325         public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType) {
 326             return false;
 327         }
 328 
 329         @Override
 330         public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight) throws HeadlessException {
 331             return null;
 332         }
 333     }
 334 }


  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
  21  * questions.
  22  */
  23 
  24 /*
  25   @test
  26   @bug 7040577
  27   @library ../../../regtesthelpers
  28   @build Sysout
  29   @summary Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env
  30   @author andrei dmitriev: area=awt.headless
  31   @run main/othervm -Djava.awt.headless=true ExceptionContract
  32 */
  33 
  34 import java.awt.*;
  35 import java.util.Properties;
  36 import test.java.awt.regtesthelpers.Sysout;
  37 
  38 import java.awt.datatransfer.Clipboard;


  39 import java.awt.font.TextAttribute;
  40 import java.awt.im.InputMethodHighlight;
  41 import java.awt.image.*;

  42 import java.net.URL;
  43 import java.util.Map;
  44 import java.util.Properties;
  45 
  46 public class ExceptionContract {
  47 
  48     private static boolean passed = false;
  49     public static void main(String[] args)  {
  50         //Case1
  51         try{
  52             new _Toolkit().getLockingKeyState(1);
  53         } catch (HeadlessException he){
  54             passed = true;
  55         }
  56         if (!passed){
  57             throw new RuntimeException("Tk.getLockingKeyState() didn't throw HeadlessException while in the headless mode.");
  58         }
  59 
  60         passed = false;
  61         //Case2


  92         }
  93 
  94 
  95         @Override
  96         public void setLockingKeyState(int keyCode, boolean on) throws UnsupportedOperationException {
  97             super.setLockingKeyState(keyCode, on);
  98         }
  99 
 100         @Override
 101         public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
 102             return super.getLockingKeyState(keyCode);
 103         }
 104 
 105 
 106         @Override
 107         public void loadSystemColors(int[] systemColors) throws HeadlessException {
 108             return;
 109         }
 110 
 111         @Override














































































































 112         public Dimension getScreenSize() throws HeadlessException {
 113             return null;
 114         }
 115 
 116         @Override
 117         public int getScreenResolution() throws HeadlessException {
 118             return 0;
 119         }
 120 
 121         @Override
 122         public ColorModel getColorModel() throws HeadlessException {
 123             return null;
 124         }
 125 
 126         @Override
 127         public String[] getFontList() {
 128             return new String[0];
 129         }
 130 
 131         @Override


 182         public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props) {
 183             return null;
 184         }
 185 
 186         @Override
 187         public void beep() {
 188 
 189         }
 190 
 191         @Override
 192         public Clipboard getSystemClipboard() throws HeadlessException {
 193             return null;
 194         }
 195 
 196         @Override
 197         protected EventQueue getSystemEventQueueImpl() {
 198             return null;
 199         }
 200 
 201         @Override





 202         public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
 203             return false;
 204         }
 205 
 206         @Override
 207         public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType) {
 208             return false;
 209         }
 210 
 211         @Override
 212         public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight) throws HeadlessException {
 213             return null;
 214         }
 215     }
 216 }