Skip to content

Commit 8f5a324

Browse files
committed
refined test programs
1 parent 653b2c1 commit 8f5a324

13 files changed

Lines changed: 23 additions & 110 deletions

src/test/java/org/msgpack/TestCrossLang.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@
55
import static org.junit.Assert.assertFalse;
66
import static org.junit.Assert.assertArrayEquals;
77

8-
import java.math.BigInteger;
9-
import java.nio.ByteBuffer;
108
import java.io.IOException;
119
import java.io.ByteArrayOutputStream;
1210
import java.io.FileInputStream;
13-
import java.util.ArrayList;
14-
import java.util.HashMap;
1511
import java.util.Iterator;
16-
import java.util.List;
17-
import java.util.Map;
1812

1913
import org.msgpack.MessagePack;
2014
import org.msgpack.type.Value;
@@ -23,6 +17,7 @@
2317

2418
import org.junit.Test;
2519

20+
2621
public class TestCrossLang {
2722
private byte[] readData(String path) throws IOException {
2823
ByteArrayOutputStream bo = new ByteArrayOutputStream();

src/test/java/org/msgpack/TestSimpleArrays.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public GenericsTest() {
203203
}
204204
}
205205

206+
@SuppressWarnings({ "unchecked", "rawtypes" })
206207
@Test
207208
public void testGenerics() throws Exception {
208209
MessagePack msgpack = new MessagePack();
@@ -270,6 +271,7 @@ public Dim2Test() {
270271
}
271272
}
272273

274+
@SuppressWarnings({ "unchecked", "rawtypes" })
273275
@Test
274276
public void testDim2() throws Exception {
275277
MessagePack msgpack = new MessagePack();
@@ -334,6 +336,7 @@ public Dim3Test() {
334336
}
335337
}
336338

339+
@SuppressWarnings({ "unchecked", "rawtypes" })
337340
@Test
338341
public void testDim3() throws Exception {
339342
MessagePack msgpack = new MessagePack();

src/test/java/org/msgpack/TestSimpleConvertUnconvert.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
package org.msgpack;
22

33
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertTrue;
54
import static org.junit.Assert.assertArrayEquals;
65

7-
import java.math.BigInteger;
8-
import java.nio.ByteBuffer;
96
import java.io.IOException;
10-
import java.util.ArrayList;
11-
import java.util.HashMap;
12-
import java.util.Iterator;
13-
import java.util.List;
14-
import java.util.Map;
157

168
import org.msgpack.MessagePack;
179
import org.msgpack.type.Value;
18-
import org.msgpack.unpacker.Converter;
19-
import org.msgpack.packer.Unconverter;
2010

2111
import org.junit.Test;
2212

13+
2314
public class TestSimpleConvertUnconvert {
2415
@Test
2516
public void testSimpleConvert() throws IOException {

src/test/java/org/msgpack/TestSimplePackUnpack.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
package org.msgpack;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertTrue;
5-
6-
import java.math.BigInteger;
73
import java.nio.ByteBuffer;
84
import java.io.IOException;
9-
import java.util.ArrayList;
10-
import java.util.HashMap;
11-
import java.util.Iterator;
12-
import java.util.List;
13-
import java.util.Map;
145

156
import org.junit.Test;
167
import org.msgpack.MessagePack;
178
import org.msgpack.type.Value;
189

19-
import org.junit.Test;
2010

2111
public class TestSimplePackUnpack {
12+
@SuppressWarnings("unused")
2213
@Test
2314
public void testSimplePackUnpack() throws IOException {
2415
MessagePack msgpack = new MessagePack();

src/test/java/org/msgpack/TestSimplePackable.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
package org.msgpack;
22

33
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertTrue;
54
import static org.junit.Assert.assertArrayEquals;
65

7-
import java.math.BigInteger;
8-
import java.nio.ByteBuffer;
96
import java.io.IOException;
107
import java.util.ArrayList;
11-
import java.util.HashMap;
12-
import java.util.Iterator;
138
import java.util.List;
14-
import java.util.Map;
159

1610
import org.msgpack.MessagePack;
17-
import org.msgpack.type.Value;
1811
import org.msgpack.packer.Packer;
1912
import org.msgpack.packer.BufferPacker;
2013
import org.msgpack.unpacker.Unpacker;
2114
import org.msgpack.unpacker.BufferUnpacker;
2215

2316
import org.junit.Test;
2417

18+
2519
public class TestSimplePackable {
2620
// all files are REQUIRED
2721
public static class Sample01 implements MessagePackable {

src/test/java/org/msgpack/io/TestLinkedBufferInput.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
package org.msgpack.io;
22

33
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertTrue;
54
import static org.junit.Assert.fail;
65

7-
import java.math.BigInteger;
86
import java.nio.ByteBuffer;
97
import java.io.IOException;
10-
import java.io.EOFException;
118
import java.io.DataInputStream;
129
import java.io.ByteArrayInputStream;
1310
import java.io.DataOutputStream;
1411
import java.io.ByteArrayOutputStream;
15-
import java.util.ArrayList;
16-
import java.util.HashMap;
17-
import java.util.Iterator;
18-
import java.util.List;
19-
import java.util.Map;
20-
import java.util.Arrays;
21-
22-
import org.msgpack.MessagePack;
23-
import org.msgpack.type.Value;
2412

2513
import org.junit.Test;
2614

15+
2716
public class TestLinkedBufferInput {
2817
@Test
2918
public void testReadByte() throws IOException {

src/test/java/org/msgpack/io/TestLinkedBufferOutput.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,13 @@
33
import static org.junit.Assert.assertEquals;
44
import static org.junit.Assert.assertArrayEquals;
55

6-
import java.math.BigInteger;
7-
import java.nio.ByteBuffer;
86
import java.io.IOException;
97
import java.io.DataOutputStream;
108
import java.io.ByteArrayOutputStream;
11-
import java.util.ArrayList;
12-
import java.util.HashMap;
13-
import java.util.Iterator;
14-
import java.util.List;
15-
import java.util.Map;
16-
import java.util.Arrays;
17-
18-
import org.msgpack.MessagePack;
19-
import org.msgpack.type.Value;
209

2110
import org.junit.Test;
2211

12+
2313
public class TestLinkedBufferOutput {
2414
@Test
2515
public void testGetSize() throws IOException {

src/test/java/org/msgpack/template/TestListTemplate.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.io.ByteArrayOutputStream;
77
import java.util.List;
88

9-
import org.junit.Ignore;
109
import org.junit.Test;
1110
import org.msgpack.MessagePack;
1211
import org.msgpack.TestSet;
@@ -48,7 +47,7 @@ public void testList() throws Exception {
4847
public <E> void testList(List<E> v, Class<E> elementClass) throws Exception {
4948
MessagePack msgpack = new MessagePack();
5049
Template<E> elementTemplate = msgpack.lookup(elementClass);
51-
Template<List<E>> tmpl = new ListTemplate(elementTemplate);
50+
Template<List<E>> tmpl = new ListTemplate<E>(elementTemplate);
5251
ByteArrayOutputStream out = new ByteArrayOutputStream();
5352
Packer packer = msgpack.createPacker(out);
5453
tmpl.write(packer, v);
@@ -69,7 +68,7 @@ public void testList() throws Exception {
6968
public <E> void testList(List<E> v, Class<E> elementClass) throws Exception {
7069
MessagePack msgpack = new MessagePack();
7170
Template<E> elementTemplate = msgpack.lookup(elementClass);
72-
Template<List<E>> tmpl = new ListTemplate(elementTemplate);
71+
Template<List<E>> tmpl = new ListTemplate<E>(elementTemplate);
7372
ByteArrayOutputStream out = new ByteArrayOutputStream();
7473
Packer packer = msgpack.createPacker(out);
7574
tmpl.write(packer, v);
@@ -90,7 +89,7 @@ public void testList() throws Exception {
9089
public <E> void testList(List<E> v, Class<E> elementClass) throws Exception {
9190
MessagePack msgpack = new MessagePack();
9291
Template<E> elementTemplate = msgpack.lookup(elementClass);
93-
Template<List<E>> tmpl = new ListTemplate(elementTemplate);
92+
Template<List<E>> tmpl = new ListTemplate<E>(elementTemplate);
9493
BufferPacker packer = msgpack.createBufferPacker();
9594
tmpl.write(packer, v);
9695
byte[] bytes = packer.toByteArray();
@@ -110,7 +109,7 @@ public void testList() throws Exception {
110109
public <E> void testList(List<E> v, Class<E> elementClass) throws Exception {
111110
MessagePack msgpack = new MessagePack();
112111
Template<E> elementTemplate = msgpack.lookup(elementClass);
113-
Template<List<E>> tmpl = new ListTemplate(elementTemplate);
112+
Template<List<E>> tmpl = new ListTemplate<E>(elementTemplate);
114113
BufferPacker packer = msgpack.createBufferPacker();
115114
tmpl.write(packer, v);
116115
byte[] bytes = packer.toByteArray();

src/test/java/org/msgpack/template/TestMapTemplate.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
import java.io.ByteArrayInputStream;
66
import java.io.ByteArrayOutputStream;
7-
import java.util.List;
87
import java.util.Map;
98

10-
import org.junit.Ignore;
119
import org.junit.Test;
1210
import org.msgpack.MessagePack;
1311
import org.msgpack.TestSet;
@@ -50,7 +48,7 @@ public <K, V> void testMap(Map<K, V> v, Class<K> keyElementClass, Class<V> value
5048
MessagePack msgpack = new MessagePack();
5149
Template<K> keyElementTemplate = msgpack.lookup(keyElementClass);
5250
Template<V> valueElementTemplate = msgpack.lookup(valueElementClass);
53-
Template<Map<K, V>> tmpl = new MapTemplate(keyElementTemplate, valueElementTemplate);
51+
Template<Map<K, V>> tmpl = new MapTemplate<K, V>(keyElementTemplate, valueElementTemplate);
5452
ByteArrayOutputStream out = new ByteArrayOutputStream();
5553
Packer packer = msgpack.createPacker(out);
5654
tmpl.write(packer, v);
@@ -72,7 +70,7 @@ public <K, V> void testMap(Map<K, V> v, Class<K> keyElementClass, Class<V> value
7270
MessagePack msgpack = new MessagePack();
7371
Template<K> keyElementTemplate = msgpack.lookup(keyElementClass);
7472
Template<V> valueElementTemplate = msgpack.lookup(valueElementClass);
75-
Template<Map<K, V>> tmpl = new MapTemplate(keyElementTemplate, valueElementTemplate);
73+
Template<Map<K, V>> tmpl = new MapTemplate<K, V>(keyElementTemplate, valueElementTemplate);
7674
ByteArrayOutputStream out = new ByteArrayOutputStream();
7775
Packer packer = msgpack.createPacker(out);
7876
tmpl.write(packer, v);
@@ -94,7 +92,7 @@ public <K, V> void testMap(Map<K, V> v, Class<K> keyElementClass, Class<V> value
9492
MessagePack msgpack = new MessagePack();
9593
Template<K> keyElementTemplate = msgpack.lookup(keyElementClass);
9694
Template<V> valueElementTemplate = msgpack.lookup(valueElementClass);
97-
Template<Map<K, V>> tmpl = new MapTemplate(keyElementTemplate, valueElementTemplate);
95+
Template<Map<K, V>> tmpl = new MapTemplate<K, V>(keyElementTemplate, valueElementTemplate);
9896
BufferPacker packer = msgpack.createBufferPacker();
9997
tmpl.write(packer, v);
10098
byte[] bytes = packer.toByteArray();
@@ -115,7 +113,7 @@ public <K, V> void testMap(Map<K, V> v, Class<K> keyElementClass, Class<V> value
115113
MessagePack msgpack = new MessagePack();
116114
Template<K> keyElementTemplate = msgpack.lookup(keyElementClass);
117115
Template<V> valueElementTemplate = msgpack.lookup(valueElementClass);
118-
Template<Map<K, V>> tmpl = new MapTemplate(keyElementTemplate, valueElementTemplate);
116+
Template<Map<K, V>> tmpl = new MapTemplate<K, V>(keyElementTemplate, valueElementTemplate);
119117
BufferPacker packer = msgpack.createBufferPacker();
120118
tmpl.write(packer, v);
121119
byte[] bytes = packer.toByteArray();

src/test/java/org/msgpack/type/TestEquals.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
package org.msgpack.type;
22

3-
import static org.junit.Assert.assertArrayEquals;
4-
import static org.junit.Assert.assertEquals;
53
import static org.junit.Assert.assertTrue;
64

75
import java.math.BigInteger;
8-
import java.util.ArrayList;
9-
import java.util.HashMap;
10-
import java.util.Iterator;
11-
import java.util.List;
12-
import java.util.Map;
136

147
import org.junit.Test;
15-
import org.msgpack.MessagePack;
168
import org.msgpack.TestSet;
17-
import org.msgpack.packer.BufferPacker;
18-
import org.msgpack.unpacker.BufferUnpacker;
19-
import org.msgpack.unpacker.Converter;
209
import org.msgpack.type.Value;
2110
import org.msgpack.type.ValueFactory;
2211

@@ -197,14 +186,17 @@ public void testNull() {
197186
testEquals(v1, v2);
198187
}
199188

189+
@SuppressWarnings("unused")
200190
private boolean compatibleWithByte(long v) {
201191
return (long)Byte.MIN_VALUE <= v && v <= (long)Byte.MAX_VALUE;
202192
}
203193

194+
@SuppressWarnings("unused")
204195
private boolean compatibleWithShort(long v) {
205196
return (long)Short.MIN_VALUE <= v && v <= (long)Short.MAX_VALUE;
206197
}
207198

199+
@SuppressWarnings("unused")
208200
private boolean compatibleWithInt(long v) {
209201
return (long)Integer.MIN_VALUE <= v && v <= (long)Integer.MAX_VALUE;
210202
}

0 commit comments

Comments
 (0)