@Test public void testFloat() throws Exception { float f = RandomUtil.randomFloat(); wrapper.writeFloat(f); Assert.assertEquals(f, wrapper.readFloat(), 0.000001); }
@Test public void testReadData() throws Exception { ActiveMQBuffer dynamic = ActiveMQBuffers.dynamicBuffer(1); String str1 = RandomUtil.randomString(); String str2 = RandomUtil.randomString(); double d1 = RandomUtil.randomDouble(); float f1 = RandomUtil.randomFloat(); dynamic.writeUTF(str1); dynamic.writeString(str2); dynamic.writeDouble(d1); dynamic.writeFloat(f1); LargeMessageControllerImpl readBuffer = splitBuffer(3, dynamic.toByteBuffer().array()); Assert.assertEquals(str1, readBuffer.readUTF()); Assert.assertEquals(str2, readBuffer.readString()); Assert.assertEquals(d1, readBuffer.readDouble(), 0.000001); Assert.assertEquals(f1, readBuffer.readFloat(), 0.000001); }
break; case VertxConstants.TYPE_FLOAT: bodyBuffer.writeFloat((Float) body); break; case VertxConstants.TYPE_INT:
@Test public void testReadDataOverCached() throws Exception { clearDataRecreateServerDirs(); ActiveMQBuffer dynamic = ActiveMQBuffers.dynamicBuffer(1); String str1 = RandomUtil.randomString(); String str2 = RandomUtil.randomString(); double d1 = RandomUtil.randomDouble(); float f1 = RandomUtil.randomFloat(); dynamic.writeUTF(str1); dynamic.writeString(str2); dynamic.writeDouble(d1); dynamic.writeFloat(f1); LargeMessageControllerImpl readBuffer = splitBuffer(3, dynamic.toByteBuffer().array(), getTestFile()); Assert.assertEquals(str1, readBuffer.readUTF()); Assert.assertEquals(str2, readBuffer.readString()); Assert.assertEquals(d1, readBuffer.readDouble(), 0.00000001); Assert.assertEquals(f1, readBuffer.readFloat(), 0.000001); readBuffer.readerIndex(0); Assert.assertEquals(str1, readBuffer.readUTF()); Assert.assertEquals(str2, readBuffer.readString()); Assert.assertEquals(d1, readBuffer.readDouble(), 0.00000001); Assert.assertEquals(f1, readBuffer.readFloat(), 0.000001); readBuffer.close(); }