- * The USB port type.
- * @param
-{
- /**
- * Returns the number of ports.
- *
- * @return The number of ports.
- */
- byte getNumberOfPorts();
-
- /**
- * Returns the ports.
- *
- * @return The ports.
- */
- List getUsbPorts();
-
- /**
- * Returns the USB port with the specified port number.
- *
- * @param number
- * The USB port number.
- * @return The USB port or null if no such port.
- */
- P getUsbPort(final byte number);
-
- /**
- * Returns the attached USB devices.
- *
- * @return The attached USB devices.
- */
- List
- * This test verifies that error conditions are generated and proper
- * exceptions are thrown in the operation.
- *
- * @author Thanh Ngo
- */
-
-@SuppressWarnings("all")
-@RunWith(TCKRunner.class)
-public class BulkIOErrorConditionsTest extends TestCase
-{
- //-------------------------------------------------------------------------
- // Ctor(s)
- //
-
-
- public BulkIOErrorConditionsTest()
- {
- thisTest = new IOErrorConditionsTest(UsbConst.ENDPOINT_TYPE_BULK);
- }
-
- //-------------------------------------------------------------------------
- // Protected overridden methods
- //
-
- protected void setUp() throws Exception {
- thisTest.setUp();
-
- }
-
- protected void tearDown() throws Exception {
- thisTest.tearDown();
- }
-
-
-
- /**
- * Null Data Buffer
- */
- public void testNullDataBufferInIrp()
- {
- thisTest.testNullDataBufferInIrp();
- }
- /**
- * Null Data Buffer
- */
- public void testNullDataBufferAsByteArray()
- {
- thisTest.testNullDataBufferAsByteArray();
- }
-
- /**
- * Action against a closed pipe
- */
- public void testActionAgainstClosePipeAbortAllSubmissions()
- {
- thisTest.testActionAgainstClosePipeAbortAllSubmissions();
- }
- /**
- * Action against a closed pipe
- */
- public void testActionAgainstClosePipeSubmit()
- {
- thisTest.testActionAgainstClosePipeSubmit();
- }
-
- /**
- * Close a pipe with pending operation
- */
- public void testClosePipePendingAction()
- {
- thisTest.testClosePipePendingAction();
- }
-
- // Moved method testOpenPipeOnInactiveAlternateSetting into the optional setInterface tests @P1D7
-
- /**
- * Open a pipe on an unclaimed interface
- */
- public void testOpenPipeOnUnclaimedInterface()
- {
- thisTest.testOpenPipeOnUnclaimedInterface();
- }
-
- /**
- * Claim an already claimed interface
- */
- public void testClaimAnAlreadyClaimedInterface()
- {
- thisTest.testClaimAnAlreadyClaimedInterface();
-
- }
-
-
- private IOErrorConditionsTest thisTest = null;
-}
diff --git a/src/test/java/javax/usb/tck/BulkIOTests.java b/src/test/java/javax/usb/tck/BulkIOTests.java
deleted file mode 100755
index a71ccfc..0000000
--- a/src/test/java/javax/usb/tck/BulkIOTests.java
+++ /dev/null
@@ -1,576 +0,0 @@
-/**
- * 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 java.util.*;
-
-import javax.usb.*;
-
-import org.junit.runner.RunWith;
-
-import org.usb4java.test.TCKRunner;
-
-import junit.framework.*;
-
-/**
- * Bulk IO Test -- Synchronous and asynchronous byte[], IRP, and IRP List submissions
- *
- * The goal of the Bulk, Interrupt, and Isochronous IO test is to
- * verify that IN and OUT pipes can be opened and closed, and verify
- * that bulk, interrupt, and isochronous transfer operations work successfully, proper
- * events are generated, and proper exceptions are thrown in the operation.
- *
- * @author Leslie Blair
- */
-
-
-@SuppressWarnings("all")
-@RunWith(TCKRunner.class)
-public class BulkIOTests extends TestCase
-{
- public void setUp() throws Exception
- {
- endpointType = UsbConst.ENDPOINT_TYPE_BULK;
- usbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice();
- Assert.assertNotNull("Device required for test not found",usbDevice);
- IOMethods.createListofAllAvailablePipesOfSpecifiedEndpointType(usbDevice, endpointType, usbPipeListGlobal);
- super.setUp();
- }
- public void tearDown() throws Exception
- {
- IOMethods.releaseListOfPipes(usbPipeListGlobal);
- super.tearDown();
- }
-
- public void testByteArray_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer8bytes_passthrough()
- {
-
- byte testType = IOTests.BYTE_ARRAY;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 8;
- byte []transformType = {IOTests.TRANSFORM_TYPE_PASSTHROUGH};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {8};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
-
- public void testByteArray_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer16bytes_invertBits()
- {
-
- byte testType = IOTests.BYTE_ARRAY;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 8;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_BITS};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {16};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- public void testByteArray_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer24bytes_invertAltBits()
- {
-
- byte testType = IOTests.BYTE_ARRAY;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 8;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_ALTERNATE_BITS};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {24};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testByteArray_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer17bytes_passthrough()
- {
- byte testType = IOTests.BYTE_ARRAY;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 64;
- byte []transformType = {IOTests.TRANSFORM_TYPE_PASSTHROUGH};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {17};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testByteArray_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer66bytes_invertBits()
- {
- byte testType = IOTests.BYTE_ARRAY;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 64;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_BITS};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {66};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testByteArray_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer129bytes_invertAltBits()
- {
- byte testType = IOTests.BYTE_ARRAY;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 64;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_ALTERNATE_BITS};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {129};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- public void testSingleIRP_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer8bytes_invertBits()
- {
-
- byte testType = IOTests.IRP;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 8;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_BITS};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {8};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- public void testSingleIRP_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer16bytes_invertAltBits()
- {
-
- byte testType = IOTests.IRP;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 8;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_ALTERNATE_BITS};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {16};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- public void testSingleIRP_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer64bytes_passthrough()
- {
-
- byte testType = IOTests.IRP;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 8;
- byte []transformType = {IOTests.TRANSFORM_TYPE_PASSTHROUGH};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {64};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testSingleIRP_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer25bytes_invertBits()
- {
- byte testType = IOTests.IRP;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 64;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_BITS};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {25};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testSingleIRP_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer72bytes_invertAltBits()
- {
- byte testType = IOTests.IRP;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 64;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_ALTERNATE_BITS};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {72};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
-
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testSingleIRP_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer130bytes_passthrough()
- {
- byte testType = IOTests.IRP;
- /*
- * values from table
- */
- int numberOfIrps = 1;
- int endpointmaxPacketSize = 64;
- byte []transformType = {IOTests.TRANSFORM_TYPE_PASSTHROUGH};
-
- boolean[] IrpAcceptShortPacket = {true};
- boolean[] verifyAcceptShortPacket = {true};
-
-
- int []OUTLength = {130};
- int []OUTOffset = {0};
- int []OUTExpectedActualLength = {OUTLength[0]};
- Exception[] OUTExpectedException = {null};
-
- int []INLength = {OUTLength[0]};
- int []INOffset = {OUTOffset[0]};
- int []INExpectedActualLength = {OUTLength[0]};
- Exception[] INExpectedException = {null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- public void testIRPListBuffersMultiplesOfMaxPacketSizeOf8bytes()
- {
-
- byte testType = IOTests.IRPLIST;
- /*
- * values from table
- */
- int numberOfIrps = 3;
- int endpointmaxPacketSize = 8;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_BITS, IOTests.TRANSFORM_TYPE_INVERT_ALTERNATE_BITS,
- IOTests.TRANSFORM_TYPE_PASSTHROUGH};
-
- boolean[] IrpAcceptShortPacket = {true, true, true};
- boolean[] verifyAcceptShortPacket = {true, true, true};
-
-
- int []OUTLength = {8,16, 24};
- int []OUTOffset = {0, 8, 24};
- int []OUTExpectedActualLength = {OUTLength[0], OUTLength[1], OUTLength[2]};
- Exception[] OUTExpectedException = {null, null, null};
-
- int []INLength = {OUTLength[0], OUTLength[1], OUTLength[2]};
- int []INOffset = {OUTOffset[0], OUTOffset[1], OUTOffset[2]};
- int []INExpectedActualLength = {OUTLength[0],OUTLength[1], OUTLength[2]};
- Exception[] INExpectedException = {null, null, null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
-
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testIRPListBuffersNOTMultiplesOfMaxPacketSizeOf64bytes()
- {
- byte testType = IOTests.IRPLIST;
- /*
- * values from table
- */
- int numberOfIrps = 3;
- int endpointmaxPacketSize = 64;
- byte []transformType = {IOTests.TRANSFORM_TYPE_INVERT_BITS, IOTests.TRANSFORM_TYPE_INVERT_ALTERNATE_BITS,
- IOTests.TRANSFORM_TYPE_PASSTHROUGH};
-
- boolean[] IrpAcceptShortPacket = {true, true, true};
- boolean[] verifyAcceptShortPacket = {true, true, true};
-
-
- int []OUTLength = {12, 75, 130};
- int []OUTOffset = {0, 12, 87};
- int []OUTExpectedActualLength = {OUTLength[0], OUTLength[1], OUTLength[2]};
- Exception[] OUTExpectedException = {null, null, null};
-
- int []INLength = {OUTLength[0], OUTLength[1], OUTLength[2]};
- int []INOffset = {OUTOffset[0], OUTOffset[1], OUTOffset[2]};
- int []INExpectedActualLength = {OUTLength[0],OUTLength[1], OUTLength[2]};
- Exception[] INExpectedException = {null, null, null};
-
- IOTests thisIOTest = new IOTests(usbDevice, usbPipeListGlobal, endpointType, testType);
- thisIOTest.RoundTripIOTest(testType, numberOfIrps, endpointmaxPacketSize,
- IrpAcceptShortPacket, verifyAcceptShortPacket, OUTLength, OUTOffset, OUTExpectedActualLength,
- OUTExpectedException,
- INLength, INOffset, INExpectedActualLength,
- INExpectedException,
- transformType );
-
- };
- /**
- * Constructor
- */
- public BulkIOTests()
- {
- super();
- };
-
- protected BulkIOTests(UsbDevice newUsbDevice, List newUsbPipeList, byte newEndpointType)
- {
- usbPipeListGlobal = newUsbPipeList;
- usbDevice = newUsbDevice;
- endpointType = newEndpointType;
- };
-
-
-
- private List usbPipeListGlobal = new ArrayList();
- private byte endpointType;
- private UsbDevice usbDevice;
-
-
- private static void printDebug(String infoString)
- {
- if ( printDebug )
- {
- System.out.println(infoString);
- }
- }
- private static boolean printDebug = false;
- //private static boolean printDebug = true;
-}
diff --git a/src/test/java/javax/usb/tck/BulkIOTestwithSynchronizedUsbPipe.java b/src/test/java/javax/usb/tck/BulkIOTestwithSynchronizedUsbPipe.java
deleted file mode 100755
index 5e5d0be..0000000
--- a/src/test/java/javax/usb/tck/BulkIOTestwithSynchronizedUsbPipe.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * 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 java.util.*;
-
-import javax.usb.*;
-import javax.usb.util.*;
-
-import org.junit.runner.RunWith;
-
-import org.usb4java.test.TCKRunner;
-
-import junit.framework.*;
-
-/**
- * Bulk IO Test -- Synchronous and asynchronous byte[], IRP, and IRP List submissions
- * using UsbUtil.synchronizedUsbPipe
- *
- * The goal of the Bulk, Interrupt, and Isochronous IO test is to
- * verify that IN and OUT pipes can be opened and closed, and verify
- * that bulk, interrupt, and isochronous transfer operations work successfully, proper
- * events are generated, and proper exceptions are thrown in the operation.
- *
- * @author Leslie Blair
- */
-
-
-@SuppressWarnings("all")
-@RunWith(TCKRunner.class)
-public class BulkIOTestwithSynchronizedUsbPipe extends TestCase
-{
- public void setUp() throws Exception
- {
- endpointType = UsbConst.ENDPOINT_TYPE_BULK;
- usbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice();
- Assert.assertNotNull("Device required for test not found",usbDevice);
- IOMethods.createListofAllAvailablePipesOfSpecifiedEndpointType(usbDevice, endpointType, usbPipeListNotSynchronized);
- for ( int i=0; i
- * 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")
-@RunWith(TCKRunner.class)
-public class DefaultControlPipeTestErrorConditions 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 testUsbShortPacketException()
- {
- usbDevice.addUsbDeviceListener(deviceListener);
-
- for ( int i=0; (i < iterations); i++ )
- {
- for ( int j=0; j
- * This test is the same as the DefaultControlPipeTestErrorConditions except a
- * UsbUtil.SynchronizedUsbDevice is used in place of a UsbDevice.
- *
- * 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")
-@RunWith(TCKRunner.class)
-public class DefaultControlPipeTestErrorConditionswithSynchronizedUsbDevice extends TestCase
-{
- public void setUp() throws Exception
- {
- originalUsbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice();
- usbDevice = new UsbUtil.SynchronizedUsbDevice(originalUsbDevice);
- assertNotNull("Device required for test not found",usbDevice);
- DCPIRPTestErrorConditions = new DefaultControlPipeTestErrorConditions(usbDevice);
- super.setUp();
-
- }
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- public void testUsbShortPacketException()
- {
- DCPIRPTestErrorConditions.testUsbShortPacketException();
- };
-
- // TODO No idea how to detect a STALL condition in libusb 0.1
- public void disabled_testUsbStallException()
- {
- DCPIRPTestErrorConditions.disabled_testUsbStallException();
- };
-
- public void testNotCallingsetDataForIRP()
- {
- DCPIRPTestErrorConditions.testNotCallingsetDataForIRP();
- };
-
-
-
- private UsbDevice originalUsbDevice;
- private UsbDevice usbDevice;
- DefaultControlPipeTestErrorConditions DCPIRPTestErrorConditions;
-}
diff --git a/src/test/java/javax/usb/tck/DefaultControlPipeTestIRP.java b/src/test/java/javax/usb/tck/DefaultControlPipeTestIRP.java
deleted file mode 100755
index e17535a..0000000
--- a/src/test/java/javax/usb/tck/DefaultControlPipeTestIRP.java
+++ /dev/null
@@ -1,903 +0,0 @@
-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 org.junit.runner.RunWith;
-
-import org.usb4java.test.TCKRunner;
-
-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")
-@RunWith(TCKRunner.class)
-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
- * 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")
-@RunWith(TCKRunner.class)
-public class DefaultControlPipeTestIRPListwithSynchronizedUsbDevice extends TestCase
-{
-
-
- public void setUp() throws Exception
- {
- originalUsbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice();
- usbDevice = new UsbUtil.SynchronizedUsbDevice(originalUsbDevice);
- assertNotNull("Device required for test not found",usbDevice);
- DCPIRPTestList = new DefaultControlPipeTestIRPList(usbDevice);
- super.setUp();
-
- }
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
-
-
- /**
- * testBuffersMultiplesOfMaxPacketSize()--send OUT data which will be saved in device and made
- * available on next IN request. Size of OUT data will be a multiple of maxPacketSize (64 bytes)
- */
- public void testBuffersMultiplesOfMaxPacketSize()
- {
- DCPIRPTestList.testBuffersMultiplesOfMaxPacketSize();
- };
-
- /**
- * testBuffersNotMultiplesOfMaxPacketSize()--send OUT data which will be saved in device and made
- * available on next IN request. Size of OUT data will not be a multiple of maxPacketSize (64 bytes).
- */
- public void testBuffersNotMultiplesOfMaxPacketSize()
- {
- DCPIRPTestList.testBuffersNotMultiplesOfMaxPacketSize();
- };
-
- private UsbDevice originalUsbDevice;
- private UsbDevice usbDevice;
- DefaultControlPipeTestIRPList DCPIRPTestList;
-}
-
diff --git a/src/test/java/javax/usb/tck/DefaultControlPipeTestIRPwithSynchronizedUsbDevice.java b/src/test/java/javax/usb/tck/DefaultControlPipeTestIRPwithSynchronizedUsbDevice.java
deleted file mode 100755
index 33f1fd6..0000000
--- a/src/test/java/javax/usb/tck/DefaultControlPipeTestIRPwithSynchronizedUsbDevice.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * 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 javax.usb.*;
-import javax.usb.util.*;
-
-import org.junit.runner.RunWith;
-
-import org.usb4java.test.TCKRunner;
-
-import junit.framework.TestCase;
-
-/**
- * Default Control Pipe Test -- Synchronous and asynchronous IRP submissions
- * using UsbUtilSynchronizedUsbDevice
- *
- * This test is the same as the DefaultControlPipeTestIRP except a
- * UsbUtil.SynchronizedUsbDevice is used in place of a UsbDevice.
- *
- * 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")
-@RunWith(TCKRunner.class)
-public class DefaultControlPipeTestIRPwithSynchronizedUsbDevice extends TestCase
-{
- public void setUp() throws Exception
- {
- originalUsbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice();
- usbDevice = new UsbUtil.SynchronizedUsbDevice(originalUsbDevice);
- assertNotNull("Device required for test not found",usbDevice);
- DCPIRPTest = new DefaultControlPipeTestIRP(usbDevice);
- super.setUp();
-
- }
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- public void testBuffersMultiplesOfMaxPacketSize_1packets()
- {
-
- DCPIRPTest.testBuffersMultiplesOfMaxPacketSize_1packets();
-
- };
- public void testBuffersMultiplesOfMaxPacketSize_2packets()
- {
- DCPIRPTest.testBuffersMultiplesOfMaxPacketSize_2packets();
- };
-
- public void testBuffersMultiplesOfMaxPacketSize_moreThan2Packets()
- {
- DCPIRPTest.testBuffersMultiplesOfMaxPacketSize_moreThan2Packets();
- };
-
- public void testBuffersNotMultiplesOfMaxPacketSize_1packets()
- {
- DCPIRPTest.testBuffersNotMultiplesOfMaxPacketSize_1packets();
- };
-
- public void testBuffersNotMultiplesOfMaxPacketSize_2packets()
- {
- DCPIRPTest.testBuffersNotMultiplesOfMaxPacketSize_2packets();
- };
-
- public void testBuffersNotMultiplesOfMaxPacketSize_MoreThan2packets()
- {
- DCPIRPTest.testBuffersNotMultiplesOfMaxPacketSize_MoreThan2packets();
- };
-
- public void testRequestClearFeature()
- {
- DCPIRPTest.testRequestClearFeature();
- };
-
- public void testRequestGetDescriptor()
- {
- DCPIRPTest.testRequestGetDescriptor();
- };
-
-
- private UsbDevice originalUsbDevice;
- private UsbDevice usbDevice;
- DefaultControlPipeTestIRP DCPIRPTest;
-}
\ No newline at end of file
diff --git a/src/test/java/javax/usb/tck/FindControlIODevice.java b/src/test/java/javax/usb/tck/FindControlIODevice.java
deleted file mode 100755
index d4392df..0000000
--- a/src/test/java/javax/usb/tck/FindControlIODevice.java
+++ /dev/null
@@ -1,330 +0,0 @@
-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
- *
- */
-
-/*
- * Change Activity: See below.
- *
- * FLAG REASON RELEASE DATE WHO DESCRIPTION
- * ---- -------- -------- ------ -------- ------------------------------------
- * 0000 nnnnnnn yymmdd Initial Development
- * $P1 tck.rel1 041222 raulortz Redesign TCK to create base and optional
- * tests. Separate setConfig, setInterface
- * and isochronous transfers as optionals.
- */
-
-import java.util.*;
-import javax.usb.*;
-import javax.usb.util.*;
-
-import org.junit.runner.RunWith;
-
-import org.usb4java.test.TCKRunner;
-
-/**
- * FindControlIODevice
- *
- * This Singleton class finds the first device with a UsbEndpoint with the type
- * ENDPOINT_TYPE_CONTROL and returns the device. Used by the
- * ControlIODevice class.
- * usage: (FindControlIODevice.getInstance()).getControlIODevice()
- * @author Joshua Lowry
- */
-
-@SuppressWarnings("all")
-public class FindControlIODevice extends Object
-{
- //--------------------------------------------------------------------------
- // Ctor(s)
- //
-
- /**
- * The constructor is protected as this is a singleton class.
- */
- protected FindControlIODevice()
- {
- }
-
- //--------------------------------------------------------------------------
- // Public methods
- //
-
- /**
- * Creates and returns the sole instance of the FindControlIODevice class.
- * @return FindControlIODevice
- */
- public static FindControlIODevice getInstance()
- {
- if ( instance == null )
- {
- instance = new FindControlIODevice();
- instance.init();
- }
- return instance;
- }
-
- //--------------------------------------------------------------------------
- // Protected methods
- //
-
- /** Initializes the FindControlIODevice instance */
- protected void init()
- {
- // empty
- }
-
-
- //--------------------------------------------------------------------------
- // Public methods
- //
-
- /**
- * Finds the first device with a Control Pipe other than the default Control
- * Pipe and returns it. Returns null if no such device is found.
- * @return UsbDevice
- */
- public UsbDevice getControlIODevice()
- {
- virtualRootUsbHub = getVirtualRootUsbHub();
- usbDevices = null;
- // get all connected devices
- if ( debug )
- {
- usbDevices = getAllUsbDevices(virtualRootUsbHub);
- System.out.println("Found " + usbDevices.size() + " devices total.");
- }
- usbDevices = getUsbDevicesWithCtrlEndpoint(virtualRootUsbHub);
- if ( usbDevices.isEmpty() )
- {
- if ( debug )
- {
- System.out.println("List Empty");
- }
- return null;
- } else
- {
- // return the first item
- return(UsbDevice)usbDevices.get(0);
- }
- }
-
- /**
- * Finds a list of devices with a Control Pipe other than the default Cotrol
- * Pipe and returns it. Returns null if no devices are found.
- * @return UsbDevice
- */
- public List getControlIODevicesList()
- {
- virtualRootUsbHub = getVirtualRootUsbHub();
- usbDevices = null;
- // get all connected devices
- if ( debug )
- {
- usbDevices = getAllUsbDevices(virtualRootUsbHub);
- System.out.println("Found " + usbDevices.size() + " devices total.");
- }
- usbDevices = getUsbDevicesWithCtrlEndpoint(virtualRootUsbHub);
- if ( usbDevices.isEmpty() )
- {
- if ( debug )
- {
- System.out.println("List Empty");
- }
- return null;
- }
-
- // return the list
- return usbDevices;
- }
-
- //--------------------------------------------------------------------------
- // Private methods
- //
-
- /*
- * Get the virtual root UsbHub.
- * @return
- */
- private static UsbHub getVirtualRootUsbHub()
- {
- UsbServices services = null;
- UsbHub virtualRootUsbHub = null;
-
- /* First we need to get the UsbServices.
- * This might throw either an UsbException or SecurityException.
- * A SecurityException means we're not allowed to access the USB bus,
- * while a UsbException indicates there is a problem either in
- * the javax.usb implementation or the OS USB support.
- */
- try
- {
- services = UsbHostManager.getUsbServices();
- } catch ( UsbException uE )
- {
- throw new RuntimeException("Error : " + uE.getMessage());
- } catch ( SecurityException sE )
- {
- throw new RuntimeException("Error : " + sE.getMessage());
- }
-
- /* Now we need to get the virtual root UsbHub,
- * everything is connected to it. The Virtual Root UsbHub
- * doesn't actually correspond to any physical device, it's
- * strictly virtual. Each of the devices connected to one of its
- * ports corresponds to a physical host controller located in
- * the system. Those host controllers are (usually) located inside
- * the computer, e.g. as a PCI board, or a chip on the mainboard,
- * or a PCMCIA card. The virtual root UsbHub aggregates all these
- * host controllers.
- *
- * This also may throw an UsbException or SecurityException.
- */
- try
- {
- virtualRootUsbHub = services.getRootUsbHub();
- } catch ( UsbException uE )
- {
- throw new RuntimeException("Error : " + uE.getMessage());
- } catch ( SecurityException sE )
- {
- throw new RuntimeException("Error : " + sE.getMessage());
- }
-
- return virtualRootUsbHub;
- }
-
-
- /*
- * This forms an inclusive list of all UsbDevices connected to this
- * UsbDevice.
- *
- * 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
- */
- 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 error conditions are generated and proper
- * exceptions are thrown in the operation.
- *
- * @author Thanh Ngo
- */
-
-@SuppressWarnings("all")
-@Ignore("These tests are triggered by other tests and must not run directly")
-public class IOErrorConditionsTest extends TestCase
-{
- //-------------------------------------------------------------------------
- // Ctor(s)
- //
-
- public IOErrorConditionsTest(String name)
- {
- super(name);
- }
- public IOErrorConditionsTest(int typeOfTest)
- {
- testType = typeOfTest;
- }
-
- //-------------------------------------------------------------------------
- // Protected overridden methods
- //
-
- protected void setUp() throws Exception {
- printDebug("setUp");
-
-
- usbDevice = programmableDevice.getProgrammableDevice();
- assertTrue("Find Programmable board Failed! Got a null instance",
- usbDevice != null);
-
-
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- printDebug("tearDown");
- try // @P1A
- { // @P1A
- if ( (outPipe!=null)&&(outPipe.isOpen()) ) // @P1C
- { // @P1C
- outPipe.abortAllSubmissions(); // @P1C
- IOMethods.closePipe(outPipe); // @P1C
- } // @P1C
- if ( (inPipe!=null)&&(inPipe.isOpen()) ) // @P1C
- { // @P1C
- inPipe.abortAllSubmissions(); // @P1C
- IOMethods.closePipe(inPipe); // @P1C
- } // @P1C
- if ( (myIface!=null)&&(myIface.isClaimed()) ) // @P1C
- { // @P1C
- IOMethods.releaseInterface(myIface); // @P1C
- } // @P1C
- } catch ( UsbDisconnectedException uDE ) // @P1A
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } // @P1A
-
- super.tearDown();
- }
-
- //-------------------------------------------------------------------------
- // Public testXyz() methods
- //
-
- /**
- * Null Data Buffer
- */
- public void testNullDataBufferInIrp()
- {
- printDebug("testNullDataBufferInIrp");
- if ( testType == bulkTest )
- {
- doTestNullDataBufferInIrp(UsbConst.ENDPOINT_TYPE_BULK);
- } else if ( testType == intTest )
- {
-
- doTestNullDataBufferInIrp(UsbConst.ENDPOINT_TYPE_INTERRUPT);
-
- } else if ( testType == isochronousTest )
- {
- doTestNullDataBufferInIrp(UsbConst.ENDPOINT_TYPE_ISOCHRONOUS);
-
- } else
- {
- fail("Test is defined for only bulk and isochronous endpoints.");
- }
- }
- /**
- * Null Data Buffer
- */
- public void testNullDataBufferAsByteArray()
- {
- printDebug("testNullDataBufferAsByteArray");
- if ( testType == bulkTest )
- {
- doTestNullDataBufferAsByteArray(UsbConst.ENDPOINT_TYPE_BULK);
- } else if ( testType == intTest )
- {
- doTestNullDataBufferAsByteArray(UsbConst.ENDPOINT_TYPE_INTERRUPT);
-
- } else if ( testType == isochronousTest )
- {
- doTestNullDataBufferAsByteArray(UsbConst.ENDPOINT_TYPE_ISOCHRONOUS);
-
- } else
- {
- fail("Test is defined for only bulk and isochronous endpoints.");
- }
- }
-
- /**
- * Action against a closed pipe
- */
- public void testActionAgainstClosePipeAbortAllSubmissions()
- {
- printDebug("testActionAgainstClosePipeAbortAllSubmissions");
- if ( testType == bulkTest )
- {
-
- doTestActionAgainstClosePipeAbortAllSubmissions(UsbConst.ENDPOINT_TYPE_BULK);
- } else if ( testType == intTest )
- {
- doTestActionAgainstClosePipeAbortAllSubmissions(UsbConst.ENDPOINT_TYPE_INTERRUPT);
- } else if ( testType == isochronousTest )
- {
- doTestActionAgainstClosePipeAbortAllSubmissions(UsbConst.ENDPOINT_TYPE_ISOCHRONOUS);
- } else
- {
- fail("Test is defined for only bulk and isochronous endpoints.");
- }
-
-
- }
- /**
- * Action against a closed pipe
- */
- public void testActionAgainstClosePipeSubmit()
- {
- printDebug("testActionAgainstClosePipeSubmit");
- if ( testType == bulkTest )
- {
-
- doTestActionAgainstClosePipeSubmit(UsbConst.ENDPOINT_TYPE_BULK);
- } else if ( testType == intTest )
- {
- doTestActionAgainstClosePipeSubmit(UsbConst.ENDPOINT_TYPE_INTERRUPT);
- } else if ( testType == isochronousTest )
- {
- doTestActionAgainstClosePipeSubmit(UsbConst.ENDPOINT_TYPE_ISOCHRONOUS);
- } else
- {
- fail("Test is defined for only bulk and isochronous endpoints.");
- }
-
-
- }
-
- /**
- * Close a pipe with pending operation
- */
- public void testClosePipePendingAction()
-
- {
- printDebug("testClosePipePendingAction");
- if ( testType == bulkTest )
- {
- doTestClosePipePendingAction(UsbConst.ENDPOINT_TYPE_BULK);
- } else if ( testType == intTest )
- {
- doTestClosePipePendingAction(UsbConst.ENDPOINT_TYPE_INTERRUPT);
- } else if ( testType == isochronousTest )
- {
- doTestClosePipePendingAction(UsbConst.ENDPOINT_TYPE_ISOCHRONOUS);
- } else
- {
- fail("Test is defined for only bulk and isochronous endpoints.");
- }
-
-
- }
-
- /**
- * Open a pipe on an inactive interface
- */
- public void testOpenPipeOnInactiveAlternateSetting()
- {
- printDebug("testOpenPipeOnInactiveAlternateSetting");
- if ( testType == bulkTest )
- {
-
- doTestOpenPipeOnInactiveAlternateSetting(UsbConst.ENDPOINT_TYPE_BULK);
- } else if ( testType == intTest )
- {
- doTestOpenPipeOnInactiveAlternateSetting(UsbConst.ENDPOINT_TYPE_INTERRUPT);
- } else if ( testType == isochronousTest )
- {
- doTestOpenPipeOnInactiveAlternateSetting(UsbConst.ENDPOINT_TYPE_ISOCHRONOUS);
- } else
- {
- fail("Test is defined for only bulk and isochronous endpoints.");
- }
- }
-
- /**
- * Open a pipe on an unclaimed interface
- */
- public void testOpenPipeOnUnclaimedInterface()
- {
- printDebug("testOpenPipeOnUnclaimedInterface");
- if ( testType == bulkTest )
- {
-
- doTestOpenPipeOnUnclaimedInterface(UsbConst.ENDPOINT_TYPE_BULK);
- } else if ( testType == intTest )
- {
- doTestOpenPipeOnUnclaimedInterface(UsbConst.ENDPOINT_TYPE_INTERRUPT);
- } else if ( testType == isochronousTest )
- {
- doTestOpenPipeOnUnclaimedInterface(UsbConst.ENDPOINT_TYPE_ISOCHRONOUS);
- } else
- {
- fail("Test is defined for only bulk and isochronous endpoints.");
- }
-
- }
-
- /**
- * Claim an already claimed interface
- */
- public void testClaimAnAlreadyClaimedInterface()
- {
- printDebug("testClaimAnAlreadyClaimedInterface");
-
-
- myIface = null;
- boolean usbe = false;
-
- if ( usbDevice.isConfigured() )
- {
- UsbConfiguration usbConfiguration =
- usbDevice.getUsbConfiguration((byte) 1);
- myIface = usbConfiguration.getUsbInterface((byte) 0);
-
- //claim the interface
- IOMethods.claimInterface(myIface);
-
- try
- {
- assertTrue("in doTestClaimAnAlreadyClaimedInterface() --isClaimed() should == true): ",
- myIface.isClaimed());
- myIface.claim();
- fail("should caused UsbClaimException!");
- } catch ( UsbClaimException uce )
- {
-
- usbe = true;
- } catch ( UsbException ue )
- {
- fail("UsbClaimException expected. unexpected UsbException!" + ue);
- } catch ( UsbDisconnectedException uDE ) // @P1C
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } catch ( Exception e ) // @P1C
- {
- fail("UsbClaimException expected. unexpected Exception" + e);
- }
-
- if ( !usbe )
- assertTrue("Test Claim an already claimed interface did not throw UsbNotClaimedException!", false);
-
- } else
- {
- fail("device is not configured!");
- }
-
-
-
- }
-
-// /**
-// * Claim an inactive interface
-// */
-// public void testClaimAnInactiveInterface()
-// {
-// boolean usbe = false;
-// UsbInterface inActiveInterface = getInactiveInterface();
-// if ( null == inActiveInterface )
-// {
-// fail("could not locate an inactive interface to test!");
-// }
-// try
-// {
-// inActiveInterface.claim();
-// fail("should throw Exception when claim an inactive interface!");
-// }
-// catch ( UsbClaimException uce )
-// {
-// }
-// catch ( UsbException ue )
-// {
-// }
-// catch ( UsbNotActiveException unae )
-// {
-// }
-// }
-
-
- /**
- * private functions
- */
-
- /**
- * Test error conditions -- Null Data Buffer
- */
- private void doTestNullDataBufferAsByteArray(int endpointType)
- {
- outPipe = null;
- UsbEndpoint outEndpoint = null;
-
- //UsbInterface myIface = null;
- UsbIrp usbIrp = null;
- boolean usbe = false;
-
-
- if ( usbDevice.isConfigured() )
- {
-
- outEndpoint = getEndpointOfType(usbDevice, endpointType, UsbConst.REQUESTTYPE_DIRECTION_OUT);
-
- assertFalse("could not find output endpoint", null == outEndpoint);
-
- // @P2D4
- assertTrue("Interface was not claimed!", myIface.isClaimed());
-
- //we have an endpoint; now try submitting a null byte array and an IRP
- //with a null data
-
- outPipe = outEndpoint.getUsbPipe();
- assertTrue("output pipe is not active!!!", outPipe.isActive());
- IOMethods.openPipe(outPipe);
-
- //submit null byte array
- byte [] nullBuffer = null;
- try
- {
- outPipe.syncSubmit(nullBuffer);
- fail("Expected a UsbException when submitting a null byte array.");
- } catch ( IllegalArgumentException iAE )
- {
- usbe = true;
- } catch ( UsbException uE )
- {
- fail("java.lang.IllegalArgumentException was expected. Unexpected UsbException on submitting null buffer:" + uE);
- } catch ( UsbDisconnectedException uDE ) // @P1C
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } catch ( Exception e ) // @P1C
- {
- fail("java.lang.IllegalArgumentException was expected. Unexpected generic exception." + e);
- }
-
- assertTrue("java.lang.IllegalArgumentException not received when submitting a null byte []", usbe);
-
-
- } else
- {
- fail ("UsbDevice is not configured!");
- }
-
-
- }
- /**
- * Test error conditions -- Null Data Buffer
- */
- private void doTestNullDataBufferInIrp(int endpointType)
- {
-
- outPipe = null;
- UsbEndpoint outEndpoint = null;
-
- //UsbInterface myIface = null;
- UsbIrp usbIrp = null;
- boolean usbe = false;
-
-
- if ( usbDevice.isConfigured() )
- {
-
- outEndpoint = getEndpointOfType(usbDevice, endpointType, UsbConst.REQUESTTYPE_DIRECTION_OUT);
-
- assertFalse("could not find output endpoint", null == outEndpoint);
-
- // @P2D4
- assertTrue("Interface was not claimed!", myIface.isClaimed());
-
- //we have an endpoint; now try submitting a null byte array and an IRP
- //with a null data
-
- outPipe = outEndpoint.getUsbPipe();
- assertTrue("output pipe is not active!!!", outPipe.isActive());
- IOMethods.openPipe(outPipe);
-
- //submit null byte array
- byte [] nullBuffer = null;
-
-
- //submit IRP with null data
-
- usbIrp = outPipe.createUsbIrp();
-
- try
- {
- usbIrp.setData(nullBuffer);
- fail("Expected a UsbException when setting null data in IRP.");
- outPipe.syncSubmit(usbIrp);
- fail("Expected a UsbException when submitting an IRP with a null byte array in IRP.");
- } catch ( IllegalArgumentException iAE )
- {
- usbe = true;
- } catch ( UsbException uE )
- {
- fail("java.lang.IllegalArgumentException was expected. Unexpected UsbException on settin null data in IRP:" + uE);
- } catch ( UsbDisconnectedException uDE ) // @P1C
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } catch ( Exception e ) // @P1C
- {
- fail("java.lang.IllegalArgumentException was expected. Unexpected generic exception." + e);
- }
-
- assertTrue("java.lang.IllegalArgumentException not received when submitting a null byte [] in IRP", usbe);
-
- } else
- {
- fail ("UsbDevice is not configured!");
- }
-
- }
-
- /**
- * Test error conditions -- Action against a closed pipe
- */
- private void doTestActionAgainstClosePipeAbortAllSubmissions(int endpointType)
- {
-
-
-
- outPipe = null;
- UsbEndpoint outEndpoint = null;
- boolean usbe = false;
-
-
- if ( usbDevice.isConfigured() )
- {
-
- outEndpoint = getEndpointOfType(usbDevice, endpointType, UsbConst.REQUESTTYPE_DIRECTION_OUT);
-
- assertFalse("could not find output endpoint", null == outEndpoint);
- outPipe = outEndpoint.getUsbPipe();
- assertTrue("output pipe is not active!!!", outPipe.isActive());
- assertFalse("pipe should not be open.", outPipe.isOpen());
-
- // @P2D4
- assertTrue("Interface was not claimed!", myIface.isClaimed());
-
-
- try
- {
- outPipe.abortAllSubmissions(); // should throw UsbNotOpenException
- assertFalse("Pipe should have been closed at this part of the test.", outPipe.isOpen());
- fail("abortAllSumissions should have thrown a UsbNotOpenException when called on a closed pipe.");
- } catch ( UsbNotOpenException ue )
- {
- usbe = true;
- } catch ( UsbDisconnectedException uDE ) // @P1C
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } catch ( Exception e ) // @P1C
- {
- fail ("UsbNotOpenException was expected. Unexpected exception: " + e);
- }
-
-
-
- if ( !usbe )
- assertTrue("Test Action Agains Close Pipe abortAllSubmission() did not throw UsbNotOpenException!", false);
-
- }
-
- else
- {
- fail ("UsbDevice is not configured!");
- }
-
- }
- /**
- * Test error conditions -- Action against a closed pipe
- */
- private void doTestActionAgainstClosePipeSubmit(int endpointType)
- {
-
- outPipe = null;
- UsbEndpoint outEndpoint = null;
- boolean usbe = false;
-
-
- if ( usbDevice.isConfigured() )
- {
-
- outEndpoint = getEndpointOfType(usbDevice, endpointType, UsbConst.REQUESTTYPE_DIRECTION_OUT);
-
- assertFalse("could not find output endpoint", null == outEndpoint);
- outPipe = outEndpoint.getUsbPipe();
- assertTrue("output pipe is not active!!!", outPipe.isActive());
- assertFalse("pipe should not be open.", outPipe.isOpen());
-
- // @P2D4
- assertTrue("Interface was not claimed!", myIface.isClaimed());
-
-
- try
- {
- byte [] data = {1,2,3,4,5};
- outPipe.syncSubmit(data);
- assertFalse("Pipe should have been closed at this part of the test.", outPipe.isOpen());
- fail("Submit should have thrown a UsbNotOpenException when called on a closed pipe.");
- } catch ( UsbNotOpenException ue )
- {
- usbe = true;
- } catch ( UsbDisconnectedException uDE ) // @P1C
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } catch ( Exception e ) // @P1A
-
- {
- fail ("UsbNotOpenException was expected. Unexpected exception: " + e);
- }
-
-
- if ( !usbe )
- assertTrue("Test Action Agains Close Pipe Submit did not throw UsbNotOpenException!", false);
-
- }
-
- else
- {
- fail ("UsbDevice is not configured!");
- }
-
-
-
-
-
-
- }
-
- /**
- * Test error conditions -- Close a pipe with pending operation
- */
- private void doTestClosePipePendingAction(int endpointType)
- {
-
- inPipe = null;
- boolean usbe = false;
- UsbEndpoint inEndpoint = null;
-
- // get an out endpoint
- if ( usbDevice.isConfigured() )
- {
-
- inEndpoint = getEndpointOfType(usbDevice, endpointType, UsbConst.REQUESTTYPE_DIRECTION_IN);
-
- assertFalse("could not find endpoint", null == inEndpoint);
-
- inPipe = inEndpoint.getUsbPipe();
- assertTrue("output pipe is not active!!!", inPipe.isActive());
- assertFalse("pipe should not be open.", inPipe.isOpen());
-
- // @P2D4
- assertTrue("Interface was not claimed!", myIface.isClaimed());
-
- // open the pipe
- IOMethods.openPipe(inPipe);
- assertTrue("pipe should be opened", inPipe.isOpen());
-
- try
- {
- //List listOfIrps = new ArrayList();
- List inList = new ArrayList();
- UsbIrp inIrp = null;
-
- for ( int i = 0; i < 1000; i++ )
- {
-
- inIrp = inPipe.createUsbIrp();
- inIrp.setData(new byte[inPipe.getUsbEndpoint().getUsbEndpointDescriptor().wMaxPacketSize()]); // @P2A
- inList.add(inIrp);
- }
- inPipe.asyncSubmit(inList);
- inPipe.close(); // should throw UsbException
- fail ("UsbException should have been thrown when closing pipe with pending submissions.");
- } catch ( UsbException ue )
- {
- usbe = true;
-
- } catch ( UsbDisconnectedException uDE ) // @P1C
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } catch ( Exception e ) // @P1C
- {
- fail("Unexpected Exception: " + e);
- }
- if ( !usbe )
- assertTrue("Test Close Pipe With Pending Operations usbPipe.close() did not throw UsbException!", false);
-
-
- } else
- {
- fail ("UsbDevice is not configured!");
- }
-
- }
-
- /**
- * Test error conditions -- Open a pipe on an inactive interface
- */
- private void doTestOpenPipeOnInactiveAlternateSetting(int endpointType)
- {
-
-
- myIface = null;
- boolean usbe = false;
- UsbEndpoint inEndpoint = null;
- inPipe = null;
-
-
- if ( usbDevice.isConfigured() )
- {
- inEndpoint = getEndpointOfType(usbDevice, endpointType, UsbConst.REQUESTTYPE_DIRECTION_IN);
- if ( (endpointType == UsbConst.ENDPOINT_TYPE_BULK)||
- (endpointType == UsbConst.ENDPOINT_TYPE_INTERRUPT) )
- {
-
-
- assertFalse("could not find endpoint", null == inEndpoint);
- // @P2D3
- } else
- {
-
-
- assertFalse("could not find endpoint", null == inEndpoint);
- // @P2D3
- }
-
- inPipe = inEndpoint.getUsbPipe();
- assertFalse("Pipe should not be active!!!",
- inPipe.isActive());
-
-
- if ( !myIface.isActive() )
- {
- try
- {
- inPipe.open();
- fail("should caused UsbNotActiveException!");
- } catch ( UsbNotActiveException ue )
- {
- usbe = true;
- } catch ( UsbException ue )
- {
- fail("UsbNotActiveException was expected. Unexpected UsbException: " + ue);
- } catch ( UsbDisconnectedException uDE ) // @P1C
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } catch ( Exception e ) // @P1C
- {
- fail("UsbNotActiveException was expected. Unexpected Exception: " + e);
- }
- } else
- {
- fail("Interface should have been inactive at this point.");
- }
- if ( !usbe )
- assertTrue("Test Open Pipe On Inactive Interface did not throw UsbNotActiveException!", false);
-
- }
-
-
- else
- {
- fail ("UsbDevice is not configured!");
- }
-
- assertFalse("Leaving routine but interface was not released!", myIface.isClaimed());
- }
-
-
- private void doTestOpenPipeOnUnclaimedInterface(int endpointType)
- {
- myIface = null;
- boolean usbe = false;
- UsbEndpoint inEndpoint = null;
- inPipe = null;
-
-
- if ( usbDevice.isConfigured() )
- {
- inEndpoint = getEndpointOfType(usbDevice, endpointType, UsbConst.REQUESTTYPE_DIRECTION_IN);
-
-
- assertFalse("could not find endpoint", null == inEndpoint);
-
- // @P2D4
- try
- {
- inEndpoint.getUsbInterface().release();
- } catch ( UsbClaimException ue )
- {
- fail("The interface should have been durring getEndpointOfType method call!");
- } catch ( UsbException ue )
- {
- fail("Unexpected exception: " + ue);
- } catch ( UsbDisconnectedException uDE ) // @P1C
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } // @P1A
-
- if ( myIface.isActive() )
- {
- inPipe = inEndpoint.getUsbPipe();
- assertTrue("pipe is not active!!!",
- inPipe.isActive());
- try
- {
-
-
- inPipe.open();
- fail("should caused UsbNotClaimedException!");
-
- } catch ( UsbNotClaimedException ue )
- {
- usbe = true;
- } catch ( UsbException ue )
- {
- fail("UsbNotClaimedException was expected. Unexpected UsbException: " + ue);
- } catch ( UsbDisconnectedException uDE ) // @P1C
- { // @P1A
- fail ("A connected device should't throw the UsbDisconnectedException!"); // @P1A
- } catch ( Exception e ) // @P1A
- {
- fail("UsbNotClaimedException was expected. Unexpected Exception: " + e);
-
- }
- if ( !usbe )
- assertTrue("Test Open Pipe On Unclaimed Interface did not throw UsbNotClaimedException!", false);
- }
-
- else
- {
- fail("Interface should have been active.");
- }
-
-
- }
-
-
-
- }
-
-
-// /**
-// * looking for an inactive interface
-// * return null if not found
-// */
-// private UsbInterface getInactiveInterface()
-// {
-// UsbConfiguration config = null;
-// UsbHub virtualRootUsbHub = getVirtualRootUsbHub();
-// List usbDevices = null;
-// byte firstInterface = 0;
-// // get all connected devices
-// usbDevices = getAllUsbDevices(virtualRootUsbHub);
-// System.out.println("Found " + usbDevices.size() + " devices total.");
-//
-// // find an inactive interface
-// for ( int i = 0; i > usbDevices.size(); i++ )
-// {
-// UsbDevice device = (UsbDevice)usbDevices.get(i);
-// List configurations = device.getUsbConfigurations();
-// for ( int j = 0; i
- * The goal of the Bulk, Interrupt, and Isochronous IO test is to
- * verify that IN and OUT pipes can be opened and closed, and verify
- * that bulk, interrupt, and isochronous transfer operations work successfully, proper
- * events are generated, and proper exceptions are thrown in the operation.
- *
- * @author Leslie Blair
- */
-
-
-@SuppressWarnings("all")
-public class IOShortPacketTest
-{
-
- protected void RoundTripIOTestShortPacket(byte testType, int syncOrAsync,int numIrps, int endpointmaxPacketSize,
- boolean []acceptShortPacket, boolean []verifyAcceptShortPacket,
- int[] OUTLength, int[] OUTOffset, int[] OUTExpectedLength,
- Exception []OUTexpectedException,
-
- int[] INLength, int[]INOffset, int[]INExpectedLength,
- Exception []INexpectedException,
- byte [] transformType
- )
-
- {
-
- //Note that this code is based on IOTests.RounTripTest which handles IRP, IRPList, and Byte array. Since only IRPs
- //are being sent in this test, some of the complexity has been removed; however, although the numIrps is always
- //one for this test, the code has not been changed to get rid of the arrays.
-
- //ensure all values set up
- Assert.assertEquals(numIrps,transformType.length);
- Assert.assertEquals(numIrps,OUTLength.length);
- Assert.assertEquals(numIrps,OUTOffset.length);
- Assert.assertEquals(numIrps,acceptShortPacket.length);
- Assert.assertEquals(numIrps,verifyAcceptShortPacket.length);
- Assert.assertEquals(numIrps,OUTExpectedLength.length);
- Assert.assertEquals(numIrps,OUTexpectedException.length);
- Assert.assertEquals(numIrps,INLength.length);
- Assert.assertEquals(numIrps,INOffset.length);
- Assert.assertEquals(numIrps,INExpectedLength.length);
- Assert.assertEquals(numIrps,INexpectedException.length);
-
- Assert.assertNotNull("usbDevice is null, but should not be null.", usbDevice);
- Assert.assertEquals("For short packet test, number of IRPs should be 1.", 1, numIrps);
-
-
- /*
- * set up Pipes and add listeners
- */
- UsbPipe inPipe = null;
- UsbPipe outPipe = null;
-
- //we need two int values back from method call so we'll put them in the array
- int [] pipeListIndexes = new int[2];
- int inPipeArrayIndex = 0;
- int outPipeArrayIndex = 1;
-
- IOMethods.findINandOUTPipesForTest(usbPipeListGlobal, endpointmaxPacketSize, pipeListIndexes, inPipeArrayIndex, outPipeArrayIndex);
- inPipe = (UsbPipe) usbPipeListGlobal.get(pipeListIndexes[inPipeArrayIndex]);
- outPipe = (UsbPipe) usbPipeListGlobal.get(pipeListIndexes[outPipeArrayIndex]);
- IOMethods.verifyThePipes(inPipe, outPipe, endpointmaxPacketSize);
-
- inPipe.addUsbPipeListener(inPipeListener);
- outPipe.addUsbPipeListener(outPipeListener);
-
- IOMethods.openPipe(inPipe);
- IOMethods.openPipe(outPipe);
-
-
-
- //define buffers to be used in IRPs or sent as byte[]
- byte[] aggregateOUTbuffer = null;
- byte[] aggregateINbuffer = null;
-
-
- //for byte array and single IRP, the OUT and IN buffers are the length specified by the tests
- aggregateOUTbuffer = new byte[OUTLength[0]];
- aggregateINbuffer = new byte[INLength[0]];
-
-
- printDebug("RoundTripTestShortPacket -- IRP " + transmitListStrings[syncOrAsync] +" " + endpointTypeStrings[endpointType]);
-
-
-
-
-
-
- /*
- * Create the OUT and IN IRPs or byte arrrays
- */
- List transmitBuffers = new ArrayList();
- List listOfOUTIrps = new ArrayList();
- List listOfINIrps = new ArrayList();
-
- for ( int k = 0 ; k < numIrps; k++ )
- {
- //create transmit buffer for OUT and IN IRPs
- TransmitBuffer currentTransmitBuffer = new TransmitBuffer(transformType[k], OUTLength[k]);
- transmitBuffers.add(currentTransmitBuffer);
-
-
- //create OUT IRP
- UsbIrp currentOUTIrp = outPipe.createUsbIrp();
- listOfOUTIrps.add(currentOUTIrp);
-
- //set data in OUT IRP
- currentOUTIrp.setData(aggregateOUTbuffer, OUTOffset[k], OUTLength[k]);
- currentOUTIrp.setAcceptShortPacket(acceptShortPacket[k]);
-
- //OUT IRP is ready to go!
-
-
- if ( endpointType == UsbConst.ENDPOINT_TYPE_ISOCHRONOUS )
- {
- /*
- * For isochronous transfers, all IN Irps will have an offset of zero and
- * the same buffer length.
- */
- //get the longest required buffer length for all of the IRPs. All of the IRPs in the list
- //have the same length buffer.
- int standardISOINBufferLength = INLength[0];
- for ( int l = 1; l
- * The goal of the Bulk, Interrupt, and Isochronous IO test is to
- * verify that IN and OUT pipes can be opened and closed, and verify
- * that bulk, interrupt, and isochronous transfer operations work successfully, proper
- * events are generated, and proper exceptions are thrown in the operation.
- *
- * @author Leslie Blair
- */
-
-
-@SuppressWarnings("all")
-public class IOTests
-{
-
-
-
-
- protected void RoundTripIOTest(byte testType, int numIrps, int endpointmaxPacketSize,
- boolean []acceptShortPacket, boolean []verifyAcceptShortPacket,
- int[] OUTLength, int[] OUTOffset, int[] OUTExpectedLength,
- Exception []OUTexpectedException,
-
- int[] INLength, int[]INOffset, int[]INExpectedLength,
- Exception []INexpectedException,
- byte [] transformType
- )
-
- {
-
- //ensure all values set up
- Assert.assertEquals(numIrps,transformType.length);
- Assert.assertEquals(numIrps,OUTLength.length);
- Assert.assertEquals(numIrps,OUTOffset.length);
- Assert.assertEquals(numIrps,acceptShortPacket.length);
- Assert.assertEquals(numIrps,verifyAcceptShortPacket.length);
- Assert.assertEquals(numIrps,OUTExpectedLength.length);
- Assert.assertEquals(numIrps,OUTexpectedException.length);
- Assert.assertEquals(numIrps,INLength.length);
- Assert.assertEquals(numIrps,INOffset.length);
- Assert.assertEquals(numIrps,INExpectedLength.length);
- Assert.assertEquals(numIrps,INexpectedException.length);
-
- Assert.assertNotNull("usbDevice is null, but should not be null.", usbDevice);
-
-
- /*
- * set up Pipes and add listeners
- */
- UsbPipe inPipe = null;
- UsbPipe outPipe = null;
-
- //we need two int values back from method call so we'll put them in the array
- int [] pipeListIndexes = new int[2];
- int inPipeArrayIndex = 0;
- int outPipeArrayIndex = 1;
-
- IOMethods.findINandOUTPipesForTest(usbPipeListGlobal, endpointmaxPacketSize, pipeListIndexes, inPipeArrayIndex, outPipeArrayIndex);
- inPipe = (UsbPipe) usbPipeListGlobal.get(pipeListIndexes[inPipeArrayIndex]);
- outPipe = (UsbPipe) usbPipeListGlobal.get(pipeListIndexes[outPipeArrayIndex]);
- IOMethods.verifyThePipes(inPipe, outPipe, endpointmaxPacketSize);
-
- inPipe.addUsbPipeListener(inPipeListener);
- outPipe.addUsbPipeListener(outPipeListener);
-
- IOMethods.openPipe(inPipe);
- IOMethods.openPipe(outPipe);
-
- if ( (inPipe instanceof UsbUtil.SynchronizedUsbPipe) && (outPipe instanceof UsbUtil.SynchronizedUsbPipe) )
- printDebug("SynchronizedUsbPipes under test.");
-
- /*
- * set up the IRPs or byte arrays and send and verify the data
- */
- for ( int iterations=0; (iterations < totalIterations); iterations++ )
- {
- for ( int syncOrAsync=0; syncOrAsync
- * This test verifies that error conditions are generated and proper
- * exceptions are thrown in the operation.
- *
- * @author Thanh Ngo
- */
-
-@SuppressWarnings("all")
-@RunWith(TCKRunner.class)
-public class InterruptIOErrorConditionsTest extends TestCase
-{
- //-------------------------------------------------------------------------
- // Ctor(s)
- //
-
-
- public InterruptIOErrorConditionsTest()
- {
- thisTest = new IOErrorConditionsTest(UsbConst.ENDPOINT_TYPE_INTERRUPT);
- }
-
- //-------------------------------------------------------------------------
- // Protected overridden methods
- //
-
- protected void setUp() throws Exception {
- thisTest.setUp();
-
- }
-
- protected void tearDown() throws Exception {
- thisTest.tearDown();
- }
-
-
-
- /**
- * Null Data Buffer
- */
- public void testNullDataBufferInIrp()
- {
- thisTest.testNullDataBufferInIrp();
- }
- /**
- * Null Data Buffer
- */
- public void testNullDataBufferAsByteArray()
- {
- thisTest.testNullDataBufferAsByteArray();
- }
-
- /**
- * Action against a closed pipe
- */
- public void testActionAgainstClosePipeAbortAllSubmissions()
- {
- thisTest.testActionAgainstClosePipeAbortAllSubmissions();
- }
- /**
- * Action against a closed pipe
- */
- public void testActionAgainstClosePipeSubmit()
- {
- thisTest.testActionAgainstClosePipeSubmit();
- }
-
- /**
- * Close a pipe with pending operation
- */
- public void testClosePipePendingAction()
- {
- thisTest.testClosePipePendingAction();
- }
-
- // Moved method testOpenPipeOnInactiveAlternateSetting into the optional setInterface tests @P1D7
-
- /**
- * Open a pipe on an unclaimed interface
- */
- public void testOpenPipeOnUnclaimedInterface()
- {
- thisTest.testOpenPipeOnUnclaimedInterface();
- }
-
- /**
- * Claim an already claimed interface
- */
- public void testClaimAnAlreadyClaimedInterface()
- {
- thisTest.testClaimAnAlreadyClaimedInterface();
-
- }
-
-
- private IOErrorConditionsTest thisTest = null;
-}
diff --git a/src/test/java/javax/usb/tck/InterruptIOTests.java b/src/test/java/javax/usb/tck/InterruptIOTests.java
deleted file mode 100755
index fe44e14..0000000
--- a/src/test/java/javax/usb/tck/InterruptIOTests.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * 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 java.util.*;
-
-import javax.usb.*;
-
-import org.junit.runner.RunWith;
-
-import org.usb4java.test.TCKRunner;
-
-
-
-import junit.framework.*;
-
-/**
- * Interrupt IO Test -- Synchronous and asynchronous byte[], IRP, and IRP List submissions
- *
- * The goal of the Bulk, Interrupt, and Isochronous IO test is to
- * verify that IN and OUT pipes can be opened and closed, and verify
- * that bulk, interrupt, and isochronous transfer operations work successfully, proper
- * events are generated, and proper exceptions are thrown in the operation.
- *
- * @author Leslie Blair
- */
-
-
-@SuppressWarnings("all")
-@RunWith(TCKRunner.class)
-public class InterruptIOTests extends TestCase
-{
- public void setUp() throws Exception
- {
- endpointType = UsbConst.ENDPOINT_TYPE_INTERRUPT;
- usbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice();
- Assert.assertNotNull("Device required for test not found",usbDevice);
- IOMethods.createListofAllAvailablePipesOfSpecifiedEndpointType(usbDevice, endpointType, usbPipeListGlobal);
- super.setUp();
- }
- public void tearDown() throws Exception
- {
- IOMethods.releaseListOfPipes(usbPipeListGlobal);
- super.tearDown();
- }
-
- public void testByteArray_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer8bytes_passthrough()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.testByteArray_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer8bytes_passthrough();
- };
- public void testByteArray_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer16bytes_invertBits()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.testByteArray_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer16bytes_invertBits();
- };
- public void testByteArray_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer24bytes_invertAltBits()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.testByteArray_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer24bytes_invertAltBits();
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testByteArray_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer17bytes_passthrough()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.disabled_testByteArray_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer17bytes_passthrough();
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testByteArray_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer66bytes_invertBits()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.disabled_testByteArray_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer66bytes_invertBits();
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testByteArray_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer129bytes_invertAltBits()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.disabled_testByteArray_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer129bytes_invertAltBits();
- };
- public void testSingleIRP_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer8bytes_invertBits()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.testSingleIRP_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer8bytes_invertBits();
- };
- public void testSingleIRP_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer16bytes_invertAltBits()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.testSingleIRP_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer16bytes_invertAltBits();
- };
- public void testSingleIRP_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer64bytes_passthrough()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.testSingleIRP_BuffersMultiplesOfMaxPacketSize_maxPacketSizeOf8bytes_buffer64bytes_passthrough();
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testSingleIRP_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer25bytes_invertBits()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.disabled_testSingleIRP_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer25bytes_invertBits();
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testSingleIRP_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer72bytes_invertAltBits()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.disabled_testSingleIRP_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer72bytes_invertAltBits();
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testSingleIRP_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer130bytes_passthrough()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.disabled_testSingleIRP_BuffersNOTMultiplesOfMaxPacketSize_maxPacketSizeOf64bytes_buffer130bytes_passthrough();
- };
- public void testIRPListBuffersMultiplesOfMaxPacketSizeOf8bytes()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.testIRPListBuffersMultiplesOfMaxPacketSizeOf8bytes();
- };
- // TODO Disabled because 64 byte packet size not supported by test firmware
- public void disabled_testIRPListBuffersNOTMultiplesOfMaxPacketSizeOf64bytes()
- {
- BulkIOTests thisInterruptTest = new BulkIOTests(usbDevice, usbPipeListGlobal, endpointType);
- thisInterruptTest.disabled_testIRPListBuffersNOTMultiplesOfMaxPacketSizeOf64bytes();
- };
-
-
-
- private List usbPipeListGlobal = new ArrayList();
- private byte endpointType;
- private UsbDevice usbDevice;
-
-
-}
diff --git a/src/test/java/javax/usb/tck/InterruptIOTestwithSynchronizedUsbPipe.java b/src/test/java/javax/usb/tck/InterruptIOTestwithSynchronizedUsbPipe.java
deleted file mode 100755
index a7f800d..0000000
--- a/src/test/java/javax/usb/tck/InterruptIOTestwithSynchronizedUsbPipe.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * 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 java.util.*;
-
-import javax.usb.*;
-import javax.usb.util.*;
-
-import org.junit.runner.RunWith;
-
-import org.usb4java.test.TCKRunner;
-
-import junit.framework.*;
-
-/**
- * Interrupt IO Test -- Synchronous and asynchronous byte[], IRP, and IRP List submissions
- * with UsbUtil.synchronizedUsbPipe
- *
- * The goal of the Bulk, Interrupt, and Isochronous IO test is to
- * verify that IN and OUT pipes can be opened and closed, and verify
- * that bulk, interrupt, and isochronous transfer operations work successfully, proper
- * events are generated, and proper exceptions are thrown in the operation.
- *
- * @author Leslie Blair
- */
-
-
-@SuppressWarnings("all")
-@RunWith(TCKRunner.class)
-public class InterruptIOTestwithSynchronizedUsbPipe extends TestCase
-{
- public void setUp() throws Exception
- {
- endpointType = UsbConst.ENDPOINT_TYPE_INTERRUPT;
- usbDevice = FindProgrammableDevice.getInstance().getProgrammableDevice();
- Assert.assertNotNull("Device required for test not found",usbDevice);
- IOMethods.createListofAllAvailablePipesOfSpecifiedEndpointType(usbDevice, endpointType, usbPipeListNotSynchronized);
- for ( int i=0; i
- * 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")
-@RunWith(TCKRunner.class)
-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
deleted file mode 100755
index 48ca3f0..0000000
--- a/src/test/java/javax/usb/tck/VerifyIrpMethods.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/**
- * 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
deleted file mode 100755
index 84db706..0000000
--- a/src/test/java/javax/usb/tck/sigtest/ClassDesc.java
+++ /dev/null
@@ -1,319 +0,0 @@
-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
deleted file mode 100755
index 0736943..0000000
--- a/src/test/java/javax/usb/tck/sigtest/MemberDesc.java
+++ /dev/null
@@ -1,49 +0,0 @@
-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
deleted file mode 100755
index 534da70..0000000
--- a/src/test/java/javax/usb/tck/sigtest/MethodDesc.java
+++ /dev/null
@@ -1,180 +0,0 @@
-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
deleted file mode 100755
index 721b2bc..0000000
--- a/src/test/java/javax/usb/tck/sigtest/ProjectDesc.java
+++ /dev/null
@@ -1,179 +0,0 @@
-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
deleted file mode 100755
index ec194a3..0000000
--- a/src/test/java/javax/usb/tck/sigtest/SigTestUtils.java
+++ /dev/null
@@ -1,441 +0,0 @@
-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/java/org/libusb4java/BosDescriptorTest.java b/src/test/java/org/usb4java/BosDescriptorTest.java
similarity index 96%
rename from src/test/java/org/libusb4java/BosDescriptorTest.java
rename to src/test/java/org/usb4java/BosDescriptorTest.java
index f7de17d..6f736cd 100644
--- a/src/test/java/org/libusb4java/BosDescriptorTest.java
+++ b/src/test/java/org/usb4java/BosDescriptorTest.java
@@ -3,13 +3,15 @@
* See LICENSE.md for licensing information.
*/
-package org.libusb4java;
+package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.usb4java.BosDescriptor;
+import org.usb4java.LibUsb;
/**
* Tests the {@link BosDescriptor} class.
diff --git a/src/test/java/org/libusb4java/BosDevCapabilityDescriptorTest.java b/src/test/java/org/usb4java/BosDevCapabilityDescriptorTest.java
similarity index 95%
rename from src/test/java/org/libusb4java/BosDevCapabilityDescriptorTest.java
rename to src/test/java/org/usb4java/BosDevCapabilityDescriptorTest.java
index e879928..3f5fd73 100644
--- a/src/test/java/org/libusb4java/BosDevCapabilityDescriptorTest.java
+++ b/src/test/java/org/usb4java/BosDevCapabilityDescriptorTest.java
@@ -3,13 +3,15 @@
* See LICENSE.md for licensing information.
*/
-package org.libusb4java;
+package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.usb4java.BosDevCapabilityDescriptor;
+import org.usb4java.LibUsb;
/**
* Tests the {@link BosDevCapabilityDescriptor} class.
diff --git a/src/test/java/org/libusb4java/ConfigDescriptorTest.java b/src/test/java/org/usb4java/ConfigDescriptorTest.java
similarity index 97%
rename from src/test/java/org/libusb4java/ConfigDescriptorTest.java
rename to src/test/java/org/usb4java/ConfigDescriptorTest.java
index b2d9571..fbac11d 100644
--- a/src/test/java/org/libusb4java/ConfigDescriptorTest.java
+++ b/src/test/java/org/usb4java/ConfigDescriptorTest.java
@@ -3,13 +3,15 @@
* See LICENSE.md for licensing information.
*/
-package org.libusb4java;
+package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.usb4java.ConfigDescriptor;
+import org.usb4java.LibUsb;
/**
* Tests the {@link ConfigDescriptor} class.
diff --git a/src/test/java/org/usb4java/ConfigTest.java b/src/test/java/org/usb4java/ConfigTest.java
deleted file mode 100644
index dfaa4ee..0000000
--- a/src/test/java/org/usb4java/ConfigTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2013 Klaus Reimer