Skip to content

Commit 98b9f2e

Browse files
committed
AMQ-7166 - upgrade mqtt client library
1 parent c96f3d7 commit 98b9f2e

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTCodecTest.java

+25
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import static org.junit.Assert.assertEquals;
2020
import static org.junit.Assert.assertFalse;
2121
import static org.junit.Assert.assertTrue;
22+
import static org.junit.Assert.fail;
2223

24+
import java.net.ProtocolException;
2325
import java.util.ArrayList;
2426
import java.util.List;
2527
import java.util.concurrent.TimeUnit;
@@ -34,6 +36,7 @@
3436
import org.fusesource.mqtt.codec.MQTTFrame;
3537
import org.fusesource.mqtt.codec.PUBLISH;
3638
import org.fusesource.mqtt.codec.SUBSCRIBE;
39+
import org.fusesource.mqtt.codec.UNSUBSCRIBE;
3740
import org.junit.Before;
3841
import org.junit.Test;
3942
import org.slf4j.Logger;
@@ -254,6 +257,28 @@ public void testMessageDecoding() throws Exception {
254257
assertEquals(MESSAGE_SIZE, publish.payload().length());
255258
}
256259

260+
@Test
261+
public void testMessageDecodingCorrupted() throws Exception {
262+
UNSUBSCRIBE unsubscribe = new UNSUBSCRIBE();
263+
264+
MQTTFrame frame = unsubscribe.encode();
265+
266+
DataByteArrayOutputStream str = new DataByteArrayOutputStream(5);
267+
str.write(new byte[] {0,0,0,0,0});
268+
269+
frame.buffers[0] = str.toBuffer();
270+
271+
boolean decodingFailed = false;
272+
try {
273+
unsubscribe.decode(frame);
274+
} catch (ProtocolException pe) {
275+
decodingFailed = true;
276+
}
277+
if (!decodingFailed) {
278+
fail("Should have failed decoding the frame");
279+
}
280+
}
281+
257282
@Test
258283
public void testMessageDecodingPerformance() throws Exception {
259284

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
<mockito-version>1.10.19</mockito-version>
9898
<owasp-dependency-check-version>3.3.0</owasp-dependency-check-version>
9999
<powermock-version>1.6.5</powermock-version>
100-
<mqtt-client-version>1.14</mqtt-client-version>
100+
<mqtt-client-version>1.15</mqtt-client-version>
101101
<openjpa-version>1.2.0</openjpa-version>
102102
<org-apache-derby-version>10.14.2.0</org-apache-derby-version>
103103
<org.osgi.core-version>4.3.1</org.osgi.core-version>

0 commit comments

Comments
 (0)