|
|
|
@ -49,8 +49,8 @@ public class ByteBufferConverterTests { |
|
|
|
|
public void byteArrayToByteBuffer() throws Exception { |
|
|
|
|
byte[] bytes = new byte[] { 1, 2, 3 }; |
|
|
|
|
ByteBuffer convert = this.conversionService.convert(bytes, ByteBuffer.class); |
|
|
|
|
assertThat(bytes, not(sameInstance(convert.array()))); |
|
|
|
|
assertThat(bytes, equalTo(convert.array())); |
|
|
|
|
assertThat(convert.array(), not(sameInstance(bytes))); |
|
|
|
|
assertThat(convert.array(), equalTo(bytes)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -58,8 +58,8 @@ public class ByteBufferConverterTests { |
|
|
|
|
byte[] bytes = new byte[] { 1, 2, 3 }; |
|
|
|
|
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); |
|
|
|
|
byte[] convert = this.conversionService.convert(byteBuffer, byte[].class); |
|
|
|
|
assertThat(bytes, not(sameInstance(convert))); |
|
|
|
|
assertThat(bytes, equalTo(convert)); |
|
|
|
|
assertThat(convert, not(sameInstance(bytes))); |
|
|
|
|
assertThat(convert, equalTo(bytes)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -67,8 +67,8 @@ public class ByteBufferConverterTests { |
|
|
|
|
byte[] bytes = new byte[] { 1, 2, 3 }; |
|
|
|
|
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); |
|
|
|
|
OtherType convert = this.conversionService.convert(byteBuffer, OtherType.class); |
|
|
|
|
assertThat(bytes, not(sameInstance(convert.bytes))); |
|
|
|
|
assertThat(bytes, equalTo(convert.bytes)); |
|
|
|
|
assertThat(convert.bytes, not(sameInstance(bytes))); |
|
|
|
|
assertThat(convert.bytes, equalTo(bytes)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -76,8 +76,17 @@ public class ByteBufferConverterTests { |
|
|
|
|
byte[] bytes = new byte[] { 1, 2, 3 }; |
|
|
|
|
OtherType otherType = new OtherType(bytes); |
|
|
|
|
ByteBuffer convert = this.conversionService.convert(otherType, ByteBuffer.class); |
|
|
|
|
assertThat(bytes, not(sameInstance(convert.array()))); |
|
|
|
|
assertThat(bytes, equalTo(convert.array())); |
|
|
|
|
assertThat(convert.array(), not(sameInstance(bytes))); |
|
|
|
|
assertThat(convert.array(), equalTo(bytes)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void byteBufferToByteBuffer() throws Exception { |
|
|
|
|
byte[] bytes = new byte[] { 1, 2, 3 }; |
|
|
|
|
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); |
|
|
|
|
ByteBuffer convert = this.conversionService.convert(byteBuffer, ByteBuffer.class); |
|
|
|
|
assertThat(convert, not(sameInstance(byteBuffer.rewind()))); |
|
|
|
|
assertThat(convert, equalTo(byteBuffer.rewind())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|