< prev index next >
test/sun/security/smartcardio/TestConnect.java
Print this page
rev 13550 : imported patch 8059212-Modify-smartcardio-manual-regression-tests-so-that-they-do-not-just-fail-if-no-cardreader-found
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -38,27 +38,16 @@
import javax.smartcardio.CardTerminal;
public class TestConnect extends Utils {
public static void main(String[] args) throws Exception {
- TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null, "SunPCSC");
- System.out.println(factory);
-
- List<CardTerminal> terminals = factory.terminals().list();
- System.out.println("Terminals: " + terminals);
- if (terminals.isEmpty()) {
- throw new Exception("No card terminals available");
- }
- CardTerminal terminal = terminals.get(0);
-
- if (terminal.isCardPresent() == false) {
- System.out.println("*** Insert card");
- if (terminal.waitForCardPresent(20 * 1000) == false) {
- throw new Exception("no card available");
- }
+ CardTerminal terminal = getTerminal(args, "SunPCSC");
+ if (terminal == null) {
+ System.out.println("Skipping the test: " +
+ "no card terminals available");
+ return;
}
- System.out.println("card present: " + terminal.isCardPresent());
Card card = terminal.connect("*");
System.out.println("card: " + card);
if (card.getProtocol().equals("T=0") == false) {
throw new Exception("Not T=0 protocol");
< prev index next >