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
+ * 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