本文整理了Java中org.hamcrest.core.Is.is()
方法的一些代码示例,展示了Is.is()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Is.is()
方法的具体详情如下:
包路径:org.hamcrest.core.Is
类名称:Is
方法名:is
[英]A shortcut to the frequently used is(instanceOf(SomeClass.class))
.
For example:
assertThat(cheese, is(Cheddar.class))
instead of:
assertThat(cheese, is(instanceOf(Cheddar.class)))
[中]常用is(instanceOf(SomeClass.class))
的快捷方式。
例如:
assertThat(cheese, is(Cheddar.class))
而不是:
assertThat(cheese, is(instanceOf(Cheddar.class)))
代码示例来源:origin: spring-projects/spring-framework
@Test
public void componentTwoConstructorsNoHint() {
this.context = new AnnotationConfigApplicationContext(BaseConfiguration.class,
TwoConstructorsComponent.class);
assertThat(this.context.getBean(TwoConstructorsComponent.class).name, is("fallback"));
}
代码示例来源:origin: LMAX-Exchange/disruptor
private static void assertLastEvent(int[] event, long sequence, DummyEventHandler<int[]>... eh1)
{
for (DummyEventHandler<int[]> eh : eh1)
{
assertThat(eh.lastEvent, is(event));
assertThat(eh.lastSequence, is(sequence));
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test // SPR-14498
public void assertValueWithNumberConversionAndMatcher() throws Exception {
new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, is(5.0), Double.class);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Test that a call to get with a Callable concurrently properly synchronize the
* invocations.
*/
@Test
public void testCacheGetSynchronized() throws InterruptedException {
T cache = getCache();
final AtomicInteger counter = new AtomicInteger();
final List<Object> results = new CopyOnWriteArrayList<>();
final CountDownLatch latch = new CountDownLatch(10);
String key = createRandomKey();
Runnable run = () -> {
try {
Integer value = cache.get(key, () -> {
Thread.sleep(50); // make sure the thread will overlap
return counter.incrementAndGet();
});
results.add(value);
}
finally {
latch.countDown();
}
};
for (int i = 0; i < 10; i++) {
new Thread(run).start();
}
latch.await();
assertEquals(10, results.size());
results.forEach(r -> assertThat(r, is(1))); // Only one method got invoked
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testMapKeyExpressionInWhere() {
doInHibernate( this::sessionFactory, s -> {
// JPA form
Query query = s.createQuery( "select te from TestEntity te join te.values v where ?1 in (key(v)) " );
query.setParameter( 1, keyValue );
assertThat( query.list().size(), is( 1 ) );
// Hibernate additional form
query = s.createQuery( "select te from TestEntity te where ?1 in (key(te.values))" );
query.setParameter( 1, keyValue );
assertThat( query.list().size(), is( 1 ) );
// Test key property dereference
query = s.createQuery( "select te from TestEntity te join te.values v where key(v).name in :names" );
query.setParameterList( "names", Arrays.asList( keyValue.name ) );
assertThat( query.list().size(), is( 1 ) );
} );
}
代码示例来源:origin: web3j/web3j
private void confirmBalance(
String address, String contractAddress, BigInteger expected) throws Exception {
Function function = balanceOf(address);
String responseValue = callSmartContractFunction(function, contractAddress);
List<Type> response = FunctionReturnDecoder.decode(
responseValue, function.getOutputParameters());
assertThat(response.size(), is(1));
assertThat(response.get(0), equalTo(new Uint256(expected)));
}
代码示例来源:origin: neo4j/neo4j
@Test
void shouldFindAllArchives() throws Exception
{
RotatingFileOutputStreamSupplier supplier = new RotatingFileOutputStreamSupplier( fileSystem, logFile, 10, 0, 2,
DIRECT_EXECUTOR );
write( supplier, "A string longer than 10 bytes" );
write( supplier, "A string longer than 10 bytes" );
assertThat( fileSystem.fileExists( logFile ), is( true ) );
assertThat( fileSystem.fileExists( archiveLogFile1 ), is( true ) );
assertThat( fileSystem.fileExists( archiveLogFile2 ), is( false ) );
List<File> allArchives = getAllArchives( fileSystem, logFile );
assertThat( allArchives.size(), is( 1 ) );
assertThat( allArchives, hasItem( archiveLogFile1 ) );
}
代码示例来源:origin: real-logic/aeron
@Test
public void shouldSendMultipleSetupFramesOnChannelWhenTimeoutWithoutStatusMessage()
{
sender.doWork();
assertThat(receivedFrames.size(), is(1));
currentTimestamp += Configuration.PUBLICATION_SETUP_TIMEOUT_NS - 1;
sender.doWork();
currentTimestamp += 10;
sender.doWork();
assertThat(receivedFrames.size(), is(2));
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue(jiraKey = "HHH-11651")
public void testUnwrappingAbstractMultiTenantConnectionProvider() {
final MultiTenantConnectionProvider multiTenantConnectionProvider = serviceRegistry.getService(
MultiTenantConnectionProvider.class );
final AbstractMultiTenantConnectionProvider connectionProvider = multiTenantConnectionProvider.unwrap(
AbstractMultiTenantConnectionProvider.class );
assertThat( connectionProvider, is( notNullValue() ) );
}
代码示例来源:origin: camunda/camunda-bpm-platform
private HistoricProcessInstance getHistoricProcessInstanceWithAssertion(ProcessDefinition processDefinition) {
List<HistoricProcessInstance> entities = processEngineRule.getHistoryService().createHistoricProcessInstanceQuery()
.processDefinitionId(processDefinition.getId()).list();
assertThat(entities, is(notNullValue()));
assertThat(entities.size(), is(1));
return entities.get(0);
}
代码示例来源:origin: mulesoft/mule
@Test
public void findDomainApplicationsWillNonExistentDomainReturnsEmptyCollection() {
Collection<Application> domainApplications = deploymentService.findDomainApplications("");
assertThat(domainApplications, notNullValue());
assertThat(domainApplications.isEmpty(), is(true));
}
代码示例来源:origin: hamcrest/JavaHamcrest
@Test public void
supportsMixedTypes() {
final Matcher<SampleSubClass> matcher = allOf(
equalTo(new SampleBaseClass("bad")),
is(notNullValue()),
equalTo(new SampleBaseClass("good")),
equalTo(new SampleSubClass("ugly")));
assertDoesNotMatch("didn't fail last sub-matcher", matcher, new SampleSubClass("good"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public void execute(DelegateExecution execution) throws Exception {
assertThat(execution.getVariableLocal("targetOrderId"),is(notNullValue()));
}
}
代码示例来源:origin: neo4j/neo4j
private void assertLogOccurred( Level level, String message )
{
ArrayList<LoggingEvent> events = getLoggingEvents();
assertThat( events, hasSize( 1 ) );
LoggingEvent event = events.get( 0 );
assertThat( event.getLoggerName(), is( getClass().getName() ) );
assertThat( event.getLevel(), is( level ) );
assertThat( event.getMessage(), is( message ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testRestrictionsOnComponentTypes() {
doInHibernate( this::sessionFactory, session -> {
session.enableFilter( "statusFilter" ).setParameter( "status", "active" );
final Criteria query = session.createCriteria( Student.class );
query.add( Restrictions.eq( "id", STUDENT_ID ) );
query.add( Restrictions.eq( "address", new Address( "London", "Lollard St" ) ) );
query.add( Restrictions.eq( "name", "dre" ) );
final List list = query.list();
assertThat( list.size(), is( 1 ) );
});
}
代码示例来源:origin: web3j/web3j
private void confirmAllowance(String owner, String spender, String contractAddress,
BigInteger expected) throws Exception {
Function function = allowance(owner, spender);
String responseValue = callSmartContractFunction(function, contractAddress);
List<Type> response = FunctionReturnDecoder.decode(
responseValue, function.getOutputParameters());
assertThat(response.size(), is(function.getOutputParameters().size()));
assertThat(response.get(0), equalTo(new Uint256(expected)));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void componentSingleConstructor() {
this.context = new AnnotationConfigApplicationContext(BaseConfiguration.class,
SingleConstructorComponent.class);
assertThat(this.context.getBean(SingleConstructorComponent.class).autowiredName, is("foo"));
}
代码示例来源:origin: google/agera
@Test
public void shouldAddByteArrayColumnForInsert() {
final byte[] value = "value".getBytes();
assertThat(sqlInsertRequest()
.table(TABLE)
.column(COLUMN, value)
.compile().contentValues.getAsByteArray(COLUMN),
is(value));
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue( jiraKey = "HHH-11651")
public void testUnwrappingConnectionProvider() {
final MultiTenantConnectionProvider multiTenantConnectionProvider = serviceRegistry.getService(
MultiTenantConnectionProvider.class );
final ConnectionProvider connectionProvider = multiTenantConnectionProvider.unwrap( ConnectionProvider.class );
assertThat( connectionProvider, is( notNullValue() ) );
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void shouldPointToItself() {
// given
testRule.deploy(CALLED_PROCESS);
// when
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY);
// assume
assertThat(processInstance.getRootProcessInstanceId(), notNullValue());
// then
assertThat(processInstance.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId()));
}
内容来源于网络,如有侵权,请联系作者删除!