jdk/test/sun/security/smartcardio/TestDirect.java
changeset 35778 e2a3c03097de
parent 26196 da88c934115d
child 41106 f37e9bfeae01
equal deleted inserted replaced
35777:656b9a28f19e 35778:e2a3c03097de
     1 /*
     1 /*
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    38 
    38 
    39 public class TestDirect {
    39 public class TestDirect {
    40     public static void main(String[] args) throws Exception {
    40     public static void main(String[] args) throws Exception {
    41         TerminalFactory terminalFactory = TerminalFactory.getDefault();
    41         TerminalFactory terminalFactory = TerminalFactory.getDefault();
    42         List<CardTerminal> cardTerminals = terminalFactory.terminals().list();
    42         List<CardTerminal> cardTerminals = terminalFactory.terminals().list();
       
    43         if (cardTerminals.isEmpty()) {
       
    44             System.out.println("Skipping the test: " +
       
    45                     "no card terminals available");
       
    46             return;
       
    47         }
    43         System.out.println("Terminals: " + cardTerminals);
    48         System.out.println("Terminals: " + cardTerminals);
    44         if (cardTerminals.isEmpty()) {
       
    45             throw new Exception("No card terminals available");
       
    46         }
       
    47         CardTerminal cardTerminal = cardTerminals.get(0);
    49         CardTerminal cardTerminal = cardTerminals.get(0);
    48         Card card = cardTerminal.connect("DIRECT");
    50         Card card = cardTerminal.connect("DIRECT");
    49         card.disconnect(true);
    51         card.disconnect(true);
    50 
    52 
    51         System.out.println("OK.");
    53         System.out.println("OK.");