diff --git a/java/UsbView.launch b/java/UsbView.launch
index e067e1e..0997abe 100644
--- a/java/UsbView.launch
+++ b/java/UsbView.launch
@@ -8,5 +8,4 @@
-
diff --git a/java/src/ch/ntb/inf/libusbJava/LibusbJava1.java b/java/src/ch/ntb/inf/libusbJava/LibusbJava1.java
index 1346d05..9e6b179 100644
--- a/java/src/ch/ntb/inf/libusbJava/LibusbJava1.java
+++ b/java/src/ch/ntb/inf/libusbJava/LibusbJava1.java
@@ -1387,13 +1387,29 @@ public class LibusbJava1 {
/**
* This method is only used for testing the DLL-code that throws exceptions
- * in the java environment.
+ * in the java environment.
*
* @param code
* Code of the error to be simulated and hence the code of the
* exception that shall be thrown.
*
* @throws LibusbError
+ * @deprecated This function is only for testing purpose and should not be
+ * called in production code
*/
+ @Deprecated
public static native void libusb_exceptionTest(int code) throws LibusbError;
+
+ /**
+ * This method is only used for testing the DLL helpercode. It creates a
+ * byte Array of the given size from the given string.
+ *
+ * @param str String to be copied into the array
+ * @param size Size of the array to be created
+ *
+ * @deprecated This function is only for testing purpose and should not be
+ * called in production code
+ */
+ @Deprecated
+ public static native byte[] to_byteArrayTest(String str, int size);
}
diff --git a/java/test/ch/ntb/inf/libusbJava/test/DeviceTest.java b/java/test/ch/ntb/inf/libusbJava/test/DeviceTest.java
index e1a09d9..20b3a02 100644
--- a/java/test/ch/ntb/inf/libusbJava/test/DeviceTest.java
+++ b/java/test/ch/ntb/inf/libusbJava/test/DeviceTest.java
@@ -37,6 +37,7 @@ import ch.ntb.inf.libusbJava.Utils;
import ch.ntb.inf.libusbJava.testApp.AbstractDeviceInfo;
import ch.ntb.inf.libusbJava.testApp.AbstractDeviceInfo.TransferMode;
+@SuppressWarnings("deprecation")
public class DeviceTest {
private static final String testdevicePropertiesFile = "testdevice.properties";
diff --git a/java/test/ch/ntb/inf/libusbJava/test/LibusbJava1Test.java b/java/test/ch/ntb/inf/libusbJava/test/LibusbJava1Test.java
index 9934b47..8d20de4 100644
--- a/java/test/ch/ntb/inf/libusbJava/test/LibusbJava1Test.java
+++ b/java/test/ch/ntb/inf/libusbJava/test/LibusbJava1Test.java
@@ -2,6 +2,7 @@ package ch.ntb.inf.libusbJava.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -24,8 +25,9 @@ public class LibusbJava1Test {
* This test is used to check if the library constructs and throws the
* correct exceptions if requested to do so.
*/
+ @SuppressWarnings("deprecation")
@Test
- public void testLibusb_exceptionTest() {
+ public void testLibusb_exception() {
/*
* We go through every currently possible error just to check a several
* different error codes.
@@ -43,6 +45,43 @@ public class LibusbJava1Test {
assertTrue("Exception occured", exception_occured);
}
}
+
+ /**
+ * Tests a helper function in the DLL that creates a byte array object from
+ * a piece of memory given.
+ */
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testLibusb_to_byteArrayWithContent() {
+ final String str = "SimpleTest";
+ final int testLen = 5;
+ final byte[] reference = str.substring(0, testLen).getBytes();
+
+ byte[] result = LibusbJava1.to_byteArrayTest(str, testLen);
+
+ assertNotNull("Got a byte array", result);
+ assertEquals("Byte array has correct length", testLen, result.length);
+
+ for (int i = 0;i < result.length;i++)
+ {
+ assertEquals("Array content is correct", reference[i], result[i]);
+ }
+ }
+
+ /**
+ * Tests a helper function in the DLL that creates a byte array object from
+ * a piece of memory given.
+ */
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testLibusb_to_byteArrayLength0() {
+ final String str = "SimpleTest";
+
+ byte[] result = LibusbJava1.to_byteArrayTest(str, 0);
+
+ assertNotNull("Got a byte array", result);
+ assertEquals("Byte array has correct length", 0, result.length);
+ }
@Test
public void testLibusb_init() {
@@ -68,12 +107,17 @@ public class LibusbJava1Test {
Usb_Device devices = LibusbJava1.libusb_get_device_list(handle);
assertNotNull("Got devices", devices);
System.out.println(devices.toString());
+ assertNull("Bus is null", devices.getBus());
LibusbJava1.libusb_exit(handle);
}
@Test
- public void testLibusb_get_bus_number() {
- fail("Not yet implemented");
+ public void testLibusb_get_bus_number() throws LibusbError {
+ long handle = LibusbJava1.libusb_init();
+ Usb_Device devices = LibusbJava1.libusb_get_device_list(handle);
+ assertNotNull("Got devices", devices);
+ System.out.println(devices.getBus());
+ LibusbJava1.libusb_exit(handle);
}
@Test
diff --git a/java/test/ch/ntb/inf/libusbJava/test/MemoryLeakTest.java b/java/test/ch/ntb/inf/libusbJava/test/MemoryLeakTest.java
index bc70d69..e26e7d0 100644
--- a/java/test/ch/ntb/inf/libusbJava/test/MemoryLeakTest.java
+++ b/java/test/ch/ntb/inf/libusbJava/test/MemoryLeakTest.java
@@ -30,6 +30,7 @@ import ch.ntb.inf.libusbJava.Utils;
import ch.ntb.inf.libusbJava.testApp.AbstractDeviceInfo;
import ch.ntb.inf.libusbJava.testApp.AbstractDeviceInfo.TransferMode;
+@SuppressWarnings("deprecation")
public class MemoryLeakTest {
private static final String testdevicePropertiesFile = "testdevice.properties";
diff --git a/java/test/ch/ntb/inf/libusbJava/test/TestLibUsbJava.java b/java/test/ch/ntb/inf/libusbJava/test/TestLibUsbJava.java
index a495590..7804611 100644
--- a/java/test/ch/ntb/inf/libusbJava/test/TestLibUsbJava.java
+++ b/java/test/ch/ntb/inf/libusbJava/test/TestLibUsbJava.java
@@ -19,6 +19,7 @@ import ch.ntb.inf.libusbJava.Usb_Interface_Descriptor;
* This class replicates the code from testlibusb.c supplied in the
* libusb-0.1.12 release.
*/
+@SuppressWarnings("deprecation")
public class TestLibUsbJava {
static boolean verbose;
diff --git a/java/test/ch/ntb/inf/libusbJava/test/exceptions/LibusbErrorTest.java b/java/test/ch/ntb/inf/libusbJava/test/exceptions/LibusbErrorTest.java
index 4011ae0..0d5e53a 100644
--- a/java/test/ch/ntb/inf/libusbJava/test/exceptions/LibusbErrorTest.java
+++ b/java/test/ch/ntb/inf/libusbJava/test/exceptions/LibusbErrorTest.java
@@ -1,8 +1,6 @@
package ch.ntb.inf.libusbJava.test.exceptions;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.Collection;