01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package com.sun.cardreader;
28:
29: import com.sun.midp.i3test.TestCase;
30: import java.io.IOException;
31:
32: /**
33: * This test case tests basic SlotFactory functionality, primarily configuration
34: * properties.
35: */
36: public class TestSlotFactory extends TestCase {
37: public static final int SLOT_COUNT = 1;
38:
39: /**
40: * Test card devices configuration reading and device creation.
41: */
42: private void testInit() throws java.io.IOException,
43: CardDeviceException {
44: boolean stub_flag = false;
45:
46: try {
47: SlotFactory.init();
48: } catch (CardDeviceException e) {
49: if (e.getMessage().equals("stub")) {
50: stub_flag = true;
51: } else {
52: throw e;
53: }
54: }
55:
56: if (!stub_flag) {
57: int deviceCount = SlotFactory.getCardDeviceCount();
58: assertTrue(deviceCount == 1);
59:
60: int slotCount = SlotFactory.getCardSlotCount();
61: assertTrue(slotCount == 1);
62: } else {
63: assertTrue(true);
64: }
65: }
66:
67: /**
68: * Test card slot creation.
69: */
70: private void testSlotCreation() throws IOException,
71: CardDeviceException {
72: /* Placeholder */
73: assertTrue(true);
74: }
75:
76: /**
77: * Run tests.
78: */
79: public void runTests() {
80: try {
81: declare("testInit");
82: testInit();
83:
84: declare("testSlotCreation");
85: testSlotCreation();
86: } catch (Throwable t) {
87: fail("" + t);
88: }
89: }
90: }
|