Skip to content

Commit b13a096

Browse files
committed
fix a bunch of warnings and add headers
1 parent 3508084 commit b13a096

File tree

7 files changed

+55
-24
lines changed

7 files changed

+55
-24
lines changed

core-test/src/test/java/tel/schich/javacan/test/BcmCanSocketTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ void testMessageFrameAccess() {
113113
assertArrayEquals(frameData[i], dataBuffer.array());
114114
}
115115
// check no frame after the last index
116-
assertThrows(IllegalArgumentException.class, () -> {
117-
message.getFrame(frameData.length);
118-
});
116+
assertThrows(IllegalArgumentException.class, () -> message.getFrame(frameData.length));
119117
}
120118

121119
@Test
@@ -151,9 +149,7 @@ void testMessageFDFrameAccess() {
151149
assertArrayEquals(frameData[i], dataBuffer.array());
152150
}
153151
// check no frame after the last index
154-
assertThrows(IllegalArgumentException.class, () -> {
155-
message.getFrame(frameData.length);
156-
});
152+
assertThrows(IllegalArgumentException.class, () -> message.getFrame(frameData.length));
157153
}
158154

159155
@Test

core-test/src/test/java/tel/schich/javacan/test/RawCanSocketTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import tel.schich.javacan.CanChannels;
2727
import tel.schich.javacan.CanFilter;
2828
import tel.schich.javacan.CanFrame;
29-
import tel.schich.javacan.CanSocketOptions;
3029
import tel.schich.javacan.JavaCAN;
3130
import tel.schich.javacan.RawCanChannel;
3231
import tel.schich.javacan.platform.linux.LinuxNativeOperationException;
@@ -123,6 +122,7 @@ void testFilters() throws Exception {
123122
}
124123
}
125124

125+
@Test
126126
void testMaxFilterValidation() throws Exception {
127127
try (final RawCanChannel socket = CanChannels.newRawChannel()) {
128128
socket.bind(CAN_INTERFACE);

epoll-test/src/test/java/tel/schich/javacan/test/select/EPollSelectorTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public void testWriteRead() throws IOException {
6767
selector.register(ch, EnumSet.of(SelectorRegistration.Operation.READ));
6868

6969
CanFrame inputFrame = CanFrame.create(0x7EF, FD_NO_FLAGS, new byte[]{1, 2, 3, 4});
70-
runDelayed(ofMillis(200), () -> {
71-
ch.write(inputFrame);
72-
});
70+
runDelayed(ofMillis(200), () -> ch.write(inputFrame));
7371
assertTimeoutPreemptively(ofMillis(300), () -> {
7472
List<IOEvent<UnixFileDescriptor>> events = selector.select();
7573
assertEquals(1, events.size(), "With one registered channel there should only be one selection key!");
@@ -109,7 +107,7 @@ public void testEPollFdReuse() throws IOException, InterruptedException {
109107
try (final EPollSelector selector = EPollSelector.open()) {
110108

111109
SelectorRegistration<UnixFileDescriptor, RawCanChannel> firstRegistration = configureAndRegisterChannel(selector);
112-
try (RawCanChannel firstChannel = firstRegistration.getChannel()) {
110+
try (RawCanChannel ignored = firstRegistration.getChannel()) {
113111
CanTestHelper.sendFrameViaUtils(CAN_INTERFACE, CanFrame.create(0x3, CanFrame.FD_NO_FLAGS, new byte[] {1}));
114112
assertEquals(1, selector.selectNow().size());
115113

epoll-test/src/test/java/tel/schich/javacan/test/util/CanBrokerTest.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*/
2323
package tel.schich.javacan.test.util;
2424

25-
import org.junit.Assert;
2625
import org.junit.jupiter.api.Test;
2726
import org.slf4j.Logger;
2827
import org.slf4j.LoggerFactory;
@@ -37,8 +36,7 @@
3736
import java.util.concurrent.ThreadFactory;
3837

3938
import static java.util.concurrent.TimeUnit.SECONDS;
40-
import static org.junit.jupiter.api.Assertions.assertEquals;
41-
import static org.junit.jupiter.api.Assertions.assertNotNull;
39+
import static org.junit.jupiter.api.Assertions.*;
4240

4341
class CanBrokerTest {
4442
private static final Logger LOGGER = LoggerFactory.getLogger(CanBrokerTest.class);
@@ -67,13 +65,11 @@ void testLoopback() throws Exception {
6765
try {
6866
brokerA.removeDevice(CanTestHelper.CAN_INTERFACE);
6967
} catch (IOException e) {
70-
Assert.fail("Removing the device from brokerA should not fail: " + e.getLocalizedMessage());
68+
fail("Removing the device from brokerA should not fail: " + e.getLocalizedMessage());
7169
}
7270
});
7371

74-
brokerB.addDevice(CanTestHelper.CAN_INTERFACE, (d, frame) -> {
75-
LOGGER.debug(String.valueOf(frame));
76-
});
72+
brokerB.addDevice(CanTestHelper.CAN_INTERFACE, (d, frame) -> LOGGER.debug(String.valueOf(frame)));
7773
brokerB.send(expected);
7874

7975
CanFrame actual = f.get(2, SECONDS);
@@ -91,9 +87,7 @@ void testExternal() throws Exception {
9187

9288
CanBroker can = new CanBroker(FACTORY, EPollSelector.open());
9389
can.addFilter(new CanFilter(id));
94-
can.addDevice(CanTestHelper.CAN_INTERFACE, (ch, frame) -> {
95-
f.complete(frame);
96-
});
90+
can.addDevice(CanTestHelper.CAN_INTERFACE, (ch, frame) -> f.complete(frame));
9791

9892
CanTestHelper.sendFrameViaUtils(CanTestHelper.CAN_INTERFACE, expected);
9993

epoll-test/src/test/java/tel/schich/javacan/test/util/IsotpListenerTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ void testBroker() throws Exception {
6161
IsotpSocketAddress addrb = IsotpSocketAddress.isotpAddress(SFF_ECU_RESPONSE_BASE + DESTINATION_ECU_1);
6262

6363
try (IsotpListener broker = new IsotpListener(threadFactory, EPollSelector.open(), Duration.ofSeconds(5))) {
64-
6564
try (IsotpCanChannel a = CanChannels.newIsotpChannel()) {
6665
try (IsotpCanChannel b = CanChannels.newIsotpChannel()) {
6766
final ByteBuffer buf = IsotpCanChannel.allocateSufficientMemory();
@@ -74,8 +73,8 @@ void testBroker() throws Exception {
7473
broker.addChannel(a, new PingPing(lock, condition, buf));
7574
broker.addChannel(b, new PingPing(lock, condition, buf));
7675

77-
buf.put(randomByte())
78-
.flip();
76+
buf.put(randomByte());
77+
buf.flip();
7978
a.write(buf);
8079

8180
try {

epoll/src/main/java/tel/schich/javacan/util/CopyingFrameHandlerProxy.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* The MIT License
3+
* Copyright © 2018 Phillip Schichtel
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
123
package tel.schich.javacan.util;
224

325
import tel.schich.javacan.CanFrame;

epoll/src/main/java/tel/schich/javacan/util/CopyingMessageHandlerProxy.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* The MIT License
3+
* Copyright © 2018 Phillip Schichtel
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
123
package tel.schich.javacan.util;
224

325
import tel.schich.javacan.IsotpCanChannel;

0 commit comments

Comments
 (0)