本文整理了Java中org.hamcrest.Matchers.sameInstance()
方法的一些代码示例,展示了Matchers.sameInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matchers.sameInstance()
方法的具体详情如下:
包路径:org.hamcrest.Matchers
类名称:Matchers
方法名:sameInstance
[英]Creates a matcher that matches only when the examined object is the same instance as the specified target object.
[中]创建仅当检查的对象与指定的目标对象是同一实例时才匹配的匹配器。
代码示例
代码示例来源:origin: spring-projects/spring-framework
@Test
public void byteArrayToByteBuffer() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
ByteBuffer cOnvert= this.conversionService.convert(bytes, ByteBuffer.class);
assertThat(convert.array(), not(sameInstance(bytes)));
assertThat(convert.array(), equalTo(bytes));
}
代码示例来源:origin: skylot/jadx
public void check() {
TestCls v = new TestCls();
v.a = 3;
map.put("a", v);
Iterable it = test("a");
TestCls next = it.iterator().next();
assertThat(next, sameInstance(v));
assertThat(next.a, is(4));
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void currentAttributes() {
SimpAttributesContextHolder.setAttributes(this.simpAttributes);
assertThat(SimpAttributesContextHolder.currentAttributes(), sameInstance(this.simpAttributes));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void getAttributes() {
assertThat(SimpAttributesContextHolder.getAttributes(), nullValue());
SimpAttributesContextHolder.setAttributes(this.simpAttributes);
assertThat(SimpAttributesContextHolder.getAttributes(), sameInstance(this.simpAttributes));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void byteBufferToByteArray() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
byte[] cOnvert= this.conversionService.convert(byteBuffer, byte[].class);
assertThat(convert, not(sameInstance(bytes)));
assertThat(convert, equalTo(bytes));
}
代码示例来源:origin: google/agera
@Test
public void shouldAllowForChainedCallsToSendIfFailed() {
assertThat(SUCCESS_WITH_VALUE.ifSucceededSendTo(mockReceiver),
sameInstance(SUCCESS_WITH_VALUE));
}
代码示例来源:origin: spring-projects/spring-framework
@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()));
assertThat(convert, equalTo(ByteBuffer.wrap(bytes)));
assertThat(convert.array(), equalTo(bytes));
}
代码示例来源:origin: google/agera
@Test
public void shouldReturnFailureForMapOfFailed() {
assertThat(FAILURE_WITH_THROWABLE.ifSucceededMap(mockValueFunction),
sameInstance(FAILURE_WITH_THROWABLE));
verifyZeroInteractions(mockValueFunction);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void byteBufferToOtherType() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
OtherType cOnvert= this.conversionService.convert(byteBuffer, OtherType.class);
assertThat(convert.bytes, not(sameInstance(bytes)));
assertThat(convert.bytes, equalTo(bytes));
}
代码示例来源:origin: google/agera
@Test
public void shouldReturnOtherResultForOrAttemptGetFromOfFailure() {
assertThat(FAILURE_WITH_THROWABLE.orAttemptGetFrom(mockOtherValueFailingAttemptSupplier),
sameInstance(FAILURE));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void getSessionMutex() {
assertThat(this.simpAttributes.getSessionMutex(), sameInstance(this.map));
}
代码示例来源:origin: google/agera
@Test
public void shouldAllowForChainedCallsToBind() {
assertThat(SUCCESS_WITH_VALUE.ifSucceededBind(STRING_VALUE, mockBinder),
sameInstance(SUCCESS_WITH_VALUE));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void otherTypeToByteBuffer() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
OtherType otherType = new OtherType(bytes);
ByteBuffer cOnvert= this.conversionService.convert(otherType, ByteBuffer.class);
assertThat(convert.array(), not(sameInstance(bytes)));
assertThat(convert.array(), equalTo(bytes));
}
代码示例来源:origin: google/agera
@Test
public void shouldAllowForChainedCallsToBindFrom() {
assertThat(SUCCESS_WITH_VALUE.ifSucceededBindFrom(mockSupplier, mockBinder),
sameInstance(SUCCESS_WITH_VALUE));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void getSessionMutexExplicit() {
Object mutex = new Object();
this.simpAttributes.setAttribute(SimpAttributes.SESSION_MUTEX_NAME, mutex);
assertThat(this.simpAttributes.getSessionMutex(), sameInstance(mutex));
}
代码示例来源:origin: google/agera
@Test
@SuppressWarnings("unchecked")
public void shouldReturnFailureForMergeOfFailed() {
assertThat(FAILURE_WITH_THROWABLE.ifSucceededMerge(STRING_VALUE, mockMerger),
sameInstance((Result) FAILURE_WITH_THROWABLE));
verifyZeroInteractions(mockValueFunction);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void createDateTimeFormatterWithFallback() {
DateTimeFormatter fallback = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG);
DateTimeFormatter formatter = factory.createDateTimeFormatter(fallback);
assertThat(formatter, is(sameInstance(fallback)));
}
代码示例来源:origin: google/agera
@Test
@SuppressWarnings("unchecked")
public void shouldReturnFailureForMergeFromOfFailed() {
assertThat(FAILURE_WITH_THROWABLE.ifSucceededMergeFrom(mockSupplier, mockMerger),
sameInstance((Result) FAILURE_WITH_THROWABLE));
verifyZeroInteractions(mockValueFunction);
verifyZeroInteractions(mockSupplier);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void registerDestructionCallback() {
Runnable callback = Mockito.mock(Runnable.class);
this.simpAttributes.registerDestructionCallback("name1", callback);
assertThat(this.simpAttributes.getAttribute(
SimpAttributes.DESTRUCTION_CALLBACK_NAME_PREFIX + "name1"), sameInstance(callback));
}
代码示例来源:origin: google/agera
@Test
public void shouldReturnFailureForFlatMapOfFailed() {
assertThat(FAILURE_WITH_THROWABLE.ifSucceededAttemptMap(mockSucceededValueFunction),
sameInstance(FAILURE_WITH_THROWABLE));
verifyZeroInteractions(mockSucceededValueFunction);
}