Make JNI lib more robust by validating handle objects

This commit is contained in:
Klaus Reimer 2013-04-17 20:22:57 +02:00
parent 6ecf63c8ff
commit b9e427ded5
47 changed files with 1188 additions and 148 deletions

View File

@ -9,13 +9,18 @@
void setConfigDescriptor(JNIEnv* env,
struct libusb_config_descriptor* descriptor, jobject object)
{
SET_POINTER(env, descriptor, object, "pointer");
SET_POINTER(env, descriptor, object, "configDescriptorPointer");
}
struct libusb_config_descriptor* unwrapConfigDescriptor(JNIEnv* env,
jobject descriptor)
{
UNWRAP_POINTER(env, descriptor, struct libusb_config_descriptor*, "pointer");
UNWRAP_POINTER(env, descriptor, struct libusb_config_descriptor*, "configDescriptorPointer");
}
void resetConfigDescriptor(JNIEnv* env, jobject obj)
{
RESET_POINTER(env, obj, "configDescriptorPointer");
}
/**

View File

@ -10,5 +10,6 @@
void setConfigDescriptor(JNIEnv*, struct libusb_config_descriptor*, jobject);
struct libusb_config_descriptor* unwrapConfigDescriptor(JNIEnv*, jobject);
void resetConfigDescriptor(JNIEnv*, jobject);
#endif

View File

@ -14,3 +14,8 @@ libusb_context* unwrapContext(JNIEnv* env, jobject context)
{
UNWRAP_POINTER(env, context, libusb_context*, "contextPointer");
}
void resetContext(JNIEnv* env, jobject obj)
{
RESET_POINTER(env, obj, "contextPointer");
}

View File

@ -10,5 +10,6 @@
void setContext(JNIEnv*, libusb_context*, jobject);
libusb_context* unwrapContext(JNIEnv*, jobject);
void resetContext(JNIEnv*, jobject);
#endif

View File

@ -7,15 +7,20 @@
void setDeviceHandle(JNIEnv* env, libusb_device_handle* deviceHandle, jobject object)
{
SET_POINTER(env, deviceHandle, object, "handlePointer");
SET_POINTER(env, deviceHandle, object, "deviceHandlePointer");
}
jobject wrapDeviceHandle(JNIEnv* env, libusb_device_handle* deviceHandle)
{
WRAP_POINTER(env, deviceHandle, "DeviceHandle", "handlePointer");
WRAP_POINTER(env, deviceHandle, "DeviceHandle", "deviceHandlePointer");
}
libusb_device_handle* unwrapDeviceHandle(JNIEnv* env, jobject deviceHandle)
{
UNWRAP_POINTER(env, deviceHandle, libusb_device_handle*, "handlePointer");
UNWRAP_POINTER(env, deviceHandle, libusb_device_handle*, "deviceHandlePointer");
}
void resetDeviceHandle(JNIEnv* env, jobject object)
{
RESET_POINTER(env, object, "deviceHandlePointer");
}

View File

@ -11,5 +11,6 @@
void setDeviceHandle(JNIEnv*, libusb_device_handle*, jobject);
jobject wrapDeviceHandle(JNIEnv*, libusb_device_handle*);
libusb_device_handle* unwrapDeviceHandle(JNIEnv*, jobject);
void resetDeviceHandle(JNIEnv*, jobject);
#endif

View File

@ -8,7 +8,7 @@
void setDeviceList(JNIEnv* env, libusb_device** list, int size, jobject object)
{
SET_POINTER(env, list, object, "pointer");
SET_POINTER(env, list, object, "deviceListPointer");
jclass cls = (*env)->GetObjectClass(env, object);
jfieldID field = (*env)->GetFieldID(env, cls, "size", "I");
@ -17,7 +17,12 @@ void setDeviceList(JNIEnv* env, libusb_device** list, int size, jobject object)
libusb_device** unwrapDeviceList(JNIEnv* env, jobject list)
{
UNWRAP_POINTER(env, list, libusb_device**, "pointer");
UNWRAP_POINTER(env, list, libusb_device**, "deviceListPointer");
}
void resetDeviceList(JNIEnv* env, jobject obj)
{
RESET_POINTER(env, obj, "deviceListPointer");
}
/**

View File

@ -10,5 +10,6 @@
void setDeviceList(JNIEnv*, libusb_device**, int, jobject);
libusb_device** unwrapDeviceList(JNIEnv*, jobject);
void resetDeviceList(JNIEnv*, jobject);
#endif

View File

@ -8,7 +8,7 @@
jobject wrapEndpointDescriptor(JNIEnv *env,
const struct libusb_endpoint_descriptor *descriptor)
{
WRAP_POINTER(env, descriptor, "EndpointDescriptor", "pointer");
WRAP_POINTER(env, descriptor, "EndpointDescriptor", "endpointDescriptorPointer");
}
jobjectArray wrapEndpointDescriptors(JNIEnv *env, int count,
@ -28,7 +28,7 @@ jobjectArray wrapEndpointDescriptors(JNIEnv *env, int count,
struct libusb_endpoint_descriptor *unwrapEndpointDescriptor(JNIEnv *env,
jobject obj)
{
UNWRAP_POINTER(env, obj, struct libusb_endpoint_descriptor*, "pointer");
UNWRAP_POINTER(env, obj, struct libusb_endpoint_descriptor*, "endpointDescriptorPointer");
}
/**

View File

@ -65,7 +65,10 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, exit)
JNIEnv *env, jclass class, jobject context
)
{
libusb_exit(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return;
libusb_exit(ctx);
resetContext(env, context);
}
/**
@ -76,7 +79,9 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, setDebug)
JNIEnv *env, jclass class, jobject context, jint level
)
{
libusb_set_debug(unwrapContext(env, context), level);
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return;
libusb_set_debug(ctx, level);
}
/**
@ -88,9 +93,10 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getDeviceList)
)
{
NOT_NULL(env, deviceList, return 0);
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
libusb_device **list;
ssize_t result = libusb_get_device_list(unwrapContext(env, context),
&list);
ssize_t result = libusb_get_device_list(ctx, &list);
if (result >= 0) setDeviceList(env, list, result, deviceList);
return result;
}
@ -104,7 +110,10 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, freeDeviceList)
)
{
NOT_NULL(env, deviceList, return);
libusb_free_device_list(unwrapDeviceList(env, deviceList), unrefDevices);
libusb_device **list = unwrapDeviceList(env, deviceList);
if (!list) return;
libusb_free_device_list(list, unrefDevices);
resetDeviceList(env, deviceList);
}
/**
@ -116,7 +125,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getBusNumber)
)
{
NOT_NULL(env, device, return 0);
return libusb_get_bus_number(unwrapDevice(env, device));
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
return libusb_get_bus_number(dev);
}
/**
@ -128,8 +139,10 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getPortNumber)
)
{
NOT_NULL(env, device, return 0);
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
#if defined(LIBUSBX_API_VERSION)
return libusb_get_port_number(unwrapDevice(env, device));
return libusb_get_port_number(dev);
#else
return 0;
#endif
@ -145,11 +158,14 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getPortPath)
{
NOT_NULL(env, device, return 0);
NOT_NULL(env, path, return 0);
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
jsize size = (*env)->GetArrayLength(env, path);
unsigned char buffer[size];
#if defined(LIBUSBX_API_VERSION)
int result = libusb_get_port_path(unwrapContext(env, context),
unwrapDevice(env, device), buffer, size);
int result = libusb_get_port_path(ctx, dev, buffer, size);
#else
int result = 0;
#endif
@ -166,8 +182,10 @@ JNIEXPORT jobject JNICALL METHOD_NAME(LibUsb, getParent)
)
{
NOT_NULL(env, device, return NULL);
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return NULL;
#if defined(LIBUSBX_API_VERSION)
return wrapDevice(env, libusb_get_parent(unwrapDevice(env, device)));
return wrapDevice(env, libusb_get_parent(dev));
#else
return NULL;
#endif
@ -182,7 +200,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getDeviceAddress)
)
{
NOT_NULL(env, device, return 0);
return libusb_get_device_address(unwrapDevice(env, device));
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
return libusb_get_device_address(dev);
}
/**
@ -194,7 +214,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getDeviceSpeed)
)
{
NOT_NULL(env, device, return 0);
return libusb_get_device_speed(unwrapDevice(env, device));
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
return libusb_get_device_speed(dev);
}
/**
@ -206,7 +228,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getMaxPacketSize)
)
{
NOT_NULL(env, device, return 0);
return libusb_get_max_packet_size(unwrapDevice(env, device), endpoint);
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
return libusb_get_max_packet_size(dev, endpoint);
}
/**
@ -218,7 +242,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getMaxIsoPacketSize)
)
{
NOT_NULL(env, device, return 0);
return libusb_get_max_iso_packet_size(unwrapDevice(env, device), endpoint);
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
return libusb_get_max_iso_packet_size(dev, endpoint);
}
/**
@ -230,7 +256,9 @@ JNIEXPORT jobject JNICALL METHOD_NAME(LibUsb, refDevice)
)
{
NOT_NULL(env, device, return NULL);
libusb_ref_device(unwrapDevice(env, device));
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return NULL;
libusb_ref_device(dev);
return device;
}
@ -243,7 +271,9 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, unrefDevice)
)
{
NOT_NULL(env, device, return);
libusb_unref_device(unwrapDevice(env, device));
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return;
libusb_unref_device(dev);
}
/**
@ -256,8 +286,10 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, open)
{
NOT_NULL(env, device, return 0);
NOT_NULL(env, handle, return 0);
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
libusb_device_handle *deviceHandle;
int result = libusb_open(unwrapDevice(env, device), &deviceHandle);
int result = libusb_open(dev, &deviceHandle);
if (!result) setDeviceHandle(env, deviceHandle, handle);
return result;
}
@ -271,8 +303,10 @@ JNIEXPORT jobject JNICALL METHOD_NAME(LibUsb, openDeviceWithVidPid)
jint productId
)
{
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return NULL;
return wrapDeviceHandle(env, libusb_open_device_with_vid_pid(
unwrapContext(env, context), vendorId, productId));
ctx, vendorId, productId));
}
/**
@ -284,7 +318,10 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, close)
)
{
NOT_NULL(env, handle, return);
libusb_close(unwrapDeviceHandle(env, handle));
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return;
libusb_close(dev_handle);
resetDeviceHandle(env, handle);
}
/**
@ -296,7 +333,9 @@ JNIEXPORT jobject JNICALL METHOD_NAME(LibUsb, getDevice)
)
{
NOT_NULL(env, handle, return NULL);
return wrapDevice(env, libusb_get_device(unwrapDeviceHandle(env, handle)));
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return NULL;
return wrapDevice(env, libusb_get_device(dev_handle));
}
/**
@ -309,9 +348,10 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getConfiguration)
{
NOT_NULL(env, handle, return 0);
NOT_NULL(env, buffer, return 0);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
int config;
int result = libusb_get_configuration(unwrapDeviceHandle(env, handle),
&config);
int result = libusb_get_configuration(dev_handle, &config);
if (!result)
{
jclass cls = (*env)->GetObjectClass(env, buffer);
@ -330,7 +370,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, setConfiguration)
)
{
NOT_NULL(env, handle, return 0);
return libusb_set_configuration(unwrapDeviceHandle(env, handle), config);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
return libusb_set_configuration(dev_handle, config);
}
/**
@ -342,7 +384,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, claimInterface)
)
{
NOT_NULL(env, handle, return 0);
return libusb_claim_interface(unwrapDeviceHandle(env, handle), iface);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
return libusb_claim_interface(dev_handle, iface);
}
/**
@ -354,7 +398,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, releaseInterface)
)
{
NOT_NULL(env, handle, return 0);
return libusb_release_interface(unwrapDeviceHandle(env, handle), iface);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
return libusb_release_interface(dev_handle, iface);
}
/**
@ -366,8 +412,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, setInterfaceAltSetting)
)
{
NOT_NULL(env, handle, return 0);
return libusb_set_interface_alt_setting(unwrapDeviceHandle(env, handle),
iface, setting);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
return libusb_set_interface_alt_setting(dev_handle, iface, setting);
}
/**
@ -379,7 +426,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, clearHalt)
)
{
NOT_NULL(env, handle, return 0);
return libusb_clear_halt(unwrapDeviceHandle(env, handle), endpoint);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
return libusb_clear_halt(dev_handle, endpoint);
}
/**
@ -391,7 +440,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, resetDevice)
)
{
NOT_NULL(env, handle, return 0);
return libusb_reset_device(unwrapDeviceHandle(env, handle));
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
return libusb_reset_device(dev_handle);
}
/**
@ -403,7 +454,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, kernelDriverActive)
)
{
NOT_NULL(env, handle, return 0);
return libusb_kernel_driver_active(unwrapDeviceHandle(env, handle), iface);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
return libusb_kernel_driver_active(dev_handle, iface);
}
/**
@ -415,7 +468,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, detachKernelDriver)
)
{
NOT_NULL(env, handle, return 0);
return libusb_detach_kernel_driver(unwrapDeviceHandle(env, handle), iface);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
return libusb_detach_kernel_driver(dev_handle, iface);
}
/**
@ -427,7 +482,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, attachKernelDriver)
)
{
NOT_NULL(env, handle, return 0);
return libusb_attach_kernel_driver(unwrapDeviceHandle(env, handle), iface);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
return libusb_attach_kernel_driver(dev_handle, iface);
}
/**
@ -484,8 +541,11 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getDeviceDescriptor)
{
NOT_NULL(env, device, return 0);
NOT_NULL(env, descriptor, return 0);
struct libusb_device_descriptor *data = malloc(sizeof(struct libusb_device_descriptor));
int result = libusb_get_device_descriptor(unwrapDevice(env, device), data);
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
struct libusb_device_descriptor *data =
malloc(sizeof(struct libusb_device_descriptor));
int result = libusb_get_device_descriptor(dev, data);
if (!result) setDeviceDescriptor(env, data, descriptor);
return result;
}
@ -501,9 +561,11 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getStringDescriptorAscii)
{
NOT_NULL(env, handle, return 0);
NOT_NULL(env, string, return 0);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
unsigned char buffer[length + 1];
int result = libusb_get_string_descriptor_ascii(
unwrapDeviceHandle(env, handle), index, buffer, length);
dev_handle, index, buffer, length);
if (result >= 0)
{
buffer[result] = 0;
@ -525,9 +587,10 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getActiveConfigDescriptor)
{
NOT_NULL(env, device, return 0);
NOT_NULL(env, descriptor, return 0);
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
struct libusb_config_descriptor *config;
int result = libusb_get_active_config_descriptor(
unwrapDevice(env, device), &config);
int result = libusb_get_active_config_descriptor(dev, &config);
if (!result) setConfigDescriptor(env, config, descriptor);
return result;
}
@ -542,9 +605,10 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getConfigDescriptor)
{
NOT_NULL(env, device, return 0);
NOT_NULL(env, descriptor, return 0);
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
struct libusb_config_descriptor *config;
int result = libusb_get_config_descriptor(
unwrapDevice(env, device), index, &config);
int result = libusb_get_config_descriptor(dev, index, &config);
if (!result) setConfigDescriptor(env, config, descriptor);
return result;
}
@ -559,9 +623,11 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getConfigDescriptorByValue)
{
NOT_NULL(env, device, return 0);
NOT_NULL(env, descriptor, return 0);
libusb_device *dev = unwrapDevice(env, device);
if (!dev) return 0;
struct libusb_config_descriptor *config;
int result = libusb_get_config_descriptor_by_value(
unwrapDevice(env, device), index, &config);
dev, index, &config);
if (!result) setConfigDescriptor(env, config, descriptor);
return result;
}
@ -575,7 +641,11 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, freeConfigDescriptor)
)
{
NOT_NULL(env, descriptor, return);
libusb_free_config_descriptor(unwrapConfigDescriptor(env, descriptor));
struct libusb_config_descriptor *config = unwrapConfigDescriptor(env,
descriptor);
if (!config) return;
libusb_free_config_descriptor(config);
resetConfigDescriptor(env, descriptor);
}
/**
@ -590,10 +660,11 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getDescriptor)
NOT_NULL(env, handle, return 0);
NOT_NULL(env, data, return 0);
DIRECT_BUFFER(env, data, return 0);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
unsigned char *ptr = (*env)->GetDirectBufferAddress(env, data);
jlong size = (*env)->GetDirectBufferCapacity(env, data);
return libusb_get_descriptor(unwrapDeviceHandle(env, handle),
type, index, ptr, size);
return libusb_get_descriptor(dev_handle, type, index, ptr, size);
}
/**
@ -608,10 +679,11 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getStringDescriptor)
NOT_NULL(env, handle, return 0);
NOT_NULL(env, data, return 0);
DIRECT_BUFFER(env, data, return 0);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
unsigned char *ptr = (*env)->GetDirectBufferAddress(env, data);
jlong size = (*env)->GetDirectBufferCapacity(env, data);
return libusb_get_string_descriptor(unwrapDeviceHandle(env, handle),
index, langId, ptr, size);
return libusb_get_string_descriptor(dev_handle, index, langId, ptr, size);
}
/**
@ -626,10 +698,12 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, controlTransfer)
NOT_NULL(env, handle, return 0);
NOT_NULL(env, data, return 0);
DIRECT_BUFFER(env, data, return 0);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
unsigned char *ptr = (*env)->GetDirectBufferAddress(env, data);
jlong size = (*env)->GetDirectBufferCapacity(env, data);
return libusb_control_transfer(unwrapDeviceHandle(env, handle),
bmRequestType, bRequest, wValue, wIndex, ptr, size, timeout);
return libusb_control_transfer(dev_handle, bmRequestType, bRequest,
wValue, wIndex, ptr, size, timeout);
}
/**
@ -645,11 +719,13 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, bulkTransfer)
NOT_NULL(env, data, return 0);
NOT_NULL(env, transferred, return 0);
DIRECT_BUFFER(env, data, return 0);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
int sent;
unsigned char *ptr = (*env)->GetDirectBufferAddress(env, data);
jlong size = (*env)->GetDirectBufferCapacity(env, data);
int result = libusb_bulk_transfer(unwrapDeviceHandle(env, handle),
endpoint, ptr, size, &sent, timeout);
int result = libusb_bulk_transfer(dev_handle, endpoint, ptr, size, &sent,
timeout);
if (!result)
{
jclass cls = (*env)->GetObjectClass(env, transferred);
@ -673,11 +749,13 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, interruptTransfer)
NOT_NULL(env, data, return 0);
NOT_NULL(env, transferred, return 0);
DIRECT_BUFFER(env, data, return 0);
libusb_device_handle *dev_handle = unwrapDeviceHandle(env, handle);
if (!dev_handle) return 0;
int sent;
unsigned char *ptr = (*env)->GetDirectBufferAddress(env, data);
jlong size = (*env)->GetDirectBufferCapacity(env, data);
int result = libusb_interrupt_transfer(unwrapDeviceHandle(env, handle),
endpoint, ptr, size, &sent, timeout);
int result = libusb_interrupt_transfer(dev_handle, endpoint, ptr, size,
&sent, timeout);
if (!result)
{
jclass cls = (*env)->GetObjectClass(env, transferred);
@ -696,7 +774,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, tryLockEvents)
JNIEnv *env, jclass class, jobject context
)
{
return libusb_try_lock_events(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
return libusb_try_lock_events(ctx);
}
/**
@ -707,7 +787,9 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, lockEvents)
JNIEnv *env, jclass class, jobject context
)
{
libusb_lock_events(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return;
libusb_lock_events(ctx);
}
/**
@ -718,7 +800,9 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, unlockEvents)
JNIEnv *env, jclass class, jobject context
)
{
libusb_unlock_events(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return;
libusb_unlock_events(ctx);
}
/**
@ -729,7 +813,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, eventHandlingOk)
JNIEnv *env, jclass class, jobject context
)
{
return libusb_event_handling_ok(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
return libusb_event_handling_ok(ctx);
}
/**
@ -740,7 +826,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, eventHandlerActive)
JNIEnv *env, jclass class, jobject context
)
{
return libusb_event_handler_active(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
return libusb_event_handler_active(ctx);
}
/**
@ -751,7 +839,9 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, lockEventWaiters)
JNIEnv *env, jclass class, jobject context
)
{
libusb_lock_event_waiters(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return;
libusb_lock_event_waiters(ctx);
}
/**
@ -762,7 +852,9 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, unlockEventWaiters)
JNIEnv *env, jclass class, jobject context
)
{
libusb_unlock_event_waiters(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return;
libusb_unlock_event_waiters(ctx);
}
/**
@ -773,10 +865,12 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, waitForEvent)
JNIEnv *env, jclass class, jobject context, jlong timeout
)
{
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
struct timeval tv;
tv.tv_sec = timeout / 1000000;
tv.tv_usec = timeout % 1000000;
return libusb_wait_for_event(unwrapContext(env, context), &tv);
return libusb_wait_for_event(ctx, &tv);
}
/**
@ -788,12 +882,13 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, handleEventsTimeoutCompleted)
jobject completed
)
{
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
struct timeval tv;
tv.tv_sec = timeout / 1000000;
tv.tv_usec = timeout % 1000000;
int complete;
int result = libusb_handle_events_timeout_completed(
unwrapContext(env, context), &tv, &complete);
int result = libusb_handle_events_timeout_completed(ctx, &tv, &complete);
if (!result && completed)
{
jclass cls = (*env)->GetObjectClass(env, completed);
@ -811,10 +906,12 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, handleEventsTimeout)
JNIEnv *env, jclass class, jobject context, jlong timeout
)
{
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
struct timeval tv;
tv.tv_sec = timeout / 1000000;
tv.tv_usec = timeout % 1000000;
return libusb_handle_events_timeout(unwrapContext(env, context), &tv);
return libusb_handle_events_timeout(ctx, &tv);
}
/**
@ -825,7 +922,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, handleEvents)
JNIEnv *env, jclass class, jobject context
)
{
return libusb_handle_events(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
return libusb_handle_events(ctx);
}
/**
@ -836,9 +935,10 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, handleEventsCompleted)
JNIEnv *env, jclass class, jobject context, jobject completed
)
{
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
int complete;
int result = libusb_handle_events_completed(
unwrapContext(env, context), &complete);
int result = libusb_handle_events_completed(ctx, &complete);
if (!result && completed)
{
jclass cls = (*env)->GetObjectClass(env, completed);
@ -856,10 +956,12 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, handleEventsLocked)
JNIEnv *env, jclass class, jobject context, jlong timeout
)
{
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
struct timeval tv;
tv.tv_sec = timeout / 1000000;
tv.tv_usec = timeout % 1000000;
return libusb_handle_events_locked(unwrapContext(env, context), &tv);
return libusb_handle_events_locked(ctx, &tv);
}
/**
@ -870,7 +972,9 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, pollfdsHandleTimeouts)
JNIEnv *env, jclass class, jobject context
)
{
return libusb_pollfds_handle_timeouts(unwrapContext(env, context));
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
return libusb_pollfds_handle_timeouts(ctx);
}
/**
@ -881,9 +985,10 @@ JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, getNextTimeout)
JNIEnv *env, jclass class, jobject context, jobject timeout
)
{
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return 0;
struct timeval tv;
int result = libusb_get_next_timeout(
unwrapContext(env, context), &tv);
int result = libusb_get_next_timeout(ctx, &tv);
if (result == 1)
{
jclass cls = (*env)->GetObjectClass(env, timeout);
@ -935,9 +1040,11 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, setPollfdNotifiers)
JNIEnv *env, jclass class, jobject context
)
{
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return;
(*env)->GetJavaVM(env, &jvm);
libusb_set_pollfd_notifiers(unwrapContext(env, context),
triggerPollfdAdded, triggerPollfdRemoved, NULL);
libusb_set_pollfd_notifiers(ctx, triggerPollfdAdded, triggerPollfdRemoved,
NULL);
}
/**
@ -948,8 +1055,9 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, unsetPollfdNotifiers)
JNIEnv *env, jclass class, jobject context
)
{
libusb_set_pollfd_notifiers(unwrapContext(env, context),
NULL, NULL, NULL);
struct libusb_context *ctx = unwrapContext(env, context);
if (!ctx) return;
libusb_set_pollfd_notifiers(ctx, NULL, NULL, NULL);
}
/**
@ -971,5 +1079,8 @@ JNIEXPORT void JNICALL METHOD_NAME(LibUsb, freeTransfer)
JNIEnv *env, jclass class, jobject transfer
)
{
libusb_free_transfer(unwrapTransfer(env, transfer));
struct libusb_transfer *handle = unwrapTransfer(env, transfer);
if (!handle) return;
libusb_free_transfer(handle);
resetTransfer(env, transfer);
}

View File

@ -16,6 +16,11 @@ struct libusb_transfer* unwrapTransfer(JNIEnv *env, jobject obj)
UNWRAP_POINTER(env, obj, struct libusb_transfer*, "pointer");
}
void resetTransfer(JNIEnv* env, jobject obj)
{
RESET_POINTER(env, obj, "pointer");
}
/**
* void setDevHandle(DeviceHandle)
*/

View File

@ -10,5 +10,6 @@
jobject wrapTransfer(JNIEnv*, struct libusb_transfer*);
struct libusb_transfer* unwrapTransfer(JNIEnv*, jobject);
void resetTransfer(JNIEnv*, jobject);
#endif

View File

@ -10,3 +10,10 @@ jint illegalArgument(JNIEnv *env, char *message)
jclass cls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
return (*env)->ThrowNew(env, cls, message);
}
jint illegalState(JNIEnv *env, char *message)
{
jclass cls = (*env)->FindClass(env, "java/lang/IllegalStateException");
return (*env)->ThrowNew(env, cls, message);
}

View File

@ -26,6 +26,13 @@
(*ENV)->SetLongField(ENV, OBJECT, field, (jptr) PTR); \
}
#define RESET_POINTER(ENV, OBJECT, FIELD) \
{ \
jclass cls = (*ENV)->GetObjectClass(ENV, OBJECT); \
jfieldID field = (*ENV)->GetFieldID(ENV, cls, FIELD, "J"); \
(*ENV)->SetLongField(ENV, OBJECT, field, 0); \
}
#define WRAP_POINTER(ENV, PTR, CLASS_NAME, FIELD) \
{ \
if (!PTR) return NULL; \
@ -44,6 +51,8 @@
if (!OBJECT) return NULL; \
jclass cls = (*ENV)->GetObjectClass(ENV, OBJECT); \
jfieldID field = (*ENV)->GetFieldID(ENV, cls, FIELD, "J"); \
jptr ptr = (jptr) (*ENV)->GetLongField(ENV, OBJECT, field); \
if (!ptr) illegalState(ENV, FIELD" is not initialized"); \
return (TYPE) (jptr) (*ENV)->GetLongField(ENV, OBJECT, field); \
}
@ -94,5 +103,6 @@
if (getEnvResult == JNI_EDETACHED) (*jvm)->DetachCurrentThread(jvm);
jint illegalArgument(JNIEnv *env, char *message);
jint illegalState(JNIEnv *env, char *message);
#endif

View File

@ -31,7 +31,7 @@ import de.ailis.usb4java.utils.DescriptorUtils;
public final class ConfigDescriptor implements UsbConfigurationDescriptor
{
/** The native pointer to the descriptor structure. */
private long pointer;
private long configDescriptorPointer;
/**
* Constructs a new config descriptor which can be passed to the
@ -49,7 +49,7 @@ public final class ConfigDescriptor implements UsbConfigurationDescriptor
*/
public long getPointer()
{
return this.pointer;
return this.configDescriptorPointer;
}
@Override

View File

@ -27,7 +27,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
public final class DeviceHandle
{
/** The native pointer to the device handle structure. */
private long handlePointer;
private long deviceHandlePointer;
/**
* Constructs a new device handle. Must be passed to
@ -46,13 +46,13 @@ public final class DeviceHandle
*/
public long getPointer()
{
return this.handlePointer;
return this.deviceHandlePointer;
}
@Override
public int hashCode()
{
return new HashCodeBuilder().append(this.handlePointer).toHashCode();
return new HashCodeBuilder().append(this.deviceHandlePointer).toHashCode();
}
@Override
@ -61,12 +61,12 @@ public final class DeviceHandle
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
final DeviceHandle other = (DeviceHandle) obj;
return this.handlePointer == other.handlePointer;
return this.deviceHandlePointer == other.deviceHandlePointer;
}
@Override
public String toString()
{
return String.format("libusb handle 0x%x", this.handlePointer);
return String.format("libusb handle 0x%x", this.deviceHandlePointer);
}
}

View File

@ -24,7 +24,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
public final class DeviceList implements Iterable<Device>
{
/** The native pointer to the devices array. */
private long pointer;
private long deviceListPointer;
/** The number of devices in the list. */
private int size;
@ -45,7 +45,7 @@ public final class DeviceList implements Iterable<Device>
*/
public long getPointer()
{
return this.pointer;
return this.deviceListPointer;
}
/**
@ -76,7 +76,7 @@ public final class DeviceList implements Iterable<Device>
@Override
public int hashCode()
{
return new HashCodeBuilder().append(this.pointer).toHashCode();
return new HashCodeBuilder().append(this.deviceListPointer).toHashCode();
}
@Override
@ -85,6 +85,6 @@ public final class DeviceList implements Iterable<Device>
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
final DeviceList other = (DeviceList) obj;
return this.pointer == other.pointer;
return this.deviceListPointer == other.deviceListPointer;
}
}

View File

@ -31,7 +31,7 @@ import de.ailis.usb4java.utils.DescriptorUtils;
public final class EndpointDescriptor implements UsbEndpointDescriptor
{
/** The native pointer to the descriptor structure. */
private long pointer;
private long endpointDescriptorPointer;
/**
* Package-private constructor to prevent manual instantiation. Endpoint
@ -49,7 +49,7 @@ public final class EndpointDescriptor implements UsbEndpointDescriptor
*/
public long getPointer()
{
return this.pointer;
return this.endpointDescriptorPointer;
}
@Override

View File

@ -5,10 +5,11 @@
package de.ailis.usb4java.libusb;
import static de.ailis.usb4java.UsbAssume.assumeUsbTestsEnabled;
import static de.ailis.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNotNull;
import java.nio.ByteBuffer;
@ -56,7 +57,8 @@ public class LibUSBDeviceTest
LibUsb.init(this.context);
this.device = findTestDevice();
if (this.device == null)
throw new IllegalStateException("Need at least one USB device " +
throw new IllegalStateException("Need at least one USB device "
+
"with at least one endpoint to execute this test");
}
catch (Throwable e)
@ -140,16 +142,6 @@ public class LibUSBDeviceTest
assertTrue(LibUsb.getBusNumber(this.device) >= 0);
}
/**
* Tests the {@link LibUsb#getBusNumber(Device)} method without a device.
*/
@Test(expected = IllegalArgumentException.class)
public void testGetBusNumberWithoutDevice()
{
assumeUsbTestsEnabled();
LibUsb.getBusNumber(null);
}
/**
* Tests the {@link LibUsb#getPortNumber(Device)} method.
*/
@ -161,16 +153,6 @@ public class LibUSBDeviceTest
assertTrue(LibUsb.getPortNumber(this.device) >= 0);
}
/**
* Tests the {@link LibUsb#getPortNumber(Device)} method without a device.
*/
@Test(expected = IllegalArgumentException.class)
public void testGetPortNumberWithoutDevice()
{
assumeUsbTestsEnabled();
LibUsb.getPortNumber(null);
}
/**
* Tests the {@link LibUsb#getPortPath(Context, Device, byte[])} method.
*/
@ -221,6 +203,30 @@ public class LibUSBDeviceTest
LibUsb.getPortPath(this.context, this.device, null);
}
/**
* Tests {@link LibUsb#getPortPath(Context, Device, byte[])} method with
* uninitialized USB context.
*/
@Test(expected = IllegalStateException.class)
public void testGetPortPathWithUninitializedContext()
{
assumeUsbTestsEnabled();
assumeNotNull(this.device);
final Context context = new Context();
LibUsb.getPortPath(context, this.device, new byte[16]);
}
/**
* Tests {@link LibUsb#getPortPath(Context, Device, byte[])} method with
* uninitialized device.
*/
@Test(expected = IllegalStateException.class)
public void testGetPortPathWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getPortPath(this.context, new Device(), new byte[16]);
}
/**
* Tests the {@link LibUsb#getParent(Device)} method.
*/
@ -425,14 +431,27 @@ public class LibUSBDeviceTest
* crash.
*/
@Test
public void testOpen()
public void testOpenAndClose()
{
assumeUsbTestsEnabled();
assumeNotNull(this.device);
DeviceHandle handle = new DeviceHandle();
int result = LibUsb.open(this.device, handle);
assertTrue(result == LibUsb.SUCCESS || result == LibUsb.ERROR_ACCESS);
if (result == LibUsb.SUCCESS) LibUsb.close(handle);
if (result == LibUsb.SUCCESS)
{
LibUsb.close(handle);
try
{
LibUsb.close(handle);
fail("Double-close should throw IllegalStateException");
}
catch (IllegalStateException e)
{
// Expected behavior
}
}
}
/**
@ -878,6 +897,16 @@ public class LibUSBDeviceTest
finally
{
LibUsb.freeConfigDescriptor(desc);
try
{
LibUsb.freeConfigDescriptor(desc);
fail("Double-free should throw IllegalStateException");
}
catch (IllegalStateException e)
{
// Expected behavior
}
}
}
@ -1104,4 +1133,27 @@ public class LibUSBDeviceTest
LibUsb.interruptTransfer(new DeviceHandle(), 0, ByteBuffer.allocate(0),
null, 0);
}
/**
* Tests the {@link LibUsb#getDeviceList(Context, DeviceList)} and
* LibUsb#freeDeviceList(DeviceList, boolean)} methods.
*/
@Test
public void testGetAndFreeDeviceList()
{
assumeUsbTestsEnabled();
DeviceList list = new DeviceList();
assertTrue(LibUsb.getDeviceList(this.context, list) >= 0);
LibUsb.freeDeviceList(list, true);
try
{
LibUsb.freeDeviceList(list, true);
fail("Double-free should throw IllegalStateException");
}
catch (IllegalStateException e)
{
// Expected behavior
}
}
}

View File

@ -5,7 +5,7 @@
package de.ailis.usb4java.libusb;
import static de.ailis.usb4java.UsbAssume.assumeUsbTestsEnabled;
import static de.ailis.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

View File

@ -5,13 +5,22 @@
package de.ailis.usb4java.libusb;
import static de.ailis.usb4java.UsbAssume.assumeUsbTestsEnabled;
import static de.ailis.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.FileDescriptor;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.junit.Test;
import de.ailis.usb4java.libusb.mocks.PollfdListenerMock;
/**
* Tests the {@link LibUsb} class.
*
@ -166,10 +175,13 @@ public class LibUSBTest
assumeUsbTestsEnabled();
assertEquals(LibUsb.SUCCESS, LibUsb.init(null));
LibUsb.exit(null);
// Double-exit without a context should work
LibUsb.exit(null);
}
/**
* Tests the initialization and deinitialization of libusb with a custom
* Tests the initialization and deinitialization of libusb with a custom USB
* context.
*/
@Test
@ -179,5 +191,752 @@ public class LibUSBTest
Context context = new Context();
assertEquals(LibUsb.SUCCESS, LibUsb.init(context));
LibUsb.exit(context);
try
{
LibUsb.exit(context);
fail("Double-exit should throw IllegalStateException");
}
catch (IllegalStateException e)
{
// Expected behavior
}
}
/**
* Tests {@link LibUsb#exit(Context)} method with uninitialized Context
*/
@Test(expected = IllegalStateException.class)
public void testExitWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.exit(context);
}
/**
* Tests {@link LibUsb#setDebug(Context, int)} method with uninitialized USB
* context
*/
@Test(expected = IllegalStateException.class)
public void testSetDebugWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.setDebug(context, 0);
}
/**
* Tests {@link LibUsb#getDeviceList(Context, DeviceList)} method with
* uninitialized USB context.
*/
@Test(expected = IllegalStateException.class)
public void testGetDeviceListWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.getDeviceList(context, new DeviceList());
}
/**
* Tests {@link LibUsb#freeDeviceList(DeviceList, boolean)} method with
* uninitialized list.
*/
@Test(expected = IllegalStateException.class)
public void testFreeDeviceListWithUninitializedList()
{
assumeUsbTestsEnabled();
LibUsb.freeDeviceList(new DeviceList(), true);
}
/**
* Tests {@link LibUsb#freeDeviceList(DeviceList, boolean)} method without
* list.
*/
@Test(expected = IllegalArgumentException.class)
public void testFreeDeviceListWithoutList()
{
assumeUsbTestsEnabled();
LibUsb.freeDeviceList(null, true);
}
/**
* Tests the {@link LibUsb#getBusNumber(Device)} method without a device.
*/
@Test(expected = IllegalArgumentException.class)
public void testGetBusNumberWithoutDevice()
{
assumeUsbTestsEnabled();
LibUsb.getBusNumber(null);
}
/**
* Tests the {@link LibUsb#getBusNumber(Device)} method with uninitialized
* device.
*/
@Test(expected = IllegalStateException.class)
public void testGetBusNumberWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getBusNumber(new Device());
}
/**
* Tests the {@link LibUsb#getPortNumber(Device)} method without a device.
*/
@Test(expected = IllegalArgumentException.class)
public void testGetPortNumberWithoutDevice()
{
assumeUsbTestsEnabled();
LibUsb.getPortNumber(null);
}
/**
* Tests the {@link LibUsb#getPortNumber(Device)} method with uninitialized
* device.
*/
@Test(expected = IllegalStateException.class)
public void testGetPortNumberWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getPortNumber(new Device());
}
/**
* Tests the {@link LibUsb#getParent(Device)} method with uninitialized
* device.
*/
@Test(expected = IllegalStateException.class)
public void testGetParentWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getParent(new Device());
}
/**
* Tests the {@link LibUsb#getDeviceAddress(Device)} method with
* uninitialized device.
*/
@Test(expected = IllegalStateException.class)
public void testGetDeviceAddressWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getDeviceAddress(new Device());
}
/**
* Tests the {@link LibUsb#getDeviceSpeed(Device)} method with uninitialized
* device.
*/
@Test(expected = IllegalStateException.class)
public void testGetDeviceDeviceSpeedWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getDeviceSpeed(new Device());
}
/**
* Tests the {@link LibUsb#getMaxPacketSize(Device, int)} method with
* uninitialized device.
*/
@Test(expected = IllegalStateException.class)
public void testMaxPacketSizeWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getMaxPacketSize(new Device(), 0);
}
/**
* Tests the {@link LibUsb#getMaxIsoPacketSize(Device, int)} method with
* uninitialized device.
*/
@Test(expected = IllegalStateException.class)
public void testMaxIsoPacketSizeWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getMaxIsoPacketSize(new Device(), 0);
}
/**
* Tests the {@link LibUsb#refDevice(Device)} method with uninitialized
* device.
*/
@Test(expected = IllegalStateException.class)
public void testRefDeviceWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.refDevice(new Device());
}
/**
* Tests the {@link LibUsb#unrefDevice(Device)} method with uninitialized
* device.
*/
@Test(expected = IllegalStateException.class)
public void testUnrefDeviceWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.unrefDevice(new Device());
}
/**
* Tests the {@link LibUsb#open(Device, DeviceHandle)} method with
* uninitialized device.
*/
@Test(expected = IllegalStateException.class)
public void testOpenWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.open(new Device(), new DeviceHandle());
}
/**
* Tests the {@link LibUsb#close(DeviceHandle)} method with uninitialized
* device handle.
*/
@Test(expected = IllegalStateException.class)
public void testCloseWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.close(new DeviceHandle());
}
/**
* Tests the {@link LibUsb#getDevice(DeviceHandle)} method with
* uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testGetDeviceWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.getDevice(new DeviceHandle());
}
/**
* Tests the {@link LibUsb#getConfiguration(DeviceHandle, IntBuffer)} method
* with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testGetConfigurationWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.getConfiguration(new DeviceHandle(), IntBuffer.allocate(1));
}
/**
* Tests the {@link LibUsb#setConfiguration(DeviceHandle, int)} method with
* uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testSetConfigurationWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.setConfiguration(new DeviceHandle(), 0);
}
/**
* Tests the {@link LibUsb#claimInterface(DeviceHandle, int)} method with
* uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testClaimInterfaceWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.claimInterface(new DeviceHandle(), 0);
}
/**
* Tests the {@link LibUsb#releaseInterface(DeviceHandle, int)} method with
* uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testReleaseInterfaceWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.releaseInterface(new DeviceHandle(), 0);
}
/**
* Tests the {@link LibUsb#setInterfaceAltSetting(DeviceHandle, int, int)}
* method with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testSetInterfaceAltSettingWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.setInterfaceAltSetting(new DeviceHandle(), 0, 0);
}
/**
* Tests the {@link LibUsb#clearHalt(DeviceHandle, int)} method with
* uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testClearHaltWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.clearHalt(new DeviceHandle(), 0);
}
/**
* Tests the {@link LibUsb#resetDevice(DeviceHandle)} method with
* uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testResetDeviceWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.resetDevice(new DeviceHandle());
}
/**
* Tests the {@link LibUsb#kernelDriverActive(DeviceHandle, int)} method
* with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testKernelDriverActiveWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.kernelDriverActive(new DeviceHandle(), 0);
}
/**
* Tests the {@link LibUsb#detachKernelDriver(DeviceHandle, int)} method
* with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testDetachKernelDriverWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.detachKernelDriver(new DeviceHandle(), 0);
}
/**
* Tests the {@link LibUsb#attachKernelDriver(DeviceHandle, int)} method
* with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testAttachKernelDriverWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.attachKernelDriver(new DeviceHandle(), 0);
}
/**
* Tests the {@link LibUsb#getDeviceDescriptor(Device, DeviceDescriptor)}
* method with uninitialized device.
*/
@Test(expected = IllegalStateException.class)
public void testGetDeviceDescriptorWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getDeviceDescriptor(new Device(), new DeviceDescriptor());
}
/**
* Tests the
* {@link LibUsb#getStringDescriptorAscii(DeviceHandle, int, StringBuffer, int)}
* method with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testGetStringDescriptorAsciiWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.getStringDescriptorAscii(new DeviceHandle(), 0,
new StringBuffer(), 0);
}
/**
* Tests the
* {@link LibUsb#getActiveConfigDescriptor(Device, ConfigDescriptor)} method
* with uninitialized device.
*/
@Test(expected = IllegalStateException.class)
public void testGetActiveConfigDescriptorWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getActiveConfigDescriptor(new Device(), new ConfigDescriptor());
}
/**
* Tests the
* {@link LibUsb#getConfigDescriptor(Device, int, ConfigDescriptor)} method
* with uninitialized device.
*/
@Test(expected = IllegalStateException.class)
public void testGetConfigDescriptorWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getConfigDescriptor(new Device(), 0, new ConfigDescriptor());
}
/**
* Tests the
* {@link LibUsb#getConfigDescriptorByValue(Device, int, ConfigDescriptor)}
* method with uninitialized device.
*/
@Test(expected = IllegalStateException.class)
public void testGetConfigDescriptorByValueWithUninitializedDevice()
{
assumeUsbTestsEnabled();
LibUsb.getConfigDescriptorByValue(new Device(), 0,
new ConfigDescriptor());
}
/**
* Tests the {@link LibUsb#freeConfigDescriptor(ConfigDescriptor)} method
* with uninitialized descriptor.
*/
@Test(expected = IllegalStateException.class)
public void testFreeConfigDescriptorWithUninitializedDescriptor()
{
assumeUsbTestsEnabled();
LibUsb.freeConfigDescriptor(new ConfigDescriptor());
}
/**
* Tests the
* {@link LibUsb#getDescriptor(DeviceHandle, int, int, ByteBuffer)} method
* with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testGetDescriptorWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.getDescriptor(new DeviceHandle(), 0, 0,
ByteBuffer.allocateDirect(1));
}
/**
* Tests the
* {@link LibUsb#getStringDescriptor(DeviceHandle, int, int, ByteBuffer)}
* method with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testGetStringDescriptorWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.getStringDescriptor(new DeviceHandle(), 0, 0,
ByteBuffer.allocateDirect(1));
}
/**
* Tests the
* {@link LibUsb#controlTransfer(DeviceHandle, int, int, int, int, ByteBuffer, int)}
* method with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testControlTransferWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.controlTransfer(new DeviceHandle(), 0, 0, 0, 0,
ByteBuffer.allocateDirect(1), 0);
}
/**
* Tests the
* {@link LibUsb#bulkTransfer(DeviceHandle, int, ByteBuffer, IntBuffer, int)}
* method with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testBulkTransferWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.bulkTransfer(new DeviceHandle(), 0,
ByteBuffer.allocateDirect(1), IntBuffer.allocate(1), 0);
}
/**
* Tests the
* {@link LibUsb#interruptTransfer(DeviceHandle, int, ByteBuffer, IntBuffer, int)}
* method with uninitialized device handle.
*/
@Test(expected = IllegalStateException.class)
public void testInterruptTransferWithUninitializedHandle()
{
assumeUsbTestsEnabled();
LibUsb.interruptTransfer(new DeviceHandle(), 0,
ByteBuffer.allocateDirect(1), IntBuffer.allocate(1), 0);
}
/**
* Tests the {@link LibUsb#freeTransfer(Transfer)} method with uninitialized
* device handle.
*/
@Test(expected = IllegalStateException.class)
public void testFreeTransferWithUninitializedTransfer()
{
assumeUsbTestsEnabled();
LibUsb.freeTransfer(new Transfer());
}
/**
* Tests {@link LibUsb#openDeviceWithVidPid(Context, int, int)} with
* uninitialized USB context.
*/
@Test(expected = IllegalStateException.class)
public void testOpenDeviceWithVidPid()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.openDeviceWithVidPid(context, 0, 0);
}
/**
* Tests {@link LibUsb#tryLockEvents(Context)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testTryLockEventsWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.tryLockEvents(context);
}
/**
* Tests {@link LibUsb#lockEvents(Context)} with uninitialized USB context.
*/
@Test(expected = IllegalStateException.class)
public void testLockEventsWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.lockEvents(context);
}
/**
* Tests {@link LibUsb#unlockEvents(Context)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testUnlockEventsWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.unlockEvents(context);
}
/**
* Tests {@link LibUsb#eventHandlingOk(Context)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testEventHandlingOkWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.eventHandlingOk(context);
}
/**
* Tests {@link LibUsb#eventHandlerActive(Context)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testEventHandlerActiveWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.eventHandlerActive(context);
}
/**
* Tests {@link LibUsb#lockEventWaiters(Context)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testLockEventWaitersWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.lockEventWaiters(context);
}
/**
* Tests {@link LibUsb#unlockEventWaiters(Context)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testUnlockEventWaitersWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.unlockEventWaiters(context);
}
/**
* Tests {@link LibUsb#waitForEvent(Context, long)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testWaitForEventWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.waitForEvent(context, 53);
}
/**
* Tests
* {@link LibUsb#handleEventsTimeoutCompleted(Context, long, IntBuffer)}
* with uninitialized USB context.
*/
@Test(expected = IllegalStateException.class)
public void testHandleEventsTimeoutCompletedWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.handleEventsTimeoutCompleted(context, 53, IntBuffer.allocate(1));
}
/**
* Tests {@link LibUsb#handleEventsTimeout(Context, long)} with
* uninitialized USB context.
*/
@Test(expected = IllegalStateException.class)
public void testHandleEventsTimeoutWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.handleEventsTimeout(context, 53);
}
/**
* Tests {@link LibUsb#handleEvents(Context)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testHandleEventsWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.handleEvents(context);
}
/**
* Tests {@link LibUsb#handleEventsCompleted(Context, IntBuffer)} with
* uninitialized USB context.
*/
@Test(expected = IllegalStateException.class)
public void testHandleEventsCompletedWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.handleEventsCompleted(context, IntBuffer.allocate(1));
}
/**
* Tests {@link LibUsb#handleEventsLocked(Context, long)} with uninitialized
* USB context.
*/
@Test(expected = IllegalStateException.class)
public void testHandleEventsLockedWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.handleEventsLocked(context, 53);
}
/**
* Tests {@link LibUsb#pollfdsHandleTimeouts(Context)} with uninitialized
* USB context.
*/
@Test(expected = IllegalStateException.class)
public void testPollfdsHandleTimeoutsWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.pollfdsHandleTimeouts(context);
}
/**
* Tests {@link LibUsb#getNextTimeout(Context, IntBuffer)} with
* uninitialized USB context.
*/
@Test(expected = IllegalStateException.class)
public void testGetNextTimeoutWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.getNextTimeout(context, IntBuffer.allocate(1));
}
/**
* Tests {@link LibUsb#setPollfdNotifiers(Context)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testSetPollfdNotifiersWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.setPollfdNotifiers(context);
}
/**
* Tests {@link LibUsb#unsetPollfdNotifiers(Context)} with uninitialized USB
* context.
*/
@Test(expected = IllegalStateException.class)
public void testUnsetPollfdNotifiersWithUninitializedContext()
{
assumeUsbTestsEnabled();
final Context context = new Context();
LibUsb.unsetPollfdNotifiers(context);
}
/**
* Tests the
* {@link LibUsb#setPollfdNotifiers(Context, PollfdListener, Object)}
* method.
*/
@Test
public void testPollFdNotifiers()
{
assumeUsbTestsEnabled();
PollfdListenerMock listener = new PollfdListenerMock();
Context context = new Context();
LibUsb.init(context);
LibUsb.setPollfdNotifiers(context, listener, "test");
FileDescriptor fd = new FileDescriptor();
LibUsb.triggerPollfdAdded(fd, 53);
assertEquals(53, listener.addedEvents);
assertSame(fd, listener.addedFd);
assertSame("test", listener.addedUserData);
assertNull(listener.removedFd);
assertNull(listener.removedUserData);
listener.reset();
fd = new FileDescriptor();
LibUsb.triggerPollfdRemoved(fd);
assertEquals(0, listener.addedEvents);
assertNull(listener.addedFd);
assertNull(listener.addedUserData);
assertSame(fd, listener.removedFd);
assertSame("test", listener.removedUserData);
LibUsb.setPollfdNotifiers(context, null, null);
listener.reset();
fd = new FileDescriptor();
LibUsb.triggerPollfdAdded(fd, 53);
assertEquals(0, listener.addedEvents);
assertNull(listener.addedFd);
assertNull(listener.addedUserData);
assertNull(listener.removedFd);
assertNull(listener.removedUserData);
listener.reset();
fd = new FileDescriptor();
LibUsb.triggerPollfdRemoved(fd);
assertEquals(0, listener.addedEvents);
assertNull(listener.addedFd);
assertNull(listener.addedUserData);
assertNull(listener.removedFd);
assertNull(listener.removedUserData);
}
}

View File

@ -5,12 +5,13 @@
package de.ailis.usb4java.libusb;
import static de.ailis.usb4java.UsbAssume.assumeUsbTestsEnabled;
import static de.ailis.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.lang.reflect.Field;
@ -64,6 +65,16 @@ public class TransferTest
Transfer transfer = LibUsb.allocTransfer(0);
assertNotNull(transfer);
LibUsb.freeTransfer(transfer);
try
{
LibUsb.freeTransfer(transfer);
fail("Double-free should throw IllegalStateException");
}
catch (IllegalStateException e)
{
// Expected behavior
}
}
/**
@ -78,7 +89,8 @@ public class TransferTest
{
try
{
Field field = DeviceHandle.class.getDeclaredField("handlePointer");
Field field =
DeviceHandle.class.getDeclaredField("deviceHandlePointer");
field.setAccessible(true);
field.set(handle, pointer);
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2013 Klaus Reimer <k@ailis.de>
* See LICENSE.md for licensing information.
*/
package de.ailis.usb4java.libusb.mocks;
import java.io.FileDescriptor;
import de.ailis.usb4java.libusb.PollfdListener;
/**
* A mocked pollfd listener implementation.
*
* @author Klaus Reimer (k@ailis.de)
*/
public class PollfdListenerMock implements PollfdListener
{
/** The file descriptor reported by the added event. */
public FileDescriptor addedFd;
/** The file descriptor reported by the removed event. */
public FileDescriptor removedFd;
/** The events number reported by the added event. */
public int addedEvents;
/** The user data reported by the added event. */
public Object addedUserData;
/** The user data reported by the removed event. */
public Object removedUserData;
@Override
public void pollfdAdded(FileDescriptor fd, int events, Object userData)
{
this.addedEvents = events;
this.addedFd = fd;
this.addedUserData = userData;
}
@Override
public void pollfdRemoved(FileDescriptor fd, Object userData)
{
this.removedFd = fd;
this.removedUserData = userData;
}
/**
* Resets the mock object state.
*/
public void reset()
{
this.addedEvents = 0;
this.addedFd = null;
this.addedUserData = null;
this.removedFd = null;
this.removedUserData = null;
}
}

View File

@ -3,7 +3,7 @@
* See LICENSE.md for licensing information.
*/
package de.ailis.usb4java;
package de.ailis.usb4java.test;
import org.junit.internal.runners.JUnit38ClassRunner;
import org.junit.runner.Description;

View File

@ -3,7 +3,7 @@
* See LICENSE.md for licensing information.
*/
package de.ailis.usb4java;
package de.ailis.usb4java.test;
import static org.junit.Assume.assumeTrue;

View File

@ -25,7 +25,7 @@ import javax.usb.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
//import javax.usb.util.*;
import junit.framework.TestCase;

View File

@ -15,7 +15,7 @@ import javax.usb.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.*;

View File

@ -16,7 +16,7 @@ import javax.usb.util.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.*;

View File

@ -15,7 +15,7 @@ import javax.usb.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;

View File

@ -15,7 +15,7 @@ import javax.usb.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.Assert;
import junit.framework.TestCase;

View File

@ -31,7 +31,7 @@ import javax.usb.event.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
/**
* Control I/O Test - Synchronous and asynchronous Control Irp and Control

View File

@ -16,7 +16,7 @@ import javax.usb.event.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.TestCase;

View File

@ -15,7 +15,7 @@ import javax.usb.util.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.TestCase;

View File

@ -25,7 +25,7 @@ import javax.usb.event.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.TestCase;

View File

@ -25,7 +25,7 @@ import javax.usb.event.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.TestCase;

View File

@ -14,7 +14,7 @@ import javax.usb.util.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.TestCase;

View File

@ -14,7 +14,7 @@ import javax.usb.util.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.TestCase;

View File

@ -27,7 +27,7 @@ import javax.usb.util.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
/**
* FindControlIODevice

View File

@ -29,7 +29,7 @@ import javax.usb.util.StandardRequest;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.TestCase;

View File

@ -23,7 +23,7 @@ import javax.usb.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
//import javax.usb.util.*;
import junit.framework.TestCase;

View File

@ -15,7 +15,7 @@ import javax.usb.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;

View File

@ -16,7 +16,7 @@ import javax.usb.util.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import junit.framework.*;

View File

@ -15,7 +15,7 @@ import javax.usb.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;

View File

@ -7,7 +7,7 @@ import javax.usb.util.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import java.util.*;

View File

@ -13,7 +13,7 @@ import javax.usb.tck.sigtest.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
import java.io.*;
import junit.framework.*;

View File

@ -28,7 +28,7 @@ import javax.usb.*;
import org.junit.runner.RunWith;
import de.ailis.usb4java.TCKRunner;
import de.ailis.usb4java.test.TCKRunner;
/**
* Usb Interface Policy Test