8055731: sun/security/smartcardio/TestDirect.java throws java.lang.IndexOutOfBoundsException
authorigerasim
Sat, 23 Aug 2014 01:05:50 +0400
changeset 26196 da88c934115d
parent 26195 64b54ed39429
child 26197 1bb6b68b87cd
8055731: sun/security/smartcardio/TestDirect.java throws java.lang.IndexOutOfBoundsException Reviewed-by: valeriep
jdk/test/sun/security/smartcardio/TestDirect.java
--- a/jdk/test/sun/security/smartcardio/TestDirect.java	Thu Aug 21 14:36:49 2014 +0200
+++ b/jdk/test/sun/security/smartcardio/TestDirect.java	Sat Aug 23 01:05:50 2014 +0400
@@ -30,6 +30,7 @@
 
 // This test requires special hardware.
 
+import java.util.List;
 import javax.smartcardio.Card;
 import javax.smartcardio.CardTerminal;
 import javax.smartcardio.CardTerminals;
@@ -38,8 +39,12 @@
 public class TestDirect {
     public static void main(String[] args) throws Exception {
         TerminalFactory terminalFactory = TerminalFactory.getDefault();
-        CardTerminals cardTerminals = terminalFactory.terminals();
-        CardTerminal cardTerminal = cardTerminals.list().get(0);
+        List<CardTerminal> cardTerminals = terminalFactory.terminals().list();
+        System.out.println("Terminals: " + cardTerminals);
+        if (cardTerminals.isEmpty()) {
+            throw new Exception("No card terminals available");
+        }
+        CardTerminal cardTerminal = cardTerminals.get(0);
         Card card = cardTerminal.connect("DIRECT");
         card.disconnect(true);