Skip to content

Commit 48c633b

Browse files
committed
Minor cleanup
1 parent 768ccd8 commit 48c633b

File tree

5 files changed

+16
-32
lines changed

5 files changed

+16
-32
lines changed

java-does-usb/src/main/java/net/codecrete/usb/macos/TransferTimeout.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ static synchronized ScheduledExecutorService getScheduledExecutorService() {
5959
return scheduledExecutorService;
6060
}
6161

62-
ScheduledFuture<?> future;
63-
MacosUSBDevice.EndpointInfo endpointInfo;
64-
boolean completed;
62+
private final ScheduledFuture<?> future;
63+
private final MacosUSBDevice.EndpointInfo endpointInfo;
64+
private boolean completed;
6565

6666
private static ScheduledExecutorService scheduledExecutorService;
6767
}

java-does-usb/src/test/java/net/codecrete/usb/AlternateInterfaceTest.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,9 @@ void selectAlternateIntf_succeeds() {
3838

3939
@Test
4040
void selectInvalidAlternateIntf_fails() {
41-
assertThrows(USBException.class, () -> {
42-
testDevice.selectAlternateSetting(1, 0);
43-
});
41+
assertThrows(USBException.class, () -> testDevice.selectAlternateSetting(1, 0));
4442

45-
assertThrows(USBException.class, () -> {
46-
testDevice.selectAlternateSetting(LOOPBACK_INTF_LOOPBACK, 2);
47-
});
43+
assertThrows(USBException.class, () -> testDevice.selectAlternateSetting(LOOPBACK_INTF_LOOPBACK, 2));
4844
}
4945

5046
@Test
@@ -61,12 +57,8 @@ void transferOnValidEndpoint_succeeds() {
6157
void transferOnInvalidEndpoint_fails() {
6258
testDevice.selectAlternateSetting(LOOPBACK_INTF_LOOPBACK, 1);
6359

64-
assertThrows(USBException.class, () -> {
65-
testDevice.transferOut(ECHO_EP_OUT, new byte[] { 1, 2, 3 });
66-
});
60+
assertThrows(USBException.class, () -> testDevice.transferOut(ECHO_EP_OUT, new byte[] { 1, 2, 3 }));
6761

68-
assertThrows(USBException.class, () -> {
69-
testDevice.transferIn(ECHO_EP_IN, 16);
70-
});
62+
assertThrows(USBException.class, () -> testDevice.transferIn(ECHO_EP_IN, 16));
7163
}
7264
}

java-does-usb/src/test/java/net/codecrete/usb/StallTest.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ void stalledBulkTransferOut_recovers() {
2121
haltEndpoint(USBDirection.OUT, LOOPBACK_EP_OUT);
2222

2323
byte[] data = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
24-
assertThrows(USBStallException.class, () -> {
25-
testDevice.transferOut(LOOPBACK_EP_OUT, data);
26-
});
24+
assertThrows(USBStallException.class, () -> testDevice.transferOut(LOOPBACK_EP_OUT, data));
2725

2826
testDevice.clearHalt(USBDirection.OUT, LOOPBACK_EP_OUT);
2927

@@ -36,9 +34,7 @@ void stalledBulkTransferOut_recovers() {
3634
void stalledBulkTransferIn_recovers() {
3735
haltEndpoint(USBDirection.IN, LOOPBACK_EP_IN);
3836

39-
assertThrows(USBStallException.class, () -> {
40-
testDevice.transferIn(LOOPBACK_EP_IN, LOOPBACK_MAX_PACKET_SIZE);
41-
});
37+
assertThrows(USBStallException.class, () -> testDevice.transferIn(LOOPBACK_EP_IN, LOOPBACK_MAX_PACKET_SIZE));
4238

4339
testDevice.clearHalt(USBDirection.IN, LOOPBACK_EP_IN);
4440

@@ -50,9 +46,9 @@ void stalledBulkTransferIn_recovers() {
5046

5147
@Test
5248
void invalidControlTransfer_throws() {
53-
assertThrows(USBStallException.class, () -> {
54-
testDevice.controlTransferIn(new USBControlTransfer(USBRequestType.VENDOR, USBRecipient.INTERFACE, (byte) 0x08, (short) 0, (short) interfaceNumber), 2);
55-
});
49+
assertThrows(USBStallException.class, () -> testDevice.controlTransferIn(
50+
new USBControlTransfer(USBRequestType.VENDOR, USBRecipient.INTERFACE, (byte) 0x08,
51+
(short) 0, (short) interfaceNumber), 2));
5652
}
5753

5854
void haltEndpoint(USBDirection direction, int endpointNumber) {

java-does-usb/src/test/java/net/codecrete/usb/StreamTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void mediumTransfer_succeeds() {
3939
}
4040

4141
@Test
42-
void transferWithZLP_succeeds() throws Throwable {
42+
void transferWithZLP_succeeds() {
4343
final byte[] sampleData = generateRandomBytes(2 * LOOPBACK_MAX_PACKET_SIZE, 197007894);
4444
var writer = CompletableFuture.runAsync(() -> {
4545
testDevice.transferOut(LOOPBACK_EP_OUT, Arrays.copyOfRange(sampleData, 0, LOOPBACK_MAX_PACKET_SIZE));
@@ -66,7 +66,7 @@ void largeTransferSmallChunks_succeeds() {
6666
}
6767

6868
@Test
69-
void largeTransferBigChunks_succeeds() throws Throwable {
69+
void largeTransferBigChunks_succeeds() {
7070
final int numBytes = 230763;
7171
byte[] sampleData = generateRandomBytes(numBytes, 3829007493L);
7272
var writer = CompletableFuture.runAsync(() -> writeBytes(sampleData, 150));

java-does-usb/src/test/java/net/codecrete/usb/TimeoutTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public class TimeoutTest extends TestDeviceBase {
2323
@Test
2424
@Timeout(value = 1, unit = TimeUnit.SECONDS)
2525
void bulkTransferIn_timesOut() {
26-
assertThrows(USBTimeoutException.class, () -> {
27-
testDevice.transferIn(LOOPBACK_EP_IN, 200);
28-
});
26+
assertThrows(USBTimeoutException.class, () -> testDevice.transferIn(LOOPBACK_EP_IN, 200));
2927
}
3028

3129
@Test
@@ -70,9 +68,7 @@ void interruptTransferIn_timesOut() {
7068
Assumptions.assumeTrue(isLoopbackDevice(),
7169
"Interrupt transfer only supported by loopback test device");
7270

73-
assertThrows(USBTimeoutException.class, () -> {
74-
testDevice.transferIn(ECHO_EP_IN, 200);
75-
});
71+
assertThrows(USBTimeoutException.class, () -> testDevice.transferIn(ECHO_EP_IN, 200));
7672
}
7773

7874
@Test

0 commit comments

Comments
 (0)