Skip to content

Commit 1dd2333

Browse files
committed
Minor fixes and some new test cases.
Signed-off-by: Tatiana Leon <tatiana.leon@digi.com>
1 parent 14b24e4 commit 1dd2333

File tree

9 files changed

+2206
-11
lines changed

9 files changed

+2206
-11
lines changed

library/src/main/java/com/digi/xbee/api/connection/serial/AbstractSerialPort.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ public void writeData(byte[] data, int offset, int length) throws IOException {
444444
if (offset < 0)
445445
throw new IllegalArgumentException("Offset cannot be less than 0.");
446446
if (length < 1)
447-
throw new IllegalArgumentException("Length cannot be less than 0.");
447+
throw new IllegalArgumentException("Length cannot be less than 1.");
448448
if (offset >= data.length)
449449
throw new IllegalArgumentException("Offset must be less than the data length.");
450450
if (offset + length > data.length)
@@ -503,7 +503,7 @@ public int readData(byte[] data, int offset, int length) throws IOException {
503503
if (offset < 0)
504504
throw new IllegalArgumentException("Offset cannot be less than 0.");
505505
if (length < 1)
506-
throw new IllegalArgumentException("Length cannot be less than 0.");
506+
throw new IllegalArgumentException("Length cannot be less than 1.");
507507
if (offset >= data.length)
508508
throw new IllegalArgumentException("Offset must be less than the buffer length.");
509509
if (offset + length > data.length)

library/src/main/java/com/digi/xbee/api/connection/serial/SerialPortInfo.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class SerialPortInfo {
2626
*
2727
* @param portName Name of the port.
2828
*
29+
* @throws NullPointerException if {@code portName == null}.
30+
*
2931
* @see #SerialPortInfo(String, String)
3032
*/
3133
public SerialPortInfo(String portName) {
@@ -37,11 +39,16 @@ public SerialPortInfo(String portName) {
3739
* the given parameters.
3840
*
3941
* @param portName Name of the port.
40-
* @param portDescription Description of the port.
42+
* @param portDescription Description of the port. It may be {@code null}.
43+
*
44+
* @throws NullPointerException if {@code portName == null}.
4145
*
4246
* @see #SerialPortInfo(String)
4347
*/
4448
public SerialPortInfo(String portName, String portDescription) {
49+
if (portName == null)
50+
throw new NullPointerException("Serial port name cannot be null.");
51+
4552
this.portName = portName;
4653
this.portDescription = portDescription;
4754
}
@@ -60,7 +67,7 @@ public String getPortName() {
6067
/**
6168
* Returns the serial port description.
6269
*
63-
* @return The serial port description.
70+
* @return The serial port description. It may be {@code null}.
6471
*
6572
* @see #getPortName()
6673
*/

library/src/test/java/com/digi/xbee/api/XBeeDeviceReadDataTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public class XBeeDeviceReadDataTest {
5353
private XBee16BitAddress addr16;
5454
private String receivedData;
5555

56-
5756
@Before
5857
public void setUp() throws Exception {
5958
addr64 = new XBee64BitAddress("0013A20040A820DB");

0 commit comments

Comments
 (0)