The BytesField support for putting raw bytes into a message does not work unless the bytes are compatible with the charset. e.g., the test below will fail. If QF/J is to support raw data fields (and encoded fields), some areas that currently work on/as Strings will need to change to work on byte[]s or ByteBuffers. In the mean time, if BytesField can't work, best to remove it.
public void testBytesFieldForReal()
throws Exception
{
byte[] data = new byte[256];
for(int i = 0; i < 256; ++i)
data[i] = (byte)i;
BytesField field = new BytesField(RawData.FIELD);
field.setValue(data);
StringBuilder sb = new StringBuilder();
field.toString(sb);
byte[] tagBytes = sb.toString().getBytes(CharsetSupport.getCharset());
assertEquals(256 + 3, tagBytes.length);
for(int i = 0; i < data.length; ++i)
assertEquals(data[i], tagBytes[i + 3]);
}
|