diff --git a/pom.xml b/pom.xml
index 856c222..088239d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -275,13 +275,6 @@
1.2.0-SNAPSHOT
test
-
- org.usb4java
- libusb4java
- linux-x86
- 1.2.0-SNAPSHOT
- test
-
org.apache.commons
commons-lang3
diff --git a/src/test/java/org/usb4java/BosDescriptorTest.java b/src/test/java/org/usb4java/BosDescriptorTest.java
index 6f736cd..82db403 100644
--- a/src/test/java/org/usb4java/BosDescriptorTest.java
+++ b/src/test/java/org/usb4java/BosDescriptorTest.java
@@ -6,12 +6,11 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
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.
@@ -29,9 +28,11 @@ public class BosDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new BosDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new BosDescriptor();
+ }
}
/**
@@ -40,7 +41,10 @@ public class BosDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/BosDevCapabilityDescriptorTest.java b/src/test/java/org/usb4java/BosDevCapabilityDescriptorTest.java
index 3f5fd73..afd3fb2 100644
--- a/src/test/java/org/usb4java/BosDevCapabilityDescriptorTest.java
+++ b/src/test/java/org/usb4java/BosDevCapabilityDescriptorTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class BosDevCapabilityDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new BosDevCapabilityDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new BosDevCapabilityDescriptor();
+ }
}
/**
@@ -40,7 +43,10 @@ public class BosDevCapabilityDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/ConfigDescriptorTest.java b/src/test/java/org/usb4java/ConfigDescriptorTest.java
index fbac11d..69b056b 100644
--- a/src/test/java/org/usb4java/ConfigDescriptorTest.java
+++ b/src/test/java/org/usb4java/ConfigDescriptorTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class ConfigDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new ConfigDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new ConfigDescriptor();
+ }
}
/**
@@ -40,7 +43,10 @@ public class ConfigDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/ContainerIdDescriptorTest.java b/src/test/java/org/usb4java/ContainerIdDescriptorTest.java
index 63976a0..3540dcb 100644
--- a/src/test/java/org/usb4java/ContainerIdDescriptorTest.java
+++ b/src/test/java/org/usb4java/ContainerIdDescriptorTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class ContainerIdDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new ContainerIdDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new ContainerIdDescriptor();
+ }
}
/**
@@ -40,7 +43,10 @@ public class ContainerIdDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/DeviceDescriptorTest.java b/src/test/java/org/usb4java/DeviceDescriptorTest.java
index 35023dd..58c4664 100644
--- a/src/test/java/org/usb4java/DeviceDescriptorTest.java
+++ b/src/test/java/org/usb4java/DeviceDescriptorTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class DeviceDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new DeviceDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new DeviceDescriptor();
+ }
}
/**
@@ -40,7 +43,10 @@ public class DeviceDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/EndpointDescriptorTest.java b/src/test/java/org/usb4java/EndpointDescriptorTest.java
index f3d3c1e..021f5b7 100644
--- a/src/test/java/org/usb4java/EndpointDescriptorTest.java
+++ b/src/test/java/org/usb4java/EndpointDescriptorTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class EndpointDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new EndpointDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new EndpointDescriptor();
+ }
}
/**
@@ -40,7 +43,10 @@ public class EndpointDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/InterfaceDescriptorTest.java b/src/test/java/org/usb4java/InterfaceDescriptorTest.java
index e570958..baade23 100644
--- a/src/test/java/org/usb4java/InterfaceDescriptorTest.java
+++ b/src/test/java/org/usb4java/InterfaceDescriptorTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class InterfaceDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new InterfaceDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new InterfaceDescriptor();
+ }
}
/**
@@ -40,7 +43,10 @@ public class InterfaceDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/InterfaceTest.java b/src/test/java/org/usb4java/InterfaceTest.java
index 03fb7f7..80a8f10 100644
--- a/src/test/java/org/usb4java/InterfaceTest.java
+++ b/src/test/java/org/usb4java/InterfaceTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class InterfaceTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new Interface();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new Interface();
+ }
}
/**
@@ -40,7 +43,10 @@ public class InterfaceTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/LibUSBDeviceTest.java b/src/test/java/org/usb4java/LibUSBDeviceTest.java
index 29710cd..32570d5 100644
--- a/src/test/java/org/usb4java/LibUSBDeviceTest.java
+++ b/src/test/java/org/usb4java/LibUSBDeviceTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
@@ -62,20 +63,23 @@ public class LibUSBDeviceTest
@Before
public void setUp()
{
- this.context = new Context();
- LibUsb.init(this.context);
- try
+ if (isUsbTestsEnabled())
{
- this.device = this.findTestDevice();
- if (this.device == null)
+ this.context = new Context();
+ LibUsb.init(this.context);
+ try
{
- throw new IllegalStateException("Need at least one USB device "
- + "with at least one endpoint to execute this test");
+ this.device = this.findTestDevice();
+ if (this.device == null)
+ {
+ throw new IllegalStateException("Need at least one USB device "
+ + "with at least one endpoint to execute this test");
+ }
+ }
+ catch (final Throwable e)
+ {
+ this.device = null;
}
- }
- catch (final Throwable e)
- {
- this.device = null;
}
}
@@ -145,13 +149,16 @@ public class LibUSBDeviceTest
@After
public void tearDown()
{
- if (this.device != null)
+ if (isUsbTestsEnabled())
{
- LibUsb.unrefDevice(this.device);
- }
- if (this.context != null)
- {
- LibUsb.exit(this.context);
+ if (this.device != null)
+ {
+ LibUsb.unrefDevice(this.device);
+ }
+ if (this.context != null)
+ {
+ LibUsb.exit(this.context);
+ }
}
}
diff --git a/src/test/java/org/usb4java/SsEndpointCompanionDescriptorTest.java b/src/test/java/org/usb4java/SsEndpointCompanionDescriptorTest.java
index 654a8b5..74affbe 100644
--- a/src/test/java/org/usb4java/SsEndpointCompanionDescriptorTest.java
+++ b/src/test/java/org/usb4java/SsEndpointCompanionDescriptorTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class SsEndpointCompanionDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new SsEndpointCompanionDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new SsEndpointCompanionDescriptor();
+ }
}
/**
@@ -40,7 +43,10 @@ public class SsEndpointCompanionDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/SsUsbDeviceCapabilityDescriptorTest.java b/src/test/java/org/usb4java/SsUsbDeviceCapabilityDescriptorTest.java
index f523a9b..76a2388 100644
--- a/src/test/java/org/usb4java/SsUsbDeviceCapabilityDescriptorTest.java
+++ b/src/test/java/org/usb4java/SsUsbDeviceCapabilityDescriptorTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class SsUsbDeviceCapabilityDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new SsUsbDeviceCapabilityDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new SsUsbDeviceCapabilityDescriptor();
+ }
}
/**
@@ -40,7 +43,10 @@ public class SsUsbDeviceCapabilityDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/Usb20ExtensionDescriptorTest.java b/src/test/java/org/usb4java/Usb20ExtensionDescriptorTest.java
index b7dc479..752ace0 100644
--- a/src/test/java/org/usb4java/Usb20ExtensionDescriptorTest.java
+++ b/src/test/java/org/usb4java/Usb20ExtensionDescriptorTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class Usb20ExtensionDescriptorTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.descriptor = new Usb20ExtensionDescriptor();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.descriptor = new Usb20ExtensionDescriptor();
+ }
}
/**
@@ -40,7 +43,10 @@ public class Usb20ExtensionDescriptorTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/VersionTest.java b/src/test/java/org/usb4java/VersionTest.java
index 16779ed..b8843c1 100644
--- a/src/test/java/org/usb4java/VersionTest.java
+++ b/src/test/java/org/usb4java/VersionTest.java
@@ -6,6 +6,7 @@
package org.usb4java;
import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
+import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;
import org.junit.After;
import org.junit.Before;
@@ -29,9 +30,11 @@ public class VersionTest
@Before
public void setUp()
{
- assumeUsbTestsEnabled();
- LibUsb.init(null);
- this.version = new Version();
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.init(null);
+ this.version = new Version();
+ }
}
/**
@@ -40,7 +43,10 @@ public class VersionTest
@After
public void tearDown()
{
- LibUsb.exit(null);
+ if (isUsbTestsEnabled())
+ {
+ LibUsb.exit(null);
+ }
}
/**
diff --git a/src/test/java/org/usb4java/test/UsbAssume.java b/src/test/java/org/usb4java/test/UsbAssume.java
index 1a2494a..226708d 100644
--- a/src/test/java/org/usb4java/test/UsbAssume.java
+++ b/src/test/java/org/usb4java/test/UsbAssume.java
@@ -23,19 +23,19 @@ public class UsbAssume
/** If TCK tests are to be executed. */
private static Boolean tckTests;
-
+
/**
- * Assume that USB tests are enabled. Call this in the first line of
- * tests method or preparation methods when you want to ignore the
- * tests when the system is not able to run the tests anyway.
+ * Check if USB tests are enabled.
*
* USB tests can be controlled with the system property USB_TESTS. When
* set to true then USB tests are always run, if set to false then they
* are never run. If this property is not set then the command-line tool
* lsusb is called. If this tool returned at least two lines of text then
* USB tests are enabled. In all other cases they are disabled.
+ *
+ * @return True if USB tests are enabled, false if not.
*/
- public static void assumeUsbTestsEnabled()
+ public static boolean isUsbTestsEnabled()
{
if (usbTests == null && System.getProperty("USB_TESTS") != null)
usbTests = Boolean.valueOf(System.getProperty("USB_TESTS"));
@@ -77,8 +77,27 @@ public class UsbAssume
// not be run.
}
}
- assumeTrue("This test is ignored when USB_TESTS property is not set",
- usbTests);
+ return usbTests;
+ }
+
+ /**
+ * Assume that USB tests are enabled. Call this in the first line of
+ * tests method or preparation methods when you want to ignore the
+ * tests when the system is not able to run the tests anyway.
+ *
+ * USB tests can be controlled with the system property USB_TESTS. When
+ * set to true then USB tests are always run, if set to false then they
+ * are never run. If this property is not set then the command-line tool
+ * lsusb is called. If this tool returned at least two lines of text then
+ * USB tests are enabled. In all other cases they are disabled.
+ */
+ public static void assumeUsbTestsEnabled()
+ {
+ if (!isUsbTestsEnabled())
+ {
+ assumeTrue("This test is ignored when USB_TESTS property is not set",
+ usbTests);
+ }
}
/**