changeset 9935:9b42c55da54c

8055731: sun/security/smartcardio/TestDirect.java throws java.lang.IndexOutOfBoundsException Reviewed-by: valeriep
author igerasim
date Sat, 23 Aug 2014 01:05:50 +0400
parents be8eccf988cc
children 11062c9f48b7
files test/sun/security/smartcardio/TestDirect.java
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/security/smartcardio/TestDirect.java	Sun Aug 24 18:23:06 2014 -0400
+++ b/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);