本文整理了Java中org.assertj.core.api.AbstractByteArrayAssert.isEqualTo()
方法的一些代码示例,展示了AbstractByteArrayAssert.isEqualTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractByteArrayAssert.isEqualTo()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractByteArrayAssert
类名称:AbstractByteArrayAssert
方法名:isEqualTo
暂无
代码示例来源:origin: apache/geode
/**
* final File expectedStatArchiveFile = new File(TestUtil.getResourcePath(getClass(),
* "StatArchiveWriterReaderJUnitTest_" + this.testName.getMethodName() + "_expected.gfs"));
*/
public static void compareStatArchiveFiles(final File expectedStatArchiveFile,
final File actualStatArchiveFile) throws IOException {
assertThat(expectedStatArchiveFile).exists();
assertThat(actualStatArchiveFile.length()).isEqualTo(expectedStatArchiveFile.length());
assertThat(readBytes(actualStatArchiveFile)).isEqualTo(readBytes(expectedStatArchiveFile));
}
代码示例来源:origin: SonarSource/sonarqube
private static void verifySameContent(TestResponse response, File file) throws IOException {
assertThat(IOUtils.toByteArray(response.getInputStream())).isEqualTo(FileUtils.readFileToByteArray(file));
}
}
代码示例来源:origin: apache/geode
@Test
public void decodeUncompressedAddressToBytesShouldReturnActualBytes() {
long encodedAddress = 549755813697L;
Integer value = Integer.MAX_VALUE;
byte[] actual = OffHeapRegionEntryHelper.decodeUncompressedAddressToBytes(encodedAddress);
byte[] expectedValue = ByteBuffer.allocate(Integer.SIZE / Byte.SIZE).putInt(value).array();
assertThat(actual).isEqualTo(expectedValue);
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void decode() {
assertThat(Hex.decode("41424344")).isEqualTo(new byte[] { (byte) 'A', (byte) 'B', (byte) 'C',
(byte) 'D' });
}
代码示例来源:origin: apache/geode
@Test
public void testToByteArray() throws IOException {
final byte[] expected = new byte[] {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE};
final byte[] actual = IOUtils.toByteArray(new ByteArrayInputStream(expected));
assertThat(actual).isNotNull();
assertThat(actual.length).isEqualTo(expected.length);
assertThat(actual).isEqualTo(expected);
}
代码示例来源:origin: apache/geode
@Test
public void newValueIsPdxInstanceUsesItsSerializedValue() throws Exception {
PdxInstanceImpl newValue = mock(PdxInstanceImpl.class);
when(event.basicGetNewValue()).thenReturn(newValue);
byte[] bytes = new byte[] {0, 3, 4};
when(newValue.toBytes()).thenReturn(bytes);
instance.serializeNewValueIfNeeded(region, event);
ArgumentCaptor<byte[]> captor = ArgumentCaptor.forClass(byte[].class);
verify(event, times(1)).setCachedSerializedNewValue(captor.capture());
assertThat(captor.getValue()).isEqualTo(bytes);
}
}
代码示例来源:origin: apache/geode
@Test
public void newValueIsCachedDeserializableUsesItsSerializedValue() {
CachedDeserializable newValue = mock(CachedDeserializable.class);
when(event.basicGetNewValue()).thenReturn(newValue);
byte[] bytes = new byte[] {0, 3, 4};
when(newValue.getSerializedValue()).thenReturn(bytes);
instance.serializeNewValueIfNeeded(region, event);
ArgumentCaptor<byte[]> captor = ArgumentCaptor.forClass(byte[].class);
verify(event, times(1)).setCachedSerializedNewValue(captor.capture());
assertThat(captor.getValue()).isEqualTo(bytes);
}
代码示例来源:origin: apache/geode
@Test
public void encodedAddressShouldBeDecodableEvenIfValueIsUnserialized() {
Integer value = Integer.MAX_VALUE;
byte[] unSerializedValue = ByteBuffer.allocate(Integer.SIZE / Byte.SIZE).putInt(value).array();
boolean isSerialized = false;
boolean isCompressed = false;
long encodedAddress =
OffHeapRegionEntryHelper.encodeDataAsAddress(unSerializedValue, isSerialized, isCompressed);
byte[] actualValue = (byte[]) OffHeapRegionEntryHelper.decodeAddressToObject(encodedAddress);
assertThat(actualValue).isEqualTo(unSerializedValue);
}
代码示例来源:origin: apache/geode
@Test
public void oldSecurityShouldSucceedIfAuthorized() throws Exception {
when(this.securityService.isClientSecurityRequired()).thenReturn(true);
when(this.securityService.isIntegratedSecurity()).thenReturn(false);
this.put65.cmdExecute(this.message, this.serverConnection, this.securityService, 0);
ArgumentCaptor<byte[]> argument = ArgumentCaptor.forClass(byte[].class);
verify(this.replyMessage).addBytesPart(argument.capture());
assertThat(argument.getValue()).isEqualTo(OK_BYTES);
verify(this.authzRequest).putAuthorize(eq(REGION_NAME), eq(KEY), eq(VALUE), eq(true),
eq(CALLBACK_ARG));
verify(this.replyMessage).send(this.serverConnection);
}
代码示例来源:origin: apache/geode
@Test
public void decodeCompressedDataAsAddressToRawBytes() {
long encodedAddress = 549755813703L;
byte[] expected = new byte[] {127, -1, -1, -1};
byte[] bytes = OffHeapRegionEntryHelper.decodeAddressToRawBytes(encodedAddress);
assertThat(bytes).isEqualTo(expected);
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void returnsControlForCorrectOID() throws Exception {
PasswordPolicyControlFactory ctrlFactory = new PasswordPolicyControlFactory();
Control control = mock(Control.class);
when(control.getID()).thenReturn(PasswordPolicyControl.OID);
when(control.getEncodedValue()).thenReturn(
PasswordPolicyResponseControlTests.OPENLDAP_LOCKED_CTRL);
Control result = ctrlFactory.getControlInstance(control);
assertThat(result).isNotNull();
assertThat(PasswordPolicyResponseControlTests.OPENLDAP_LOCKED_CTRL).isEqualTo(result.getEncodedValue());
}
}
代码示例来源:origin: apache/geode
@Test
public void newValueIsSerializableUsesItsSerializedValue() {
String newValue = "newValue";
when(event.basicGetNewValue()).thenReturn(newValue);
instance.serializeNewValueIfNeeded(region, event);
ArgumentCaptor<byte[]> captor = ArgumentCaptor.forClass(byte[].class);
verify(event, times(1)).setCachedSerializedNewValue(captor.capture());
assertThat(captor.getValue()).isEqualTo(EntryEventImpl.serialize(newValue));
}
代码示例来源:origin: apache/geode
@Test
public void serializeToBlobWithNullReturnsBytesOfNull() throws Exception {
byte[] bytes = serializeToBlob(null);
assertThat(bytes).isNotNull().isEqualTo(this.bytesOfNull);
}
代码示例来源:origin: apache/geode
@Test
public void decodeUncompressedAddressToBytesShouldDecodeLongIfItsSerializedAndIfItsNotTooBig() {
Long value = 0L;
long encodedAddress = 123L;
byte[] actual = OffHeapRegionEntryHelper.decodeUncompressedAddressToBytes(encodedAddress);
byte[] expectedValue = EntryEventImpl.serialize(value);
assertThat(actual).isEqualTo(expectedValue);
}
代码示例来源:origin: apache/geode
@Test
public void serializeNullToStreamWritesNullAsBytes() throws Exception {
HeapDataOutputStream hdos = createHeapDataOutputStream();
serializeTo(null, hdos);
assertThat(hdos.toByteArray()).isNotNull().isEqualTo(this.bytesOfNull);
}
代码示例来源:origin: apache/geode
@Test
public void serializeMapToStreamWritesMapAsBytes() throws Exception {
HeapDataOutputStream hdos = createHeapDataOutputStream();
serializeTo(this.mapWithTwoEntries, hdos);
assertThat(hdos.toByteArray()).isNotNull().isEqualTo(bytesOfMap);
}
代码示例来源:origin: line/armeria
@Test
public void writeUncompressed() throws Exception {
final ByteBuf buf = GrpcTestUtil.requestByteBuf();
final ByteBufHttpData framed = framer.writePayload(buf);
assertThat(framed.array()).isEqualTo(GrpcTestUtil.uncompressedFrame(GrpcTestUtil.requestByteBuf()));
assertThat(buf.refCnt()).isEqualTo(0);
framed.release();
}
代码示例来源:origin: line/armeria
@Test
public void emptyNotCompressed() throws Exception {
framer.setCompressor(new Gzip());
framer.setMessageCompression(true);
final ByteBuf buf = GrpcTestUtil.protoByteBuf(SimpleRequest.getDefaultInstance());
assertThat(buf.readableBytes()).isEqualTo(0);
final ByteBufHttpData framed = framer.writePayload(buf);
assertThat(framed.array()).isEqualTo(GrpcTestUtil.uncompressedFrame(
GrpcTestUtil.protoByteBuf(SimpleRequest.getDefaultInstance())));
assertThat(buf.refCnt()).isEqualTo(0);
framed.release();
}
代码示例来源:origin: line/armeria
@Test
public void compressed() throws Exception {
framer.setCompressor(new Gzip());
framer.setMessageCompression(true);
final ByteBuf buf = GrpcTestUtil.requestByteBuf();
final ByteBufHttpData framed = framer.writePayload(buf);
assertThat(framed.array()).isEqualTo(GrpcTestUtil.compressedFrame(GrpcTestUtil.requestByteBuf()));
assertThat(buf.refCnt()).isEqualTo(0);
framed.release();
}
代码示例来源:origin: apache/geode
@Test
public void getSerializedValueShouldSerializeTheValue() {
Object regionEntryValue = getValue();
byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
boolean isSerialized = false;
boolean isCompressed = false;
OffHeapStoredObject chunk = (OffHeapStoredObject) ma
.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
byte[] serializedValue = chunk.getSerializedValue();
assertThat(serializedValue).isEqualTo(EntryEventImpl.serialize(regionEntryValueAsBytes));
chunk.release();
}
内容来源于网络,如有侵权,请联系作者删除!