List of usage examples for java.time Duration ofMillis
public static Duration ofMillis(long millis)
From source file:org.onosproject.newoptical.OpticalPathProvisionerTest.java
/** * Checks setupPath method works./*from w ww. ja va 2 s . co m*/ */ @Test public void testSetupPath() { Bandwidth bandwidth = Bandwidth.bps(100); Duration latency = Duration.ofMillis(10); List<Link> links = Stream.of(LINK1, LINK2, LINK3, LINK4, LINK5, LINK6).collect(Collectors.toList()); Path path = new DefaultPath(PROVIDER_ID, links, 0); OpticalConnectivityId cid = target.setupPath(path, bandwidth, latency); assertNotNull(cid); // Checks intents are installed as expected assertEquals(1, intentService.submitted.size()); assertEquals(OpticalConnectivityIntent.class, intentService.submitted.get(0).getClass()); OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.submitted.get(0); assertEquals(CP31, connIntent.getSrc()); assertEquals(CP52, connIntent.getDst()); }
From source file:org.onosproject.newoptical.OpticalPathProvisionerTest.java
/** * Checks removeConnectivity method works. *//* w w w.ja va 2 s . c om*/ @Test public void testRemoveConnectivity() { Bandwidth bandwidth = Bandwidth.bps(100); Duration latency = Duration.ofMillis(10); OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency); // Checks intents are withdrawn assertTrue(target.removeConnectivity(cid)); assertEquals(1, intentService.withdrawn.size()); assertEquals(OpticalConnectivityIntent.class, intentService.withdrawn.get(0).getClass()); OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.withdrawn.get(0); assertEquals(CP31, connIntent.getSrc()); assertEquals(CP52, connIntent.getDst()); }
From source file:org.onosproject.newoptical.OpticalPathProvisionerTest.java
/** * Checks getPath method works./*w ww .j ava 2 s . c o m*/ */ @Test public void testGetPath() { Bandwidth bandwidth = Bandwidth.bps(100); Duration latency = Duration.ofMillis(10); List<Link> links = Stream.of(LINK1, LINK2, LINK3, LINK4, LINK5, LINK6).collect(Collectors.toList()); OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency); Optional<List<Link>> path = target.getPath(cid); // Checks returned path is as expected assertTrue(path.isPresent()); assertEquals(links, path.get()); }
From source file:org.onosproject.newoptical.OpticalPathProvisionerTest.java
/** * Checks if PATH_INSTALLED event comes up after intent whose master is this node is installed. */// w w w . j a va 2s. c o m @Test public void testInstalledEventLocal() { Bandwidth bandwidth = Bandwidth.bps(100); Duration latency = Duration.ofMillis(10); OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency); // notify all intents are installed intentService.notifyInstalled(); assertEquals(1, listener.events.size()); assertEquals(OpticalPathEvent.Type.PATH_INSTALLED, listener.events.get(0).type()); assertEquals(cid, listener.events.get(0).subject()); }
From source file:org.onosproject.newoptical.OpticalPathProvisionerTest.java
/** * Checks if PATH_INSTALLED event comes up after intent whose master is remote node is installed. *///ww w .j a v a2 s. c o m @Test public void testInstalledEventRemote() { // set the master for ingress device of intent to remote node mastershipService.setMastership(DEVICE2.id(), MastershipRole.NONE); Bandwidth bandwidth = Bandwidth.bps(100); Duration latency = Duration.ofMillis(10); OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency); // notify all intents are installed intentService.notifyInstalled(); // remote nodes must not receive event before distributed map is updated assertEquals(0, listener.events.size()); }
From source file:org.onosproject.newoptical.OpticalPathProvisionerTest.java
/** * Checks if PATH_REMOVED event comes up after packet link is removed. *///from w ww .j av a 2 s . co m @Test public void testRemovedEventLocal() { Bandwidth bandwidth = Bandwidth.bps(100); Duration latency = Duration.ofMillis(10); OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency); // notify all intents are installed intentService.notifyInstalled(); target.removeConnectivity(cid); // notify all intents are withdrawn intentService.notifyWithdrawn(); // must have received "INSTALLED" and "REMOVED" events assertEquals(2, listener.events.size()); assertEquals(OpticalPathEvent.Type.PATH_INSTALLED, listener.events.get(0).type()); assertEquals(cid, listener.events.get(0).subject()); assertEquals(OpticalPathEvent.Type.PATH_REMOVED, listener.events.get(1).type()); assertEquals(cid, listener.events.get(1).subject()); }
From source file:org.onosproject.newoptical.OpticalPathProvisionerTest.java
/** * Checks if PATH_REMOVED event comes up after packet link is removed. *//*from w w w .j a v a 2 s . c o m*/ @Test public void testRemovedEventRemote() { // set the master for ingress device of intent to remote node mastershipService.setMastership(DEVICE2.id(), MastershipRole.NONE); Bandwidth bandwidth = Bandwidth.bps(100); Duration latency = Duration.ofMillis(10); OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency); // notify all intents are installed intentService.notifyInstalled(); target.removeConnectivity(cid); // notify all intents are withdrawn intentService.notifyWithdrawn(); // remote nodes must not receive event before distributed map is updated assertEquals(0, listener.events.size()); }
From source file:org.onosproject.store.primitives.resources.impl.AsyncConsistentSetMultimapTest.java
@Override protected CopycatServer createCopycatServer(Address address) { CopycatServer server = CopycatServer.builder(address, members).withTransport(new LocalTransport(registry)) .withStorage(Storage.builder().withStorageLevel(StorageLevel.MEMORY) .withDirectory(testDir + "/" + address.port()).build()) .withStateMachine(ResourceManagerState::new).withSerializer(serializer.clone()) .withHeartbeatInterval(Duration.ofMillis(25)).withElectionTimeout(Duration.ofMillis(50)) .withSessionTimeout(Duration.ofMillis(100)).build(); copycatServers.add(server);// w w w . jav a2 s . com return server; }
From source file:org.springframework.cloud.function.web.flux.response.FluxReturnValueHandler.java
private ResponseBodyEmitter getEmitter(Long timeout, Publisher<?> flux, MediaType mediaType) { Publisher<?> exported = flux instanceof Mono ? Mono.from(flux) : Flux.from(flux).timeout(Duration.ofMillis(timeout), Flux.empty()); if (!MediaType.ALL.equals(mediaType) && EVENT_STREAM.isCompatibleWith(mediaType)) { // TODO: more subtle content negotiation return new FluxResponseSseEmitter<>(MediaType.APPLICATION_JSON, exported); }/*from ww w.j av a2 s . c om*/ return new FluxResponseBodyEmitter<>(mediaType, exported); }
From source file:org.springframework.cloud.gateway.test.websocket.WebSocketIntegrationTests.java
@Test public void echo() throws Exception { int count = 100; Flux<String> input = Flux.range(1, count).map(index -> "msg-" + index); ReplayProcessor<Object> output = ReplayProcessor.create(count); client.execute(getUrl("/echo"), session -> { logger.debug("Starting to send messages"); return session.send(input.doOnNext(s -> logger.debug("outbound " + s)).map(s -> session.textMessage(s))) .thenMany(session.receive().take(count).map(WebSocketMessage::getPayloadAsText)) .subscribeWith(output).doOnNext(s -> logger.debug("inbound " + s)).then().doOnSuccessOrError( (aVoid, ex) -> logger.debug("Done with " + (ex != null ? ex.getMessage() : "success"))); }).block(Duration.ofMillis(5000)); assertThat(output.collectList().block(Duration.ofMillis(5000))) .isEqualTo(input.collectList().block(Duration.ofMillis(5000))); }