List of usage examples for java.time Duration ofMinutes
public static Duration ofMinutes(long minutes)
From source file:org.apache.james.mailrepository.memory.MemoryMailRepositoryStoreTest.java
@Test public void selectShouldNotReturnDifferentResultsWhenUsedInAConcurrentEnvironment() throws Exception { MailRepositoryUrl url = MailRepositoryUrl.from("memory1://repo"); int threadCount = 10; ConcurrentTestRunner.builder()// w w w . java 2 s .c om .operation((threadNb, operationNb) -> repositoryStore.select(url) .store(FakeMail.builder().name("name" + threadNb) .mimeMessage(MimeMessageBuilder.mimeMessageBuilder().setText("Any body")).build())) .threadCount(10).runSuccessfullyWithin(Duration.ofMinutes(1)); long actualSize = repositoryStore.get(url).get().size(); assertThat(actualSize).isEqualTo(threadCount); }
From source file:org.apache.james.queue.rabbitmq.view.cassandra.configuration.CassandraMailQueueViewConfigurationTest.java
@Test void validateConfigurationChangeShouldAcceptDividingSliceWindow() { CassandraMailQueueViewConfiguration configuration = CassandraMailQueueViewConfiguration.builder() .bucketCount(2).updateBrowseStartPace(1000).sliceWindow(Duration.ofHours(1)).build(); assertThatCode(() -> configuration.validateConfigurationChange(CassandraMailQueueViewConfiguration.builder() .bucketCount(2).updateBrowseStartPace(1000).sliceWindow(Duration.ofMinutes(20)).build())) .doesNotThrowAnyException(); }
From source file:org.apache.james.queue.rabbitmq.view.cassandra.configuration.CassandraMailQueueViewConfigurationTest.java
@Test void validateConfigurationChangeShouldRejectArbitraryDecreaseSliceWindow() { CassandraMailQueueViewConfiguration configuration = CassandraMailQueueViewConfiguration.builder() .bucketCount(2).updateBrowseStartPace(1000).sliceWindow(Duration.ofHours(1)).build(); assertThatThrownBy(() -> configuration.validateConfigurationChange(CassandraMailQueueViewConfiguration .builder().bucketCount(2).updateBrowseStartPace(1000).sliceWindow(Duration.ofMinutes(25)).build())) .isInstanceOf(IllegalArgumentException.class); }
From source file:org.apache.samza.table.caching.TestCachingTable.java
private void doTestSerialize(TableDescriptor cache) { CachingTableDescriptor desc;//from w w w. j a va 2s . co m TableDescriptor table = createDummyTableDescriptor("2"); if (cache == null) { desc = new CachingTableDescriptor("1", table).withReadTtl(Duration.ofMinutes(3)) .withWriteTtl(Duration.ofMinutes(4)).withCacheSize(1000); } else { desc = new CachingTableDescriptor("1", table, cache); } desc.withWriteAround(); Map<String, String> tableConfig = desc.toConfig(new MapConfig()); assertEquals("2", CachingTableDescriptor.REAL_TABLE_ID, "1", tableConfig); if (cache == null) { assertEquals("180000", CachingTableDescriptor.READ_TTL_MS, "1", tableConfig); assertEquals("240000", CachingTableDescriptor.WRITE_TTL_MS, "1", tableConfig); } else { assertEquals(cache.getTableId(), CachingTableDescriptor.CACHE_TABLE_ID, "1", tableConfig); } assertEquals("true", CachingTableDescriptor.WRITE_AROUND, "1", tableConfig); }
From source file:org.cloudfoundry.client.v2.ApplicationsTest.java
@Test public void associateRoute() throws TimeoutException, InterruptedException { String applicationName = this.nameFactory.getApplicationName(); String domainName = this.nameFactory.getDomainName(); Mono.when(this.organizationId, this.spaceId) .then(function((organizationId, spaceId) -> Mono.when( createApplicationId(this.cloudFoundryClient, spaceId, applicationName), createRouteWithDomain(this.cloudFoundryClient, organizationId, spaceId, domainName, "test-host", "/test/path").map(ResourceUtils::getId)))) .as(thenKeep(function((applicationId, routeId) -> requestAssociateRoute(this.cloudFoundryClient, applicationId, routeId)))) .then(function((applicationId, routeId) -> Mono .when(getSingleRouteId(this.cloudFoundryClient, applicationId), Mono.just(routeId)))) .as(StepVerifier::create).consumeNextWith(tupleEquality()).expectComplete() .verify(Duration.ofMinutes(5)); }
From source file:org.cloudfoundry.client.v2.ApplicationsTest.java
@Test public void copy() throws TimeoutException, InterruptedException { String applicationName = this.nameFactory.getApplicationName(); String copyApplicationName = this.nameFactory.getApplicationName(); this.spaceId//from w ww .java 2 s .co m .then(spaceId -> Mono.when( createApplicationId(this.cloudFoundryClient, spaceId, applicationName).as(thenKeep( applicationId -> uploadApplication(this.cloudFoundryClient, applicationId))), requestCreateApplication(this.cloudFoundryClient, spaceId, copyApplicationName) .map(ResourceUtils::getId))) .as(thenKeep(function((sourceId, targetId) -> this.cloudFoundryClient.applicationsV2() .copy(CopyApplicationRequest.builder().applicationId(targetId).sourceApplicationId(sourceId) .build()) .then(job -> JobUtils.waitForCompletion(this.cloudFoundryClient, job))))) .then(function( (sourceId, targetId) -> Mono.when(downloadApplication(this.cloudFoundryClient, sourceId), downloadApplication(this.cloudFoundryClient, targetId)))) .as(StepVerifier::create).consumeNextWith(tupleEquality()).expectComplete() .verify(Duration.ofMinutes(5)); }
From source file:org.cloudfoundry.client.v2.ApplicationsTest.java
@Test public void create() throws TimeoutException, InterruptedException { String applicationName = this.nameFactory.getApplicationName(); this.spaceId/* w ww .ja va2s .c o m*/ .then(spaceId -> Mono.when(Mono.just(spaceId), requestCreateApplication(this.cloudFoundryClient, spaceId, applicationName) .map(ResourceUtils::getEntity))) .as(StepVerifier::create).consumeNextWith(consumer((spaceId, entity) -> { assertThat(entity.getSpaceId()).isEqualTo(spaceId); assertThat(entity.getName()).isEqualTo(applicationName); })).expectComplete().verify(Duration.ofMinutes(5)); }
From source file:org.cloudfoundry.client.v2.ApplicationsTest.java
@Test public void delete() throws TimeoutException, InterruptedException { String applicationName = this.nameFactory.getApplicationName(); this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName)) .as(thenKeep(applicationId -> this.cloudFoundryClient.applicationsV2() .delete(DeleteApplicationRequest.builder().applicationId(applicationId).build()))) .then(applicationId -> requestGetApplication(this.cloudFoundryClient, applicationId)) .as(StepVerifier::create)//w w w.j a v a 2 s .c o m .consumeErrorWith(t -> assertThat(t).isInstanceOf(ClientV2Exception.class) .hasMessageMatching("CF-AppNotFound\\([0-9]+\\): The app could not be found: .*")) .verify(Duration.ofMinutes(5)); }
From source file:org.cloudfoundry.client.v2.ApplicationsTest.java
@Test public void downloadDroplet() throws TimeoutException, InterruptedException { String applicationName = this.nameFactory.getApplicationName(); this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName)) .as(thenKeep(applicationId -> uploadAndStartApplication(this.cloudFoundryClient, applicationId))) .flatMap(// ww w.ja v a 2 s. c o m applicationId -> this.cloudFoundryClient.applicationsV2() .downloadDroplet(DownloadApplicationDropletRequest.builder() .applicationId(applicationId).build()) .as(OperationUtils::collectByteArray)) .as(StepVerifier::create).consumeNextWith(isTestApplicationDroplet()).expectComplete() .verify(Duration.ofMinutes(5)); }
From source file:org.cloudfoundry.client.v2.ApplicationsTest.java
@Test public void environment() throws TimeoutException, InterruptedException { String applicationName = this.nameFactory.getApplicationName(); this.spaceId.then(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName)) .then(applicationId -> Mono.when(Mono.just(applicationId), this.cloudFoundryClient.applicationsV2() .environment(ApplicationEnvironmentRequest.builder().applicationId(applicationId).build()) .map(response -> getStringApplicationEnvValue(response.getApplicationEnvironmentJsons(), "VCAP_APPLICATION", "application_id")))) .as(StepVerifier::create).consumeNextWith(tupleEquality()).expectComplete() .verify(Duration.ofMinutes(5)); }