|
19 | 19 | import static org.junit.Assert.assertTrue;
|
20 | 20 |
|
21 | 21 | import com.google.common.collect.Lists;
|
| 22 | +import java.util.Arrays; |
22 | 23 |
|
23 | 24 | import org.jboss.netty.buffer.ChannelBuffer;
|
24 | 25 | import org.junit.Before;
|
@@ -266,4 +267,127 @@ public void testFloat64Array() {
|
266 | 267 | rawMessage.setFloat64Array("data", new double[] { 1, 2, 3, 4, 5 });
|
267 | 268 | checkSerializeAndDeserialize(rawMessage);
|
268 | 269 | }
|
| 270 | + |
| 271 | + @Test |
| 272 | + public void testChannelBufferFixedSizeWithInitialization() { |
| 273 | + topicDefinitionResourceProvider.add("foo/foo", "uint8[5] data"); |
| 274 | + ChannelBuffer buffer = MessageBuffers.dynamicBuffer(); |
| 275 | + buffer.writeBytes(new byte[] { 1, 2, 3, 4, 5 }); |
| 276 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 277 | + rawMessage.setChannelBuffer("data", buffer); |
| 278 | + checkSerializeAndDeserialize(rawMessage); |
| 279 | + } |
| 280 | + |
| 281 | + @Test |
| 282 | + public void testChannelBufferFixedSizeWithIncompleteInitialization() { |
| 283 | + topicDefinitionResourceProvider.add("foo/foo", "uint8[5] data"); |
| 284 | + ChannelBuffer buffer = MessageBuffers.dynamicBuffer(); |
| 285 | + buffer.writeBytes(new byte[] { 1, 2, 3 }); |
| 286 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 287 | + rawMessage.setChannelBuffer("data", buffer); |
| 288 | + checkSerializeAndDeserialize(rawMessage); |
| 289 | + } |
| 290 | + |
| 291 | + @Test |
| 292 | + public void testChannelBufferFixedSizeNoInitialization() { |
| 293 | + topicDefinitionResourceProvider.add("foo/foo", "uint8[5] data"); |
| 294 | + ChannelBuffer buffer = MessageBuffers.dynamicBuffer(); |
| 295 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 296 | + rawMessage.setChannelBuffer("data", buffer); |
| 297 | + checkSerializeAndDeserialize(rawMessage); |
| 298 | + } |
| 299 | + |
| 300 | + @Test |
| 301 | + public void testInt32FixedSizeArrayWithInitialization() { |
| 302 | + topicDefinitionResourceProvider.add("foo/foo", "int32[5] data"); |
| 303 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 304 | + rawMessage.setInt32Array("data", new int[] { 1, 2, 3, 4, 5 }); |
| 305 | + checkSerializeAndDeserialize(rawMessage); |
| 306 | + } |
| 307 | + |
| 308 | + @Test |
| 309 | + public void testInt32FixedSizeArrayWithIncompleteInitialization() { |
| 310 | + topicDefinitionResourceProvider.add("foo/foo", "int32[5] data"); |
| 311 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 312 | + rawMessage.setInt32Array("data", new int[] { 1, 2, 3 }); |
| 313 | + checkSerializeAndDeserialize(rawMessage); |
| 314 | + } |
| 315 | + |
| 316 | + @Test |
| 317 | + public void testInt32FixedSizeArrayNoInitialization() { |
| 318 | + topicDefinitionResourceProvider.add("foo/foo", "int32[5] data"); |
| 319 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 320 | + checkSerializeAndDeserialize(rawMessage); |
| 321 | + } |
| 322 | + |
| 323 | + @Test |
| 324 | + public void testFloat64FixedSizeArrayWithInitialization() { |
| 325 | + topicDefinitionResourceProvider.add("foo/foo", "float64[5] data"); |
| 326 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 327 | + rawMessage.setFloat64Array("data", new double[] { 1, 2, 3, 4, 5 }); |
| 328 | + checkSerializeAndDeserialize(rawMessage); |
| 329 | + } |
| 330 | + |
| 331 | + @Test |
| 332 | + public void testFloat64FixedSizeArrayWithIncompleteInitialization() { |
| 333 | + topicDefinitionResourceProvider.add("foo/foo", "float64[5] data"); |
| 334 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 335 | + rawMessage.setFloat64Array("data", new double[] { 1, 2, 3 }); |
| 336 | + checkSerializeAndDeserialize(rawMessage); |
| 337 | + } |
| 338 | + |
| 339 | + @Test |
| 340 | + public void testFloat64FixedSizeArrayNoInitialization() { |
| 341 | + topicDefinitionResourceProvider.add("foo/foo", "float64[5] data"); |
| 342 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 343 | + checkSerializeAndDeserialize(rawMessage); |
| 344 | + } |
| 345 | + |
| 346 | + @Test |
| 347 | + public void testStringFixedSizeArrayWithInitialization() { |
| 348 | + topicDefinitionResourceProvider.add("foo/foo", "string[5] data"); |
| 349 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 350 | + String[] stringArray = new String[] { "String 1", "String 2", "String 3", "String 4", "String 5" }; |
| 351 | + rawMessage.setStringList("data", Arrays.asList(stringArray)); |
| 352 | + checkSerializeAndDeserialize(rawMessage); |
| 353 | + } |
| 354 | + |
| 355 | + @Test |
| 356 | + public void testStringFixedSizeArrayWithIncompleteInitialization() { |
| 357 | + topicDefinitionResourceProvider.add("foo/foo", "string[5] data"); |
| 358 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 359 | + String[] stringArray = new String[] { "String 1", "String 2", "String 3" }; |
| 360 | + rawMessage.setStringList("data", Arrays.asList(stringArray)); |
| 361 | + checkSerializeAndDeserialize(rawMessage); |
| 362 | + } |
| 363 | + |
| 364 | + @Test |
| 365 | + public void testStringFixedSizeArrayWithNoInitialization() { |
| 366 | + topicDefinitionResourceProvider.add("foo/foo", "string[5] data"); |
| 367 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 368 | + checkSerializeAndDeserialize(rawMessage); |
| 369 | + } |
| 370 | + |
| 371 | + @Test |
| 372 | + public void testByteFixedSizeArrayWithInitialization() { |
| 373 | + topicDefinitionResourceProvider.add("foo/foo", "byte[5] data"); |
| 374 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 375 | + rawMessage.setInt8Array("data", new byte[] { 1, 2, 3, 4, 5 }); |
| 376 | + checkSerializeAndDeserialize(rawMessage); |
| 377 | + } |
| 378 | + |
| 379 | + @Test |
| 380 | + public void testByteFixedSizeArrayWithIncompleteInitialization() { |
| 381 | + topicDefinitionResourceProvider.add("foo/foo", "byte[5] data"); |
| 382 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 383 | + rawMessage.setInt8Array("data", new byte[] { 1, 2, 3 }); |
| 384 | + checkSerializeAndDeserialize(rawMessage); |
| 385 | + } |
| 386 | + |
| 387 | + @Test |
| 388 | + public void testByteFixedSizeArrayWithNoInitialization() { |
| 389 | + topicDefinitionResourceProvider.add("foo/foo", "byte[5] data"); |
| 390 | + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); |
| 391 | + checkSerializeAndDeserialize(rawMessage); |
| 392 | + } |
269 | 393 | }
|
0 commit comments