@Test public void componentTwoConstructorsNoHint() { this.context = new AnnotationConfigApplicationContext(BaseConfiguration.class, TwoConstructorsComponent.class); assertThat(this.context.getBean(TwoConstructorsComponent.class).name, is("fallback")); }
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)); } }
/** * 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 }
@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 ) ); } ); }
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))); }
@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 ) ); }
@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)); }
@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() ) ); }
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); }
@Test public void findDomainApplicationsWillNonExistentDomainReturnsEmptyCollection() { Collection<Application> domainApplications = deploymentService.findDomainApplications(""); assertThat(domainApplications, notNullValue()); assertThat(domainApplications.isEmpty(), is(true)); }
@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")); }
@Override public void execute(DelegateExecution execution) throws Exception { assertThat(execution.getVariableLocal("targetOrderId"),is(notNullValue())); } }
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 ) ); }
@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 ) ); }); }
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))); }
@Test public void componentSingleConstructor() { this.context = new AnnotationConfigApplicationContext(BaseConfiguration.class, SingleConstructorComponent.class); assertThat(this.context.getBean(SingleConstructorComponent.class).autowiredName, is("foo")); }
@Test public void shouldAddByteArrayColumnForInsert() { final byte[] value = "value".getBytes(); assertThat(sqlInsertRequest() .table(TABLE) .column(COLUMN, value) .compile().contentValues.getAsByteArray(COLUMN), is(value)); }
@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() ) ); }
@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())); }