target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void createFromValue() { StepVerifier.create(Eventual.of("x")) .expectNext("x") .verifyComplete(); }
public static <T> Eventual<T> of(T value) { return fromMono(Mono.just(value)); }
Eventual implements Publisher<T> { public static <T> Eventual<T> of(T value) { return fromMono(Mono.just(value)); } }
Eventual implements Publisher<T> { public static <T> Eventual<T> of(T value) { return fromMono(Mono.just(value)); } Eventual(Publisher<T> publisher); }
Eventual implements Publisher<T> { public static <T> Eventual<T> of(T value) { return fromMono(Mono.just(value)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> error(Throwable error); Eventual<R> map(Function<? super T...
Eventual implements Publisher<T> { public static <T> Eventual<T> of(T value) { return fromMono(Mono.just(value)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> error(Throwable error); Eventual<R> map(Function<? super T...
@Test public void createFromCompletionStage() { CompletableFuture<String> future = new CompletableFuture<>(); Eventual<String> eventual = Eventual.from(future); StepVerifier.create(eventual) .thenRequest(1) .expectNextCount(0) .then(() -> future.complete("hello")) .expectNext("hello") .verifyComplete(); }
public static <T> Eventual<T> from(CompletionStage<T> completionStage) { return fromMono(Mono.fromCompletionStage(completionStage)); }
Eventual implements Publisher<T> { public static <T> Eventual<T> from(CompletionStage<T> completionStage) { return fromMono(Mono.fromCompletionStage(completionStage)); } }
Eventual implements Publisher<T> { public static <T> Eventual<T> from(CompletionStage<T> completionStage) { return fromMono(Mono.fromCompletionStage(completionStage)); } Eventual(Publisher<T> publisher); }
Eventual implements Publisher<T> { public static <T> Eventual<T> from(CompletionStage<T> completionStage) { return fromMono(Mono.fromCompletionStage(completionStage)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> erro...
Eventual implements Publisher<T> { public static <T> Eventual<T> from(CompletionStage<T> completionStage) { return fromMono(Mono.fromCompletionStage(completionStage)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> erro...
@Test public void createFromError() { Eventual<String> eventual = Eventual.error(new JustATestException()); StepVerifier.create(eventual) .expectError(RuntimeException.class) .verify(); }
public static <T> Eventual<T> error(Throwable error) { return fromMono(Mono.error(error)); }
Eventual implements Publisher<T> { public static <T> Eventual<T> error(Throwable error) { return fromMono(Mono.error(error)); } }
Eventual implements Publisher<T> { public static <T> Eventual<T> error(Throwable error) { return fromMono(Mono.error(error)); } Eventual(Publisher<T> publisher); }
Eventual implements Publisher<T> { public static <T> Eventual<T> error(Throwable error) { return fromMono(Mono.error(error)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> error(Throwable error); Eventual<R> map(Functi...
Eventual implements Publisher<T> { public static <T> Eventual<T> error(Throwable error) { return fromMono(Mono.error(error)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> error(Throwable error); Eventual<R> map(Functi...
@Test public void reportsTimers() throws Exception { Timer timer = mock(Timer.class); when(timer.getCount()).thenReturn(1L); when(timer.getMeanRate()).thenReturn(2.0); when(timer.getOneMinuteRate()).thenReturn(3.0); when(timer.getFiveMinuteRate()).thenReturn(4.0); when(timer.getFifteenMinuteRate()).thenReturn(5.0); Sna...
@Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); gauges.forEach((name, gauge) -> doReport(name, ...
GraphiteReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); ga...
GraphiteReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); ga...
GraphiteReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); ga...
GraphiteReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); ga...
@Test public void runOnceIfNoErrors() throws IOException { tryTimes(2, task, null); verify(task).run(); }
public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { task.run()...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
@Test public void mapsValues() { StepVerifier.create(new Eventual<>(Flux.just("hello")).map(String::toUpperCase)) .expectNext("HELLO") .verifyComplete(); }
public <R> Eventual<R> map(Function<? super T, ? extends R> transformation) { return fromMono(Mono.from(publisher).map(transformation)); }
Eventual implements Publisher<T> { public <R> Eventual<R> map(Function<? super T, ? extends R> transformation) { return fromMono(Mono.from(publisher).map(transformation)); } }
Eventual implements Publisher<T> { public <R> Eventual<R> map(Function<? super T, ? extends R> transformation) { return fromMono(Mono.from(publisher).map(transformation)); } Eventual(Publisher<T> publisher); }
Eventual implements Publisher<T> { public <R> Eventual<R> map(Function<? super T, ? extends R> transformation) { return fromMono(Mono.from(publisher).map(transformation)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> ...
Eventual implements Publisher<T> { public <R> Eventual<R> map(Function<? super T, ? extends R> transformation) { return fromMono(Mono.from(publisher).map(transformation)); } Eventual(Publisher<T> publisher); static Eventual<T> of(T value); static Eventual<T> from(CompletionStage<T> completionStage); static Eventual<T> ...
@Test public void chunkedReturnsTrueWhenChunkedTransferEncodingIsSet() { HttpHeaders headers = requestBuilder() .header(TRANSFER_ENCODING, CHUNKED) .build() .headers(); assertThat(chunked(headers), is(true)); HttpHeaders headers2 = requestBuilder() .header(TRANSFER_ENCODING, "foo") .addHeader(TRANSFER_ENCODING, CHUNKED...
public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; }
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } }
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); }
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); static boolean chunked(HttpHeaders headers); static boolean keepAlive(HttpH...
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); static boolean chunked(HttpHeaders headers); static boolean keepAlive(HttpH...
@Test public void chunkedReturnsFalseWhenChunkedTransferEncodingIsNotSet() { HttpHeaders headers = requestBuilder() .header(TRANSFER_ENCODING, "foo") .build() .headers(); assertThat(chunked(headers), is(false)); }
public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; }
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } }
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); }
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); static boolean chunked(HttpHeaders headers); static boolean keepAlive(HttpH...
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); static boolean chunked(HttpHeaders headers); static boolean keepAlive(HttpH...
@Test public void chunkedReturnsTrueWhenChunkedTransferEncodingIsAbsent() { HttpHeaders headers = requestBuilder().build().headers(); assertThat(chunked(headers), is(false)); }
public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; }
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } }
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); }
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); static boolean chunked(HttpHeaders headers); static boolean keepAlive(HttpH...
HttpMessageSupport { public static boolean chunked(HttpHeaders headers) { for (String value : headers.getAll(TRANSFER_ENCODING)) { if (value.equalsIgnoreCase(CHUNKED.toString())) { return true; } } return false; } private HttpMessageSupport(); static boolean chunked(HttpHeaders headers); static boolean keepAlive(HttpH...
@Test public void keepAliveReturnsTrueWhenHttpConnectionMustBeKeptAlive() { HttpHeaders connectionHeaderAbsent = requestBuilder().build().headers(); HttpHeaders connectionHeaderClose = requestBuilder() .header(CONNECTION, CLOSE) .build() .headers(); HttpHeaders connectionHeaderKeepAlive = requestBuilder() .header(CONNE...
public static boolean keepAlive(HttpHeaders headers, HttpVersion version) { Optional<String> connection = headers.get(CONNECTION); if (connection.isPresent()) { if (CLOSE.toString().equalsIgnoreCase(connection.get())) { return false; } if (KEEP_ALIVE.toString().equalsIgnoreCase(connection.get())) { return true; } } ret...
HttpMessageSupport { public static boolean keepAlive(HttpHeaders headers, HttpVersion version) { Optional<String> connection = headers.get(CONNECTION); if (connection.isPresent()) { if (CLOSE.toString().equalsIgnoreCase(connection.get())) { return false; } if (KEEP_ALIVE.toString().equalsIgnoreCase(connection.get())) {...
HttpMessageSupport { public static boolean keepAlive(HttpHeaders headers, HttpVersion version) { Optional<String> connection = headers.get(CONNECTION); if (connection.isPresent()) { if (CLOSE.toString().equalsIgnoreCase(connection.get())) { return false; } if (KEEP_ALIVE.toString().equalsIgnoreCase(connection.get())) {...
HttpMessageSupport { public static boolean keepAlive(HttpHeaders headers, HttpVersion version) { Optional<String> connection = headers.get(CONNECTION); if (connection.isPresent()) { if (CLOSE.toString().equalsIgnoreCase(connection.get())) { return false; } if (KEEP_ALIVE.toString().equalsIgnoreCase(connection.get())) {...
HttpMessageSupport { public static boolean keepAlive(HttpHeaders headers, HttpVersion version) { Optional<String> connection = headers.get(CONNECTION); if (connection.isPresent()) { if (CLOSE.toString().equalsIgnoreCase(connection.get())) { return false; } if (KEEP_ALIVE.toString().equalsIgnoreCase(connection.get())) {...
@Test public void rejectsMultipleContentLengthInSingleHeader() { assertThrows(IllegalArgumentException.class, () -> get("/foo") .addHeader(CONTENT_LENGTH, "15, 16") .build()); }
public static Builder get(String uri) { return new Builder(GET, uri); }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); stat...
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); stat...
@Test public void rejectsMultipleContentLengthHeaders() { assertThrows(IllegalArgumentException.class, () -> get("/foo") .addHeader(CONTENT_LENGTH, "15") .addHeader(CONTENT_LENGTH, "16") .build()); }
public static Builder get(String uri) { return new Builder(GET, uri); }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); stat...
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); stat...
@Test public void rejectsInvalidContentLength() { assertThrows(IllegalArgumentException.class, () -> get("/foo") .addHeader(CONTENT_LENGTH, "foo") .build()); }
public static Builder get(String uri) { return new Builder(GET, uri); }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); stat...
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); stat...
@Test public void setsHostHeaderFromAuthorityIfSet() { LiveHttpRequest request = get("http: assertThat(request.header(HOST), isValue("www.hotels.com")); }
public static Builder get(String uri) { return new Builder(GET, uri); }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); }
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); stat...
LiveHttpRequest implements LiveHttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); stat...
@Test public void ensuresContentLengthIsPositive() { Exception e = assertThrows(IllegalArgumentException.class, () -> LiveHttpRequest.post("/y") .header("Content-Length", -3) .build()); assertEquals("Invalid Content-Length found. -3", e.getMessage()); }
public static Builder post(String uri) { return new Builder(POST, uri); }
LiveHttpRequest implements LiveHttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } }
LiveHttpRequest implements LiveHttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } LiveHttpRequest(Builder builder); }
LiveHttpRequest implements LiveHttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); st...
LiveHttpRequest implements LiveHttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } LiveHttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); st...
@Test public void closesConnectionIfGraphiteIsUnavailable() throws Exception { doThrow(new UnknownHostException("UNKNOWN-HOST")).when(graphite).connect(); reporter.report(map("gauge", gauge(1)), emptyMap(), emptyMap(), emptyMap(), emptyMap()); InOrder inOrder = inOrder(graphite); inOrder.verify(graphite).connect(); inO...
@Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); gauges.forEach((name, gauge) -> doReport(name, ...
GraphiteReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); ga...
GraphiteReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); ga...
GraphiteReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); ga...
GraphiteReporter extends ScheduledReporter { @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { long timestamp = clock.getTime() / 1000; try { initConnection(); ga...
@Test public void rejectsMultipleContentLengthInSingleHeader() { assertThrows(IllegalArgumentException.class, () -> get("/foo") .addHeader(CONTENT_LENGTH, "15, 16") .build()); }
public static Builder get(String uri) { return new Builder(GET, uri); }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder p...
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder p...
@Test public void rejectsMultipleContentLengthHeaders() { assertThrows(IllegalArgumentException.class, () -> get("/foo") .addHeader(CONTENT_LENGTH, "15") .addHeader(CONTENT_LENGTH, "16") .build()); }
public static Builder get(String uri) { return new Builder(GET, uri); }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder p...
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder p...
@Test public void rejectsInvalidContentLength() { assertThrows(IllegalArgumentException.class, () -> get("/foo") .addHeader(CONTENT_LENGTH, "foo") .build()); }
public static Builder get(String uri) { return new Builder(GET, uri); }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder p...
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder p...
@Test public void setsHostHeaderFromAuthorityIfSet() { HttpRequest request = get("http: assertThat(request.header(HOST), isValue("www.hotels.com")); }
public static Builder get(String uri) { return new Builder(GET, uri); }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); }
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder p...
HttpRequest implements HttpMessage { public static Builder get(String uri) { return new Builder(GET, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder p...
@Test public void ensuresContentLengthIsPositive() { Exception e = assertThrows(IllegalArgumentException.class, () -> HttpRequest.post("/y") .header("Content-Length", -3) .build()); assertEquals("Invalid Content-Length found. -3", e.getMessage()); }
public static Builder post(String uri) { return new Builder(POST, uri); }
HttpRequest implements HttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } }
HttpRequest implements HttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } HttpRequest(Builder builder); }
HttpRequest implements HttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder...
HttpRequest implements HttpMessage { public static Builder post(String uri) { return new Builder(POST, uri); } HttpRequest(Builder builder); static Builder get(String uri); static Builder head(String uri); static Builder post(String uri); static Builder delete(String uri); static Builder put(String uri); static Builder...
@Test public void testSubstitutions() { String urlPattern = "\\/foo\\/(a|b|c)(\\/.*)?"; RewriteConfig config = new RewriteConfig(urlPattern, "/bar/$1$2"); assertThat(config.rewrite("/foo/b/something").get(), CoreMatchers.equalTo("/bar/b/something")); config = new RewriteConfig(urlPattern, "/bar/$1/x$2"); assertThat(con...
@Override public Optional<String> rewrite(String originalUri) { Matcher matcher = compiledUrlPattern.matcher(originalUri); if (matcher.matches()) { return Optional.of(preprocessedReplacement.substitute(matcher)); } return Optional.empty(); }
RewriteConfig implements RewriteRule { @Override public Optional<String> rewrite(String originalUri) { Matcher matcher = compiledUrlPattern.matcher(originalUri); if (matcher.matches()) { return Optional.of(preprocessedReplacement.substitute(matcher)); } return Optional.empty(); } }
RewriteConfig implements RewriteRule { @Override public Optional<String> rewrite(String originalUri) { Matcher matcher = compiledUrlPattern.matcher(originalUri); if (matcher.matches()) { return Optional.of(preprocessedReplacement.substitute(matcher)); } return Optional.empty(); } RewriteConfig(String urlPattern, String...
RewriteConfig implements RewriteRule { @Override public Optional<String> rewrite(String originalUri) { Matcher matcher = compiledUrlPattern.matcher(originalUri); if (matcher.matches()) { return Optional.of(preprocessedReplacement.substitute(matcher)); } return Optional.empty(); } RewriteConfig(String urlPattern, String...
RewriteConfig implements RewriteRule { @Override public Optional<String> rewrite(String originalUri) { Matcher matcher = compiledUrlPattern.matcher(originalUri); if (matcher.matches()) { return Optional.of(preprocessedReplacement.substitute(matcher)); } return Optional.empty(); } RewriteConfig(String urlPattern, String...
@Test public void exposesNameAndStatusViaAdminInterface() throws ExecutionException, InterruptedException { DerivedStyxService service = new DerivedStyxService("derived-service", new CompletableFuture<>()); HttpResponse response = Mono.from(service.adminInterfaceHandlers().get("status").handle(get, MOCK_CONTEXT) .flatM...
@Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .stream())); }
AbstractStyxService implements StyxService { @Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .st...
AbstractStyxService implements StyxService { @Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .st...
AbstractStyxService implements StyxService { @Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .st...
AbstractStyxService implements StyxService { @Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .st...
@Test public void shouldCreateAChunkedResponse() { assertThat(HttpResponse.response().build().chunked(), is(false)); assertThat(HttpResponse.response().setChunked().build().chunked(), is(true)); }
public static Builder response() { return new Builder(); }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); @Override Optional<String> header(CharSequence name); @Override List<String> headers(CharSequence name);...
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); @Override Optional<String> header(CharSequence name); @Override List<String> headers(CharSequence name);...
@Test public void rejectsMultipleContentLengthInSingleHeader() { assertThrows(IllegalArgumentException.class, () -> HttpResponse.response() .addHeader(CONTENT_LENGTH, "15, 16") .ensureContentLengthIsValid() .build()); }
public static Builder response() { return new Builder(); }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); @Override Optional<String> header(CharSequence name); @Override List<String> headers(CharSequence name);...
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); @Override Optional<String> header(CharSequence name); @Override List<String> headers(CharSequence name);...
@Test public void rejectsMultipleContentLength() { assertThrows(IllegalArgumentException.class, () -> HttpResponse.response() .addHeader(CONTENT_LENGTH, "15") .addHeader(CONTENT_LENGTH, "16") .ensureContentLengthIsValid() .build()); }
public static Builder response() { return new Builder(); }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); @Override Optional<String> header(CharSequence name); @Override List<String> headers(CharSequence name);...
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); @Override Optional<String> header(CharSequence name); @Override List<String> headers(CharSequence name);...
@Test public void closesConnectionOnReporterStop() throws Exception { reporter.stop(); verify(graphite).close(); verifyNoMoreInteractions(graphite); }
@Override public void stop() { try { super.stop(); } finally { try { graphite.close(); } catch (IOException e) { LOGGER.debug("Error disconnecting from Graphite", e); } } }
GraphiteReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { graphite.close(); } catch (IOException e) { LOGGER.debug("Error disconnecting from Graphite", e); } } } }
GraphiteReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { graphite.close(); } catch (IOException e) { LOGGER.debug("Error disconnecting from Graphite", e); } } } private GraphiteReporter(MetricRegistry registry, GraphiteSender graphit...
GraphiteReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { graphite.close(); } catch (IOException e) { LOGGER.debug("Error disconnecting from Graphite", e); } } } private GraphiteReporter(MetricRegistry registry, GraphiteSender graphit...
GraphiteReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { graphite.close(); } catch (IOException e) { LOGGER.debug("Error disconnecting from Graphite", e); } } } private GraphiteReporter(MetricRegistry registry, GraphiteSender graphit...
@Test public void rejectsInvalidContentLength() { assertThrows(IllegalArgumentException.class, () -> HttpResponse.response() .addHeader(CONTENT_LENGTH, "foo") .ensureContentLengthIsValid() .build()); }
public static Builder response() { return new Builder(); }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); }
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); @Override Optional<String> header(CharSequence name); @Override List<String> headers(CharSequence name);...
HttpResponse implements HttpMessage { public static Builder response() { return new Builder(); } private HttpResponse(Builder builder); static Builder response(); static Builder response(HttpResponseStatus status); @Override Optional<String> header(CharSequence name); @Override List<String> headers(CharSequence name);...
@Test public void providesEncodedQuery() { assertThat(query.encodedQuery(), is("foo=alpha&bar=beta&foo=gamma")); }
String encodedQuery() { return encodedQuery; }
UrlQuery { String encodedQuery() { return encodedQuery; } }
UrlQuery { String encodedQuery() { return encodedQuery; } private UrlQuery(List<Parameter> parameters); }
UrlQuery { String encodedQuery() { return encodedQuery; } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
UrlQuery { String encodedQuery() { return encodedQuery; } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
@Test public void providesParameterNames() { assertThat(query.parameterNames(), contains("foo", "bar")); }
Iterable<String> parameterNames() { return parameters().stream().map(Parameter::key).distinct().collect(toList()); }
UrlQuery { Iterable<String> parameterNames() { return parameters().stream().map(Parameter::key).distinct().collect(toList()); } }
UrlQuery { Iterable<String> parameterNames() { return parameters().stream().map(Parameter::key).distinct().collect(toList()); } private UrlQuery(List<Parameter> parameters); }
UrlQuery { Iterable<String> parameterNames() { return parameters().stream().map(Parameter::key).distinct().collect(toList()); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
UrlQuery { Iterable<String> parameterNames() { return parameters().stream().map(Parameter::key).distinct().collect(toList()); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
@Test public void providesValueByKey() { assertThat(query.parameterValue("foo"), isValue("alpha")); assertThat(query.parameterValue("bar"), isValue("beta")); assertThat(query.parameterValue("no_such_key"), isAbsent()); }
Optional<String> parameterValue(String name) { return stream(parameterValues(name).spliterator(), false).findFirst(); }
UrlQuery { Optional<String> parameterValue(String name) { return stream(parameterValues(name).spliterator(), false).findFirst(); } }
UrlQuery { Optional<String> parameterValue(String name) { return stream(parameterValues(name).spliterator(), false).findFirst(); } private UrlQuery(List<Parameter> parameters); }
UrlQuery { Optional<String> parameterValue(String name) { return stream(parameterValues(name).spliterator(), false).findFirst(); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
UrlQuery { Optional<String> parameterValue(String name) { return stream(parameterValues(name).spliterator(), false).findFirst(); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
@Test public void providesValuesByKey() { assertThat(query.parameterValues("foo"), contains("alpha", "gamma")); assertThat(query.parameterValues("bar"), contains("beta")); assertThat(query.parameterValues("no_such_key"), is(emptyIterable())); }
Iterable<String> parameterValues(String name) { return parameters().stream() .filter(parameter -> parameter.key.equals(name)) .map(Parameter::value) .collect(toList()); }
UrlQuery { Iterable<String> parameterValues(String name) { return parameters().stream() .filter(parameter -> parameter.key.equals(name)) .map(Parameter::value) .collect(toList()); } }
UrlQuery { Iterable<String> parameterValues(String name) { return parameters().stream() .filter(parameter -> parameter.key.equals(name)) .map(Parameter::value) .collect(toList()); } private UrlQuery(List<Parameter> parameters); }
UrlQuery { Iterable<String> parameterValues(String name) { return parameters().stream() .filter(parameter -> parameter.key.equals(name)) .map(Parameter::value) .collect(toList()); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); ...
UrlQuery { Iterable<String> parameterValues(String name) { return parameters().stream() .filter(parameter -> parameter.key.equals(name)) .map(Parameter::value) .collect(toList()); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); ...
@Test public void providesFullParameters() { assertThat(query.parameters(), contains( new Parameter("foo", "alpha"), new Parameter("bar", "beta"), new Parameter("foo", "gamma") )); }
List<Parameter> parameters() { return parameters; }
UrlQuery { List<Parameter> parameters() { return parameters; } }
UrlQuery { List<Parameter> parameters() { return parameters; } private UrlQuery(List<Parameter> parameters); }
UrlQuery { List<Parameter> parameters() { return parameters; } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
UrlQuery { List<Parameter> parameters() { return parameters; } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
@Test public void buildsNewQueryFromExistingQuery() { assertThat(query.newBuilder().build(), equalTo(query)); }
Builder newBuilder() { return new Builder(this); }
UrlQuery { Builder newBuilder() { return new Builder(this); } }
UrlQuery { Builder newBuilder() { return new Builder(this); } private UrlQuery(List<Parameter> parameters); }
UrlQuery { Builder newBuilder() { return new Builder(this); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
UrlQuery { Builder newBuilder() { return new Builder(this); } private UrlQuery(List<Parameter> parameters); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
@Test public void acceptsOnlyNonEmptyName() { assertThrows(IllegalArgumentException.class, () -> requestCookie("", "value")); }
private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); }
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } }
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } private Reques...
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } private Reques...
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } private Reques...
@Test public void acceptsOnlyNonNullName() { assertThrows(IllegalArgumentException.class, () -> requestCookie(null, "value")); }
private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); }
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } }
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } private Reques...
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } private Reques...
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } private Reques...
@Test public void acceptsOnlyNonNullValue() { assertThrows(NullPointerException.class, () -> requestCookie("name", null)); }
private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); }
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } }
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } private Reques...
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } private Reques...
RequestCookie { private RequestCookie(String name, String value) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name cannot be null or empty"); } requireNonNull(value, "value cannot be null"); this.name = name; this.value = value; this.hashCode = Objects.hash(name, value); } private Reques...
@Test public void injectsToPipelineWhenRouteFound() { HttpHandler pipeline = mock(HttpHandler.class); when(pipeline.handle(any(LiveHttpRequest.class), any(HttpInterceptor.Context.class))).thenReturn(Eventual.of(respOk)); HttpRouter router = mock(HttpRouter.class); when(router.route(any(LiveHttpRequest.class), any(HttpI...
@Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.path()))); }
RouteHandlerAdapter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.p...
RouteHandlerAdapter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.p...
RouteHandlerAdapter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.p...
RouteHandlerAdapter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.p...
@Test public void unwiseCharsAreNotAccepted() throws Exception { String urlWithUnwiseChars = "/search.do?foo={&srsReport=Landing|AutoS|HOTEL|Hotel%20Il%20Duca%20D%27Este|0|0|0|2|1|2|284128&srsr=Landing|AutoS|HOTEL|Hotel%20Il%20Duca%20D%27Este|0|0|0|2|1|2|284128"; assertThrows(IllegalArgumentException.class, () -> url(u...
private Url(Builder builder) { this.scheme = builder.scheme; this.authority = builder.authority; this.path = builder.path; this.query = Optional.ofNullable(builder.queryBuilder).map(UrlQuery.Builder::build); this.fragment = builder.fragment; }
Url implements Comparable<Url> { private Url(Builder builder) { this.scheme = builder.scheme; this.authority = builder.authority; this.path = builder.path; this.query = Optional.ofNullable(builder.queryBuilder).map(UrlQuery.Builder::build); this.fragment = builder.fragment; } }
Url implements Comparable<Url> { private Url(Builder builder) { this.scheme = builder.scheme; this.authority = builder.authority; this.path = builder.path; this.query = Optional.ofNullable(builder.queryBuilder).map(UrlQuery.Builder::build); this.fragment = builder.fragment; } private Url(Builder builder); }
Url implements Comparable<Url> { private Url(Builder builder) { this.scheme = builder.scheme; this.authority = builder.authority; this.path = builder.path; this.query = Optional.ofNullable(builder.queryBuilder).map(UrlQuery.Builder::build); this.fragment = builder.fragment; } private Url(Builder builder); String schem...
Url implements Comparable<Url> { private Url(Builder builder) { this.scheme = builder.scheme; this.authority = builder.authority; this.path = builder.path; this.query = Optional.ofNullable(builder.queryBuilder).map(UrlQuery.Builder::build); this.fragment = builder.fragment; } private Url(Builder builder); String schem...
@Test public void requestDoFinallyActivatesWhenSuccessfullyCompleted() { Requests.doFinally(request, completed::set) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.complete(); assertThat(completed.get(), is(Optional.empty())); }
public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHtt...
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHtt...
@Test public void responseDoFinallyActivatesWhenSuccessfullyCompleted() { Requests.doFinally(response, completed::set) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.complete(); assertThat(completed.get(), is(Optional.empty())); }
public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHtt...
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHtt...
@Test public void requestDoFinallyActivatesWhenErrors() { RuntimeException cause = new RuntimeException("help!!"); Requests.doFinally(request, completed::set) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.error(cause); assertThat(completed.get(), is(Op...
public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHtt...
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHtt...
@Test public void responseDoFinallyActivatesWhenErrors() { RuntimeException cause = new RuntimeException("help!!"); Requests.doFinally(response, completed::set) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.error(cause); assertThat(completed.get(), is(...
public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHtt...
Requests { public static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action) { return request.newBuilder() .body(it -> it.doOnEnd(action)) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHtt...
@Test public void requestDoOnCompleteActivatesWhenSuccessfullyCompleted() { Requests.doOnComplete(request, () -> completed.set(Optional.empty())) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.complete(); assertThat(completed.get(), is(Optional.empty())...
public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttpRes...
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttpRes...
@Test public void responseDoOnCompleteActivatesWhenSuccessfullyCompleted() { Requests.doOnComplete(response, () -> completed.set(Optional.empty())) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.complete(); assertThat(completed.get(), is(Optional.empty(...
public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttpRes...
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttpRes...
@Test public void requestDoOnCompleteDoesNotActivatesWhenErrors() { RuntimeException cause = new RuntimeException("help!!"); Requests.doOnComplete(request, () -> completed.set(Optional.empty())) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.error(cause...
public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttpRes...
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttpRes...
@Test public void responseDoOnCompleteDoesNotActivatesWhenErrors() { RuntimeException cause = new RuntimeException("help!!"); Requests.doOnComplete(response, () -> completed.set(Optional.empty())) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.error(cau...
public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttpRes...
Requests { public static LiveHttpRequest doOnComplete(LiveHttpRequest request, Runnable action) { return request.newBuilder() .body(it -> it.doOnEnd(ifSuccessful(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttpRes...
@Test public void requestDoOnErrorDoesNotActivatesWhenSuccessfullyCompleted() { Requests.doOnError(request, (cause) -> completed.set(Optional.of(cause))) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.complete(); assertThat(completed.get(), is(nullValue...
public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttp...
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttp...
@Test public void pluginsAreProvidedInOrderSpecifiedByActivePluginsCommaSeparatedList() { Map<String, SpiExtension> plugins = new LinkedHashMap<>(); Stream.of("two", "four", "three", "one") .forEach(key -> plugins.put(key, pluginMetadata())); PluginsMetadata pluginsMetadata = new PluginsMetadata("one,two,three,four", p...
public List<Pair<String, SpiExtension>> activePlugins() { return activePluginsNames.stream() .map(name -> pair(name, plugins.get(name))) .collect(toList()); }
PluginsMetadata implements Iterable<SpiExtension> { public List<Pair<String, SpiExtension>> activePlugins() { return activePluginsNames.stream() .map(name -> pair(name, plugins.get(name))) .collect(toList()); } }
PluginsMetadata implements Iterable<SpiExtension> { public List<Pair<String, SpiExtension>> activePlugins() { return activePluginsNames.stream() .map(name -> pair(name, plugins.get(name))) .collect(toList()); } PluginsMetadata(@JsonProperty("active") String active, @JsonProperty("all") Map<String, S...
PluginsMetadata implements Iterable<SpiExtension> { public List<Pair<String, SpiExtension>> activePlugins() { return activePluginsNames.stream() .map(name -> pair(name, plugins.get(name))) .collect(toList()); } PluginsMetadata(@JsonProperty("active") String active, @JsonProperty("all") Map<String, S...
PluginsMetadata implements Iterable<SpiExtension> { public List<Pair<String, SpiExtension>> activePlugins() { return activePluginsNames.stream() .map(name -> pair(name, plugins.get(name))) .collect(toList()); } PluginsMetadata(@JsonProperty("active") String active, @JsonProperty("all") Map<String, S...
@Test public void responseDoOnErrorDoesNotActivatesWhenSuccessfullyCompleted() { Requests.doOnError(response, (cause) -> completed.set(Optional.of(cause))) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.complete(); assertThat(completed.get(), is(nullVal...
public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttp...
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttp...
@Test public void requestDoOnErrorActivatesWhenErrors() { RuntimeException cause = new RuntimeException("help!!"); Requests.doOnError(request, (it) -> completed.set(Optional.of(it))) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.error(cause); assertTha...
public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttp...
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttp...
@Test public void responseDoOnErrorActivatesWhenErrors() { RuntimeException cause = new RuntimeException("help!!"); Requests.doOnError(response, (it) -> completed.set(Optional.of(it))) .consume(); publisher.next(new Buffer("content", UTF_8)); assertThat(completed.get(), is(nullValue())); publisher.error(cause); assertT...
public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); }
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttp...
Requests { public static LiveHttpRequest doOnError(LiveHttpRequest request, Consumer<Throwable> action) { return request.newBuilder() .body(it -> it.doOnEnd(ifError(action))) .build(); } private Requests(); static LiveHttpRequest doFinally(LiveHttpRequest request, Consumer<Optional<Throwable>> action); static LiveHttp...
@Test public void doesNotAcceptNegativeValues() { assertThrows(IllegalArgumentException.class, () -> newHistogram(2, 2).recordValue(-1)); }
public synchronized void recordValue(long msValue) { checkArgument(msValue >= 0, "Recorded value must be a positive number."); long currentTime = clock.tickMillis(); purgeOldHistograms(currentTime); int bucket = bucketFromTime(currentTime); window[bucket].recordValue(msValue); lastUpdateTime = currentTime; }
SlidingWindowHistogram { public synchronized void recordValue(long msValue) { checkArgument(msValue >= 0, "Recorded value must be a positive number."); long currentTime = clock.tickMillis(); purgeOldHistograms(currentTime); int bucket = bucketFromTime(currentTime); window[bucket].recordValue(msValue); lastUpdateTime = ...
SlidingWindowHistogram { public synchronized void recordValue(long msValue) { checkArgument(msValue >= 0, "Recorded value must be a positive number."); long currentTime = clock.tickMillis(); purgeOldHistograms(currentTime); int bucket = bucketFromTime(currentTime); window[bucket].recordValue(msValue); lastUpdateTime = ...
SlidingWindowHistogram { public synchronized void recordValue(long msValue) { checkArgument(msValue >= 0, "Recorded value must be a positive number."); long currentTime = clock.tickMillis(); purgeOldHistograms(currentTime); int bucket = bucketFromTime(currentTime); window[bucket].recordValue(msValue); lastUpdateTime = ...
SlidingWindowHistogram { public synchronized void recordValue(long msValue) { checkArgument(msValue >= 0, "Recorded value must be a positive number."); long currentTime = clock.tickMillis(); purgeOldHistograms(currentTime); int bucket = bucketFromTime(currentTime); window[bucket].recordValue(msValue); lastUpdateTime = ...
@Test public void snapshotComputesPercentiles() { SlidingWindowHistogramReservoir reservoir = reservoirWithSamples(1, 100); assertThat(reservoir.getSnapshot().getMin(), is(1L)); assertThat(reservoir.getSnapshot().getMax(), is(100L)); assertThat(reservoir.getSnapshot().getMean(), is(closeTo(50.5, 1))); assertThat(reserv...
@Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; }
SlidingWindowHistogramReservoir implements Reservoir { @Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; } }
SlidingWindowHistogramReservoir implements Reservoir { @Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; } SlidingWindowHistogramReservoi...
SlidingWindowHistogramReservoir implements Reservoir { @Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; } SlidingWindowHistogramReservoi...
SlidingWindowHistogramReservoir implements Reservoir { @Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; } SlidingWindowHistogramReservoi...
@Test public void snapshotExposesSamplesAsArray() { SlidingWindowHistogramReservoir reservoir = reservoirWithSamples(1, 100); assertThat(reservoir.getSnapshot().getValues(), is(toArray(Range.closed(1L, 100L)))); }
@Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; }
SlidingWindowHistogramReservoir implements Reservoir { @Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; } }
SlidingWindowHistogramReservoir implements Reservoir { @Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; } SlidingWindowHistogramReservoi...
SlidingWindowHistogramReservoir implements Reservoir { @Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; } SlidingWindowHistogramReservoi...
SlidingWindowHistogramReservoir implements Reservoir { @Override public synchronized Snapshot getSnapshot() { if (updated || snapshotExpired(clock.tickMillis())) { snapshot = new HistogramSnapshot(histogram); updated = false; snapshotCreationTime = clock.tickMillis(); } return snapshot; } SlidingWindowHistogramReservoi...
@Test public void retrievesPreviouslyRegisteredTimer() { Timer timer = metricRegistry.timer("newTimer"); assertThat(timer, is(notNullValue())); assertThat(metricRegistry.timer("newTimer"), is(sameInstance(timer))); }
@Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (IllegalArgumentException e) { Metric added = metrics.g...
CodaHaleMetricRegistry implements MetricRegistry { @Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (Ill...
CodaHaleMetricRegistry implements MetricRegistry { @Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (Ill...
CodaHaleMetricRegistry implements MetricRegistry { @Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (Ill...
CodaHaleMetricRegistry implements MetricRegistry { @Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (Ill...
@Test public void createsTimerBackedByLatencyStats() { Timer timer = metricRegistry.timer("timer"); assertThat(timer.getSnapshot(), is(instanceOf(SlidingWindowHistogramReservoir.HistogramSnapshot.class))); }
@Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (IllegalArgumentException e) { Metric added = metrics.g...
CodaHaleMetricRegistry implements MetricRegistry { @Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (Ill...
CodaHaleMetricRegistry implements MetricRegistry { @Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (Ill...
CodaHaleMetricRegistry implements MetricRegistry { @Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (Ill...
CodaHaleMetricRegistry implements MetricRegistry { @Override public Timer timer(String name) { Map<String, Metric> metrics = metricRegistry.getMetrics(); Metric metric = metrics.get(name); if (metric instanceof Timer) { return (Timer) metric; } if (metric == null) { try { return register(name, newTimer()); } catch (Ill...
@Test public void createsAnnouncerForType() { Announcer<AnnouncerTestListener> announcer = Announcer.to(AnnouncerTestListener.class); assertThat(announcer, is(notNullValue())); }
public static <T extends EventListener> Announcer<T> to(Class<? extends T> listenerType) { return new Announcer<>(listenerType); }
Announcer { public static <T extends EventListener> Announcer<T> to(Class<? extends T> listenerType) { return new Announcer<>(listenerType); } }
Announcer { public static <T extends EventListener> Announcer<T> to(Class<? extends T> listenerType) { return new Announcer<>(listenerType); } Announcer(Class<? extends T> listenerType); }
Announcer { public static <T extends EventListener> Announcer<T> to(Class<? extends T> listenerType) { return new Announcer<>(listenerType); } Announcer(Class<? extends T> listenerType); static Announcer<T> to(Class<? extends T> listenerType); void addListener(T listener); void removeListener(T listener); T announce();...
Announcer { public static <T extends EventListener> Announcer<T> to(Class<? extends T> listenerType) { return new Announcer<>(listenerType); } Announcer(Class<? extends T> listenerType); static Announcer<T> to(Class<? extends T> listenerType); void addListener(T listener); void removeListener(T listener); T announce();...
@Test public void discriminatedUnionSelectorMustBeString() { Exception e = assertThrows(InvalidSchemaException.class, () -> newDocument() .rootSchema(object( field("httpPipeline", object( field("type", integer()), field("config", union("type")) )) ) ).build()); assertThat(e.getMessage(), matchesPattern("Discriminator a...
public static Builder newDocument() { return new Builder(); }
DocumentFormat { public static Builder newDocument() { return new Builder(); } }
DocumentFormat { public static Builder newDocument() { return new Builder(); } private DocumentFormat(Builder builder); }
DocumentFormat { public static Builder newDocument() { return new Builder(); } private DocumentFormat(Builder builder); void validateObject(JsonNode tree); static Builder newDocument(); }
DocumentFormat { public static Builder newDocument() { return new Builder(); } private DocumentFormat(Builder builder); void validateObject(JsonNode tree); static Builder newDocument(); }
@Test public void pluginLoaderLoadsPluginFromJarFile() { SpiExtensionFactory factory = new SpiExtensionFactory("testgrp.TestPluginModule", pluginsPath.toString()); PluginFactory plugin = pluginFactoryLoader.load(new SpiExtension(factory, config, null)); assertThat(plugin, is(not(nullValue()))); assertThat(plugin.getCla...
@Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); }
FileSystemPluginFactoryLoader implements PluginFactoryLoader { @Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); } }
FileSystemPluginFactoryLoader implements PluginFactoryLoader { @Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); } }
FileSystemPluginFactoryLoader implements PluginFactoryLoader { @Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); } @Override PluginFactory load(SpiExtension spiExtension); }
FileSystemPluginFactoryLoader implements PluginFactoryLoader { @Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); } @Override PluginFactory load(SpiExtension spiExtension); }
@Test public void list_checksThatSubobjectUnionDiscriminatorAttributeExists() throws Exception { Exception e = assertThrows(InvalidSchemaException.class, () -> schema(field("name", string()), field("config", union("type")) )); assertEquals("Discriminator attribute 'type' not present.", e.getMessage()); }
private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = builder.pass;...
Schema { private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = buil...
Schema { private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = buil...
Schema { private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = buil...
Schema { private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = buil...
@Test public void checksThatSubobjectUnionDiscriminatorAttributeIsString() throws Exception { Exception e = assertThrows(InvalidSchemaException.class, () -> schema(field("name", string()), field("type", integer()), field("config", union("type")) )); assertThat(e.getMessage(), matchesPattern("Discriminator attribute 'ty...
private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = builder.pass;...
Schema { private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = buil...
Schema { private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = buil...
Schema { private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = buil...
Schema { private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ignore = buil...
@Test public void describesItsBehaviour() { AtLeastOneFieldPresenceConstraint constraint = new AtLeastOneFieldPresenceConstraint("http", "https"); assertThat(constraint.describe(), is("At least one of ('http', 'https') must be present.")); }
@Override public String describe() { return description; }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public String describe() { return description; } }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public String describe() { return description; } AtLeastOneFieldPresenceConstraint(String... fieldNames); }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public String describe() { return description; } AtLeastOneFieldPresenceConstraint(String... fieldNames); @Override boolean evaluate(Schema schema, JsonNode node); @Override String describe(); }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public String describe() { return description; } AtLeastOneFieldPresenceConstraint(String... fieldNames); @Override boolean evaluate(Schema schema, JsonNode node); @Override String describe(); }
@Test public void passesWhenOneRequiredFieldIsPresent() throws IOException { AtLeastOneFieldPresenceConstraint constraint = new AtLeastOneFieldPresenceConstraint("http", "https"); boolean result = constraint.evaluate( schema( field("x", integer()), field("http", integer()), field("https", integer()), atLeastOne("http",...
@Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames);...
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames);...
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames);...
@Test public void allowsSeveralFieldsToBePresent() throws IOException { AtLeastOneFieldPresenceConstraint constraint = new AtLeastOneFieldPresenceConstraint("http", "https"); boolean result = constraint.evaluate( schema( field("x", integer()), field("http", integer()), field("https", integer()), atLeastOne("http", "htt...
@Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames);...
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames);...
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames);...
@Test public void throwsExceptionWhenNoneRequiredFieldsArePresent() throws IOException { AtLeastOneFieldPresenceConstraint constraint = new AtLeastOneFieldPresenceConstraint("http", "https"); boolean result = constraint.evaluate( schema( field("x", integer()), field("http", integer()), field("https", integer()), atLeas...
@Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } }
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames);...
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames);...
AtLeastOneFieldPresenceConstraint implements Constraint { @Override public boolean evaluate(Schema schema, JsonNode node) { long fieldsPresent = ImmutableList.copyOf(node.fieldNames()) .stream() .filter(fieldNames::contains) .count(); return fieldsPresent >= 1; } AtLeastOneFieldPresenceConstraint(String... fieldNames);...
@Test public void aggregatesRequestAndStreamsResponses() { AtomicReference<String> result = new AtomicReference<>(); WebServiceHandler webServiceHandler = (request, ctx) -> { result.set(request.bodyAs(UTF_8)); return Eventual.of(response(OK) .body("abcdef", UTF_8) .build()); }; LiveHttpResponse response = Mono.from( ne...
@Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return request.aggregate(bytes) .flatMap(aggregated -> this.delegate.handle(aggregated, context)) .map(HttpResponse::stream); }
HttpAggregator implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return request.aggregate(bytes) .flatMap(aggregated -> this.delegate.handle(aggregated, context)) .map(HttpResponse::stream); } }
HttpAggregator implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return request.aggregate(bytes) .flatMap(aggregated -> this.delegate.handle(aggregated, context)) .map(HttpResponse::stream); } HttpAggregator(int bytes, WebServiceHandl...
HttpAggregator implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return request.aggregate(bytes) .flatMap(aggregated -> this.delegate.handle(aggregated, context)) .map(HttpResponse::stream); } HttpAggregator(int bytes, WebServiceHandl...
HttpAggregator implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return request.aggregate(bytes) .flatMap(aggregated -> this.delegate.handle(aggregated, context)) .map(HttpResponse::stream); } HttpAggregator(int bytes, WebServiceHandl...
@Test public void streamsRequestAndAggregatesResponses() { HttpHandler httpHandler = (request, ctx) -> Eventual.of( LiveHttpResponse.response(OK) .body(ByteStream.from("abcdef", UTF_8)) .build()); HttpResponse response = Mono.from( new HttpStreamer(500, httpHandler) .handle(HttpRequest.post("/") .body("ABCDEF", UTF_8) ...
@Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return delegate.handle(request.stream(), context) .flatMap(live -> live.aggregate(maxContentBytes)); }
HttpStreamer implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return delegate.handle(request.stream(), context) .flatMap(live -> live.aggregate(maxContentBytes)); } }
HttpStreamer implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return delegate.handle(request.stream(), context) .flatMap(live -> live.aggregate(maxContentBytes)); } HttpStreamer(int maxContentBytes, HttpHandler delegate); HttpStreamer...
HttpStreamer implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return delegate.handle(request.stream(), context) .flatMap(live -> live.aggregate(maxContentBytes)); } HttpStreamer(int maxContentBytes, HttpHandler delegate); HttpStreamer...
HttpStreamer implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { return delegate.handle(request.stream(), context) .flatMap(live -> live.aggregate(maxContentBytes)); } HttpStreamer(int maxContentBytes, HttpHandler delegate); HttpStreamer...
@Test public void delegatesTheRequestIfRequestMethodIsSupported() { WebServiceHandler handler = mock(WebServiceHandler.class); HttpMethodFilteringHandler post = new HttpMethodFilteringHandler(POST, handler); HttpRequest request = post("/some-uri").build(); post.handle(request, mock(HttpInterceptor.Context.class)); veri...
@Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } return httpHandler.handle(request, context); }
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } re...
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } re...
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } re...
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } re...
@Test public void failsIfRequestMethodIsNotSupported() throws Exception { WebServiceHandler handler = mock(WebServiceHandler.class); HttpMethodFilteringHandler post = new HttpMethodFilteringHandler(GET, handler); HttpRequest request = post("/some-uri").build(); HttpResponse response = Mono.from(post.handle(request, req...
@Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } return httpHandler.handle(request, context); }
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } re...
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } re...
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } re...
HttpMethodFilteringHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { if (!method.equals(request.method())) { return Eventual.of( HttpResponse.response(METHOD_NOT_ALLOWED) .body(errorBody, StandardCharsets.UTF_8) .build() ); } re...
@Test public void providesMeaningfulErrorMessageWhenConfiguredFactoryClassCannotBeLoaded() { String jarFile = "/plugins/oneplugin/testPluginA-1.0-SNAPSHOT.jar"; Path pluginsPath = fixturesHome(FileSystemPluginFactoryLoader.class, jarFile); SpiExtensionFactory factory = new SpiExtensionFactory("incorrect.plugin.class.na...
@Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); }
FileSystemPluginFactoryLoader implements PluginFactoryLoader { @Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); } }
FileSystemPluginFactoryLoader implements PluginFactoryLoader { @Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); } }
FileSystemPluginFactoryLoader implements PluginFactoryLoader { @Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); } @Override PluginFactory load(SpiExtension spiExtension); }
FileSystemPluginFactoryLoader implements PluginFactoryLoader { @Override public PluginFactory load(SpiExtension spiExtension) { return newPluginFactory(spiExtension); } @Override PluginFactory load(SpiExtension spiExtension); }
@Test public void throwsNullPointerExceptionForNullEvents() { FsmEventProcessor<String> processor = new FsmEventProcessor<>(stateMachine, errorHandler, "prefix"); assertThrows(NullPointerException.class, () -> processor.submit(null)); }
@Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Cause=\"{}\"", new Object[]{loggingPrefix, state...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
@Test public void propagatesEventToFsm() { FsmEventProcessor<String> processor = new FsmEventProcessor<>(stateMachine, errorHandler, "prefix"); processor.submit(new TestEventOk()); assertThat(stateMachine.currentState(), is("end")); }
@Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Cause=\"{}\"", new Object[]{loggingPrefix, state...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
@Test public void handlesStateMachineExceptions() { FsmEventProcessor<String> processor = new FsmEventProcessor<>(stateMachine, errorHandler, "prefix"); processor.submit(new TestEventError()); verify(errorHandler).accept(any(RuntimeException.class), eq("start")); assertThat(logger.lastMessage(), is( loggingEvent( ERROR...
@Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Cause=\"{}\"", new Object[]{loggingPrefix, state...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
FsmEventProcessor implements EventProcessor { @Override public void submit(Object event) { requireNonNull(event); try { stateMachine.handle(event, loggingPrefix); } catch (Throwable cause) { String eventName = event.getClass().getSimpleName(); LOGGER.error("{} {} -> ???: Exception occurred while processing event={}. Ca...
@Test public void listsResourcesFromFileSystemDirectory() { Iterable<Resource> jars = resourceIndex.list(PLUGINS_FIXTURE_PATH.toString(), ".jar"); assertThat(jars, contains(resourceWithPath("oneplugin/url-rewrite-1.0-SNAPSHOT.jar"))); }
@Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; }
FileResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; } }
FileResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; } }
FileResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; } @Override Iterable<Resource> list(String path, S...
FileResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; } @Override Iterable<Resource> list(String path, S...
@Test public void listsResourcesFromFileSystemFile() { File file = new File(PLUGINS_FIXTURE_PATH.toFile(), "groovy/UrlRewrite.groovy"); Iterable<Resource> files = resourceIndex.list(file.getPath(), ".anything"); assertThat(files, contains(resourceWithPath( PLUGINS_FIXTURE_PATH.resolve("groovy/UrlRewrite.groovy").toStri...
@Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; }
FileResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; } }
FileResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; } }
FileResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; } @Override Iterable<Resource> list(String path, S...
FileResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { ArrayList<Resource> list = new ArrayList<>(); new FileResourceIterator(new File(path), new File(path), suffix).forEachRemaining(list::add); return list; } @Override Iterable<Resource> list(String path, S...
@Test public void listsByPathAndSuffix() { ClassLoader classLoader = ClasspathResourceIndexTest.class.getClassLoader(); ClasspathResourceIndex index = new ClasspathResourceIndex(classLoader); Iterable<Resource> resources = index.list("com/hotels/styx/common/io", ".txt"); assertThat(resources, containsInAnyOrder( resour...
@Override public Iterable<Resource> list(String path, String suffix) { String classpath = path.replace("classpath:", ""); ResourceIteratorFactory resourceIteratorFactory = new DelegatingResourceIteratorFactory(); try { Enumeration<URL> resources = classLoader.getResources(classpath); return enumerationStream(resources)...
ClasspathResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { String classpath = path.replace("classpath:", ""); ResourceIteratorFactory resourceIteratorFactory = new DelegatingResourceIteratorFactory(); try { Enumeration<URL> resources = classLoader.getResourc...
ClasspathResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { String classpath = path.replace("classpath:", ""); ResourceIteratorFactory resourceIteratorFactory = new DelegatingResourceIteratorFactory(); try { Enumeration<URL> resources = classLoader.getResourc...
ClasspathResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { String classpath = path.replace("classpath:", ""); ResourceIteratorFactory resourceIteratorFactory = new DelegatingResourceIteratorFactory(); try { Enumeration<URL> resources = classLoader.getResourc...
ClasspathResourceIndex implements ResourceIndex { @Override public Iterable<Resource> list(String path, String suffix) { String classpath = path.replace("classpath:", ""); ResourceIteratorFactory resourceIteratorFactory = new DelegatingResourceIteratorFactory(); try { Enumeration<URL> resources = classLoader.getResourc...
@Test public void nonExistentResourceThrowsExceptionWhenTryingToGetInputStream() throws IOException { FileResource resource = new FileResource("foobar"); Exception e = assertThrows(FileNotFoundException.class, () -> resource.inputStream()); assertThat(e.getMessage(), matchesPattern("foobar.*")); }
@Override public InputStream inputStream() throws IOException { return new FileInputStream(file); }
FileResource implements Resource { @Override public InputStream inputStream() throws IOException { return new FileInputStream(file); } }
FileResource implements Resource { @Override public InputStream inputStream() throws IOException { return new FileInputStream(file); } FileResource(File file); FileResource(File root, File file); FileResource(String path); }
FileResource implements Resource { @Override public InputStream inputStream() throws IOException { return new FileInputStream(file); } FileResource(File file); FileResource(File root, File file); FileResource(String path); @Override String path(); @Override URL url(); @Override String absolutePath(); @Override InputS...
FileResource implements Resource { @Override public InputStream inputStream() throws IOException { return new FileInputStream(file); } FileResource(File file); FileResource(File root, File file); FileResource(String path); @Override String path(); @Override URL url(); @Override String absolutePath(); @Override InputS...
@Test public void nonExistentResourceThrowsExceptionWhenTryingToGetURL() { ClasspathResource resource = new ClasspathResource("foobar", ClasspathResourceTest.class); Exception e = assertThrows(RuntimeException.class, () -> resource.url()); assertEquals("java.io.FileNotFoundException: foobar", e.getMessage()); }
@Override public URL url() { URL url = this.classLoader.getResource(this.path); if (url == null) { throw new RuntimeException(new FileNotFoundException(this.path)); } return url; }
ClasspathResource implements Resource { @Override public URL url() { URL url = this.classLoader.getResource(this.path); if (url == null) { throw new RuntimeException(new FileNotFoundException(this.path)); } return url; } }
ClasspathResource implements Resource { @Override public URL url() { URL url = this.classLoader.getResource(this.path); if (url == null) { throw new RuntimeException(new FileNotFoundException(this.path)); } return url; } ClasspathResource(String path, Class<?> clazz); ClasspathResource(String path, ClassLoader classLo...
ClasspathResource implements Resource { @Override public URL url() { URL url = this.classLoader.getResource(this.path); if (url == null) { throw new RuntimeException(new FileNotFoundException(this.path)); } return url; } ClasspathResource(String path, Class<?> clazz); ClasspathResource(String path, ClassLoader classLo...
ClasspathResource implements Resource { @Override public URL url() { URL url = this.classLoader.getResource(this.path); if (url == null) { throw new RuntimeException(new FileNotFoundException(this.path)); } return url; } ClasspathResource(String path, Class<?> clazz); ClasspathResource(String path, ClassLoader classLo...
@Test public void nonExistentResourceThrowsExceptionWhenTryingToGetInputStream() { ClasspathResource resource = new ClasspathResource("foobar", ClasspathResourceTest.class); Exception e = assertThrows(FileNotFoundException.class, () -> resource.inputStream()); assertEquals("classpath:foobar", e.getMessage()); }
@Override public InputStream inputStream() throws FileNotFoundException { InputStream stream = classLoader.getResourceAsStream(this.path); if (stream == null) { throw new FileNotFoundException(CLASSPATH_SCHEME + path); } return stream; }
ClasspathResource implements Resource { @Override public InputStream inputStream() throws FileNotFoundException { InputStream stream = classLoader.getResourceAsStream(this.path); if (stream == null) { throw new FileNotFoundException(CLASSPATH_SCHEME + path); } return stream; } }
ClasspathResource implements Resource { @Override public InputStream inputStream() throws FileNotFoundException { InputStream stream = classLoader.getResourceAsStream(this.path); if (stream == null) { throw new FileNotFoundException(CLASSPATH_SCHEME + path); } return stream; } ClasspathResource(String path, Class<?> cl...
ClasspathResource implements Resource { @Override public InputStream inputStream() throws FileNotFoundException { InputStream stream = classLoader.getResourceAsStream(this.path); if (stream == null) { throw new FileNotFoundException(CLASSPATH_SCHEME + path); } return stream; } ClasspathResource(String path, Class<?> cl...
ClasspathResource implements Resource { @Override public InputStream inputStream() throws FileNotFoundException { InputStream stream = classLoader.getResourceAsStream(this.path); if (stream == null) { throw new FileNotFoundException(CLASSPATH_SCHEME + path); } return stream; } ClasspathResource(String path, Class<?> cl...
@Test public void canAcquireClasspathResources() { Resource resource = ResourceFactory.newResource("classpath:com/hotels/styx/common/io/resource.txt"); assertThat(resource, contains("This is an example resource.\nIt has content to use in automated tests.")); }
public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); }
ResourceFactory { public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); } }
ResourceFactory { public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); } }
ResourceFactory { public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); } static Resource newResource(String path, ClassLoader classLoader); static Resource newResource(String...
ResourceFactory { public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); } static Resource newResource(String path, ClassLoader classLoader); static Resource newResource(String...
@Test public void instantiatesClassWithZeroArgumentConstructor() { MyInterface instance = ClassFactories.newInstance(MyClass.class.getName(), MyInterface.class); assertThat(instance, is(instanceOf(MyClass.class))); }
public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException | IllegalAccessE...
ClassFactories { public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException...
ClassFactories { public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException...
ClassFactories { public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException...
ClassFactories { public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException...
@Test public void canAcquireFileResources() { String filePath = ResourceFactoryTest.class.getResource("/com/hotels/styx/common/io/resource.txt").getPath(); Resource resource = ResourceFactory.newResource(filePath); assertThat(resource, contains("This is an example resource.\nIt has content to use in automated tests."))...
public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); }
ResourceFactory { public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); } }
ResourceFactory { public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); } }
ResourceFactory { public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); } static Resource newResource(String path, ClassLoader classLoader); static Resource newResource(String...
ResourceFactory { public static Resource newResource(String path, ClassLoader classLoader) { if (path.startsWith(CLASSPATH_SCHEME)) { return new ClasspathResource(path, classLoader); } return new FileResource(path); } static Resource newResource(String path, ClassLoader classLoader); static Resource newResource(String...
@Test public void isNotEmptyString() { assertThat(checkNotEmpty(" "), is(" ") ); }
public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; }
Preconditions { public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; } }
Preconditions { public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; } private Preconditions(); }
Preconditions { public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; } private Preconditions(); static String checkNotEmpty(String value); static T checkArgument(T reference, boolean expression); static void checkArgument(b...
Preconditions { public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; } private Preconditions(); static String checkNotEmpty(String value); static T checkArgument(T reference, boolean expression); static void checkArgument(b...
@Test public void isEmptyString() { assertThrows(IllegalArgumentException.class, () -> checkNotEmpty(null)); }
public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; }
Preconditions { public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; } }
Preconditions { public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; } private Preconditions(); }
Preconditions { public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; } private Preconditions(); static String checkNotEmpty(String value); static T checkArgument(T reference, boolean expression); static void checkArgument(b...
Preconditions { public static String checkNotEmpty(String value) { if (value == null || value.length() == 0) { throw new IllegalArgumentException(); } return value; } private Preconditions(); static String checkNotEmpty(String value); static T checkArgument(T reference, boolean expression); static void checkArgument(b...
@Test public void checkArgumentFailure() { assertThrows(IllegalArgumentException.class, () -> checkArgument(0, false)); }
public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; }
Preconditions { public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; } }
Preconditions { public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; } private Preconditions(); }
Preconditions { public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; } private Preconditions(); static String checkNotEmpty(String value); static T checkArgument(T reference, boolean expression); static void checkArgument(bool...
Preconditions { public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; } private Preconditions(); static String checkNotEmpty(String value); static T checkArgument(T reference, boolean expression); static void checkArgument(bool...
@Test public void checkArgumentSuccess() { assertThat(checkArgument(0, true), is(0)); }
public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; }
Preconditions { public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; } }
Preconditions { public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; } private Preconditions(); }
Preconditions { public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; } private Preconditions(); static String checkNotEmpty(String value); static T checkArgument(T reference, boolean expression); static void checkArgument(bool...
Preconditions { public static <T> T checkArgument(T reference, boolean expression) { if (!expression) { throw new IllegalArgumentException(); } return reference; } private Preconditions(); static String checkNotEmpty(String value); static T checkArgument(T reference, boolean expression); static void checkArgument(bool...
@Test public void processesEvents() { QueueDrainingEventProcessor eventProcessor = new QueueDrainingEventProcessor((event) -> ((Consumer<Void>) event).accept(null)); Consumer<Void> event1 = mock(Consumer.class); eventProcessor.submit(event1); Consumer<Void> event2 = mock(Consumer.class); eventProcessor.submit(event2); ...
@Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}.", event, cause); } } } while (eventCount.decrementAndGe...
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
@Test public void processesQueuedEvents() { for (int i = 0; i < 1000; i++) { CyclicBarrier barrier1 = new CyclicBarrier(2); CyclicBarrier barrier2 = new CyclicBarrier(2); QueueDrainingEventProcessor eventProcessor = new QueueDrainingEventProcessor((event) -> ((Consumer<Void>) event).accept(null)); Consumer<Void> event1...
@Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}.", event, cause); } } } while (eventCount.decrementAndGe...
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
@Test public void handlesEventProcessorExceptions() throws Exception { for (int i = 0; i < 1000; i++) { CyclicBarrier barrier1 = new CyclicBarrier(2); CyclicBarrier barrier2 = new CyclicBarrier(2); CyclicBarrier barrier3 = new CyclicBarrier(2); QueueDrainingEventProcessor eventProcessor = new QueueDrainingEventProcesso...
@Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}.", event, cause); } } } while (eventCount.decrementAndGe...
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
QueueDrainingEventProcessor implements EventProcessor { @Override public void submit(Object event) { events.add(event); if (eventCount.getAndIncrement() == 0) { do { Object e = events.poll(); try { eventProcessor.submit(e); } catch (RuntimeException cause) { if (logErrors) { LOGGER.warn("Event {} threw an exception {}....
@Test public void shouldFormatHttpRequest() { String formattedRequest = sanitisedHttpMessageFormatter.formatRequest(httpRequest); assertThat(formattedRequest, matchesPattern(HTTP_REQUEST_PATTERN)); }
@Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); }
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); } }
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter s...
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter s...
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter s...
@Test public void shouldFormatLiveHttpRequest() { String formattedRequest = sanitisedHttpMessageFormatter.formatRequest(httpRequest.stream()); assertThat(formattedRequest, matchesPattern(HTTP_REQUEST_PATTERN)); }
@Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); }
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); } }
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter s...
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter s...
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatRequest(HttpRequest request) { return request == null ? NULL : formatRequest( request.version(), request.method(), request.url(), request.id(), request.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter s...
@Test public void throwsExceptionIfThereIsNoZeroArgumentConstructor() { Exception e = assertThrows(RuntimeException.class, () -> ClassFactories.newInstance(MyInvalidClass.class.getName(), MyInterface.class)); assertEquals("java.lang.InstantiationException: com.hotels.styx.proxy.ClassFactoriesTest$MyInvalidClass", e.get...
public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException | IllegalAccessE...
ClassFactories { public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException...
ClassFactories { public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException...
ClassFactories { public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException...
ClassFactories { public static <T> T newInstance(String className, Class<T> type) { try { Object instance = classForName(className).newInstance(); return type.cast(instance); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(format("No such class '%s'", className)); } catch (InstantiationException...
@Test public void shouldFormatHttpResponse() { String formattedResponse = sanitisedHttpMessageFormatter.formatResponse(httpResponse); assertThat(formattedResponse, matchesPattern(HTTP_RESPONSE_PATTERN)); }
@Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); }
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); } }
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter sanitisedHttpHeaderFor...
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter sanitisedHttpHeaderFor...
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter sanitisedHttpHeaderFor...
@Test public void shouldFormatLiveHttpResponse() { String formattedResponse = sanitisedHttpMessageFormatter.formatResponse(httpResponse.stream()); assertThat(formattedResponse, matchesPattern(HTTP_RESPONSE_PATTERN)); }
@Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); }
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); } }
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter sanitisedHttpHeaderFor...
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter sanitisedHttpHeaderFor...
SanitisedHttpMessageFormatter implements HttpMessageFormatter { @Override public String formatResponse(HttpResponse response) { return response == null ? NULL : formatResponse( response.version(), response.status(), response.headers()); } SanitisedHttpMessageFormatter(SanitisedHttpHeaderFormatter sanitisedHttpHeaderFor...
@Test public void formatShouldFormatRequest() { HttpHeaders headers = new HttpHeaders.Builder() .add("header1", "a") .add("header2", "b") .add("header3", "c") .add("header4", "d") .add("COOKIE", "cookie1=e;cookie2=f;") .add("SET-COOKIE", "cookie3=g;cookie4=h;") .build(); List<String> headersToHide = Arrays.asList("HEAD...
public String format(HttpHeaders headers) { return StreamSupport.stream(headers.spliterator(), false) .map(this::hideOrFormatHeader) .collect(joining(", ")); }
SanitisedHttpHeaderFormatter { public String format(HttpHeaders headers) { return StreamSupport.stream(headers.spliterator(), false) .map(this::hideOrFormatHeader) .collect(joining(", ")); } }
SanitisedHttpHeaderFormatter { public String format(HttpHeaders headers) { return StreamSupport.stream(headers.spliterator(), false) .map(this::hideOrFormatHeader) .collect(joining(", ")); } SanitisedHttpHeaderFormatter(List<String> headersToHide, List<String> cookiesToHide); }
SanitisedHttpHeaderFormatter { public String format(HttpHeaders headers) { return StreamSupport.stream(headers.spliterator(), false) .map(this::hideOrFormatHeader) .collect(joining(", ")); } SanitisedHttpHeaderFormatter(List<String> headersToHide, List<String> cookiesToHide); List<String> cookiesToHide(); String format...
SanitisedHttpHeaderFormatter { public String format(HttpHeaders headers) { return StreamSupport.stream(headers.spliterator(), false) .map(this::hideOrFormatHeader) .collect(joining(", ")); } SanitisedHttpHeaderFormatter(List<String> headersToHide, List<String> cookiesToHide); List<String> cookiesToHide(); String format...
@Test public void startsInInitialState() { StateMachine<State> stateMachine = stateMachineBuilder.build(); assertThat(stateMachine.currentState(), Matchers.is(STARTED)); }
public S currentState() { return currentState; }
StateMachine { public S currentState() { return currentState; } }
StateMachine { public S currentState() { return currentState; } private StateMachine(S initialState, Map<Key<S>, Function<Object, S>> transitions, BiFunction<S, Object, S> inappropriateEventHandler, StateChangeListener<S> stateChangeListener); }
StateMachine { public S currentState() { return currentState; } private StateMachine(S initialState, Map<Key<S>, Function<Object, S>> transitions, BiFunction<S, Object, S> inappropriateEventHandler, StateChangeListener<S> stateChangeListener); S currentState(); void handle(Object event, String loggingPrefi...
StateMachine { public S currentState() { return currentState; } private StateMachine(S initialState, Map<Key<S>, Function<Object, S>> transitions, BiFunction<S, Object, S> inappropriateEventHandler, StateChangeListener<S> stateChangeListener); S currentState(); void handle(Object event, String loggingPrefi...
@Test public void contentEventInBufferingState() { setUpAndRequest(5); verify(askForMore).run(); producer.newChunk(contentChunk1); verify(askForMore, times(1)).run(); producer.newChunk(contentChunk2); verify(askForMore, times(1)).run(); }
public void newChunk(ByteBuf content) { stateMachine.handle(new ContentChunkEvent(content)); }
FlowControllingHttpContentProducer { public void newChunk(ByteBuf content) { stateMachine.handle(new ContentChunkEvent(content)); } }
FlowControllingHttpContentProducer { public void newChunk(ByteBuf content) { stateMachine.handle(new ContentChunkEvent(content)); } FlowControllingHttpContentProducer( Runnable askForMore, Runnable onCompleteAction, Consumer<Throwable> onTerminateAction, String loggingPre...
FlowControllingHttpContentProducer { public void newChunk(ByteBuf content) { stateMachine.handle(new ContentChunkEvent(content)); } FlowControllingHttpContentProducer( Runnable askForMore, Runnable onCompleteAction, Consumer<Throwable> onTerminateAction, String loggingPre...
FlowControllingHttpContentProducer { public void newChunk(ByteBuf content) { stateMachine.handle(new ContentChunkEvent(content)); } FlowControllingHttpContentProducer( Runnable askForMore, Runnable onCompleteAction, Consumer<Throwable> onTerminateAction, String loggingPre...
@Test public void sanitiseRemovesNewlines() throws Exception { assertThat(Logging.sanitise("first line\nsecond line"), is("first line\\nsecond line")); }
public static String sanitise(String input) { return input.replaceAll("\\n", "\\\\n"); }
Logging { public static String sanitise(String input) { return input.replaceAll("\\n", "\\\\n"); } }
Logging { public static String sanitise(String input) { return input.replaceAll("\\n", "\\\\n"); } private Logging(); }
Logging { public static String sanitise(String input) { return input.replaceAll("\\n", "\\\\n"); } private Logging(); static String sanitise(String input); }
Logging { public static String sanitise(String input) { return input.replaceAll("\\n", "\\\\n"); } private Logging(); static String sanitise(String input); }
@Test public void matchesRequestPath() { Condition condition = condition("path() == '/some-request'"); assertThat(condition.evaluate(newRequest("/some-request").build(), context), is(true)); }
@Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); }
AntlrCondition implements Condition { @Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); } }
AntlrCondition implements Condition { @Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); } AntlrCondition(Expression<Boolean> expression); }
AntlrCondition implements Condition { @Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); } AntlrCondition(Expression<Boolean> expression); @Override boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context); }
AntlrCondition implements Condition { @Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); } AntlrCondition(Expression<Boolean> expression); @Override boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context); }