junit.framework.TestCase.assertSame()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中junit.framework.TestCase.assertSame()方法的一些代码示例,展示了TestCase.assertSame()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestCase.assertSame()方法的具体详情如下:
包路径:junit.framework.TestCase
类名称:TestCase
方法名:assertSame

TestCase.assertSame介绍

[英]Asserts that two objects refer to the same object. If they are not the same an AssertionFailedError is thrown.
[中]断言两个对象引用同一个对象。如果它们不相同,则抛出断言失败错误。

代码示例

代码示例来源:origin: google/guava

@Override
 public void run() {
  try {
   assertSame(Boolean.TRUE, future.get());
   successLatch.countDown();
  } catch (Throwable t) {
   t.printStackTrace();
   badness[0] = t;
  }
 }
})

代码示例来源:origin: google/guava

@Override
 public void run() {
  assertSame(Boolean.TRUE, memoizedSupplier.get());
 }
};

代码示例来源:origin: jankotek/mapdb

public void realRun() throws InterruptedException {
      threadsStarted.await();
      assertSame(one, q.take());
    }});
}

代码示例来源:origin: spring-projects/spring-framework

@Test // SPR-17410
public void onNextWithoutDemand() {
  // Disable writing: next item will be cached..
  this.processor.setWritePossible(false);
  DataBuffer buffer1 = mock(DataBuffer.class);
  this.processor.onNext(buffer1);
  // Send more data illegally
  DataBuffer buffer2 = mock(DataBuffer.class);
  this.processor.onNext(buffer2);
  assertNotNull("Error should flow to result publisher", this.resultSubscriber.getError());
  assertEquals(2, this.processor.getDiscardedBuffers().size());
  assertSame(buffer2, this.processor.getDiscardedBuffers().get(0));
  assertSame(buffer1, this.processor.getDiscardedBuffers().get(1));
}

代码示例来源:origin: spring-projects/spring-framework

@Test // SPR-17410
public void writePublisherError() {
  // Turn off writing so next item will be cached
  this.processor.setWritePossible(false);
  DataBuffer buffer = mock(DataBuffer.class);
  this.processor.onNext(buffer);
  // Send error while item cached
  this.processor.onError(new IllegalStateException());
  assertNotNull("Error should flow to result publisher", this.resultSubscriber.getError());
  assertEquals(1, this.processor.getDiscardedBuffers().size());
  assertSame(buffer, this.processor.getDiscardedBuffers().get(0));
}

代码示例来源:origin: spring-projects/spring-framework

@Test // SPR-17410
public void ioExceptionDuringWrite() {
  // Fail on next write
  this.processor.setWritePossible(true);
  this.processor.setFailOnWrite(true);
  // Write
  DataBuffer buffer = mock(DataBuffer.class);
  this.processor.onNext(buffer);
  assertNotNull("Error should flow to result publisher", this.resultSubscriber.getError());
  assertEquals(1, this.processor.getDiscardedBuffers().size());
  assertSame(buffer, this.processor.getDiscardedBuffers().get(0));
}

代码示例来源:origin: apache/flink

@Test
public void javaDeserializeFromFlink_1_5_ReflectiveRecord() throws IOException {
  final String avroSerializerBase64 = "AAAAAQAAAQis7QAFc3IANm9yZy5hcGFjaGUuZmxpbmsuZm9ybWF0cy5hdnJvLnR5cGV1dGlscy5BdnJv\n" +
    "U2VyaWFsaXplcgAAAAAAAAABAgABTAAEdHlwZXQAEUxqYXZhL2xhbmcvQ2xhc3M7eHIANG9yZy5hcGFj\n" +
    "aGUuZmxpbmsuYXBpLmNvbW1vbi50eXBldXRpbHMuVHlwZVNlcmlhbGl6ZXIAAAAAAAAAAQIAAHhwdnIA\n" +
    "Tm9yZy5hcGFjaGUuZmxpbmsuZm9ybWF0cy5hdnJvLnR5cGV1dGlscy5BdnJvU2VyaWFsaXplck1pZ3Jh\n" +
    "dGlvblRlc3QkU2ltcGxlUG9qbwAAAAAAAAAAAAAAeHA=";
  TypeSerializer<?> serializer = javaDeserialize(avroSerializerBase64);
  assertThat(serializer, instanceOf(AvroSerializer.class));
  AvroSerializer<?> avroSerializer = (AvroSerializer<?>) javaDeserialize(avroSerializerBase64);
  assertSame(avroSerializer.getType(), SimplePojo.class);
  assertThat(avroSerializer.getAvroSchema(), notNullValue());
}

代码示例来源:origin: apache/flink

@Test
public void javaDeserializeFromFlink_1_5_SpecificRecord() throws IOException {
  final String avroSerializerBase64 = "AAAAAQAAASOs7QAFc3IANm9yZy5hcGFjaGUuZmxpbmsuZm9ybWF0cy5hdnJvLnR5cGV1dGlscy5BdnJv\n" +
    "U2VyaWFsaXplcgAAAAAAAAABAgABTAAEdHlwZXQAEUxqYXZhL2xhbmcvQ2xhc3M7eHIANG9yZy5hcGFj\n" +
    "aGUuZmxpbmsuYXBpLmNvbW1vbi50eXBldXRpbHMuVHlwZVNlcmlhbGl6ZXIAAAAAAAAAAQIAAHhwdnIA\n" +
    "L29yZy5hcGFjaGUuZmxpbmsuZm9ybWF0cy5hdnJvLmdlbmVyYXRlZC5BZGRyZXNz7Paj+KjgQ2oMAAB4\n" +
    "cgArb3JnLmFwYWNoZS5hdnJvLnNwZWNpZmljLlNwZWNpZmljUmVjb3JkQmFzZQKi+azGtzQdDAAAeHA=";
  TypeSerializer<?> serializer = javaDeserialize(avroSerializerBase64);
  assertThat(serializer, instanceOf(AvroSerializer.class));
  AvroSerializer<?> avroSerializer = (AvroSerializer<?>) javaDeserialize(avroSerializerBase64);
  assertSame(avroSerializer.getType(), Address.class);
  assertThat(avroSerializer.getAvroSchema(), is(Address.SCHEMA$));
}

代码示例来源:origin: jankotek/mapdb

public void realRun() throws InterruptedException {
      threadsStarted.await();
      assertSame(one, q.take());
    }});
}

代码示例来源:origin: jankotek/mapdb

public void realRun() throws InterruptedException {
  assertNull(q.poll());
  threadsStarted.await();
  assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
  checkEmpty(q);
}});

代码示例来源:origin: apache/flink

@Test
public void javaDeserializeFromFlink_1_7_afterInitialization() throws IOException {
  String avroSerializerBase64 = "AAAAAQAAAeKs7QAFc3IANm9yZy5hcGFjaGUuZmxpbmsuZm9ybWF0cy5hdnJvLnR5cGV1dGlscy5BdnJv\n" +
    "U2VyaWFsaXplcgAAAAAAAAACAgADTAAOcHJldmlvdXNTY2hlbWF0AEBMb3JnL2FwYWNoZS9mbGluay9m\n" +
    "b3JtYXRzL2F2cm8vdHlwZXV0aWxzL1NlcmlhbGl6YWJsZUF2cm9TY2hlbWE7TAAGc2NoZW1hcQB+AAFM\n" +
    "AAR0eXBldAARTGphdmEvbGFuZy9DbGFzczt4cgA0b3JnLmFwYWNoZS5mbGluay5hcGkuY29tbW9uLnR5\n" +
    "cGV1dGlscy5UeXBlU2VyaWFsaXplcgAAAAAAAAABAgAAeHBzcgA+b3JnLmFwYWNoZS5mbGluay5mb3Jt\n" +
    "YXRzLmF2cm8udHlwZXV0aWxzLlNlcmlhbGl6YWJsZUF2cm9TY2hlbWEAAAAAAAAAAQMAAHhwdwEAeHNx\n" +
    "AH4ABXcBAHh2cgAvb3JnLmFwYWNoZS5mbGluay5mb3JtYXRzLmF2cm8uZ2VuZXJhdGVkLkFkZHJlc3Ps\n" +
    "9qP4qOBDagwAAHhyACtvcmcuYXBhY2hlLmF2cm8uc3BlY2lmaWMuU3BlY2lmaWNSZWNvcmRCYXNlAqL5\n" +
    "rMa3NB0MAAB4cA==";
  AvroSerializer<?> avroSerializer = (AvroSerializer<?>) javaDeserialize(avroSerializerBase64);
  assertSame(avroSerializer.getType(), Address.class);
  assertThat(avroSerializer.getAvroSchema(), is(Address.SCHEMA$));
}

代码示例来源:origin: apache/flink

@Test
public void javaDeserializeFromFlink_1_7() throws IOException {
  String avroSerializerBase64 = "AAAAAQAAAeKs7QAFc3IANm9yZy5hcGFjaGUuZmxpbmsuZm9ybWF0cy5hdnJvLnR5cGV1dGlscy5BdnJv\n" +
    "U2VyaWFsaXplcgAAAAAAAAACAgADTAAOcHJldmlvdXNTY2hlbWF0AEBMb3JnL2FwYWNoZS9mbGluay9m\n" +
    "b3JtYXRzL2F2cm8vdHlwZXV0aWxzL1NlcmlhbGl6YWJsZUF2cm9TY2hlbWE7TAAGc2NoZW1hcQB+AAFM\n" +
    "AAR0eXBldAARTGphdmEvbGFuZy9DbGFzczt4cgA0b3JnLmFwYWNoZS5mbGluay5hcGkuY29tbW9uLnR5\n" +
    "cGV1dGlscy5UeXBlU2VyaWFsaXplcgAAAAAAAAABAgAAeHBzcgA+b3JnLmFwYWNoZS5mbGluay5mb3Jt\n" +
    "YXRzLmF2cm8udHlwZXV0aWxzLlNlcmlhbGl6YWJsZUF2cm9TY2hlbWEAAAAAAAAAAQMAAHhwdwEAeHNx\n" +
    "AH4ABXcBAHh2cgAvb3JnLmFwYWNoZS5mbGluay5mb3JtYXRzLmF2cm8uZ2VuZXJhdGVkLkFkZHJlc3Ps\n" +
    "9qP4qOBDagwAAHhyACtvcmcuYXBhY2hlLmF2cm8uc3BlY2lmaWMuU3BlY2lmaWNSZWNvcmRCYXNlAqL5\n" +
    "rMa3NB0MAAB4cA==";
  AvroSerializer<?> avroSerializer = (AvroSerializer<?>) javaDeserialize(avroSerializerBase64);
  assertSame(avroSerializer.getType(), Address.class);
  assertThat(avroSerializer.getAvroSchema(), is(Address.SCHEMA$));
}

代码示例来源:origin: apache/flink

@Test
public void javaDeserializeFromFlink_1_6_GenericRecord() throws IOException {
  String avroSerializerBase64 = "AAAAAQAAAges7QAFc3IANm9yZy5hcGFjaGUuZmxpbmsuZm9ybWF0cy5hdnJvLnR5cGV1dGlscy5BdnJv\n" +
    "U2VyaWFsaXplcgAAAAAAAAABAgACTAAMc2NoZW1hU3RyaW5ndAASTGphdmEvbGFuZy9TdHJpbmc7TAAE\n" +
    "dHlwZXQAEUxqYXZhL2xhbmcvQ2xhc3M7eHIANG9yZy5hcGFjaGUuZmxpbmsuYXBpLmNvbW1vbi50eXBl\n" +
    "dXRpbHMuVHlwZVNlcmlhbGl6ZXIAAAAAAAAAAQIAAHhwdAEBeyJ0eXBlIjoicmVjb3JkIiwibmFtZSI6\n" +
    "IkFkZHJlc3MiLCJuYW1lc3BhY2UiOiJvcmcuYXBhY2hlLmZsaW5rLmZvcm1hdHMuYXZyby5nZW5lcmF0\n" +
    "ZWQiLCJmaWVsZHMiOlt7Im5hbWUiOiJudW0iLCJ0eXBlIjoiaW50In0seyJuYW1lIjoic3RyZWV0Iiwi\n" +
    "dHlwZSI6InN0cmluZyJ9LHsibmFtZSI6ImNpdHkiLCJ0eXBlIjoic3RyaW5nIn0seyJuYW1lIjoic3Rh\n" +
    "dGUiLCJ0eXBlIjoic3RyaW5nIn0seyJuYW1lIjoiemlwIiwidHlwZSI6InN0cmluZyJ9XX12cgAlb3Jn\n" +
    "LmFwYWNoZS5hdnJvLmdlbmVyaWMuR2VuZXJpY1JlY29yZAAAAAAAAAAAAAAAeHA=";
  TypeSerializer<?> serializer = javaDeserialize(avroSerializerBase64);
  AvroSerializer<?> avroSerializer = (AvroSerializer<?>) serializer;
  assertSame(avroSerializer.getType(), GenericRecord.class);
  assertThat(avroSerializer.getAvroSchema(), notNullValue());
}

代码示例来源:origin: spring-projects/spring-framework

@Test // SPR-17051
public void sessionInvalidatedBeforeSave() {
  // Request 1 creates session
  WebSession session1 = this.store.createWebSession().block();
  assertNotNull(session1);
  String id = session1.getId();
  session1.start();
  session1.save().block();
  // Request 2 retrieves session
  WebSession session2 = this.store.retrieveSession(id).block();
  assertNotNull(session2);
  assertSame(session1, session2);
  // Request 3 retrieves and invalidates
  WebSession session3 = this.store.retrieveSession(id).block();
  assertNotNull(session3);
  assertSame(session1, session3);
  session3.invalidate().block();
  // Request 2 saves session after invalidated
  session2.save().block();
  // Session should not be present
  WebSession session4 = this.store.retrieveSession(id).block();
  assertNull(session4);
}

代码示例来源:origin: apache/flink

@Test
public void compositeSerializerFromFlink_1_6_WithNestedAvroSerializer() throws IOException {
  String streamElementSerializerBase64 = "AAAAAQAAAq2s7QAFc3IAR29yZy5hcGFjaGUuZmxpbmsuc3RyZWFtaW5nLnJ1bnRpbWUuc3RyZWFtcmVj\n" +
    "b3JkLlN0cmVhbUVsZW1lbnRTZXJpYWxpemVyAAAAAAAAAAECAAFMAA50eXBlU2VyaWFsaXplcnQANkxv\n" +
    "cmcvYXBhY2hlL2ZsaW5rL2FwaS9jb21tb24vdHlwZXV0aWxzL1R5cGVTZXJpYWxpemVyO3hyADRvcmcu\n" +
    "YXBhY2hlLmZsaW5rLmFwaS5jb21tb24udHlwZXV0aWxzLlR5cGVTZXJpYWxpemVyAAAAAAAAAAECAAB4\n" +
    "cHNyADZvcmcuYXBhY2hlLmZsaW5rLmZvcm1hdHMuYXZyby50eXBldXRpbHMuQXZyb1NlcmlhbGl6ZXIA\n" +
    "AAAAAAAAAQIAAkwADHNjaGVtYVN0cmluZ3QAEkxqYXZhL2xhbmcvU3RyaW5nO0wABHR5cGV0ABFMamF2\n" +
    "YS9sYW5nL0NsYXNzO3hxAH4AAnQBAXsidHlwZSI6InJlY29yZCIsIm5hbWUiOiJBZGRyZXNzIiwibmFt\n" +
    "ZXNwYWNlIjoib3JnLmFwYWNoZS5mbGluay5mb3JtYXRzLmF2cm8uZ2VuZXJhdGVkIiwiZmllbGRzIjpb\n" +
    "eyJuYW1lIjoibnVtIiwidHlwZSI6ImludCJ9LHsibmFtZSI6InN0cmVldCIsInR5cGUiOiJzdHJpbmci\n" +
    "fSx7Im5hbWUiOiJjaXR5IiwidHlwZSI6InN0cmluZyJ9LHsibmFtZSI6InN0YXRlIiwidHlwZSI6InN0\n" +
    "cmluZyJ9LHsibmFtZSI6InppcCIsInR5cGUiOiJzdHJpbmcifV19dnIAJW9yZy5hcGFjaGUuYXZyby5n\n" +
    "ZW5lcmljLkdlbmVyaWNSZWNvcmQAAAAAAAAAAAAAAHhw";
  StreamElementSerializer<?> ser = (StreamElementSerializer<?>) javaDeserialize(streamElementSerializerBase64);
  TypeSerializer<?> containedTypeSerializer = ser.getContainedTypeSerializer();
  assertThat(containedTypeSerializer, instanceOf(AvroSerializer.class));
  AvroSerializer<?> avroSerializer = (AvroSerializer<?>) containedTypeSerializer;
  assertSame(avroSerializer.getType(), GenericRecord.class);
  assertThat(avroSerializer.getAvroSchema(), is(Address.SCHEMA$));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void retrieveExpiredSession() {
  WebSession session = this.store.createWebSession().block();
  assertNotNull(session);
  session.getAttributes().put("foo", "bar");
  session.save().block();
  String id = session.getId();
  WebSession retrieved = this.store.retrieveSession(id).block();
  assertNotNull(retrieved);
  assertSame(session, retrieved);
  // Fast-forward 31 minutes
  this.store.setClock(Clock.offset(this.store.getClock(), Duration.ofMinutes(31)));
  WebSession retrievedAgain = this.store.retrieveSession(id).block();
  assertNull(retrievedAgain);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void lastAccessTimeIsUpdatedOnRetrieve() {
  WebSession session1 = this.store.createWebSession().block();
  assertNotNull(session1);
  String id = session1.getId();
  Instant time1 = session1.getLastAccessTime();
  session1.start();
  session1.save().block();
  // Fast-forward a few seconds
  this.store.setClock(Clock.offset(this.store.getClock(), Duration.ofSeconds(5)));
  WebSession session2 = this.store.retrieveSession(id).block();
  assertNotNull(session2);
  assertSame(session1, session2);
  Instant time2 = session2.getLastAccessTime();
  assertTrue(time1.isBefore(time2));
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldReturnSelfForGetLocalWhenOriginIsNull()
{
  PipelineConfigs pipelineConfigs = createEmpty();
  assertThat(pipelineConfigs.getLocal().size(), is(0));
  assertSame(pipelineConfigs,pipelineConfigs.getLocal());
}
@Test

代码示例来源:origin: jankotek/mapdb

public void realRun() throws InterruptedException {
  assertNull(q.poll());
  threadsStarted.await();
  assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
  checkEmpty(q);
}});

代码示例来源:origin: gocd/gocd

@Test
public void shouldReturnSelfForGetLocalPartsWhenOriginIsFile()
{
  PipelineConfigs pipelineConfigs = createEmpty();
  pipelineConfigs.setOrigins(new FileConfigOrigin());
  assertThat(pipelineConfigs.getLocal().size(), is(0));
  assertSame(pipelineConfigs, pipelineConfigs.getLocal());
}
@Test

相关文章