@Test public void testDecodeNonStringWhenStringExpectedReportsUsefulError() { final DecoderImpl decoder = new DecoderImpl(); final EncoderImpl encoder = new EncoderImpl(decoder); AMQPDefinedTypes.registerAllTypes(decoder, encoder); final ByteBuffer buffer = ByteBuffer.allocate(64); final UUID encoded = UUID.randomUUID(); buffer.put(EncodingCodes.UUID); buffer.putLong(encoded.getMostSignificantBits()); buffer.putLong(encoded.getLeastSignificantBits()); buffer.flip(); byte[] copy = new byte[buffer.remaining()]; buffer.get(copy); CompositeReadableBuffer composite = new CompositeReadableBuffer(); composite.append(copy); decoder.setBuffer(composite); TypeConstructor<?> stringType = decoder.peekConstructor(); assertEquals(UUID.class, stringType.getTypeClass()); composite.mark(); try { decoder.readString(); } catch (DecodeException ex) { assertTrue(ex.getMessage().contains(EncodingCodes.toString(EncodingCodes.UUID))); } composite.reset(); UUID actual = decoder.readUUID(); assertEquals(encoded, actual); }
@Override public Class<String> getTypeClass() { return String.class; }
StringType extends AbstractPrimitiveType<String> { @Override public Class<String> getTypeClass() { return String.class; } }
StringType extends AbstractPrimitiveType<String> { @Override public Class<String> getTypeClass() { return String.class; } StringType(final EncoderImpl encoder, final DecoderImpl decoder); }
StringType extends AbstractPrimitiveType<String> { @Override public Class<String> getTypeClass() { return String.class; } StringType(final EncoderImpl encoder, final DecoderImpl decoder); @Override Class<String> getTypeClass(); @Override StringEncoding getEncoding(final String val); @Override StringEncoding getCanonicalEncoding(); @Override Collection<StringEncoding> getAllEncodings(); }
StringType extends AbstractPrimitiveType<String> { @Override public Class<String> getTypeClass() { return String.class; } StringType(final EncoderImpl encoder, final DecoderImpl decoder); @Override Class<String> getTypeClass(); @Override StringEncoding getEncoding(final String val); @Override StringEncoding getCanonicalEncoding(); @Override Collection<StringEncoding> getAllEncodings();  }