From 74396d94057f2b0b8e1cab50eea6db2b3d9996c7 Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Sun, 24 Feb 2013 02:09:14 +0100 Subject: [PATCH] Add first batch of unit tests from the javax.usb TCK --- .../usb/tck/DefaultControlPipeTestIRP.java | 898 +++++++++++++ .../javax/usb/tck/FindProgrammableDevice.java | 434 +++++++ src/test/java/javax/usb/tck/HotPlugTest.java | 1150 +++++++++++++++++ src/test/java/javax/usb/tck/IrpTest.java | 1051 +++++++++++++++ .../java/javax/usb/tck/SignatureTest.java | 43 + .../java/javax/usb/tck/TransmitBuffer.java | 240 ++++ .../javax/usb/tck/UsbInterfacePolicyTest.java | 335 +++++ .../java/javax/usb/tck/VerifyIrpMethods.java | 413 ++++++ .../java/javax/usb/tck/sigtest/ClassDesc.java | 319 +++++ .../javax/usb/tck/sigtest/MemberDesc.java | 49 + .../javax/usb/tck/sigtest/MethodDesc.java | 180 +++ .../javax/usb/tck/sigtest/ProjectDesc.java | 179 +++ .../javax/usb/tck/sigtest/SigTestUtils.java | 441 +++++++ src/test/resources/javax.usb-1.0.sig | 497 +++++++ src/test/resources/javax.usb.properties | 1 + 15 files changed, 6230 insertions(+) create mode 100755 src/test/java/javax/usb/tck/DefaultControlPipeTestIRP.java create mode 100755 src/test/java/javax/usb/tck/FindProgrammableDevice.java create mode 100755 src/test/java/javax/usb/tck/HotPlugTest.java create mode 100755 src/test/java/javax/usb/tck/IrpTest.java create mode 100755 src/test/java/javax/usb/tck/SignatureTest.java create mode 100755 src/test/java/javax/usb/tck/TransmitBuffer.java create mode 100755 src/test/java/javax/usb/tck/UsbInterfacePolicyTest.java create mode 100755 src/test/java/javax/usb/tck/VerifyIrpMethods.java create mode 100755 src/test/java/javax/usb/tck/sigtest/ClassDesc.java create mode 100755 src/test/java/javax/usb/tck/sigtest/MemberDesc.java create mode 100755 src/test/java/javax/usb/tck/sigtest/MethodDesc.java create mode 100755 src/test/java/javax/usb/tck/sigtest/ProjectDesc.java create mode 100755 src/test/java/javax/usb/tck/sigtest/SigTestUtils.java create mode 100755 src/test/resources/javax.usb-1.0.sig create mode 100644 src/test/resources/javax.usb.properties diff --git a/src/test/java/javax/usb/tck/DefaultControlPipeTestIRP.java b/src/test/java/javax/usb/tck/DefaultControlPipeTestIRP.java new file mode 100755 index 0000000..cd95fcd --- /dev/null +++ b/src/test/java/javax/usb/tck/DefaultControlPipeTestIRP.java @@ -0,0 +1,898 @@ +package javax.usb.tck; + +/** + * Copyright (c) 2004, International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + +/* + * Change Activity: See below. + * + * FLAG REASON RELEASE DATE WHO DESCRIPTION + * ---- -------- -------- ------ ------- ------------------------------------ + * 0000 nnnnnnn yymmdd Initial Development + * $P1 tck.rel1 040804 raulortz Support for UsbDisconnectedException + */ + +import java.util.*; + +import javax.usb.*; +import javax.usb.event.*; + +import junit.framework.TestCase; + +/** + * Default Control Pipe Test -- Synchronous and asynchronous IRP submissions + *

+ * This test verifies that control transfers operations work successfully + * on the Default Control Pipe and that proper events are generated and proper + * exceptions are thrown in the operation. + * + * @author Leslie Blair + */ + + +@SuppressWarnings("all") +public class DefaultControlPipeTestIRP extends TestCase +{ + public void setUp() throws Exception + { + usbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice(); + assertNotNull("Device required for test not found",usbDevice); + super.setUp(); + } + public void tearDown() throws Exception + { + + if ( debug ) + { + /* Print out some debug info + */ + System.out.println("iterations = " + iterations); + System.out.println("numSubmits = " + numSubmits); + System.out.println("numDataEvents = " + numDataEvents); + System.out.println("numExceptionEvents = " + numExceptionEvents); + System.out.println("numDetachEvents = " + numDetachEvents); + } + super.tearDown(); + } + + public void testBuffersMultiplesOfMaxPacketSize_1packets() + { + usbDevice.addUsbDeviceListener(deviceListener); + for ( int i=0; (i < iterations); i++ ) + { + for ( int j=0; j + * The list includes the provided device. If the device is also a hub, + * the list will include all devices connected to it, recursively. + * @param usbDevice The UsbDevice to use. + * @return An inclusive List of all connected UsbDevices. + */ + private static List getAllUsbDevices(UsbDevice usbDevice) + { + List list = new ArrayList(); + + list.add(usbDevice); + + /* this is just normal recursion. Nothing special. */ + if ( usbDevice.isUsbHub() ) + { + List devices = ((UsbHub)usbDevice).getAttachedUsbDevices(); + for ( int i=0; i + * This test verifies that devices can be attached and detached at runtime + * (hot plugging) and checks that proper UsbServices events are generated. + * @author Charles Jaeger + */ + + +@SuppressWarnings("all") +public class HotPlugTest extends TestCase +{ + + /* + * Assumed event flow on a renumeration of the Cypress board is... + * DeviceListener.DataEvent - response from syncSubmit of IRP + * DeviceListener.DetachedEvent - device is offlined + * ServiceListener.DetachedEvent - service is offlined + * ServiceListener.AttachedEvent - service is online + * + * Assumed device under test is a Cypress board with the BulkInt + * image running. + */ + + public void setUp() + { + try + { + usbServices = UsbHostManager.getUsbServices(); + } catch ( java.lang.SecurityException se ) + { + fail("SecurityException was not expected: " + se); + } catch ( UsbException ue ) + { + fail("UsbException was not expected: " + ue); + } + + // traverse the topology tree to locate the test device + usbDevice = + FindProgrammableDevice.getInstance().getProgrammableDevice(); + + assertTrue("USB Device was not configured", usbDevice.isConfigured()); + + // add a listener to receive events when the host has changes + // (e.g. device is unplugged or is plugged in) + usbServices.addUsbServicesListener(servicesListener); + + // add a listener to detect when the device is detached. + usbDevice.addUsbDeviceListener(deviceListener); + + // init for each test -> + numSubmits = 0; + + numDeviceDataEvents = 0; + numDeviceDetachEvents = 0; + numDeviceErrorEvents = 0; + lastUsbDeviceDataEvent = null; + lastUsbDeviceErrorEvent = null; + lastUsbDeviceDetachedEvent = null; + + numServicesAttachEvents = 0; + numServicesDetachEvents = 0; + lastServicesAttachEvent = null; + lastServicesDetachEvent = null; + // <- + + } + + public void tearDown() + { + + if ( debug ) + { + + /* Print out some debug info + */ + System.out.println("numSubmits = " + numSubmits); + System.out.println("numDataEvents = " + numDeviceDataEvents); + System.out.println("numExceptionEvents = " + numDeviceErrorEvents); + System.out.println("numDetachEvents = " + numDeviceDetachEvents); + System.out.println( + "numServicesAttachEvents = " + numServicesAttachEvents); + System.out.println( + "numServicesDetachEvents = " + numServicesDetachEvents); + + } + + usbDevice.removeUsbDeviceListener(deviceListener); + usbServices.removeUsbServicesListener(servicesListener); + + } + + /** + * Tests that the setUp() passes all assertions. + */ + public void testSetUp() + { + + // was setup successful in init of members? + assertNotNull("UsbDevice required for test not found", usbDevice); + assertNotNull( + "UsbHostManager returned null instead of usbServices object", + usbServices); + + // test the numXXX members + assertEquals("Devices detached should be 0", numDeviceDetachEvents, 0); + + assertEquals( + "Device commands issued should be 0", + numDeviceDataEvents, + 0); + + assertEquals("Device error count should be 0", numDeviceErrorEvents, 0); + + assertEquals( + "Services detached should be 0", + numServicesDetachEvents, + 0); + + assertEquals( + "Services attached should be 0", + numServicesAttachEvents, + 0); + + assertEquals("Board commands should be 0", numSubmits, 0); + + // test the lastXXX members + assertNull(lastUsbDeviceDataEvent); + assertNull(lastUsbDeviceErrorEvent); + assertNull(lastUsbDeviceDetachedEvent); + + assertNull(lastServicesAttachEvent); + assertNull(lastServicesDetachEvent); + + // + assertNotNull("usbDevice should already exist.", usbDevice); + } + + public void testUsbServicesEvent() + { + UsbServicesEvent event = new UsbServicesEvent(usbServices, usbDevice); + assertNotNull("UsbServicesEvent constructor failed.", event); + + //test methods of the UsbServicesEvent + assertNotNull( + "UsbServicesEvent.getUsbServices() returned null", + event.getUsbServices()); + assertNotNull( + "UsbServicesEvent.getUsbDevice() returned null", + event.getUsbDevice()); + + } + + /** + * Test the method that will send the reset command to the Cypress board. + */ + public void testSimulateHotPlug() + { + + // send reset command to the Cypress board + simulateHotPlug(); + + // verify that all expected events were captured + assertNotNull( + "Did not receive a DeviceListener DataEvent after submitting IRP.", + lastUsbDeviceDataEvent); + + assertNotNull( + "Did not receive a DeviceListener DetachedEvent (indicating reset not issued).", + lastUsbDeviceDetachedEvent); + + assertNotNull( + "Did not receive a ServicesListener acknowledging detach.", + lastServicesDetachEvent); + + assertNotNull( + "Did not receive a ServicesListener acknowledging attach.", + lastServicesAttachEvent); + + // Were the number of returned events correct? + assertEquals( + "The device should detach once during the run", + numDeviceDetachEvents, + 1); + + assertEquals("Only 1 command is sent", numDeviceDataEvents, 1); + + assertEquals("No errors should occur", numDeviceErrorEvents, 0); + + assertEquals( + "The service should detach once during the run", + numServicesDetachEvents, + 1); + + assertEquals( + "The service attached once during the run", + numServicesAttachEvents, + 1); + } + + /** + * Verify that proper exceptions are thrown (w/o failure) + * for all other IO calls to a disconnected device + */ + public void testExceptionsOnDisconnectedDevice() + { + + //local variable + boolean isOK = false; + + // make sure the board is online + assertNotNull("The Cypress board is not online", usbDevice); + + // flush any events from the listeners. + // ... automatically done by the setUp() process + + // reset the board + try + { + submitRenumerateIrp(); + } catch ( Exception e ) + { + e.printStackTrace(); + fail("Resetting the board should not issue any exceptions."); + } + + // verify that the correct exceptions are returned for this offline device. + + if ( null == lastServicesDetachEvent ) + { + + if ( debug ) + { + System.out.println( + "-> public void testExceptionsOnDisconnectedDevice()"); + System.out.println(" -> submitRenumerateIrp()"); + } + + // UsbException + try + { + submitRenumerateIrp(); + fail("UsbException expected"); + } catch ( UsbException e ) + { + isOK = true; + if ( debug ) + System.out.println("UsbException thrown" + e); + } catch ( Exception e ) + { + e.printStackTrace(); + fail("An Exception other than UsbException was detected."); + } + + isOK = false; + + // IllegalArgumentException - If the UsbControlIrp is not valid. + try + { + submitBadIrp(); + fail("IllegalArgumentException was expected."); + } catch ( IllegalArgumentException e ) + { + // System.out.println("good"); + isOK = true; + if ( debug ) + System.out.println("IllegalArgumentException thrown"); + } catch ( Exception e ) + { + e.printStackTrace(); + fail("Exception other than IllegalArgumentException was detected"); + } + + } else + { + fail("Can't proceed because the service got up and running quickly."); + } + + if ( null != lastServicesDetachEvent ) + { + fail("The service may have attached during test, so results are inconclusive."); + } + + // make sure board is up before leaving. + isOK = false; + try + { + waitForServiceAttachedEvent(20000); + isOK = true; + } catch ( InterruptedException e ) + { + e.printStackTrace(); + fail("Timed out before all events were seen."); + } finally + { + if ( !isOK ) + fail("UsbDevice was not detected as going online"); + } + } + + /** + * Verify proper events are generated after disconnecting. + */ + public void testDisconnectEvents() + { + // make sure the board is online + assertNotNull("The Cypress board is not online", usbDevice); + + // reset the board + try + { + submitRenumerateIrp(); + } catch ( UsbException e ) + { + e.printStackTrace(); + fail("Resetting the board should not issue any exceptions."); + } + + // make sure all the disconnect events from the listeners fire + try + { + // the total time to wait for the wanted disconnect events to occur + waitForServiceDetachedEvent(20000); + + // Disconnect events follow + // in the expected sequential order... + assertNotNull( + "The device did not detach within time", + lastUsbDeviceDetachedEvent); + assertNotNull( + "The service did not detach within time", + lastServicesDetachEvent); + assertEquals( + "1 Device detach events expected", + numDeviceDetachEvents, + 1); + assertEquals( + "1 Service detach events expected", + numServicesDetachEvents, + 1); + assertEquals("0 Device errors expected", numDeviceErrorEvents, 0); + + // make sure board is up before leaving. + waitForServiceAttachedEvent(5000); + + } catch ( InterruptedException e ) + { + e.printStackTrace(); + fail("Timed out before all events were seen."); + } + } + + /** + * Verify proper events are generated after hot plugging. + */ + public void testPlugInEvents() + { + // make sure the board is online + assertNotNull("usbDevice should already be online.", usbDevice); + + try + { + // the setUp() flushes any events from the listeners + + // reset the board + submitRenumerateIrp(); + + // wait til the board comes back up + waitForServiceAttachedEvent(20000); + + // verify that all the events from the listeners fire + + assertNotNull( + "Did not receive a DeviceListener DataEvent after submitting IRP.", + lastUsbDeviceDataEvent); + + assertNotNull( + "Did not receive a DeviceListener DetachedEvent (indicating reset not issued).", + lastUsbDeviceDetachedEvent); + + assertNotNull( + "Did not receive a ServicesListener acknowledging detach.", + lastServicesDetachEvent); + + assertNotNull( + "Did not receive a ServicesListener acknowledging attach.", + lastServicesAttachEvent); + + // Were the number of returned events correct? + assertEquals( + "The device should detach once during the run", + numDeviceDetachEvents, + 1); + + assertEquals("Only 1 command is sent", numDeviceDataEvents, 1); + + assertEquals("No errors should occur", numDeviceErrorEvents, 0); + + assertEquals( + "The service should detach once during the run", + numServicesDetachEvents, + 1); + + assertEquals( + "The service attached once during the run", + numServicesAttachEvents, + 1); + } catch ( InterruptedException e ) + { + e.printStackTrace(); + fail("Sleep was interrupted"); + } catch ( UsbException uE ) + { + /* The exception should indicate the reason for the failure. + * For this example, we'll just stop trying. + */ + fail("DCP submission failed. " + uE.toString()); + } + } + + /** + * Run a disconnect, reconnect cycle and then verify that 10 transfers will + * succeed without data error. + */ + public void testNoErrorsOnDataTransfers() + { + + // the setUp() flushes any events from the listeners + + // make sure the board is online + assertNotNull("usbDevice should already be online.", usbDevice); + assertTrue("usbDevice is not configured.", usbDevice.isConfigured()); + + //set up the board's: endpoints, pipes, etc .. + Board theBoard = new Board(usbDevice); + + // test: while online, data can be sent without error... + try + { + theBoard.sendData(); + } catch ( Exception e ) + { + e.printStackTrace(); + fail("Exception not expected."); + } + // tested: while online, data can be sent without error... + + // While transferring data through input and output endpoints + // (loop bulk data), unplug the device. + // (Vendor request to Cypress Board to renumerate will simulate unplug.) + try + { + theBoard.testAsyncInFailure(); + } catch ( InterruptedException ie ) + { + fail("Timed out while waiting for the device detach event."); + } catch ( Exception e ) + { + e.printStackTrace(); + fail("Resetting the board should not issue any exceptions."); + } + // tested: when offline, abort all submissions + + try + { + waitForServiceAttachedEvent(20000); + } catch ( InterruptedException ie ) + { + fail("Timed out while waiting for the device detach event."); + } + + // test: when online again, send data without error + // wait for the device to come back up + try + { + waitForServiceAttachedEvent(10000); + setUp(); + theBoard = new Board(usbDevice); + theBoard.sendData(); + theBoard.tearDown(); + } catch ( InterruptedException ie ) + { + fail("Timed out waiting for service attach event."); + } catch ( Exception e ) + { + fail("Exception not expected."); + } + // tested: when online again, send data without error + } + + /** + * Tell the Cypress board to initiate its reset and binary upload method. + * in order to simulate human involved device detach and attach action. + * Returns successfully once device service is attached; otherwise + * a fails method is asserted. + */ + private void simulateHotPlug() + { + /* This will block until the submission is complete. + * Note that submissions (except interrupt and bulk in-direction) + * will not block indefinitely, they will complete or fail within + * a finite amount of time. See MouseDriver.HidMouseRunnable for more details. + */ + try + { + submitRenumerateIrp(); + + waitForDeviceDataOrErrorEvent(2000); + + waitForDeviceDetachedEvent(5000); + + waitForServiceDetachedEvent(2000); + + waitForServiceAttachedEvent(10000); + + } catch ( InterruptedException e ) + { + e.printStackTrace(); + fail("Sleep was interrupted"); + } catch ( UsbException uE ) + { + /* The exception should indicate the reason for the failure. + * For this example, we'll just stop trying. + */ + fail("DCP submission failed. " + uE.toString()); + } + } + + /** + * Generates the Renumerate command for the cypress board as a UsbControlIrp + * @return the UsbControlIrp ready for use + */ + private UsbControlIrp getRenumerateIrp() + { + + byte sentbmRequestType = + UsbConst.REQUESTTYPE_DIRECTION_OUT + | UsbConst.REQUESTTYPE_TYPE_VENDOR + | UsbConst.REQUESTTYPE_RECIPIENT_DEVICE; + + short sentwIndex = 0; //first isochronous IN endpoint + + // An IRP + UsbControlIrp usbControlIrp = + usbDevice.createUsbControlIrp( + sentbmRequestType, + VENDOR_REQUEST_RENUMERATE, + VENDOR_REQUEST_DATA_OUT, + sentwIndex); + + //set variable parts of Irp + byte[] sentData = new byte[0]; + usbControlIrp.setData(sentData); + usbControlIrp.setAcceptShortPacket(true); + + return usbControlIrp; + } + + /** + * Generates an IRP that will cause the IllegalArgumentException + * on syncSubmit to the Cypress board + * @return the UsbControlIrp ready for use + private UsbControlIrp getBadIrp() { + UsbControlIrp badIrp = getRenumerateIrp(); + //set Irp data to cause IllegalArgumentException on syncSubmit + + return badIrp; + } + */ + + /** + * Sends a reset and binary upload call to the Cypress board. + * @throws UsbException + */ + private void submitRenumerateIrp() throws UsbException { + try + { + + UsbControlIrp usbControlIrp = getRenumerateIrp(); + assertNotNull("usbControlIrp should not be null", usbControlIrp); + + usbDevice.syncSubmit(usbControlIrp); + numSubmits++; + } catch ( IllegalArgumentException e ) + { + e.printStackTrace(); + fail("IllegalArgumentException was not expected."); + } + } + + /** + * Sends an invalid UsbControlIrp to the Cypress board. + * @throws IllegalArgumentException + */ + private void submitBadIrp() throws IllegalArgumentException { + + // An IRP + UsbControlIrp usbControlIrp = getRenumerateIrp(); + assertNotNull("usbControlIrp should not be null", usbControlIrp); + + //set Irp data to cause IllegalArgumentException on syncSubmit + usbControlIrp.setData(null); + + try + { + usbDevice.syncSubmit(usbControlIrp); + } catch ( UsbDisconnectedException uDE ) // @P1C + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } catch ( UsbException e ) // @P1A + { + e.printStackTrace(); + fail("UsbException not expected."); + } + numSubmits++; + } + + /** + * Wait for deviceListener deviceData or deviceError event before continuing. + * @param timeout minimum number of milliseconds before timeout is issued (suggested minimum: 2000) + * @throws InterruptedException raised if timeout occurs + */ + private void waitForDeviceDataOrErrorEvent(int timeout) + throws InterruptedException { + // up to 2 sec min timeout on submission + for ( int i = 0; i < (timeout / 20); i++ ) + { + + if ( (lastUsbDeviceDataEvent != null) + || (lastUsbDeviceErrorEvent != null) ) + { + if ( debug ) + System.out.println( + "waitForDeviceDataOrErrorEvent took less than " + + ((i + 1) * 20) + + " milliseconds"); + break; + } + Thread.sleep(20); //wait 20 ms before checkin for event + } + } + + /** + * Wait for deviceListener deviceDetached event before continuing + * @param timeout minimum number of milliseconds before timeout is issued (suggested minimum: 5000) + * @throws InterruptedException raised if timeout occurs + */ + private void waitForDeviceDetachedEvent(int timeout) + throws InterruptedException { + for ( int i = 0; i < (timeout / 20); i++ ) + { + + if ( lastUsbDeviceDetachedEvent != null ) + { + if ( debug ) + System.out.println( + "waitForDeviceDetachedEvent took less than " + + ((i + 1) * 20) + + " milliseconds"); + break; + } + Thread.sleep(20); //wait 20 ms before checkin for event + } + if ( lastUsbDeviceDetachedEvent == null ) + { + throw new InterruptedException( + "DeviceDetachedEvent not found within " + timeout + " ms"); + } + + } + + /** + * Wait for servicesListener deviceDetached event before continuing + * @param timeout minimum number of milliseconds before timeout is issued (suggested minimum: 2000) + * @throws InterruptedException raised if timeout occurs + */ + private void waitForServiceDetachedEvent(int timeout) + throws InterruptedException { + + for ( int i = 0; i < (timeout / 20); i++ ) + { + + if ( lastServicesDetachEvent != null ) + { + if ( debug ) + System.out.println( + "waitForServiceDetachedEvent took less than " + + ((i + 1) * 20) + + " milliseconds"); + break; + } + Thread.sleep(20); //wait 20 ms before checkin for event + } + } + + /** + * Wait for servicesListener deviceAttached event before continuing + * @param timeout minimum number of milliseconds before timeout is issued (suggested minimum: 5000) + * @throws InterruptedException raised if timeout occurs + */ + private void waitForServiceAttachedEvent(int timeout) + throws InterruptedException { + for ( int i = 0; i < (timeout / 20); i++ ) + { + + if ( (null != lastServicesAttachEvent) && (usbDevice.isConfigured() ) ) + { + if ( debug ) + System.out.println( + "waitForServiceAttachedEvent took less than " + + ((i + 1) * 20) + + " milliseconds"); + break; + } + Thread.sleep(20); //wait 20 ms before checkin for event + } + } + + private class Board + { + + // attributes + private UsbInterface iface; + private UsbPipe inPipe; + private UsbPipe outPipe; + private boolean hasRenumerated = false; + private boolean hasSubmittedAsyncIn = false; + + // Concrete instance of a UsbPipeListener interface + private UsbPipeListener inPipeListener = new UsbPipeListener() + { + public void dataEventOccurred(UsbPipeDataEvent updE) + { + } + public void errorEventOccurred(UsbPipeErrorEvent upeE) + { + if ( hasRenumerated && hasSubmittedAsyncIn ) // ok + { + } else //err + { + upeE.getUsbException().printStackTrace(); + fail ("No in pipe errors are expected at this point."); + } + } + }; + + private UsbPipeListener outPipeListener = new UsbPipeListener() + { + public void dataEventOccurred(UsbPipeDataEvent updE) + { + } + public void errorEventOccurred(UsbPipeErrorEvent upeE) + { + fail("No out pipe errors should occur during this test."); + } + }; + + // default no arg ctor not allowed + private Board() + { + } + + //ctor + public Board(UsbDevice usbDevice) + { + config(usbDevice); + } + + /** + * set up endpoints, pipes, etc .. + */ + private void config(UsbDevice usbDevice) + { + + try + { + // set the endpoints + List endpoints = null; + + /** + * select alternate setting for the programmable board (AS0 or AS1) + * @param usbDevice The UsbDevice obj + */ + if ( usbDevice.isConfigured() ) + { + iface = usbDevice.getUsbConfiguration((byte) 1).getUsbInterface((byte) 0); + + iface.claim(); + + // @P2D4 + iface = iface.getActiveSetting(); + + if ( debug ) + System.out.println("Select Alternate Setting 1"); + + endpoints = iface.getUsbEndpoints(); + + UsbEndpoint inEndpoint8 = + findEndpoint( + endpoints, + UsbConst.REQUESTTYPE_DIRECTION_IN, + UsbConst.ENDPOINT_TYPE_BULK, + 8); + + UsbEndpoint outEndpoint8 = + findEndpoint( + endpoints, + UsbConst.REQUESTTYPE_DIRECTION_OUT, + UsbConst.ENDPOINT_TYPE_BULK, + 8); + + inPipe = inEndpoint8.getUsbPipe(); + outPipe = outEndpoint8.getUsbPipe(); + inPipe.addUsbPipeListener(inPipeListener); + outPipe.addUsbPipeListener(outPipeListener); + inPipe.open(); + outPipe.open(); + } else + { + fail("device is not configured!"); + } + + } catch ( UsbClaimException uce ) + { + fail("UsbClaimException: " + uce); + } catch ( UsbDisconnectedException uDE ) // @P1A + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } catch ( UsbException ue ) + { + fail("UsbException: " + ue); + } catch ( UsbNotActiveException unae ) + { + unae.printStackTrace(); + fail("UsbNotActiveException: " + unae); + } + } + + public void testAsyncInFailure() throws Exception + { + int dataSize = 8; + byte[] inData = new byte[dataSize]; + + UsbIrp irp = inPipe.createUsbIrp(); + irp.setData(inData); + inPipe.asyncSubmit(irp); + + hasSubmittedAsyncIn = true; + + hasRenumerated = true; + submitRenumerateIrp(); + waitForServiceAttachedEvent(20000); + } + + + public void tearDown() + { + try + { + inPipe.abortAllSubmissions(); + outPipe.abortAllSubmissions(); + inPipe.close(); + outPipe.close(); + inPipe.removeUsbPipeListener(inPipeListener); + outPipe.removeUsbPipeListener(outPipeListener); + + if ( null != iface ) + { + if ( debug ) + System.out.println("releasing interface!!!!"); + iface.release(); + if ( debug ) + System.out.println("released interface!!!!"); + } + } catch ( UsbClaimException uce ) + { + fail("UsbClaimException: " + uce); + } catch ( UsbDisconnectedException uDE ) // @P1C + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } catch ( UsbException ue ) + { + fail("UsbException: " + ue); + } catch ( UsbNotActiveException unae ) + { + fail("UsbNotActiveException: " + unae); + } + } + + /** + * Performs bulk data transfer for 10 datum. + * @exception + */ + public void sendData() throws Exception { + for ( int tries = 0; tries < 10; tries++ ) + { + try + { + sendDatum(); + } catch ( Exception e ) + { + fail("The following exception was caught"); + e.printStackTrace(); + throw e; + } + } + } + + /** + * Will throw an exception if a buffer it sends is different than the one it receives. + */ + private void sendDatum() throws Exception { + byte txType = TRANSFORM_TYPE_PASSTHROUGH; + int dataSize = 8; + byte[] inData = new byte[dataSize]; + + TransmitBuffer txBuffer = new TransmitBuffer(txType, dataSize); + try // @P1A + { // @P1A + outPipe.syncSubmit(txBuffer.getOutBuffer()); // @P1C + inPipe.syncSubmit(inData); // @P1C + } catch ( UsbDisconnectedException uDE ) // @P1C + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } // @P1A + + if ( txBuffer.compareBuffers(inData) ) + { + // it's all good, display the data + if ( debug ) + { + System.out.print("Received data was: "); + for ( int i = 0; i < dataSize; i++ ) + System.out.print(inData[i] + ","); + System.out.println(); + } + } else + { + throw new Exception("received inData from pipe was != outData."); + } + } + + /** + * find endpoint that match the requirement + * @param totalEndpoints The List of End Points + * @param inDirection The direction ( 81 = in, 00 = out) + * @param inType The endpoint type ( 3 - interrupt, 2 - bulk) + * @param inSize The endpoint size (8 or 64 bytes for this programmable board) + */ + private UsbEndpoint findEndpoint( + List totalEndpoints, + int inDirection, + int inType, + int inSize) + { + boolean found = false; + for ( int j = 0; j < totalEndpoints.size(); j++ ) + { + UsbEndpoint ep = (UsbEndpoint) totalEndpoints.get(j); + int direction = ep.getDirection(); + int type = ep.getType(); + int maxPackageSize = + ep.getUsbEndpointDescriptor().wMaxPacketSize(); + int endpointAddress = + ep.getUsbEndpointDescriptor().bEndpointAddress(); + if ( (byte) (inDirection & 0x80) == (byte) direction + && inType == type + && inSize == maxPackageSize ) + { + return ep; + } + + } + if ( debug ) + System.out.println("End point NOT FOUND!!!"); + return null; + } + } + + private final UsbServicesListener servicesListener = + new UsbServicesListener() + { + + public void usbDeviceAttached(UsbServicesEvent use) + { + if ( debug ) + System.out.println("UsbServicesListener.usbDeviceAttached()"); + numServicesAttachEvents++; + assertNotNull(use); + lastServicesAttachEvent = use; + assertNotNull( + "Device was attached: ", + lastServicesAttachEvent.toString()); + } + + public void usbDeviceDetached(UsbServicesEvent use) + { + if ( debug ) + System.out.println("UsbServicesListener.usbDeviceDetached()"); + numServicesDetachEvents++; + assertNotNull(use); + lastServicesDetachEvent = use; + assertNotNull( + "Device was detached: ", + lastServicesDetachEvent.toString()); + + //testing attributes of the UsbServicesEvent + assertNotNull( + "UsbServicesEvent.getUsbServices() returned null", + use.getUsbServices()); + assertNotNull( + "UsbServicesEvent.getUsbDevice() returned null", + use.getUsbDevice()); + } + }; + + private final UsbDeviceListener deviceListener = new UsbDeviceListener() + { + + public void dataEventOccurred(UsbDeviceDataEvent uddE) + { + numDeviceDataEvents++; + // fail("Test that we get a data event"); + // assertEquals(0,numDataEvents); + assertNotNull(uddE); + lastUsbDeviceDataEvent = uddE; + if ( debug ) + System.out.println( + "UsbDeviceListener.dataEventOccurred(). uddE = " + + uddE + + "numDataEvents = " + + numDeviceDataEvents); + } + + public void errorEventOccurred(UsbDeviceErrorEvent udeE) + { + numDeviceErrorEvents++; + assertNotNull(udeE); + lastUsbDeviceErrorEvent = udeE; + if ( debug ) + System.out.println( + "UsbDeviceListener.errorEventOccurred(). uddE = " + + udeE + + "numExceptionEvents = " + + numDeviceErrorEvents); + assertNotNull( + "Should not have null UsbException on UsbDeviceErrorEvent.", + udeE.getUsbException()); + } + + public void usbDeviceDetached(UsbDeviceEvent udE) + { + numDeviceDetachEvents++; + assertNotNull(udE); + lastUsbDeviceDetachedEvent = udE; + if ( debug ) + System.out.println( + "UsbDeviceListener.usbDeviceDetached(). object = " + + udE + + "numDeviceDetachEvents = " + + numDeviceDetachEvents); + assertNotNull( + "Should not have null UsbDevice on usbDeviceEvent.", + udE.getUsbDevice()); + } + }; + + // for debugging + private boolean debug = false; + + // instances of USB classes + private UsbDevice usbDevice; + private UsbHostManager usbHostManager; + private UsbServices usbServices; + + private UsbDeviceDataEvent lastUsbDeviceDataEvent; + private UsbDeviceErrorEvent lastUsbDeviceErrorEvent; + private UsbDeviceEvent lastUsbDeviceDetachedEvent; + private UsbServicesEvent lastServicesDetachEvent, lastServicesAttachEvent; + + private static int numSubmits = 0; + private static int numDeviceDataEvents = 0; + private static int numDeviceErrorEvents = 0; + private static int numDeviceDetachEvents = 0; + private static int numServicesAttachEvents = 0; + private static int numServicesDetachEvents = 0; + + private static final short VENDOR_REQUEST_DATA_OUT = 0x00; + private static final byte VENDOR_REQUEST_RENUMERATE = (byte) 0xA8; + private static final byte TRANSFORM_TYPE_PASSTHROUGH = (byte) 0x01; + + private static final byte[] manufacturerString = + {(byte) 26, //length of descriptor + (byte) UsbConst.DESCRIPTOR_TYPE_STRING, + (byte) 'M', + (byte) 0x00, + (byte) 'a', + (byte) 0x00, + (byte) 'n', + (byte) 0x00, + (byte) 'u', + (byte) 0x00, + (byte) 'f', + (byte) 0x00, + (byte) 'a', + (byte) 0x00, + (byte) 'c', + (byte) 0x00, + (byte) 't', + (byte) 0x00, + (byte) 'u', + (byte) 0x00, + (byte) 'r', + (byte) 0x00, + (byte) 'e', + (byte) 0x00, + (byte) 'r', + (byte) 0x00}; +} diff --git a/src/test/java/javax/usb/tck/IrpTest.java b/src/test/java/javax/usb/tck/IrpTest.java new file mode 100755 index 0000000..4fbfd8a --- /dev/null +++ b/src/test/java/javax/usb/tck/IrpTest.java @@ -0,0 +1,1051 @@ +package javax.usb.tck; + +import javax.usb.*; +import junit.framework.TestCase; +import junit.framework.Assert; +import javax.usb.util.*; +import java.util.*; + +/** + * Copyright (c) 2004, International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + +/* + * Change Activity: See below. + * + * FLAG REASON RELEASE DATE WHO DESCRIPTION + * ---- -------- -------- ------ ------- ------------------------------------ + * 0000 nnnnnnn yymmdd Initial Development + * $P1 tck.rel1 040804 raulortz Support for UsbDisconnectedException + * $P2 tck.rel1 041222 raulortz Redesign TCK to create base and optional + * tests. Separate setConfig, setInterface + * and isochronous transfers as optionals. + */ + +/** +* IRP Test +* +* This test verifies the creation of IRP's and Control IRP's from the +* UsbDevice, UsbPipe, UsbDefaultIrp and UsbDefaultControlIrp classes. +*@author Vinitha Modepalle +*/ + + +@SuppressWarnings("all") +public class IrpTest extends TestCase +{ + + public void testUsbIrpwithPipeCreate() + { + + + try + { + //get Pipe + UsbPipe inPipe = usbPipecreate(); + Assert.assertTrue("input pipe is not active!!!", inPipe.isActive()); + Assert.assertFalse("input pipe isOpen() should == false): ", inPipe.isOpen()); + inPipe.open(); + Assert.assertTrue("input pipe isOpen() should == true): ", inPipe.isOpen()); + UsbIrp usbIrp = inPipe.createUsbIrp(); + Assert.assertTrue( "Create UsbInPipe Irp Failed! Got a null instance", usbIrp != null ); + + byte[] data = new byte[0]; + int offset = 0; + int length = 0; + boolean shortPacket = true; + int actualLength = 0; + boolean bIsUsbException = false; + UsbException usbException = null; + boolean bIsComplete = false; + + + performIrpTests(usbIrp,data, offset, length, shortPacket,actualLength, bIsUsbException, + usbException, bIsComplete); + + testWaitUntilComplete(usbIrp); + + inPipe.close(); + FindProgrammableDevice.getInstance().getProgrammableDevice().getUsbConfiguration((byte)1).getUsbInterface((byte)0).release(); + + } + catch ( UsbClaimException uce ) + { + fail("UsbClaimException: " + uce); + } + catch ( UsbNotActiveException unae ) + { + fail("UsbNotActiveException: " + unae); + } + catch ( UsbException ue ) + { + fail("UsbException: " + ue); + } + catch ( UsbDisconnectedException uDE ) // @P1C + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } // @P1A + catch ( Exception e ) + { + fail("Exception: " + e); + } + + + } + public void testUsbControlIrpwithPipeCreate() + { + byte[] data = new byte[0]; + int offset = 0; + int length = 0; + boolean shortPacket = true; + int actualLength = 0; + boolean bIsUsbException = false; + UsbException usbException = null; + boolean bIsComplete = false; + byte bmRequestType =UsbConst.REQUESTTYPE_DIRECTION_OUT |UsbConst.REQUESTTYPE_TYPE_STANDARD |UsbConst.REQUESTTYPE_RECIPIENT_DEVICE; + byte bRequest = UsbConst.REQUEST_GET_DESCRIPTOR; + short wValue = UsbConst.DESCRIPTOR_TYPE_DEVICE << 8; + short wIndex = 5; + + try + { + + UsbPipe inPipe = usbPipecreate(); + Assert.assertTrue("input pipe is not active!!!", inPipe.isActive()); + Assert.assertFalse("input pipe isOpen() should == false: ", inPipe.isOpen()); + inPipe.open(); + Assert.assertTrue("input pipe isOpen() should == true: ", inPipe.isOpen()); + UsbControlIrp usbControlIrp = inPipe.createUsbControlIrp(bmRequestType, bRequest, wValue, wIndex); + Assert.assertTrue( "Create UsbInPipe Control Irp Failed! Got a null instance", usbControlIrp != null ); + + verifyControlIrpValues(usbControlIrp, bmRequestType, bRequest, wValue, wIndex); + performIrpTests(usbControlIrp,data, offset, length, shortPacket,actualLength, bIsUsbException, + usbException, bIsComplete); + + + testWaitUntilComplete(usbControlIrp); + + inPipe.close(); + FindProgrammableDevice.getInstance().getProgrammableDevice().getUsbConfiguration((byte)1).getUsbInterface((byte)0).release(); + + } + catch ( UsbClaimException uce ) + { + fail("UsbClaimException: " + uce); + } + catch ( UsbNotActiveException unae ) + { + fail("UsbNotActiveException: " + unae); + } + catch ( UsbException ue ) + { + fail("UsbException: " + ue); + } + catch ( UsbDisconnectedException uDE ) // @P1C + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } // @P1A + catch ( Exception e ) + { + fail("Exception: " + e); + } + + + } + public void testUsbControlIrpwithDeviceCreate() + { + byte[] data = new byte[0]; + int offset = 0; + int length = 0; + boolean shortPacket = true; + int actualLength = 0; + boolean bIsUsbException = false; + UsbException usbException = null; + boolean bIsComplete = false; + byte bmRequestType =UsbConst.REQUESTTYPE_DIRECTION_OUT |UsbConst.REQUESTTYPE_TYPE_STANDARD |UsbConst.REQUESTTYPE_RECIPIENT_DEVICE; + byte bRequest = UsbConst.REQUEST_GET_DESCRIPTOR; + short wValue = UsbConst.DESCRIPTOR_TYPE_DEVICE << 8; + short wIndex = 5; + + + UsbDevice usbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice(); + Assert.assertTrue( "Find Programmable board Failed! Got a null instance", usbDevice != null ); + + UsbControlIrp usbControlIrp = usbDevice.createUsbControlIrp(bmRequestType,bRequest, wValue, wIndex); + Assert.assertTrue( "Create UsbDevice Control Irp Failed! Got a null instance", usbControlIrp != null ); + + + verifyControlIrpValues(usbControlIrp, bmRequestType, bRequest, wValue, wIndex); + performIrpTests(usbControlIrp,data, offset, length, shortPacket,actualLength, bIsUsbException, + usbException, bIsComplete); + + + testWaitUntilComplete(usbControlIrp); + + + + + } + public void testUsbIrpwithNoParmsConstructor() + { + /** This method is to create a UsbIrp using the + * constructor DefaultUsbIrp. + */ + byte[] data = new byte[0]; + int offset = 0; + int length = 0; + boolean shortPacket = true; + int actualLength = 0; + boolean bIsUsbException = false; + UsbException usbException = null; + boolean bIsComplete = false; + + + UsbIrp usbIrp = new DefaultUsbIrp(); + Assert.assertTrue( "Create Usb Irp Failed! Got a null instance", usbIrp != null ); + + + + performIrpTests(usbIrp,data, offset, length, shortPacket,actualLength, bIsUsbException, + usbException, bIsComplete); + testWaitUntilComplete(usbIrp); + + + } + public void testUsbIrpwithDataParmConstructor() + { + /** This method is to create a UsbIrp with Data using the + * constructor DefaultUsbIrp(data) + */ + byte[] data = {9,8,7,6,5,4,3,2,1}; + int offset = 0; + int length = 9; + boolean shortPacket = true; + int actualLength = 0; + boolean bIsUsbException = false; + UsbException usbException = null; + boolean bIsComplete = false; + + + UsbIrp usbIrp = new DefaultUsbIrp(data); + Assert.assertTrue( "Create Usb Irp with Data Failed! Got a null instance", usbIrp != null ); + + + performIrpTests(usbIrp,data, offset, length, shortPacket,actualLength, bIsUsbException, + usbException, bIsComplete); + + testWaitUntilComplete(usbIrp); + + + } + public void testUsbIrpwithAllParmsConstructor() + { + /** This method is to create a UsbIrp with variables using the + * constructor DefaultUsbIrp(data, offset, length, shortPacket) + */ + byte[] data = {9,8,7,6,5,4,3,2,1}; + int offset = 2; + int length = 4; + boolean shortPacket = true; + int actualLength = 0; + boolean bIsUsbException = false; + UsbException usbException = null; + boolean bIsComplete = false; + + + UsbIrp usbIrp = new DefaultUsbIrp(data, offset, length, shortPacket); + Assert.assertTrue( "Create Usb Irp with all variables Failed! Got a null instance", usbIrp != null ); + + performIrpTests(usbIrp,data, offset, length, shortPacket,actualLength, bIsUsbException, + usbException, bIsComplete); + + testWaitUntilComplete(usbIrp); + + + + + } + public void testUsbControlIrpwithBasicParmsContructor() + { + /**This method is to create a usbControlIrp using the + * constructor DefaultUsbControlIrp(bmRequestType, bRequest,wValue,wIndex) + */ + byte[] data = new byte[0]; + int offset = 0; + int length = 0; + boolean shortPacket = true; + int actualLength = 0; + boolean bIsUsbException = false; + UsbException usbException = null; + boolean bIsComplete = false; + byte bmRequestType =UsbConst.REQUESTTYPE_DIRECTION_OUT |UsbConst.REQUESTTYPE_TYPE_STANDARD |UsbConst.REQUESTTYPE_RECIPIENT_DEVICE; + byte bRequest = UsbConst.REQUEST_GET_DESCRIPTOR; + short wValue = UsbConst.DESCRIPTOR_TYPE_DEVICE << 8; + short wIndex = 5; + + + + UsbControlIrp usbControlIrp = new DefaultUsbControlIrp(bmRequestType, bRequest,wValue,wIndex); + Assert.assertTrue( "Create Usb Control Irp Failed! Got a null instance", usbControlIrp != null ); + verifyControlIrpValues(usbControlIrp, bmRequestType, bRequest, wValue, wIndex); + performIrpTests(usbControlIrp,data, offset, length, shortPacket,actualLength, bIsUsbException, + usbException, bIsComplete); + + testWaitUntilComplete(usbControlIrp); + + + } + public void testUsbControlIrpwithAllParmsConstructor() + { + /**This method is to create a usbControlIrp with Data using the + * constructor DefaultUsbControlIrp(data, offset, length, + *shortPacket, bmRequestType, bRequest, wValue, wIndex) + */ + + byte[] data = {9,8,7,6,5,4,3,2,1}; + int offset = 3; + int length = 2; + boolean shortPacket = true; + int actualLength = 0; + boolean bIsUsbException = false; + UsbException usbException = null; + boolean bIsComplete = false; + byte bmRequestType =UsbConst.REQUESTTYPE_DIRECTION_OUT |UsbConst.REQUESTTYPE_TYPE_STANDARD |UsbConst.REQUESTTYPE_RECIPIENT_DEVICE; + byte bRequest = UsbConst.REQUEST_GET_DESCRIPTOR; + short wValue = UsbConst.DESCRIPTOR_TYPE_DEVICE << 8; + short wIndex = 5; + + UsbControlIrp usbControlIrp = new DefaultUsbControlIrp(data, offset, length, shortPacket, bmRequestType, bRequest, wValue, wIndex); + Assert.assertTrue( "Create Usb Control Irp with Data Failed! Got a null instance", usbControlIrp != null ); + + verifyControlIrpValues(usbControlIrp, bmRequestType, bRequest, wValue, wIndex); + performIrpTests(usbControlIrp,data, offset, length, shortPacket,actualLength, bIsUsbException, + usbException, bIsComplete); + testWaitUntilComplete(usbControlIrp); + + + } + + public void performIrpTests(UsbIrp usbIrp, byte []data, int offset, int length, boolean shortPacket, int actualLength, + boolean bIsUsbException, UsbException usbException, boolean bIsComplete) + { + + + /* + * Verify IRP values against values supplied in parameters + */ + + + //verify that IRP was created with expected values + verifyUsbIrpValues(usbIrp, data, offset, length, shortPacket, actualLength, bIsUsbException, usbException, bIsComplete); + + + + /* + * Verify expected exceptions thrown when setting bad values + */ + //sample IRP values to be set and verified + byte[] samplebyteArrayData = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + int sampleOffset = 2; + int sampleLength = 6; + verifyExceptionsThrownForInvalidSetValues(usbIrp, samplebyteArrayData, sampleOffset, sampleLength); + + + + + /* + * Set various IRP values and verify that they were set properly + */ + //IRP values to be set and verified + byte[] byteArrayData = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + offset = 2; + length = 6; + + + shortPacket = false; + actualLength = 6; + bIsUsbException = true; + usbException = new UsbShortPacketException(); + bIsComplete = true; + + //set and verify correct setting of IRP values + setAndVerifyIrpParameters(usbIrp, byteArrayData, offset, length, shortPacket, actualLength, bIsUsbException, usbException, bIsComplete); + + } + + + /** + * This method creates a UsbDevice, + * UsbInterface, UsbEndpoints + * and UsbPipe . + */ + private UsbPipe usbPipecreate() + { + List endpoints = null; + UsbDevice usbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice(); + Assert.assertTrue( "Find Programmable board Failed! Got a null instance", usbDevice != null ); + if ( usbDevice.isConfigured() ) + { + UsbConfiguration usbConfiguration = usbDevice.getUsbConfiguration((byte)1); + UsbInterface iface = usbConfiguration.getUsbInterface((byte)0); + try + { + // @P2D4 + iface.claim(); + assertTrue("isClaimed() should be true): ", iface.isClaimed()); + endpoints = iface.getUsbEndpoints(); + assertFalse("no endpoints found!", 0 == endpoints.size()); + List totalep = endpoints; + UsbEndpoint inEndpoint, outEndpoint; + inEndpoint = findEndpoint(totalep, UsbConst.REQUESTTYPE_DIRECTION_IN, + UsbConst.ENDPOINT_TYPE_ISOCHRONOUS); + outEndpoint = findEndpoint(totalep,UsbConst.REQUESTTYPE_DIRECTION_OUT, + UsbConst.ENDPOINT_TYPE_ISOCHRONOUS); + + assertFalse("could not find input endpoint", null == inEndpoint); + assertFalse("could not find output endpoint", null == outEndpoint); + UsbPipe iPipe = inEndpoint.getUsbPipe(); + return iPipe; + } + catch ( UsbClaimException uce ) + { + fail("UsbClaimException: " + uce); + } + catch ( UsbNotActiveException unae ) + { + fail("UsbNotActiveException: " + unae); + } + catch ( UsbException ue ) + { + fail("UsbException: " + ue); + } + catch ( UsbDisconnectedException uDE ) // @P1A + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } // @P1A + catch ( Exception e ) + { + fail("Exception: " + e); + } + } + else + fail("device is not configured!"); + return null; + + + + } + + /** This method is called by UsbPipeCreate method + * to find an In Endpoint. + */ + private UsbEndpoint findEndpoint( List totalEndpoints, int inDirection, int inType) + { + boolean found =false; + for ( int j = 0; j < totalEndpoints.size(); j++ ) + { + UsbEndpoint ep = (UsbEndpoint)totalEndpoints.get(j); + int direction = ep.getDirection(); + int type = ep.getType(); + if ( ((byte)(inDirection) == (byte)direction) && (inType == type) ) + { + return ep; + } + + } + + fail("End point NOT FOUND!!!"); + return null; + + } + + + + private void testWaitUntilComplete(UsbIrp usbIrp) + { + + /* + * verify waitUntilComplete timeout + */ + ThreadTest tt = new ThreadTest(usbIrp); + do + tt.run(); + while ( tt.donef ==false ); + } + + + + + + + /** + *This method is to conduct verifications on a UsbControlIrp values + * @param usbControlIrp + * @param bmreqtype + * @param breq + * @param wval + * @param wind + */ + private void verifyControlIrpValues(UsbControlIrp usbControlIrp,byte bmreqtype, byte breq, short wval, short wind) + { + Assert.assertEquals("bmRequestType does not match the value specified when UsbControlIrp was created.",bmreqtype,usbControlIrp.bmRequestType()); + Assert.assertEquals("bRequest does not match the value specified when UsbControlIrp was created.",breq,usbControlIrp.bRequest()); + Assert.assertEquals("wValue does not match the value specified when UsbControlIrp was created.",wval,usbControlIrp.wValue()); + Assert.assertEquals("wIndex does not match the value specified when UsbControlIrp was created.",wind,usbControlIrp.wIndex()); + } + + /** + * The below procedure is to use the various set methods + * on a ControlIrp/Irp and verify if the variables retain their + * values after they are set. + */ + private void setAndVerifyIrpParameters(UsbIrp usbIrp, byte[] allData, int oset, int lgth, boolean spacket, int actualLength, boolean bException, UsbException usbException, + boolean bComplete) + { + //default IRP values + int defaultOffset = 0; + int defaultLength = allData.length; + boolean defaultShortPacket = true; + int defaultActualLength = 0; + boolean defaultIsUsbException = false; + UsbException defaultUsbException = null; + boolean defaultIsComplete = false; + + //set data byte array only; verify values + usbIrp.setData(allData); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + //set data byte array plus offset and length; verify values + usbIrp.setData(allData, oset, lgth); + verifyUsbIrpValues(usbIrp, allData, oset, lgth, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + //set data back to whole byte array only; verify values + usbIrp.setData(allData); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + //set data back to whole byte array only and set offset and length separately; verify values + usbIrp.setData(allData); + usbIrp.setOffset(oset); + usbIrp.setLength(lgth); + verifyUsbIrpValues(usbIrp, allData, oset, lgth, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + //set accept short packet; verify value + spacket = true; + usbIrp.setData(allData); + usbIrp.setAcceptShortPacket(spacket); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, spacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + spacket = false; + usbIrp.setAcceptShortPacket(spacket); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, spacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + spacket = defaultShortPacket; //set ShortPacket back to default for the rest of the tests + usbIrp.setAcceptShortPacket(spacket); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + //call setComplete; verify value + bComplete = true; + usbIrp.setData(allData); + usbIrp.setComplete(bComplete); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, spacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, bComplete); + + bComplete = false; + usbIrp.setData(allData); + usbIrp.setComplete(bComplete); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, bComplete); + + //call complete; verify value + usbIrp.setData(allData); + bComplete = true; + usbIrp.complete(); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, bComplete); + + usbIrp.setData(allData); + usbIrp.setComplete(defaultIsComplete); //set IsComplete back to default + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + + + //call setActualLength + usbIrp.setData(allData); + int expectedActualLength = defaultActualLength; + usbIrp.setActualLength(expectedActualLength); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, expectedActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + expectedActualLength = actualLength; + usbIrp.setActualLength(expectedActualLength); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, expectedActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + usbIrp.setActualLength(defaultActualLength); //set actual Length back to default + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + //call setUsbException; verify getUsbException and isUsbException + usbIrp.setData(allData); + UsbException expectedUsbException = defaultUsbException; + boolean expectedIsUsbException = defaultIsUsbException; + usbIrp.setUsbException(expectedUsbException); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, expectedIsUsbException, + expectedUsbException, defaultIsComplete); + + expectedUsbException = usbException; + expectedIsUsbException = bException; + usbIrp.setUsbException(expectedUsbException); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, expectedIsUsbException, + expectedUsbException, defaultIsComplete); + + usbIrp.setUsbException(defaultUsbException); + verifyUsbIrpValues(usbIrp, allData, defaultOffset, defaultLength, defaultShortPacket, defaultActualLength, defaultIsUsbException, + defaultUsbException, defaultIsComplete); + + } + /** + * Method verifies proper exceptions are thrown when setting invalid data in IRP + */ + private void verifyExceptionsThrownForInvalidSetValues(UsbIrp usbIrp, byte[] allData, int oset, int lgth) + { + int negLength = -1; + int negOffset = -1; + byte[] nullByteArray = null; + boolean expectedExceptionReceived = false; + + //null byte array in setData, offset, length + try + { + usbIrp.setData(nullByteArray, oset, lgth); + expectedExceptionReceived = false; + } + catch ( java.lang.IllegalArgumentException e ) + { + expectedExceptionReceived = true; + } + catch ( Exception e ) + { + expectedExceptionReceived = false; + } + Assert.assertTrue("Expected illegal argument exception (1) not received.", expectedExceptionReceived); + expectedExceptionReceived = false; + + //neg offset in setData, offset, length + try + { + usbIrp.setData(allData, negOffset, lgth); + expectedExceptionReceived = false; + } + catch ( java.lang.IllegalArgumentException e ) + { + expectedExceptionReceived = true; + } + catch ( Exception e ) + { + expectedExceptionReceived = false; + } + Assert.assertTrue("Expected illegal argument exception (1) not received.", expectedExceptionReceived); + expectedExceptionReceived = false; + + //neg length in setData, offset, length + try + { + usbIrp.setData(allData, oset, negLength); + expectedExceptionReceived = false; + } + catch ( java.lang.IllegalArgumentException e ) + { + expectedExceptionReceived = true; + } + catch ( Exception e ) + { + expectedExceptionReceived = false; + } + Assert.assertTrue("Expected illegal argument exception (2) not received.", expectedExceptionReceived); + expectedExceptionReceived = false; + + + //null byte array in setData + try + { + usbIrp.setData(nullByteArray); + expectedExceptionReceived = false; + } + catch ( java.lang.IllegalArgumentException e ) + { + expectedExceptionReceived = true; + } + catch ( Exception e ) + { + expectedExceptionReceived = false; + } + Assert.assertTrue("Expected illegal argument exception (3) not received.", expectedExceptionReceived); + expectedExceptionReceived = false; + + + //neg Length in setLength + try + { + usbIrp.setData(allData); + usbIrp.setLength(negLength); + expectedExceptionReceived = false; + } + catch ( java.lang.IllegalArgumentException e ) + { + expectedExceptionReceived = true; + } + catch ( Exception e ) + { + expectedExceptionReceived = false; + } + Assert.assertTrue("Expected illegal argument exception (4) not received.", expectedExceptionReceived); + expectedExceptionReceived = false; + + + //neg Offset in setOffset + try + { + usbIrp.setData(allData); + usbIrp.setOffset(negOffset); + expectedExceptionReceived = false; + } + catch ( java.lang.IllegalArgumentException e ) + { + expectedExceptionReceived = true; + } + catch ( Exception e ) + { + expectedExceptionReceived = false; + } + Assert.assertTrue("Expected illegal argument exception (5) not received.", expectedExceptionReceived); + expectedExceptionReceived = false; + + //neg ActualLength in setActualLength + try + { + usbIrp.setData(allData); + usbIrp.setActualLength(negLength); + expectedExceptionReceived = false; + } + catch ( java.lang.IllegalArgumentException e ) + { + expectedExceptionReceived = true; + } + catch ( Exception e ) + { + expectedExceptionReceived = false; + } + Assert.assertTrue("Expected illegal argument exception (5) not received.", expectedExceptionReceived); + expectedExceptionReceived = false; + + } + + + /* + * This method is to compare the data + * @param usbControlIrp or usbIrp + * @ param dat2. + */ + private boolean comparebytearray(UsbIrp usbIrp, byte[] dat2) + { + byte[] dat1 ; + dat1 = usbIrp.getData() ; + + if ( dat1.length != dat2.length ) + { + return false; + } + else + { + for ( int i = 0;i 6000 ) + { + fail("Timeout value exceeded"); + } + else + { + done = true; + } + } + private boolean done = false; + private long st, et, acttime; + private UsbIrp usbIrp; + } + } + +} diff --git a/src/test/java/javax/usb/tck/SignatureTest.java b/src/test/java/javax/usb/tck/SignatureTest.java new file mode 100755 index 0000000..1440ef2 --- /dev/null +++ b/src/test/java/javax/usb/tck/SignatureTest.java @@ -0,0 +1,43 @@ +package javax.usb.tck; + +/** + * Copyright (c) 2004, International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + +import javax.usb.tck.sigtest.*; +import java.io.*; +import junit.framework.*; + +/** + * This is the API signature test for the entire javax.usb.* package. + * This test verifies the existence of all expected public classes and + * interfaces. In those public classes and interfaces it verifies the + * existence, correct modifiers, arguments, and throws clauses of + * public constructors and methods. It also verifies the existence and + * correct modifiers of public fields. + * + * @author Bob Rossi + */ +@SuppressWarnings("all") +public class SignatureTest extends TestCase +{ + /** + * Test the signatures of all the classes and methods for compliance + * with the Javax.usb specification. + */ + public void testSignatures() throws IOException + { + String javaxusbtck_home = + System.getProperty("javaxusbtck_home", System.getProperty("user.dir")); + File dir = new File(javaxusbtck_home, "src/test/resources"); + File file = new File(dir, "javax.usb-1.0.sig"); + String result = ProjectDesc.compareProjectFile(file); + + Assert.assertNull(result, result); + } +} \ No newline at end of file diff --git a/src/test/java/javax/usb/tck/TransmitBuffer.java b/src/test/java/javax/usb/tck/TransmitBuffer.java new file mode 100755 index 0000000..93bfe44 --- /dev/null +++ b/src/test/java/javax/usb/tck/TransmitBuffer.java @@ -0,0 +1,240 @@ +package javax.usb.tck; + +/* + * Copyright (c) IBM Corporation, 2004 + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License. + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + * + */ + + +/** + * This is the TransmitBuffer class to create a OUT transmitt buffer based on + * parameters supply to the constructor. + * It will create an expected buffer to be received on an IN buffer also + * based on the parameters supplied to the constructor. + * @author Thanh Ngo + */ + +@SuppressWarnings("all") +public class TransmitBuffer extends Object +{ + + /** + * Constructor. + * @param ucTransformType The Data manipilation: + * 1 - Pass through + * 2 - Invert every bit starting with the second bit + * 3 - Invert every other bit (invert odd bits assuming bit numbering begins at 0) + * 4 - Drop every third byte (ex. OUT - b1, b2, b3, b4, b5, b6 IN - b1, b2, b4, b5) + * + * @param uilRPLength The length of the data byte in + * @exception IllegalArgumentException If the offset, length or data is invalid. + */ + protected TransmitBuffer(byte ucTransformType, int uilRPLength) + { + //System.out.println("type: " + ucTransformType + " length: " + uilRPLength); + if ( 0 > ucTransformType ) + throw new IllegalArgumentException("Type cannot be negative"); + if ( 0 == ucTransformType ) + throw new IllegalArgumentException("Type cannot be 0"); + if ( 5 < ucTransformType ) + throw new IllegalArgumentException("Valid value are 1 to 4"); + if ( 0 > uilRPLength ) + throw new IllegalArgumentException("Length cannot be negative"); + transformType = ucTransformType; + rpLength = uilRPLength; + outBuffer = new byte[rpLength]; + byte fill = 0; + for ( int i = 0; i < rpLength; i++ ) + outBuffer[i] = fill++; + outBuffer[0] = (byte)transformType; + outBuffer[1] = (byte)(rpLength / 256); + outBuffer[2] = (byte)(rpLength % 256); + outBuffer[3] = sequenceNumber; + int pos = 7; + while ( pos < rpLength ) + { + outBuffer[pos] = sequenceNumber; + pos += 8; + } + outBuffer[rpLength-1] = sequenceNumber; + if ( transformType_passthru == ucTransformType ) + { + inBuffer = new byte[rpLength]; + System.arraycopy(outBuffer, 0, inBuffer,0, inBuffer.length); + } + else if ( transformType_invert_every_bit == ucTransformType ) + { + inBuffer = new byte[rpLength]; + for ( int i = 0; i < inBuffer.length; i++ ) + inBuffer[i] = (byte)(outBuffer[i] ^ 0xff); + } + else if ( transformType_invert_every_other_bit == ucTransformType ) + { + inBuffer = new byte[rpLength]; + for ( int i = 0; i < inBuffer.length; i++ ) + inBuffer[i] = (byte)(outBuffer[i] ^ 0x55); + } + else if ( transformType_drop_every_third_byte == ucTransformType ) + { + int size = rpLength / 3; + size = rpLength - size; + inBuffer = new byte[size]; + int outIndex = 0; + int inIndex = 0; + while ( outIndex < rpLength ) + { + inBuffer[inIndex++] = outBuffer[outIndex++]; // 1st byte + if ( outIndex < rpLength ) + inBuffer[inIndex++] = outBuffer[outIndex++]; // 2nd byte + if ( outIndex < rpLength ) + outIndex++; // 3rd byte , skip + } + } + else + { + throw new IllegalArgumentException("Length exceed limit"); + } + mySequenceNumber = sequenceNumber; + sequenceNumber++; // next Transmitt buffer sequence + } + + //------------------------------------------------------------------------- + // Public methods + // + + /** compare the IN buffer expected to an IN buffer actually received + * @param in The Buffer to be compared with IN buffer + * @return true if the two buffers are the same, false otherwise. + */ + boolean compareBuffers(byte[] inData) + { + if ( inBuffer.length != inData.length ) + { + //System.out.println("-->length!!!"); + return false; + } + for ( int i = 0; i < inData.length; i++ ) + { + if ( inBuffer[i] != inData[i] ) + { + //System.out.println("-->False!!! i= " + i + " in: " + inBuffer[i] + " out: " + inData[i]); + return false; + } + } + return true; + } + + /** compare the OUT buffer to a buffer supplied as a parameter + * @param outData The buffer to compare with the OUT buffer + * @return true if the two buffers are the same, false otherwise + */ + protected boolean compareToOUTBuffer(byte[] outData) + { + if ( outBuffer.length != outData.length ) + return false; + for ( int i = 0; i < outData.length; i++ ) + { + if ( outBuffer[i] != outData[i] ) + { + return false; + } + } + return true; + + } + + /** compare two byte arrays supplied as a parameter. Length of byte arrays is expected to be equal. + * @param buffer1 First byte array. + * @param buffer2 Second byte array. + * @return true if the two byte arrays are the same, false otherwise + */ + protected static boolean compareTwoByteArrays(byte[] buffer1, byte[] buffer2) + { + if ( buffer1.length != buffer2.length ) + return false; + for ( int i = 0; i < buffer1.length; i++ ) + { + if ( buffer1[i] != buffer2[i] ) + { + return false; + } + } + return true; + + } + + /** Compares first "length" number of bytes of two arrays. + * The caller must ensure that the length does not exceed the + * length of either buffer1 or buffer2. + * @param buffer1 First byte array. + * @param buffer2 Second byte array. + * @param length Number of bytes to compare + * @return true if the two byte arrays are the same over the range specified, false otherwise + */ + protected static boolean compareTwoByteArraysForSpecifiedLength(byte[] buffer1, int offset1, byte[] buffer2, int offset2,int length) + { + + for ( int i = 0; i < length; i++ ) + { + if ( buffer1[i + offset1] != buffer2[i + offset2] ) + { + return false; + } + } + return true; + + } + + + + /** + * Get the IN buffer. + * @return The IN data buffer. + */ + protected byte[] getInBuffer() + { + return inBuffer; + } + + /** + * Get the OUT buffer. + * @return The OUT data buffer. + */ + protected byte[] getOutBuffer() + { + return outBuffer; + } + + /** + * Get the sequenceNumber. + * @return The sequenceNumber variable. + */ + protected int getsequenceNumber() + { + return mySequenceNumber; + } + + + + + //------------------------------------------------------------------------- + // Instance variables + // + private byte transformType; + private int rpLength; + private byte[] inBuffer = new byte[0]; + private byte[] outBuffer = new byte[0]; + private static byte sequenceNumber = 0; + private byte mySequenceNumber; + private static final byte transformType_passthru = 1; + private static final byte transformType_invert_every_bit = 2; + private static final byte transformType_invert_every_other_bit = 3; + private static final byte transformType_drop_every_third_byte = 4; + + +} diff --git a/src/test/java/javax/usb/tck/UsbInterfacePolicyTest.java b/src/test/java/javax/usb/tck/UsbInterfacePolicyTest.java new file mode 100755 index 0000000..3f6790c --- /dev/null +++ b/src/test/java/javax/usb/tck/UsbInterfacePolicyTest.java @@ -0,0 +1,335 @@ +package javax.usb.tck; + +/** + * Copyright (c) 2004, International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + +/* + * Change Activity: See below. + * + * FLAG REASON RELEASE DATE WHO DESCRIPTION + * ---- -------- -------- ------ -------- ------------------------------------ + * 0000 nnnnnnn yymmdd Initial Development + * $P1 tck.rel1 040804 raulortz Support for UsbDisconnectedException + * $P2 tck.rel1 041222 raulortz Redesign TCK to create base and optional + * tests. Separate setConfig, setInterface + * and isochronous transfers as optionals. + */ + +import junit.framework.TestCase; +import java.util.*; + +import javax.usb.*; + +/** + * Usb Interface Policy Test + *

+ * Goal: This test will use a new implementation of the UsbInterfacePolicy + * Interface to test the that the UsbInterfacePolicy is being used correctly. + * + * @author Dale Heeks + */ +@SuppressWarnings("all") +public class UsbInterfacePolicyTest extends TestCase +{ + + public UsbInterfacePolicyTest(String name) + { + + super(name); + } + + protected void setUp() throws Exception { + usbDevice = programmableDevice.getProgrammableDevice(); + assertTrue( "Find Programmable board Failed! Got a null instance", usbDevice != null ); + assertTrue("The usbDevice is not confuigured", usbDevice.isConfigured()); + usbConfiguration = usbDevice.getUsbConfiguration((byte)1); + policy1 = new InterfacePolicyImp(); + } + + protected void tearDown() throws Exception { + + } + + + /*ForceClaim policy test cases */ + /** + * Test forceClaim policy with a false return + *

+ * This test case will set the ForceClaim policy + * to false and then call claim to ensure that the + * ForceClaim policy method is invoked inside + * the UsbInterfacePolicyImp class + *

+ * NOTE: This will not check if the claim isn't forced + * because some implemetations + * will not be able to do a force claim and some will, + * + */ + + public void testIfaceForceClaimFalse() + { + + + policy1.setForceClaimPolicy(false); + + assertFalse("Force Claim tag isn't reset, this is probably a TCK defect", + policy1.getForceClaimTag() ); + + assertTrue("Can't claim Interface, this is probably a defect with your implementation", + claimIface(usbConfiguration.getUsbInterface((byte)0), policy1)); + // @P2D4 + //reset the claim tag + policy1.setForceClaimTag(false); + + releaseIface(usbConfiguration.getUsbInterface((byte)0), null); + + } + + /** + * Test forceClaim policy with a true return + *

+ * This test case will set the ForceClaim policy + * to true and then call claim to ensure that the + * ForceClaim policy method is invoked inside + * the UsbInterfacePolicyImp class + *

+ * NOTE: This will not check if the claim is forced + * because some implemetations + * will not be able to do a force claim and some will. + * + */ + public void testIfaceForceClaimTrue() + { + + policy1.setForceClaimPolicy(true); + + assertFalse("Force Claim tag isn't reset, this is probably a TCK defect", + policy1.getForceClaimTag() ); + + assertTrue("Can't claim Interface, this is probably a defect with your implementation", + claimIface(usbConfiguration.getUsbInterface((byte)0), policy1)); + // @P2D4 + //Reset the force claim tag + policy1.setForceClaimTag(false); + + releaseIface(usbConfiguration.getUsbInterface((byte)0), null); + + } + + + //This method will take an interface and policy and call the appropriate + //claim method, this method should only be used within this test + private boolean claimIface(UsbInterface iface, + UsbInterfacePolicy ifacePolicy) + { + try + { + if ( ifacePolicy == null ) + iface.claim(); + else + iface.claim(ifacePolicy); + } catch ( UsbClaimException uce ) + { + return false; + } catch ( UsbNotActiveException unae ) + { + fail("UsbNotActiveException: " + unae); + } catch ( UsbException ue ) + { + fail("UsbException: " + ue); + } catch ( UsbDisconnectedException uDE ) // @P1C + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } // @P1A + return true; + } + + + //This method takes a interface and key and make the appropriate + //interface method call + private int releaseIface(UsbInterface iface, + Object key) + { + try + { + iface.release(); + } catch ( UsbClaimException uce ) + { + return notClaimed; + } catch ( UsbNotActiveException unae ) + { + fail("UsbNotActiveException: " + unae); + } catch ( UsbException ue ) + { + fail("UsbException: " + ue); + } catch ( UsbDisconnectedException uDE ) // @P1C + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } // @P1A + return released; + } + + //Method that takes an interface and returns it's first pipe + private UsbPipe getUsbPipe(UsbInterface iface) + { + List endpoints = iface.getUsbEndpoints(); + UsbEndpoint e1 = (UsbEndpoint)endpoints.get(0); + return e1.getUsbPipe(); + } + + //Method that will call the appropriate open method given + //a pipe and a key + private int openPipe(UsbPipe pipe, Object key) + { + try + { + pipe.open(); + } catch ( UsbNotActiveException unae ) + { + fail("UsbNotActiveException: " + unae); + } catch ( UsbNotClaimedException unae ) + { + fail("UsbNotActiveException: " + unae); + } catch ( UsbException ue ) + { + fail("UsbException: " + ue); + } catch ( UsbDisconnectedException uDE ) // @P1C + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } // @P1A + + return opened; + } + + //method to close a pipe, this is for test case clean up + private boolean closePipe(UsbPipe pipe) + { + try + { + pipe.close(); + } catch ( UsbException ue ) + { + fail("UsbException: " + ue); + } catch ( UsbNotActiveException unae ) + { + fail("UsbNotOpenedException: " + unae); + } catch ( UsbDisconnectedException uDE ) // @P1C + { // @P1A + fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A + } // @P1A + return true; + } + + + private FindProgrammableDevice programmableDevice = FindProgrammableDevice.getInstance(); + private InterfacePolicyImp policy1 = null; + private UsbConfiguration usbConfiguration = null; + private UsbDevice usbDevice = null; + private UsbInterface iface = null; + private UsbEndpoint Endpoint; + private static final boolean debug = true; + private static final int released = 1111; + private static final int opened = 2222; + private static final int notClaimed = 4444; + + + /* + ************************************************************************* + ********************Test Interface Policy Implemetation class************ + *************************************************************************/ + /** + * Copyright (c) 2004, International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + + /** + * Name of class -- Usb Interface Policy test implementation + *

+ * This class is an implementation of the UsbInterfacePolicy, this + * should only be used for the Javax.usb tck. + * + * @author Dale Heeks + */ + + private class InterfacePolicyImp implements UsbInterfacePolicy + { + + /**Constuctor + * + *

+ * Default constructor, sets everything in this policy to true, + * which is also the same as the default policy + * + * + */ + public InterfacePolicyImp () + { + forceClaimPolicy = true; + forceClaimTag = false; + } + + /**Method that should be called from a claim using + * the non default interface policy + * + *@param arg0 The current UsbInterface that is being claimed + * + *@return boolean Whether to allow an interface to attempt + *a force claim + */ + public boolean forceClaim(UsbInterface arg0) + { + forceClaimTag = true; + return forceClaimPolicy; + } + + /**Allows a user to dynamically set the force claim policy + * + * @param forceClaimIn The new force claim policy + */ + public void setForceClaimPolicy(boolean forceClaimIn) + { + forceClaimPolicy = forceClaimIn; + } + + /**Allows a user to dynamically set the force claim tag + * + *

+ * The force claim tag checks to see if the force claim policy has been called + * + * @param forceClaimTagIn The new force claim tag + */ + public void setForceClaimTag(boolean forceClaimTagIn) + { + forceClaimTag = forceClaimTagIn; + } + + /**Allows a user to check the force claim tag + * + *

+ * The force claim tag checks to see if the force claim policy has been called + * + * @return boolean The force claim tag + */ + public boolean getForceClaimTag() + { + return forceClaimTag; + } + + private boolean forceClaimPolicy; + private boolean forceClaimTag; + + + + } + /*************************************************************************/ +} diff --git a/src/test/java/javax/usb/tck/VerifyIrpMethods.java b/src/test/java/javax/usb/tck/VerifyIrpMethods.java new file mode 100755 index 0000000..48ca3f0 --- /dev/null +++ b/src/test/java/javax/usb/tck/VerifyIrpMethods.java @@ -0,0 +1,413 @@ +/** + * Copyright (c) 2004, International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ +package javax.usb.tck; + +import junit.framework.Assert; + +import java.util.*; + +import javax.usb.*; +import javax.usb.event.*; + +/** + * VerifyIrpMethods + *

+ * Helper functions to verify IRPs and Events + * + * @author Leslie Blair + */ +@SuppressWarnings("all") +public class VerifyIrpMethods +{ + private static void verifyDataEventValuesAndUsbIrpValuesWithExpectedValues(UsbIrp usbIrpSubmitted, + EventObject usbEvent, + byte[] expectedData) + { + printDebug("Entering verifyDataEventValuesAndUsbIrpValuesWithExpectedValues"); + + UsbIrp usbEventIrp = null; + byte[] usbEventData = null; + + //Verify usbDataEvent is not null + Assert.assertNotNull("Event must not be null.", usbEvent); + + //Get the IRP from the Data event + if ( UsbDeviceDataEvent.class == usbEvent.getClass() ) + { + usbEventIrp = (((UsbDeviceDataEvent) usbEvent).getUsbControlIrp()); + usbEventData = (((UsbDeviceDataEvent) usbEvent).getData()); + Assert.assertNotNull("UsbDevice from Device event is unexpectedly null.",((UsbDeviceEvent)usbEvent).getUsbDevice()); + + } + else if ( UsbPipeDataEvent.class == usbEvent.getClass() ) + { + usbEventIrp = (((UsbPipeDataEvent) usbEvent).getUsbIrp()); + usbEventData = (((UsbPipeDataEvent) usbEvent).getData()); + } + + if ( usbIrpSubmitted != null ) + { + + /* + * Verify submitted IRP + */ + Assert.assertTrue("isComplete() not true.",usbIrpSubmitted.isComplete()); + + //Verify ActualLength as expected + Assert.assertEquals("ActualLength not expected value.", + expectedData.length, usbIrpSubmitted.getActualLength()); + + //Verify data in IRP + Assert.assertTrue("IRP data not as expected", TransmitBuffer.compareTwoByteArraysForSpecifiedLength( + usbIrpSubmitted.getData(),usbIrpSubmitted.getOffset(), + expectedData, 0, expectedData.length)); + + //Verify no exception + Assert.assertFalse("isUsbException() not false.", usbIrpSubmitted.isUsbException()); + Assert.assertNull("getUsbException() not null.", usbIrpSubmitted.getUsbException()); + + /* + * Verify data event IRP and data + */ + //Verify the IRP returned in data event is the same as IRP submitted + Assert.assertSame("The submitted Irp and the usbIrp returned " + + "in event are not the same object", + usbIrpSubmitted, usbEventIrp); + } + else + { + printDebug("No IRP submitted for verification. Test must by sync byte []."); + } + + //Verify data in the IRP from data event (This is really covered in assert that submitted IRP and event IRP are the same.) + Assert.assertTrue("Data from device data event IRP not expected data.", + TransmitBuffer.compareTwoByteArraysForSpecifiedLength(usbEventIrp.getData(), + usbEventIrp.getOffset(), + expectedData, 0, + expectedData.length)); + + //Note that the getData() from the DeviceDataEvent returns only the actual data transferred as opposed to the + //getData() for the DeviceDataEvent IRP which contains the entire byte[] originally set in the IRP. + //Therefore, the usbDeviceDataEvent.getData() should be an exact match for the expectedData. + Assert.assertTrue("Data from UsbDeviceDataEvent not expected data.", + TransmitBuffer.compareTwoByteArraysForSpecifiedLength(usbEventData, 0, + expectedData, 0, expectedData.length)); + + printDebug("Leaving verifyDataEventValuesAndUsbIrpValuesWithExpectedValues"); + }; + + + private static void verifyErrorEventValuesAndUsbIrpValuesWithExpectedValues(UsbIrp usbIrpSubmitted, + EventObject usbEvent, + Exception expectedException) + { + printDebug("Entering verifyErrorEventValuesAndUsbIrpValuesWithExpectedValues"); + + //Verify usbEvent is not null + Assert.assertNotNull("Event must not be null.", usbEvent); + + // Verify submitted IRP + Assert.assertTrue("isComplete() not true.",usbIrpSubmitted.isComplete()); + + //Verify exception + Assert.assertTrue("isUsbException() not true.", usbIrpSubmitted.isUsbException()); + Assert.assertNotNull("getUsbException() is null.", usbIrpSubmitted.getUsbException()); + + //Verify expected exception + if ( UsbDeviceErrorEvent.class == usbEvent.getClass() ) + { + if ( (((UsbDeviceErrorEvent)usbEvent).getUsbException()).getClass() != expectedException.getClass() ) + { + Assert.fail("\nExpected exception class is " + expectedException.getClass().toString() + + "\nReceived exception class is " + ((UsbDeviceErrorEvent)usbEvent).getUsbException().getClass().toString() ); + } + Assert.assertNotNull("UsbDevice from Device event is unexpectedly null.",((UsbDeviceEvent)usbEvent).getUsbDevice()); + } + else if ( UsbPipeErrorEvent.class == usbEvent.getClass() ) + { + if ( (((UsbPipeErrorEvent)usbEvent).getUsbException()).getClass() != expectedException.getClass() ) + { + Assert.fail("\nExpected exception class is " + expectedException.getClass().toString() + + "\nReceived exception class is " + ((UsbPipeErrorEvent)usbEvent).getUsbException().getClass().toString() ); + } + } + +/*Possible TODO -- if getUsb(Control)Irp method is added to DeviceErrorEvent and PipeErrorEvent classes + * then the following code needs to be added to this method. At that point you may consider combining this method with the + * "verifyDataEventValuesAndUsbIrpValuesWithExpectedValues" method because there will be more common code. + * + + UsbIrp usbEventIrp = null; + byte[] usbEventData = null; + //Get the IRP from the event + if ( UsbDeviceErrorEvent.class == usbEvent.getClass()) + { + usbEventIrp = (((UsbDeviceErrorEvent) usbEvent).getUsbControlIrp()); + usbEventData = (((UsbDeviceErrorEvent) usbEvent).getData()); + } + else if (UsbPipeErrorEvent.class == usbEvent.getClass()) + { + usbEventIrp = (((UsbPipeErrorEvent) usbEvent).getUsbIrp()); + usbEventData = (((UsbPipeErrorEvent) usbEvent).getData()); + } + + + + //Verify the IRP returned in event is the same as IRP submitted + Assert.assertSame("The submitted usbControlIrp and the usbControlIrp returned " + + "in event are not the same object", + usbIrpSubmitted, usbEventIrp); + //Assert.assertTrue("The submitted usbControlIrp and the usbControlIrp returned " + + // "in UsbDeviceDataEvent are not equal", + // usbIrpSubmitted.equals(usbEventIrp)); + +*/ + printDebug("Leaving verifyErrorEventValuesAndUsbIrpValuesWithExpectedValues"); + }; + + private static void validateExpectations(byte [] expectedData, Exception expectedException) throws IllegalArgumentException + { + printDebug("Entering validateExpectations"); + + /* + * The verification to be performed is based on which value, expectedData or expectedException, is set. + * One, and only one, of these values must be set. + */ + if ( (expectedData != null) && (expectedException != null) ) + { + throw new IllegalArgumentException("Both expectedData and expectedException are non-null. If a data event " + + "is expected, expectedData should be set. If an error event is expected, expectedError should be set. " + + "Both values should not be set"); + } + else if ( (expectedData == null) && (expectedException == null) ) + { + throw new IllegalArgumentException("Both expectedData and expectedException are null. If a data event " + + "is expected, expectedData should be set. If an error event is expected, expectedError should be set. " + + "One of the values must be set."); + } + + printDebug("Leaving validateExpectations"); + } + + /** + * verifyUsbIrpAfterEvent(..) verifies a UsbIrp against expected values + * @param usbIrpSubmitted IRP to verify + * @param usbEvent UsbDevice(or Pipe) Data or Error Event + * @param expectedData expected byte[] in IRP (must be null if expected exception not null) + * @param expectedActualLength actual length of data transmitted + * @param expectedException expected exception (must be null if expected data is not null) + * @param expectedAcceptShortPacket expected value of acceptShortPacket + * @param verifyAcceptShortPacket Specifies whether to verify acceptShortPacket + * @param expectedOffset expected offset for byte [] in IRP + * @param expectedLength expected length for byte [] in IRP + * @param expectedbmRequestType expected bmRequestType in control IRP + * @param expectedbRequest expected bRequest in control IRP + * @param expectedwValue expected wValue in control IRP + * @param expectedwIndex expected wIndex in control IRP + */ + protected static void verifyUsbControlIrpAfterEvent(UsbControlIrp usbControlIrpSubmitted, + EventObject usbEvent, + byte[] expectedData, + int expectedActualLength, + Exception expectedException, + boolean expectedAcceptShortPacket, + boolean verifyAcceptShortPacket, + int expectedOffset, + int expectedLength, + byte expectedbmRequestType, + byte expectedbRequest, + short expectedwValue, + short expectedwIndex) + { + printDebug("Entering verifyUsbControlIrpAfterEvent"); + + //Verify UsbControlIrp values + Assert.assertEquals("bmRequestType not expected value.", + expectedbmRequestType, usbControlIrpSubmitted.bmRequestType()); + Assert.assertEquals("bRequest not expected value.", + expectedbRequest, usbControlIrpSubmitted.bRequest()); + Assert.assertEquals("wValue not expected value.", + expectedwValue, usbControlIrpSubmitted.wValue()); + Assert.assertEquals("wIndex not expected value.", + expectedwIndex, usbControlIrpSubmitted.wIndex()); + + //verify UsbIrp values + VerifyIrpMethods.verifyUsbIrpAfterEvent(usbControlIrpSubmitted, + usbEvent, + expectedData, + expectedActualLength, + expectedException, + expectedAcceptShortPacket, + verifyAcceptShortPacket, + expectedOffset, + expectedLength); + + printDebug("Leaving verifyUsbControlIrpAfterEvent"); + }; + + /** + * verifyUsbIrpAfterEvent(..) verifies a UsbIrp against expected values + * @param usbIrpSubmitted IRP to verify + * @param usbEvent UsbDevice(or Pipe) Data or Error Event + * @param expectedData expected byte[] in IRP (must be null if expected exception not null) + * @param expectedActualLength actual length of data transmitted + * @param expectedException expected exception (must be null if expected data is not null) + * @param expectedAcceptShortPacket expected value of acceptShortPacket + * @param verifyAcceptShortPacket Specifies whether to verify acceptShortPacket + * @param expectedOffset expected offset for byte [] in IRP + * @param expectedLength expected length for byte [] in IRP + */ + protected static void verifyUsbIrpAfterEvent(UsbIrp usbIrpSubmitted, + EventObject usbEvent, + byte[] expectedData, + int expectedActualLength, + Exception expectedException, + boolean expectedAcceptShortPacket, + boolean verifyAcceptShortPacket, + int expectedOffset, + int expectedLength) + { + printDebug("Entering verifyUsbIrpAfterEvent"); + + try + { + validateExpectations(expectedData, expectedException); + } + catch ( IllegalArgumentException iaE ) + { + Assert.fail("Illegal Arguments supplied to verifyUsbIrpAfterEvent(...) method"); + } + + /* + * Verify values in UsbIrp that should be unchanged after submission. + * This verification is valid for a data event or error event + * + * Verify AcceptShortPacket, Offset, and Length not changed + */ + if ( usbIrpSubmitted != null ) + { + Assert.assertEquals("Offset changed after IRP submitted.", expectedOffset, usbIrpSubmitted.getOffset()); + Assert.assertEquals("Length changed after IRP submitted.", expectedLength, usbIrpSubmitted.getLength()); + + + + if ( verifyAcceptShortPacket ) + { + Assert.assertEquals("AcceptShortPacket changed after IRP submitted.", + expectedAcceptShortPacket, usbIrpSubmitted.getAcceptShortPacket()); + } + } + else + { + printDebug("No IRP submitted for verification. Test must by sync byte []."); + } + + + /* + * Data event verification + */ + if ( expectedData != null ) + { + //Verify expected values in UsbIrp after data event + VerifyIrpMethods.verifyDataEventValuesAndUsbIrpValuesWithExpectedValues(usbIrpSubmitted, + usbEvent, + expectedData); + } + /* + * Error event verification + */ + else + { + //Verify expected values in UsbIrp after error event + VerifyIrpMethods.verifyErrorEventValuesAndUsbIrpValuesWithExpectedValues(usbIrpSubmitted, + usbEvent, + expectedException); + } + printDebug("Leaving verifyUsbIrpAfterEvent"); + }; + + + /** + * verifyRequestTest(..) verifies a UsbIrp against expected values + * @param usbIrpSubmitted IRP to verify + * @param expectedbmRequestType expected bmRequestType in control IRP + * @param expectedbRequest expected bRequest in control IRP + * @param expectedwValue expected wValue in control IRP + * @param expectedwIndex expected wIndex in control IRP + */ + protected static void verifyRequestTest(UsbControlIrp usbControlIrpSubmitted, + byte expectedbmRequestType, + byte expectedbRequest, + short expectedwValue, + short expectedwIndex) + { + printDebug("Entering verifyRequestTest"); + + //Verify UsbControlIrp values + Assert.assertEquals("bmRequestType not expected value.", + expectedbmRequestType, usbControlIrpSubmitted.bmRequestType()); + Assert.assertEquals("bRequest not expected value.", + expectedbRequest, usbControlIrpSubmitted.bRequest()); + Assert.assertEquals("wValue not expected value.", + expectedwValue, usbControlIrpSubmitted.wValue()); + Assert.assertEquals("wIndex not expected value.", + expectedwIndex, usbControlIrpSubmitted.wIndex()); + + } + + /** + * verifyRequestTestData(..) verifies a UsbIrp against expected values + * @param usbIrpSubmitted IRP to verify + * @param expectedbmRequestType expected bmRequestType in control IRP + * @param expectedbRequest expected bRequest in control IRP + * @param expectedwValue expected wValue in control IRP + * @param expectedwIndex expected wIndex in control IRP + * @param expectedLength expected length for byte [] in IRP + * @param expectedData expected byte[] in IRP (must be null if expected exception not null) + */ + protected static void verifyRequestTestData(UsbControlIrp usbControlIrpSubmitted, + byte expectedbmRequestType, + byte expectedbRequest, + short expectedwValue, + short expectedwIndex, + int expectedLength) + { + byte[] buffer; + printDebug("Entering verifyRequestTestData"); + + //Verify UsbControlIrp values + Assert.assertEquals("bmRequestType not expected value.", + expectedbmRequestType, usbControlIrpSubmitted.bmRequestType()); + Assert.assertEquals("bRequest not expected value.", + expectedbRequest, usbControlIrpSubmitted.bRequest()); + Assert.assertEquals("wValue not expected value.", + expectedwValue, usbControlIrpSubmitted.wValue()); + Assert.assertEquals("wIndex not expected value.", + expectedwIndex, usbControlIrpSubmitted.wIndex()); + Assert.assertEquals("Length changed after IRP submitted.", + expectedLength, usbControlIrpSubmitted.getLength()); + + } + + + /** + * printDebug method will print the specified string if "debug" is true. + * Useful function for debugging + * @param infoString + */ + protected static void printDebug(String infoString) + { + if ( debug ) + { + System.out.println(infoString); + } + } + private static boolean debug = false; + //private static boolean debug = true; +} diff --git a/src/test/java/javax/usb/tck/sigtest/ClassDesc.java b/src/test/java/javax/usb/tck/sigtest/ClassDesc.java new file mode 100755 index 0000000..84db706 --- /dev/null +++ b/src/test/java/javax/usb/tck/sigtest/ClassDesc.java @@ -0,0 +1,319 @@ +package javax.usb.tck.sigtest; + +/** + * Copyright (c) 2003,2004 International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; + +/** + * This class stores all the information needed to compare the signature + * of one class to another. + * + * @author Matthew J. Duftler + */ +@SuppressWarnings("all") +public class ClassDesc extends MemberDesc +{ + private String superClassName = null; + private List interfaceNames = new Vector(); + private List constructorDescs = new Vector(); + private List methodDescs = new Vector(); + + public ClassDesc(String name, int modifiers) + { + super(name, modifiers); + } + + public void setSuperClassName(String superClassName) + { + this.superClassName = superClassName; + } + + public String getSuperClassName() + { + return superClassName; + } + + public void setInterfaceNames(List interfaceNames) + { + this.interfaceNames = interfaceNames; + } + + public List getInterfaceNames() + { + return interfaceNames; + } + + public void addConstructorDesc(MethodDesc constructorDesc) + { + constructorDescs.add(constructorDesc); + } + + public void setConstructorDescs(List constructorDescs) + { + this.constructorDescs = constructorDescs; + } + + public List getConstructorDescs() + { + return constructorDescs; + } + + public void addMethodDesc(MethodDesc methodDesc) + { + methodDescs.add(methodDesc); + } + + public void setMethodDescs(List methodDescs) + { + this.methodDescs = methodDescs; + } + + public List getMethodDescs() + { + return methodDescs; + } + + public static ClassDesc parseClassDesc(BufferedReader classDescReader) + throws IOException + { + String classDescStr = classDescReader.readLine(); + List tokens = SigTestUtils.stringToList(classDescStr, " "); + int size = tokens.size(); + int i = 0; + int modifiers = Integer.parseInt((String)tokens.get(i++)); + String className = (String)tokens.get(i++); + String superClassName = null; + String interfaceNamesListStr = null; + List interfaceNames = null; + + while (size > i) + { + String tempToken = (String)tokens.get(i++); + + if (tempToken.equals("extends")) + { + superClassName = (String)tokens.get(i++); + } + else if (tempToken.equals("implements")) + { + interfaceNamesListStr = (String)tokens.get(i++); + } + } + + if (interfaceNamesListStr != null) + { + interfaceNames = SigTestUtils.stringToList(interfaceNamesListStr, ","); + } + + ClassDesc classDesc = new ClassDesc(className, modifiers); + + classDesc.setSuperClassName(superClassName); + + if (interfaceNames != null) + { + classDesc.setInterfaceNames(interfaceNames); + } + + classDescReader.readLine(); + + String tempLine = null; + + while (!(tempLine = classDescReader.readLine()).equals("}")) + { + MethodDesc methodDesc = MethodDesc.parseMethodDesc(tempLine); + + if (methodDesc.getReturnTypeName() == null) + { + classDesc.addConstructorDesc(methodDesc); + } + else + { + classDesc.addMethodDesc(methodDesc); + } + } + + return classDesc; + } + + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + else if (obj == this) + { + return true; + } + else + { + ClassDesc that = (ClassDesc)obj; + + if (!SigTestUtils.objectsEqual(name, that.name)) + { + return false; + } + else if (modifiers != that.modifiers) + { + return false; + } + else if (!SigTestUtils.objectsEqual(superClassName, that.superClassName)) + { + return false; + } + else if (!SigTestUtils.collectionsMatch(interfaceNames, + that.interfaceNames)) + { + return false; + } + else if (!SigTestUtils.collectionsMatch(constructorDescs, + that.constructorDescs)) + { + return false; + } + else if (!SigTestUtils.collectionsMatch(methodDescs, that.methodDescs)) + { + return false; + } + else + { + return true; + } + } + } + + public String compare(ClassDesc that) + { + StringBuffer strBuf = new StringBuffer(); + + if (modifiers != that.modifiers) + { + strBuf.append("On class '" + name + "', the modifiers are '" + + Modifier.toString(that.modifiers) + + "', when they should be '" + + Modifier.toString(modifiers) + "'."); + } + + if (!SigTestUtils.objectsEqual(superClassName, that.superClassName)) + { + strBuf.append("\nClass '" + name + "' " + + (that.superClassName != null + ? "extends '" + that.superClassName + "'" + : "does not extend any class") + + ", when it should" + + (superClassName != null + ? " extend '" + superClassName + "'." + : "n't extend any class.")); + } + + if (!SigTestUtils.collectionsMatch(interfaceNames, that.interfaceNames)) + { + strBuf.append("\nClass '" + name + "' " + + (that.interfaceNames.size() > 0 + ? "implements '" + that.interfaceNames + "'" + : "does not implement any interfaces") + + ", when it should" + + (interfaceNames.size() > 0 + ? " implement '" + interfaceNames + "'." + : "n't implement any interfaces.")); + } + + List referenceExtras = new Vector(); + List candidateExtras = new Vector(); + + SigTestUtils.findExtras(constructorDescs, + that.constructorDescs, + referenceExtras, + candidateExtras); + + if (referenceExtras.size() > 0 || candidateExtras.size() > 0) + { + strBuf.append("\nClass '" + name + "'" + + (candidateExtras.size() > 0 + ? " has extraneous constructor" + + (candidateExtras.size() > 1 ? "s" : "") + " " + + SigTestUtils.getExpandedMethodList(candidateExtras) + : "") + + (referenceExtras.size() > 0 + ? (candidateExtras.size() > 0 ? " and" : "") + + " is missing constructor" + + (referenceExtras.size() > 1 ? "s" : "") + " " + + SigTestUtils.getExpandedMethodList(referenceExtras) + : "") + "."); + } + + referenceExtras = new Vector(); + candidateExtras = new Vector(); + + SigTestUtils.findExtras(methodDescs, + that.methodDescs, + referenceExtras, + candidateExtras); + + if (referenceExtras.size() > 0 || candidateExtras.size() > 0) + { + strBuf.append("\nClass '" + name + "'" + + (candidateExtras.size() > 0 + ? " has extraneous method" + + (candidateExtras.size() > 1 ? "s" : "") + " " + + SigTestUtils.getExpandedMethodList(candidateExtras) + : "") + + (referenceExtras.size() > 0 + ? (candidateExtras.size() > 0 ? " and" : "") + + " is missing method" + + (referenceExtras.size() > 1 ? "s" : "") + " " + + SigTestUtils.getExpandedMethodList(referenceExtras) + : "") + "."); + } + + return (strBuf.length() > 0) + ? strBuf.toString() + : null; + } + + public String toString() + { + StringBuffer strBuf = new StringBuffer(); + + strBuf.append(modifiers + " " + name + + (superClassName != null + ? " extends " + superClassName + : "") + + (interfaceNames.size() > 0 + ? " implements " + SigTestUtils.listToString(interfaceNames) + : "") + + "\n{\n"); + + Iterator constrIterator = constructorDescs.iterator(); + + while (constrIterator.hasNext()) + { + strBuf.append(" " + constrIterator.next() + "\n"); + } + + Iterator methodIterator = methodDescs.iterator(); + + while (methodIterator.hasNext()) + { + strBuf.append(" " + methodIterator.next() + "\n"); + } + + strBuf.append("}"); + + return strBuf.toString(); + } + + public int hashCode() + { + return toString().hashCode(); + } +} \ No newline at end of file diff --git a/src/test/java/javax/usb/tck/sigtest/MemberDesc.java b/src/test/java/javax/usb/tck/sigtest/MemberDesc.java new file mode 100755 index 0000000..0736943 --- /dev/null +++ b/src/test/java/javax/usb/tck/sigtest/MemberDesc.java @@ -0,0 +1,49 @@ +package javax.usb.tck.sigtest; + +/** + * Copyright (c) 2003,2004 International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + +/** + * This class stores the name and modifiers for a given member (class or + * method). + * + * @author Matthew J. Duftler + */ +@SuppressWarnings("all") +public class MemberDesc +{ + protected String name = null; + protected int modifiers = 0; + + public MemberDesc(String name, int modifiers) + { + this.name = name; + this.modifiers = modifiers; + } + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public void setModifiers(int modifiers) + { + this.modifiers = modifiers; + } + + public int getModifiers() + { + return modifiers; + } +} \ No newline at end of file diff --git a/src/test/java/javax/usb/tck/sigtest/MethodDesc.java b/src/test/java/javax/usb/tck/sigtest/MethodDesc.java new file mode 100755 index 0000000..534da70 --- /dev/null +++ b/src/test/java/javax/usb/tck/sigtest/MethodDesc.java @@ -0,0 +1,180 @@ +package javax.usb.tck.sigtest; + +/** + * Copyright (c) 2003,2004 International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + +import java.lang.reflect.*; +import java.util.*; + +/** + * This class stores all the information needed to identify a method + * signature. + * + * @author Matthew J. Duftler + */ +@SuppressWarnings("all") +public class MethodDesc extends MemberDesc +{ + private String returnTypeName = null; + private List paramTypeNames = new Vector(); + private List exceptionTypeNames = new Vector(); + + public MethodDesc(String name, + int modifiers, + String returnTypeName, + List paramTypeNames, + List exceptionTypeNames) + { + super(name, modifiers); + + this.returnTypeName = returnTypeName; + this.paramTypeNames = paramTypeNames; + this.exceptionTypeNames = exceptionTypeNames; + } + + public void setReturnTypeName(String returnTypeName) + { + this.returnTypeName = returnTypeName; + } + + public String getReturnTypeName() + { + return returnTypeName; + } + + public void setParameterTypeNames(List paramTypeNames) + { + this.paramTypeNames = paramTypeNames; + } + + public List getParameterTypeNames() + { + return paramTypeNames; + } + + public void setExceptionTypeNames(List exceptionTypeNames) + { + this.exceptionTypeNames = exceptionTypeNames; + } + + public List getExceptionTypeNames() + { + return exceptionTypeNames; + } + + public static MethodDesc parseMethodDesc(String methodDescStr) + { + String[] tokens = SigTestUtils.tokenize(methodDescStr, " "); + + int modifiers = Integer.parseInt(tokens[0]); + String returnTypeName = null; + int offset = 0; + + if (!tokens[2].startsWith("(")) + { + returnTypeName = tokens[1]; + offset = 1; + } + + String methodName = tokens[1 + offset]; + String parameterTypeNamesStr = tokens[2 + offset]; + + parameterTypeNamesStr = + parameterTypeNamesStr.substring(1, parameterTypeNamesStr.length() - 1); + + List parameterTypeNames = + SigTestUtils.stringToList(parameterTypeNamesStr, ","); + List exceptionTypeNames; + + if (tokens.length > (3 + offset)) + { + String exceptionTypeNamesStr = tokens[4 + offset]; + + exceptionTypeNames = + SigTestUtils.stringToList(exceptionTypeNamesStr, ","); + } + else + { + exceptionTypeNames = new Vector(); + } + + MethodDesc methodDesc = + new MethodDesc(methodName, + modifiers, + returnTypeName, + parameterTypeNames, + exceptionTypeNames); + + return methodDesc; + } + + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + else if (obj == this) + { + return true; + } + else + { + MethodDesc that = (MethodDesc)obj; + + if (!SigTestUtils.objectsEqual(name, that.name)) + { + return false; + } + else if (modifiers != that.modifiers) + { + return false; + } + else if (!SigTestUtils.objectsEqual(returnTypeName, that.returnTypeName)) + { + return false; + } + else if (!SigTestUtils.objectsEqual(paramTypeNames, that.paramTypeNames)) + { + return false; + } + else if (!SigTestUtils.collectionsMatch(exceptionTypeNames, + that.exceptionTypeNames)) + { + return false; + } + else + { + return true; + } + } + } + + public int hashCode() + { + return toString().hashCode(); + } + + public String toString(boolean expandModifiers) + { + return (expandModifiers + ? Modifier.toString(modifiers) + : modifiers + "") + " " + + (returnTypeName != null ? returnTypeName + " " : "") + + name + " (" + SigTestUtils.listToString(paramTypeNames) + ")" + + (exceptionTypeNames.size() > 0 + ? " throws " + SigTestUtils.listToString(exceptionTypeNames) + : ""); + } + + public String toString() + { + return toString(false); + } +} \ No newline at end of file diff --git a/src/test/java/javax/usb/tck/sigtest/ProjectDesc.java b/src/test/java/javax/usb/tck/sigtest/ProjectDesc.java new file mode 100755 index 0000000..721b2bc --- /dev/null +++ b/src/test/java/javax/usb/tck/sigtest/ProjectDesc.java @@ -0,0 +1,179 @@ +package javax.usb.tck.sigtest; + +/** + * Copyright (c) 2003,2004 International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + +import java.io.*; +import java.util.*; + +/** + * This class stores a name and a collection of class descriptions, + * to form a project. + * + * @author Matthew J. Duftler + */ +@SuppressWarnings("all") +public class ProjectDesc +{ + private String name; + private List classDescs = new Vector(); + + public ProjectDesc(String name) + { + this.name = name; + } + + public void addClassDesc(ClassDesc classDesc) + { + classDescs.add(classDesc); + } + + public ClassDesc getClassDesc(String className) + { + Iterator iterator = classDescs.iterator(); + + while (iterator.hasNext()) + { + ClassDesc classDesc = (ClassDesc)iterator.next(); + + if (SigTestUtils.objectsEqual(classDesc.getName(), className)) + { + return classDesc; + } + } + + return null; + } + + public void setClassDescs(List classDescs) + { + this.classDescs = classDescs; + } + + public List getClassDescs() + { + return classDescs; + } + + /** + * This method compares this project description to the specified one. + * + * @param that the project description to compare this one to + * + * @return a description of the differences, or null if they match perfectly + */ + public String compare(ProjectDesc that) + { + StringBuffer strBuf = new StringBuffer(); + Iterator iterator = classDescs.iterator(); + + while (iterator.hasNext()) + { + ClassDesc thisCD = (ClassDesc)iterator.next(); + ClassDesc thatCD = that.getClassDesc(thisCD.getName()); + + if (thatCD != null) + { + String result = thisCD.compare(thatCD); + + if (result != null) + { + strBuf.append("\n" + result); + } + } + } + + List referenceExtras = new Vector(); + List candidateExtras = new Vector(); + + SigTestUtils.findExtraClasses(this, + that, + referenceExtras, + candidateExtras); + + if (referenceExtras.size() > 0 || candidateExtras.size() > 0) + { + strBuf.append("\nProject '" + that.name + "'" + + (candidateExtras.size() > 0 + ? " has extraneous class" + + (candidateExtras.size() > 1 ? "es" : "") + " " + + SigTestUtils.getCondensedClassList(candidateExtras) + : "") + + (referenceExtras.size() > 0 + ? (candidateExtras.size() > 0 ? " and" : "") + + " is missing class" + + (referenceExtras.size() > 1 ? "es" : "") + " " + + SigTestUtils.getCondensedClassList(referenceExtras) + : "") + "."); + } + + return (strBuf.length() > 0) + ? strBuf.toString() + : null; + } + + /** + * This method compares the specified project file to the classes + * currently available on the classpath. + * + * @param file the project file to read from + * + * @return a description of the differences, or null if they match perfectly + */ + public static String compareProjectFile(File projectFile) + throws IOException + { + ProjectDesc riPD = readProjectFile("ReferenceImpl", projectFile); + ProjectDesc cdPD = SigTestUtils.getProjectDesc(riPD); + + return riPD.compare(cdPD); + } + + public String toString() + { + StringBuffer strBuf = new StringBuffer("Project '" + name + "': "); + int size = classDescs.size(); + + for (int i = 0; i < size; i++) + { + strBuf.append((i > 0 ? ", " : "") + + ((ClassDesc)classDescs.get(i)).getName()); + } + + return strBuf.toString(); + } + + /** + * This method reads the specified project file into memory. + * + * @param projectName the name to be used when referring to the project in + * error messages + * @param file the project file to read from + * + * @return a model of the project + */ + public static ProjectDesc readProjectFile(String projectName, + File file) + throws IOException + { + ProjectDesc pd = new ProjectDesc(projectName); + FileReader fileReader = new FileReader(file); + BufferedReader buf = new BufferedReader(fileReader); + + while (buf.ready()) + { + pd.addClassDesc(ClassDesc.parseClassDesc(buf)); + } + + buf.close(); + fileReader.close(); + + return pd; + } +} diff --git a/src/test/java/javax/usb/tck/sigtest/SigTestUtils.java b/src/test/java/javax/usb/tck/sigtest/SigTestUtils.java new file mode 100755 index 0000000..ec194a3 --- /dev/null +++ b/src/test/java/javax/usb/tck/sigtest/SigTestUtils.java @@ -0,0 +1,441 @@ +package javax.usb.tck.sigtest; + +/** + * Copyright (c) 2003,2004 International Business Machines Corporation. + * All Rights Reserved. + * + * This software is provided and licensed under the terms and conditions + * of the Common Public License: + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + */ + +import java.lang.reflect.*; +import java.io.*; +import java.util.*; + +/** + * This class implements static utility methods for use by the signature + * test tool. + * + * @author Matthew J. Duftler + */ +@SuppressWarnings("all") +public class SigTestUtils +{ + /** + * This method builds a new project description by using an existing one + * as a reference. The new project description is built by resolving each + * class specified in the reference description, and adding their signatures + * to the newly built project. + * + * @param referencePD the reference project description + * + * @return the new project description + */ + public static ProjectDesc getProjectDesc(ProjectDesc referencePD) + { + ProjectDesc candidatePD = new ProjectDesc("CandidateImpl"); + Iterator iterator = referencePD.getClassDescs().iterator(); + + while (iterator.hasNext()) + { + ClassDesc referenceCD = (ClassDesc)iterator.next(); + String className = referenceCD.getName(); + ClassDesc candidateCD = null; + + try + { + Class candidateClass = Class.forName(className); + + candidateCD = getClassDesc(candidateClass); + } + catch (ClassNotFoundException e) + { + } + + if (candidateCD != null) + { + candidatePD.addClassDesc(candidateCD); + } + } + + return candidatePD; + } + + public static ClassDesc getClassDesc(Class theClass) + { + String className = getClassName(theClass); + ClassDesc classDesc = new ClassDesc(className, + theClass.getModifiers()); + Class superClass = theClass.getSuperclass(); + + if (superClass != null) + { + classDesc.setSuperClassName(getClassName(superClass)); + } + + List interfaceNames = getTypeNames(theClass.getInterfaces()); + + classDesc.setInterfaceNames(interfaceNames); + + List constructorDescs = + getConstructorDescs(className, theClass.getDeclaredConstructors()); + + classDesc.setConstructorDescs(constructorDescs); + + List methodDescs = + getMethodDescs(theClass.getDeclaredMethods()); + + classDesc.setMethodDescs(methodDescs); + + return classDesc; + } + + public static List getConstructorDescs(String className, + Constructor[] constructors) + { + List constructorDescs = new Vector(); + + for (int i = 0; i < constructors.length; i++) + { + MethodDesc constructorDesc = + new MethodDesc(className, + constructors[i].getModifiers(), + null, + getTypeNames(constructors[i].getParameterTypes()), + getTypeNames(constructors[i].getExceptionTypes())); + + constructorDescs.add(constructorDesc); + } + + return constructorDescs; + } + + public static List getMethodDescs(Method[] methods) + { + List methodDescs = new Vector(); + + for (int i = 0; i < methods.length; i++) + { + MethodDesc methodDesc = + new MethodDesc(methods[i].getName(), + methods[i].getModifiers(), + getClassName(methods[i].getReturnType()), + getTypeNames(methods[i].getParameterTypes()), + getTypeNames(methods[i].getExceptionTypes())); + + methodDescs.add(methodDesc); + } + + return methodDescs; + } + + public static List getTypeNames(Class[] types) + { + List typeNames = new Vector(); + + for (int i = 0; i < types.length; i++) + { + typeNames.add(getClassName(types[i])); + } + + return typeNames; + } + + public static String listToString(List list) + { + StringBuffer strBuf = new StringBuffer(); + int size = list.size(); + + for (int i = 0; i < size; i++) + { + strBuf.append((i > 0 ? "," : "") + + list.get(i)); + } + + return strBuf.toString(); + } + + public static List stringToList(String str, String delim) + { + return Arrays.asList(tokenize(str, delim)); + } + + public static String[] tokenize(String tokenStr, String delim) + { + StringTokenizer strTok = new StringTokenizer(tokenStr, delim); + String[] tokens = new String[strTok.countTokens()]; + + for (int i = 0; i < tokens.length; i++) + { + tokens[i] = strTok.nextToken(); + } + + return tokens; + } + + public static boolean objectsEqual(Object obj1, Object obj2) + { + if (obj1 == null) + { + return (obj2 == null); + } + else + { + return obj1.equals(obj2); + } + } + + public static boolean collectionsMatch(Collection c1, Collection c2) + { + if (c1 == null) + { + return (c2 == null); + } + else + { + return c1.containsAll(c2) && c2.containsAll(c1); + } + } + + public static String getExpandedMethodList(List list) + { + StringBuffer strBuf = new StringBuffer("["); + int size = list.size(); + + for (int i = 0; i < size; i++) + { + strBuf.append((i > 0 ? ", " : "") + + ((MethodDesc)list.get(i)).toString(true)); + } + + strBuf.append("]"); + + return strBuf.toString(); + } + + public static String getCondensedClassList(List list) + { + StringBuffer strBuf = new StringBuffer("["); + int size = list.size(); + + for (int i = 0; i < size; i++) + { + strBuf.append((i > 0 ? ", " : "") + + ((ClassDesc)list.get(i)).getName()); + } + + strBuf.append("]"); + + return strBuf.toString(); + } + + public static void findExtras(Collection reference, + Collection candidate, + List referenceExtras, + List candidateExtras) + { + referenceExtras.addAll(reference); + referenceExtras.removeAll(candidate); + candidateExtras.addAll(candidate); + candidateExtras.removeAll(reference); + + if (candidateExtras.size() > 0) + { + Iterator memberDescs = candidateExtras.iterator(); + + while (memberDescs.hasNext()) + { + MemberDesc memberDesc = (MemberDesc)memberDescs.next(); + int modifiers = memberDesc.getModifiers(); + + if (Modifier.isPrivate(modifiers) + || !(Modifier.isProtected(modifiers) + || Modifier.isPublic(modifiers))) + { + memberDescs.remove(); + } + } + } + } + + public static void findExtraClasses(ProjectDesc referencePD, + ProjectDesc candidatePD, + List referenceExtras, + List candidateExtras) + { + referenceExtras.addAll(referencePD.getClassDescs()); + candidateExtras.addAll(candidatePD.getClassDescs()); + + Iterator iterator = referenceExtras.iterator(); + + while (iterator.hasNext()) + { + ClassDesc referenceCD = (ClassDesc)iterator.next(); + ClassDesc candidateCD = + candidatePD.getClassDesc(referenceCD.getName()); + + if (candidateCD != null) + { + iterator.remove(); + } + } + + iterator = candidateExtras.iterator(); + + while (iterator.hasNext()) + { + ClassDesc candidateCD = (ClassDesc)iterator.next(); + ClassDesc referenceCD = + referencePD.getClassDesc(candidateCD.getName()); + + if (referenceCD != null) + { + iterator.remove(); + } + } + } + + /* + This method will return the correct name for a class object representing + a primitive, a single instance of a class, as well as n-dimensional arrays + of primitives or instances. This logic is needed to handle the string returned + from Class.getName(). If the class object represents a single instance (or + a primitive), Class.getName() returns the fully-qualified name of the class + and no further work is needed. However, if the class object represents an + array (of n dimensions), Class.getName() returns a Descriptor (the Descriptor + grammar is defined in section 4.3 of the Java VM Spec). This method will + parse the Descriptor if necessary. + */ + public static String getClassName(Class targetClass) + { + String className = targetClass.getName(); + + return targetClass.isArray() ? parseDescriptor(className) : className; + } + + /* + See the comment above for getClassName(targetClass)... + */ + private static String parseDescriptor(String className) + { + char[] classNameChars = className.toCharArray(); + int arrayDim = 0; + int i = 0; + + while (classNameChars[i] == '[') + { + arrayDim++; + i++; + } + + StringBuffer classNameBuf = new StringBuffer(); + + switch (classNameChars[i++]) + { + case 'B' : classNameBuf.append("byte"); + break; + case 'C' : classNameBuf.append("char"); + break; + case 'D' : classNameBuf.append("double"); + break; + case 'F' : classNameBuf.append("float"); + break; + case 'I' : classNameBuf.append("int"); + break; + case 'J' : classNameBuf.append("long"); + break; + case 'S' : classNameBuf.append("short"); + break; + case 'Z' : classNameBuf.append("boolean"); + break; + case 'L' : classNameBuf.append(classNameChars, + i, classNameChars.length - i - 1); + break; + } + + for (i = 0; i < arrayDim; i++) + classNameBuf.append("[]"); + + return classNameBuf.toString(); + } + + private static OutputStream getOutputStream(String root, + String name, + boolean overwrite, + boolean verbose) + throws IOException + { + if (root != null) + { + File directory = new File(root); + + if (!directory.exists()) + { + if (!directory.mkdirs()) + { + throw new IOException("Failed to create directory '" + root + "'."); + } + else if (verbose) + { + System.out.println("Created directory '" + + directory.getAbsolutePath() + "'."); + } + } + } + + File file = new File(root, name); + String absolutePath = file.getAbsolutePath(); + + if (file.exists()) + { + if (!overwrite) + { + throw new IOException("File '" + absolutePath + "' already exists. " + + "Please remove it or enable the " + + "overwrite option."); + } + else + { + file.delete(); + + if (verbose) + { + System.out.println("Deleted file '" + absolutePath + "'."); + } + } + } + + FileOutputStream fos = new FileOutputStream(absolutePath); + + if (verbose) + { + System.out.println("Created file '" + absolutePath + "'."); + } + + return fos; + } + + public static void generateProjectFile(String classListFile, + String projectFile, + boolean overwrite) + throws IOException, + ClassNotFoundException + { + FileReader in = new FileReader(classListFile); + BufferedReader buf = new BufferedReader(in); + OutputStream out = getOutputStream(null, projectFile, overwrite, true); + PrintWriter pw = new PrintWriter(out); + String tempLine; + + while ((tempLine = buf.readLine()) != null) + { + pw.println(getClassDesc(Class.forName(tempLine))); + } + + pw.flush(); + pw.close(); + buf.close(); + in.close(); + } +} diff --git a/src/test/resources/javax.usb-1.0.sig b/src/test/resources/javax.usb-1.0.sig new file mode 100755 index 0000000..0218c0c --- /dev/null +++ b/src/test/resources/javax.usb-1.0.sig @@ -0,0 +1,497 @@ +1 javax.usb.UsbAbortException extends javax.usb.UsbException +{ + 1 javax.usb.UsbAbortException (java.lang.String) + 1 javax.usb.UsbAbortException () +} +1 javax.usb.UsbBabbleException extends javax.usb.UsbException +{ + 1 javax.usb.UsbBabbleException (java.lang.String) + 1 javax.usb.UsbBabbleException () +} +1 javax.usb.UsbBitStuffException extends javax.usb.UsbException +{ + 1 javax.usb.UsbBitStuffException (java.lang.String) + 1 javax.usb.UsbBitStuffException () +} +1 javax.usb.UsbClaimException extends javax.usb.UsbException +{ + 1 javax.usb.UsbClaimException (java.lang.String) + 1 javax.usb.UsbClaimException () +} +1537 javax.usb.UsbConfiguration +{ + 1025 boolean isActive () + 1025 java.util.List getUsbInterfaces () + 1025 javax.usb.UsbInterface getUsbInterface (byte) + 1025 boolean containsUsbInterface (byte) + 1025 javax.usb.UsbDevice getUsbDevice () + 1025 javax.usb.UsbConfigurationDescriptor getUsbConfigurationDescriptor () + 1025 java.lang.String getConfigurationString () throws javax.usb.UsbException,java.io.UnsupportedEncodingException,javax.usb.UsbDisconnectedException +} +1537 javax.usb.UsbConfigurationDescriptor implements javax.usb.UsbDescriptor +{ + 1025 short wTotalLength () + 1025 byte bNumInterfaces () + 1025 byte bConfigurationValue () + 1025 byte iConfiguration () + 1025 byte bmAttributes () + 1025 byte bMaxPower () +} +1537 javax.usb.UsbConst +{ +} +1537 javax.usb.UsbControlIrp implements javax.usb.UsbIrp +{ + 1025 byte bmRequestType () + 1025 byte bRequest () + 1025 short wValue () + 1025 short wIndex () +} +1 javax.usb.UsbCRCException extends javax.usb.UsbException +{ + 1 javax.usb.UsbCRCException (java.lang.String) + 1 javax.usb.UsbCRCException () +} +1537 javax.usb.UsbDescriptor +{ + 1025 byte bLength () + 1025 byte bDescriptorType () +} +1537 javax.usb.UsbDevice +{ + 1025 javax.usb.UsbPort getParentUsbPort () throws javax.usb.UsbDisconnectedException + 1025 boolean isUsbHub () + 1025 java.lang.String getManufacturerString () throws javax.usb.UsbException,java.io.UnsupportedEncodingException,javax.usb.UsbDisconnectedException + 1025 java.lang.String getSerialNumberString () throws javax.usb.UsbException,java.io.UnsupportedEncodingException,javax.usb.UsbDisconnectedException + 1025 java.lang.String getProductString () throws javax.usb.UsbException,java.io.UnsupportedEncodingException,javax.usb.UsbDisconnectedException + 1025 java.lang.Object getSpeed () + 1025 java.util.List getUsbConfigurations () + 1025 javax.usb.UsbConfiguration getUsbConfiguration (byte) + 1025 boolean containsUsbConfiguration (byte) + 1025 byte getActiveUsbConfigurationNumber () + 1025 javax.usb.UsbConfiguration getActiveUsbConfiguration () + 1025 boolean isConfigured () + 1025 javax.usb.UsbDeviceDescriptor getUsbDeviceDescriptor () + 1025 javax.usb.UsbStringDescriptor getUsbStringDescriptor (byte) throws javax.usb.UsbException,javax.usb.UsbDisconnectedException + 1025 java.lang.String getString (byte) throws javax.usb.UsbException,java.io.UnsupportedEncodingException,javax.usb.UsbDisconnectedException + 1025 void syncSubmit (javax.usb.UsbControlIrp) throws javax.usb.UsbException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 void asyncSubmit (javax.usb.UsbControlIrp) throws javax.usb.UsbException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 void syncSubmit (java.util.List) throws javax.usb.UsbException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 void asyncSubmit (java.util.List) throws javax.usb.UsbException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 javax.usb.UsbControlIrp createUsbControlIrp (byte,byte,short,short) + 1025 void addUsbDeviceListener (javax.usb.event.UsbDeviceListener) + 1025 void removeUsbDeviceListener (javax.usb.event.UsbDeviceListener) +} +1537 javax.usb.UsbDeviceDescriptor implements javax.usb.UsbDescriptor +{ + 1025 short bcdUSB () + 1025 byte bDeviceClass () + 1025 byte bDeviceSubClass () + 1025 byte bDeviceProtocol () + 1025 byte bMaxPacketSize0 () + 1025 short idVendor () + 1025 short idProduct () + 1025 short bcdDevice () + 1025 byte iManufacturer () + 1025 byte iProduct () + 1025 byte iSerialNumber () + 1025 byte bNumConfigurations () +} +1 javax.usb.UsbDisconnectedException extends java.lang.RuntimeException +{ + 1 javax.usb.UsbDisconnectedException (java.lang.String) + 1 javax.usb.UsbDisconnectedException () +} +1537 javax.usb.UsbEndpoint +{ + 1025 javax.usb.UsbInterface getUsbInterface () + 1025 javax.usb.UsbEndpointDescriptor getUsbEndpointDescriptor () + 1025 byte getDirection () + 1025 byte getType () + 1025 javax.usb.UsbPipe getUsbPipe () +} +1537 javax.usb.UsbEndpointDescriptor implements javax.usb.UsbDescriptor +{ + 1025 byte bEndpointAddress () + 1025 byte bmAttributes () + 1025 short wMaxPacketSize () + 1025 byte bInterval () +} +1 javax.usb.UsbException extends java.lang.Exception +{ + 1 javax.usb.UsbException (java.lang.String) + 1 javax.usb.UsbException () +} +17 javax.usb.UsbHostManager extends java.lang.Object +{ + 2 javax.usb.UsbHostManager () + 9 javax.usb.UsbServices getUsbServices () throws javax.usb.UsbException,java.lang.SecurityException + 9 java.util.Properties getProperties () throws javax.usb.UsbException,java.lang.SecurityException + 10 javax.usb.UsbServices createUsbServices () throws javax.usb.UsbException,java.lang.SecurityException + 10 void setupProperties () throws javax.usb.UsbException,java.lang.SecurityException + 26 java.lang.String USBSERVICES_PROPERTY_NOT_DEFINED () + 26 java.lang.String USBSERVICES_CLASSNOTFOUNDEXCEPTION (java.lang.String) + 26 java.lang.String USBSERVICES_EXCEPTIONININITIALIZERERROR (java.lang.String) + 26 java.lang.String USBSERVICES_INSTANTIATIONEXCEPTION (java.lang.String) + 26 java.lang.String USBSERVICES_ILLEGALACCESSEXCEPTION (java.lang.String) + 26 java.lang.String USBSERVICES_CLASSCASTEXCEPTION (java.lang.String) +} +1537 javax.usb.UsbHub implements javax.usb.UsbDevice +{ + 1025 byte getNumberOfPorts () + 1025 java.util.List getUsbPorts () + 1025 javax.usb.UsbPort getUsbPort (byte) + 1025 java.util.List getAttachedUsbDevices () + 1025 boolean isRootUsbHub () +} +1537 javax.usb.UsbInterface +{ + 1025 void claim () throws javax.usb.UsbClaimException,javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbDisconnectedException + 1025 void claim (javax.usb.UsbInterfacePolicy) throws javax.usb.UsbClaimException,javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbDisconnectedException + 1025 void release () throws javax.usb.UsbClaimException,javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbDisconnectedException + 1025 boolean isClaimed () + 1025 boolean isActive () + 1025 int getNumSettings () + 1025 byte getActiveSettingNumber () throws javax.usb.UsbNotActiveException + 1025 javax.usb.UsbInterface getActiveSetting () throws javax.usb.UsbNotActiveException + 1025 javax.usb.UsbInterface getSetting (byte) + 1025 boolean containsSetting (byte) + 1025 java.util.List getSettings () + 1025 java.util.List getUsbEndpoints () + 1025 javax.usb.UsbEndpoint getUsbEndpoint (byte) + 1025 boolean containsUsbEndpoint (byte) + 1025 javax.usb.UsbConfiguration getUsbConfiguration () + 1025 javax.usb.UsbInterfaceDescriptor getUsbInterfaceDescriptor () + 1025 java.lang.String getInterfaceString () throws javax.usb.UsbException,java.io.UnsupportedEncodingException,javax.usb.UsbDisconnectedException +} +1537 javax.usb.UsbInterfaceDescriptor implements javax.usb.UsbDescriptor +{ + 1025 byte bInterfaceNumber () + 1025 byte bAlternateSetting () + 1025 byte bNumEndpoints () + 1025 byte bInterfaceClass () + 1025 byte bInterfaceSubClass () + 1025 byte bInterfaceProtocol () + 1025 byte iInterface () +} +1537 javax.usb.UsbInterfacePolicy +{ + 1025 boolean forceClaim (javax.usb.UsbInterface) +} +1537 javax.usb.UsbIrp +{ + 1025 byte[] getData () + 1025 int getOffset () + 1025 int getLength () + 1025 int getActualLength () + 1025 void setData (byte[]) + 1025 void setData (byte[],int,int) + 1025 void setOffset (int) + 1025 void setLength (int) + 1025 void setActualLength (int) + 1025 boolean isUsbException () + 1025 javax.usb.UsbException getUsbException () + 1025 void setUsbException (javax.usb.UsbException) + 1025 boolean getAcceptShortPacket () + 1025 void setAcceptShortPacket (boolean) + 1025 boolean isComplete () + 1025 void setComplete (boolean) + 1025 void complete () + 1025 void waitUntilComplete () + 1025 void waitUntilComplete (long) +} +1 javax.usb.UsbNativeClaimException extends javax.usb.UsbClaimException +{ + 1 javax.usb.UsbNativeClaimException (java.lang.String) + 1 javax.usb.UsbNativeClaimException () +} +1 javax.usb.UsbNotActiveException extends java.lang.RuntimeException +{ + 1 javax.usb.UsbNotActiveException (java.lang.String) + 1 javax.usb.UsbNotActiveException () +} +1 javax.usb.UsbNotClaimedException extends java.lang.RuntimeException +{ + 1 javax.usb.UsbNotClaimedException (java.lang.String) + 1 javax.usb.UsbNotClaimedException () +} +1 javax.usb.UsbNotOpenException extends java.lang.RuntimeException +{ + 1 javax.usb.UsbNotOpenException (java.lang.String) + 1 javax.usb.UsbNotOpenException () +} +1 javax.usb.UsbPIDException extends javax.usb.UsbException +{ + 1 javax.usb.UsbPIDException (java.lang.String) + 1 javax.usb.UsbPIDException () +} +1537 javax.usb.UsbPipe +{ + 1025 void open () throws javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbNotClaimedException,javax.usb.UsbDisconnectedException + 1025 void close () throws javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbNotOpenException,javax.usb.UsbDisconnectedException + 1025 boolean isActive () + 1025 boolean isOpen () + 1025 javax.usb.UsbEndpoint getUsbEndpoint () + 1025 int syncSubmit (byte[]) throws javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbNotOpenException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 javax.usb.UsbIrp asyncSubmit (byte[]) throws javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbNotOpenException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 void syncSubmit (javax.usb.UsbIrp) throws javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbNotOpenException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 void asyncSubmit (javax.usb.UsbIrp) throws javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbNotOpenException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 void syncSubmit (java.util.List) throws javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbNotOpenException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 void asyncSubmit (java.util.List) throws javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbNotOpenException,java.lang.IllegalArgumentException,javax.usb.UsbDisconnectedException + 1025 void abortAllSubmissions () throws javax.usb.UsbNotActiveException,javax.usb.UsbNotOpenException,javax.usb.UsbDisconnectedException + 1025 javax.usb.UsbIrp createUsbIrp () + 1025 javax.usb.UsbControlIrp createUsbControlIrp (byte,byte,short,short) + 1025 void addUsbPipeListener (javax.usb.event.UsbPipeListener) + 1025 void removeUsbPipeListener (javax.usb.event.UsbPipeListener) +} +1 javax.usb.UsbPlatformException extends javax.usb.UsbException +{ + 1 javax.usb.UsbPlatformException (java.lang.String,int,java.lang.Exception) + 1 javax.usb.UsbPlatformException (int,java.lang.Exception) + 1 javax.usb.UsbPlatformException (java.lang.String,java.lang.Exception) + 1 javax.usb.UsbPlatformException (java.lang.String,int) + 1 javax.usb.UsbPlatformException (java.lang.Exception) + 1 javax.usb.UsbPlatformException (int) + 1 javax.usb.UsbPlatformException (java.lang.String) + 1 javax.usb.UsbPlatformException () + 1 java.lang.Exception getPlatformException () + 1 int getErrorCode () +} +1537 javax.usb.UsbPort +{ + 1025 byte getPortNumber () + 1025 javax.usb.UsbHub getUsbHub () + 1025 javax.usb.UsbDevice getUsbDevice () + 1025 boolean isUsbDeviceAttached () +} +1537 javax.usb.UsbServices +{ + 1025 javax.usb.UsbHub getRootUsbHub () throws javax.usb.UsbException,java.lang.SecurityException + 1025 void addUsbServicesListener (javax.usb.event.UsbServicesListener) + 1025 void removeUsbServicesListener (javax.usb.event.UsbServicesListener) + 1025 java.lang.String getApiVersion () + 1025 java.lang.String getImpVersion () + 1025 java.lang.String getImpDescription () +} +1 javax.usb.UsbShortPacketException extends javax.usb.UsbException +{ + 1 javax.usb.UsbShortPacketException (java.lang.String) + 1 javax.usb.UsbShortPacketException () +} +1 javax.usb.UsbStallException extends javax.usb.UsbException +{ + 1 javax.usb.UsbStallException (java.lang.String) + 1 javax.usb.UsbStallException () +} +1537 javax.usb.UsbStringDescriptor implements javax.usb.UsbDescriptor +{ + 1025 byte[] bString () + 1025 java.lang.String getString () throws java.io.UnsupportedEncodingException +} +1 javax.usb.Version extends java.lang.Object +{ + 1 javax.usb.Version () + 9 void main (java.lang.String[]) + 9 java.lang.String getApiVersion () + 9 java.lang.String getUsbVersion () +} +1 javax.usb.event.UsbDeviceDataEvent extends javax.usb.event.UsbDeviceEvent +{ + 1 javax.usb.event.UsbDeviceDataEvent (javax.usb.UsbDevice,javax.usb.UsbControlIrp) + 1 byte[] getData () + 1 javax.usb.UsbControlIrp getUsbControlIrp () +} +1 javax.usb.event.UsbDeviceErrorEvent extends javax.usb.event.UsbDeviceEvent +{ + 1 javax.usb.event.UsbDeviceErrorEvent (javax.usb.UsbDevice,javax.usb.UsbControlIrp) + 1 javax.usb.UsbException getUsbException () + 1 javax.usb.UsbControlIrp getUsbControlIrp () +} +1 javax.usb.event.UsbDeviceEvent extends java.util.EventObject +{ + 1 javax.usb.event.UsbDeviceEvent (javax.usb.UsbDevice) + 1 javax.usb.UsbDevice getUsbDevice () +} +1537 javax.usb.event.UsbDeviceListener implements java.util.EventListener +{ + 1025 void usbDeviceDetached (javax.usb.event.UsbDeviceEvent) + 1025 void errorEventOccurred (javax.usb.event.UsbDeviceErrorEvent) + 1025 void dataEventOccurred (javax.usb.event.UsbDeviceDataEvent) +} +1 javax.usb.event.UsbPipeDataEvent extends javax.usb.event.UsbPipeEvent +{ + 1 javax.usb.event.UsbPipeDataEvent (javax.usb.UsbPipe,javax.usb.UsbIrp) + 1 javax.usb.event.UsbPipeDataEvent (javax.usb.UsbPipe,byte[],int) + 1 byte[] getData () + 1 int getActualLength () +} +1 javax.usb.event.UsbPipeErrorEvent extends javax.usb.event.UsbPipeEvent +{ + 1 javax.usb.event.UsbPipeErrorEvent (javax.usb.UsbPipe,javax.usb.UsbIrp) + 1 javax.usb.event.UsbPipeErrorEvent (javax.usb.UsbPipe,javax.usb.UsbException) + 1 javax.usb.UsbException getUsbException () +} +1 javax.usb.event.UsbPipeEvent extends java.util.EventObject +{ + 1 javax.usb.event.UsbPipeEvent (javax.usb.UsbPipe,javax.usb.UsbIrp) + 1 javax.usb.event.UsbPipeEvent (javax.usb.UsbPipe) + 1 javax.usb.UsbPipe getUsbPipe () + 1 boolean hasUsbIrp () + 1 javax.usb.UsbIrp getUsbIrp () +} +1537 javax.usb.event.UsbPipeListener implements java.util.EventListener +{ + 1025 void errorEventOccurred (javax.usb.event.UsbPipeErrorEvent) + 1025 void dataEventOccurred (javax.usb.event.UsbPipeDataEvent) +} +1 javax.usb.event.UsbServicesEvent extends java.util.EventObject +{ + 1 javax.usb.event.UsbServicesEvent (javax.usb.UsbServices,javax.usb.UsbDevice) + 1 javax.usb.UsbServices getUsbServices () + 1 javax.usb.UsbDevice getUsbDevice () +} +1537 javax.usb.event.UsbServicesListener implements java.util.EventListener +{ + 1025 void usbDeviceAttached (javax.usb.event.UsbServicesEvent) + 1025 void usbDeviceDetached (javax.usb.event.UsbServicesEvent) +} +1 javax.usb.util.DefaultUsbControlIrp extends javax.usb.util.DefaultUsbIrp implements javax.usb.UsbControlIrp +{ + 1 javax.usb.util.DefaultUsbControlIrp (byte[],int,int,boolean,byte,byte,short,short) + 1 javax.usb.util.DefaultUsbControlIrp (byte,byte,short,short) + 1 byte bmRequestType () + 1 byte bRequest () + 1 short wValue () + 1 short wIndex () + 1 short wLength () +} +1 javax.usb.util.DefaultUsbIrp extends java.lang.Object implements javax.usb.UsbIrp +{ + 1 javax.usb.util.DefaultUsbIrp (byte[],int,int,boolean) + 1 javax.usb.util.DefaultUsbIrp (byte[]) + 1 javax.usb.util.DefaultUsbIrp () + 1 byte[] getData () + 1 int getOffset () + 1 int getLength () + 1 int getActualLength () + 1 void setData (byte[],int,int) throws java.lang.IllegalArgumentException + 1 void setData (byte[]) throws java.lang.IllegalArgumentException + 1 void setOffset (int) throws java.lang.IllegalArgumentException + 1 void setLength (int) throws java.lang.IllegalArgumentException + 1 void setActualLength (int) throws java.lang.IllegalArgumentException + 1 boolean isUsbException () + 1 javax.usb.UsbException getUsbException () + 1 void setUsbException (javax.usb.UsbException) + 1 boolean getAcceptShortPacket () + 1 void setAcceptShortPacket (boolean) + 1 boolean isComplete () + 1 void setComplete (boolean) + 1 void complete () + 1 void waitUntilComplete () + 1 void waitUntilComplete (long) +} +1 javax.usb.util.StandardRequest extends java.lang.Object +{ + 1 javax.usb.util.StandardRequest (javax.usb.UsbDevice) + 1 void clearFeature (byte,short,short) throws javax.usb.UsbException,java.lang.IllegalArgumentException + 1 byte getConfiguration () throws javax.usb.UsbException + 1 int getDescriptor (byte,byte,short,byte[]) throws javax.usb.UsbException + 1 byte getInterface (short) throws javax.usb.UsbException + 1 short getStatus (byte,short) throws javax.usb.UsbException,java.lang.IllegalArgumentException + 1 void setAddress (short) throws javax.usb.UsbException + 1 void setConfiguration (short) throws javax.usb.UsbException + 1 int setDescriptor (byte,byte,short,byte[]) throws javax.usb.UsbException + 1 void setFeature (byte,short,short) throws javax.usb.UsbException,java.lang.IllegalArgumentException + 1 void setInterface (short,short) throws javax.usb.UsbException + 1 short synchFrame (short) throws javax.usb.UsbException + 9 void clearFeature (javax.usb.UsbDevice,byte,short,short) throws javax.usb.UsbException,java.lang.IllegalArgumentException + 9 byte getConfiguration (javax.usb.UsbDevice) throws javax.usb.UsbException + 9 int getDescriptor (javax.usb.UsbDevice,byte,byte,short,byte[]) throws javax.usb.UsbException + 9 byte getInterface (javax.usb.UsbDevice,short) throws javax.usb.UsbException + 9 short getStatus (javax.usb.UsbDevice,byte,short) throws javax.usb.UsbException,java.lang.IllegalArgumentException + 9 void setAddress (javax.usb.UsbDevice,short) throws javax.usb.UsbException + 9 void setConfiguration (javax.usb.UsbDevice,short) throws javax.usb.UsbException + 9 int setDescriptor (javax.usb.UsbDevice,byte,byte,short,byte[]) throws javax.usb.UsbException + 9 void setFeature (javax.usb.UsbDevice,byte,short,short) throws javax.usb.UsbException,java.lang.IllegalArgumentException + 9 void setInterface (javax.usb.UsbDevice,short,short) throws javax.usb.UsbException + 9 short synchFrame (javax.usb.UsbDevice,short) throws javax.usb.UsbException + 12 void checkRecipient (byte) throws java.lang.IllegalArgumentException +} +1 javax.usb.util.UsbUtil extends java.lang.Object +{ + 1 javax.usb.util.UsbUtil () + 9 short unsignedShort (byte) + 9 int unsignedInt (byte) + 9 int unsignedInt (short) + 9 long unsignedLong (byte) + 9 long unsignedLong (short) + 9 long unsignedLong (int) + 9 short toShort (byte,byte) + 9 int toInt (byte,byte,byte,byte) + 9 long toLong (byte,byte,byte,byte,byte,byte,byte,byte) + 9 int toInt (short,short) + 9 long toLong (short,short,short,short) + 9 long toLong (int,int) + 9 java.lang.String toHexString (byte) + 9 java.lang.String toHexString (short) + 9 java.lang.String toHexString (int) + 9 java.lang.String toHexString (long) + 9 java.lang.String toHexString (long,char,int,int) + 9 java.lang.String toHexString (java.lang.String,byte[],int) + 9 java.lang.String toHexString (java.lang.String,short[],int) + 9 java.lang.String toHexString (java.lang.String,int[],int) + 9 java.lang.String toHexString (java.lang.String,long[],int) + 9 java.lang.String toHexString (java.lang.String,byte[]) + 9 java.lang.String toHexString (java.lang.String,short[]) + 9 java.lang.String toHexString (java.lang.String,int[]) + 9 java.lang.String toHexString (java.lang.String,long[]) + 9 java.lang.String getSpeedString (java.lang.Object) + 9 javax.usb.UsbDevice synchronizedUsbDevice (javax.usb.UsbDevice) + 9 javax.usb.UsbPipe synchronizedUsbPipe (javax.usb.UsbPipe) +} +9 javax.usb.util.UsbUtil$SynchronizedUsbDevice extends java.lang.Object implements javax.usb.UsbDevice +{ + 1 javax.usb.util.UsbUtil$SynchronizedUsbDevice (javax.usb.UsbDevice) + 1 javax.usb.UsbPort getParentUsbPort () + 1 boolean isUsbHub () + 1 java.lang.String getManufacturerString () throws javax.usb.UsbException,java.io.UnsupportedEncodingException + 1 java.lang.String getSerialNumberString () throws javax.usb.UsbException,java.io.UnsupportedEncodingException + 1 java.lang.String getProductString () throws javax.usb.UsbException,java.io.UnsupportedEncodingException + 1 java.lang.Object getSpeed () + 1 java.util.List getUsbConfigurations () + 1 javax.usb.UsbConfiguration getUsbConfiguration (byte) + 1 boolean containsUsbConfiguration (byte) + 1 byte getActiveUsbConfigurationNumber () + 1 javax.usb.UsbConfiguration getActiveUsbConfiguration () + 1 boolean isConfigured () + 1 javax.usb.UsbDeviceDescriptor getUsbDeviceDescriptor () + 1 javax.usb.UsbStringDescriptor getUsbStringDescriptor (byte) throws javax.usb.UsbException + 1 java.lang.String getString (byte) throws javax.usb.UsbException,java.io.UnsupportedEncodingException + 1 void syncSubmit (javax.usb.UsbControlIrp) throws javax.usb.UsbException + 1 void asyncSubmit (javax.usb.UsbControlIrp) throws javax.usb.UsbException + 1 void syncSubmit (java.util.List) throws javax.usb.UsbException + 1 void asyncSubmit (java.util.List) throws javax.usb.UsbException + 1 javax.usb.UsbControlIrp createUsbControlIrp (byte,byte,short,short) + 1 void addUsbDeviceListener (javax.usb.event.UsbDeviceListener) + 1 void removeUsbDeviceListener (javax.usb.event.UsbDeviceListener) +} +9 javax.usb.util.UsbUtil$SynchronizedUsbPipe extends java.lang.Object implements javax.usb.UsbPipe +{ + 1 javax.usb.util.UsbUtil$SynchronizedUsbPipe (javax.usb.UsbPipe) + 1 void open () throws javax.usb.UsbException,javax.usb.UsbNotActiveException,javax.usb.UsbNotClaimedException + 1 void close () throws javax.usb.UsbException,javax.usb.UsbNotOpenException + 1 boolean isActive () + 1 boolean isOpen () + 1 javax.usb.UsbEndpoint getUsbEndpoint () + 1 int syncSubmit (byte[]) throws javax.usb.UsbException,javax.usb.UsbNotOpenException + 1 javax.usb.UsbIrp asyncSubmit (byte[]) throws javax.usb.UsbException,javax.usb.UsbNotOpenException + 1 void syncSubmit (javax.usb.UsbIrp) throws javax.usb.UsbException,javax.usb.UsbNotOpenException + 1 void asyncSubmit (javax.usb.UsbIrp) throws javax.usb.UsbException,javax.usb.UsbNotOpenException + 1 void syncSubmit (java.util.List) throws javax.usb.UsbException,javax.usb.UsbNotOpenException + 1 void asyncSubmit (java.util.List) throws javax.usb.UsbException,javax.usb.UsbNotOpenException + 1 void abortAllSubmissions () throws javax.usb.UsbNotOpenException + 1 javax.usb.UsbIrp createUsbIrp () + 1 javax.usb.UsbControlIrp createUsbControlIrp (byte,byte,short,short) + 1 void addUsbPipeListener (javax.usb.event.UsbPipeListener) + 1 void removeUsbPipeListener (javax.usb.event.UsbPipeListener) +} diff --git a/src/test/resources/javax.usb.properties b/src/test/resources/javax.usb.properties new file mode 100644 index 0000000..ca120cb --- /dev/null +++ b/src/test/resources/javax.usb.properties @@ -0,0 +1 @@ +javax.usb.services = de.ailis.usb4java.Services