- use a properties file to select the test device

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@194 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-11-16 07:12:49 +00:00
parent 1f9758376a
commit f4f7ee4c4a
2 changed files with 32 additions and 3 deletions

View File

@@ -1,6 +1,11 @@
package ch.ntb.usb;
import static org.junit.Assert.fail;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import junit.framework.Assert;
import org.junit.AfterClass;
@@ -11,6 +16,10 @@ import ch.ntb.usb.AbstractDeviceInfo.WriteMode;
public class DeviceTest {
private static final String testdevicePropertiesFile = "testdevice.properties";
private static final String deviceInfoKey = "testdeviceInfo";
private static AbstractDeviceInfo devinfo;
private static byte[] testData;
@@ -21,8 +30,19 @@ public class DeviceTest {
@BeforeClass
public static void setUp() throws Exception {
// select the device
devinfo = new AT90USB1287();
// load the device info class with the key
// from 'testdevice.properties'
InputStream propInputStream = new FileInputStream(
testdevicePropertiesFile);
Properties devInfoProp = new Properties();
devInfoProp.load(propInputStream);
String devInfoClazzName = devInfoProp.getProperty(deviceInfoKey);
if (devInfoClazzName == null) {
throw new IllegalArgumentException("property " + deviceInfoKey
+ "not found in file " + testdevicePropertiesFile);
}
Class devInfoClazz = Class.forName(devInfoClazzName);
devinfo = (AbstractDeviceInfo) devInfoClazz.newInstance();
// devinfo = new CY7C68013A();
// setup test data
testData = new byte[devinfo.getMaxDataSize()];
@@ -169,7 +189,7 @@ public class DeviceTest {
@AfterClass
public static void tearDown() throws Exception {
if (dev.isOpen()) {
if (dev != null && dev.isOpen()) {
dev.close();
}
}