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 notMatchingRequestPath() { Condition condition = condition("path() == '/some-request'"); assertThat(condition.evaluate(newRequest("/random-request").build(), context), is(false)); } | @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); } |
@Test public void matchesHttpHeader() { Condition condition = condition("header('Host') == 'bbc.co.uk'"); LiveHttpRequest request = newRequest("/path") .header(HOST, "bbc.co.uk") .build(); assertThat(condition.evaluate(request, context), is(true)); LiveHttpRequest request2 = newRequest("/path") .header(HOST, "hotels.co... | @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); } |
@Test public void acceptsDoubleQuotesAsRegexp() throws Exception { assertThat( condition("path() =~ \"/shop/.*\"").evaluate(newRequest("/shop/x").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); } |
@Test public void throwsExceptionIfClassDoesNotExtendType() { Exception e = assertThrows(ClassCastException.class, () -> ClassFactories.newInstance(MyClass.class.getName(), Runnable.class)); assertEquals("Cannot cast com.hotels.styx.proxy.ClassFactoriesTest$MyClass to java.lang.Runnable", e.getMessage()); } | 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 acceptsSingleQuotesAsRegexp() throws Exception { assertThat( condition("path() =~ '/shop/.*'").evaluate(newRequest("/shop/x").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); } |
@Test public void acceptsSingleQuotesAsFunctionArgument() throws Exception { Condition condition = condition("header('Host') =~ '.*\\.co\\.uk'"); LiveHttpRequest request = newRequest() .header(HOST, "bbc.co.uk") .build(); assertThat(condition.evaluate(request, 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); } |
@Test public void acceptsDoubleQuotesAsFunctionArgument() throws Exception { Condition condition = condition("header(\"Host\") =~ '.*\\.co\\.uk'"); LiveHttpRequest request = newRequest() .header(HOST, "bbc.co.uk") .build(); assertThat(condition.evaluate(request, 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); } |
@Test public void acceptsSingleQuotesAsRightHandSide() throws Exception { assertThat( condition("path() =~ '/shop/.*'").evaluate(newRequest("/shop/x").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); } |
@Test public void acceptsDoubleQuotesAsRightHandSide() throws Exception { assertThat( condition("path() =~ \"^/shop/.*\"").evaluate(newRequest("/shop/x").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); } |
@Test public void matchesHeaderPresence() { Condition condition = condition("header('Host')"); LiveHttpRequest request = newRequest("/foo") .header(HOST, "bbc.co.uk") .build(); assertThat(condition.evaluate(request, context), is(true)); LiveHttpRequest request2 = newRequest("/foo") .build(); assertThat(condition.evalua... | @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); } |
@Test public void regexpMatchesHttpHeader() { Condition condition = condition("header('Host') =~ '.*\\.co\\.uk'"); LiveHttpRequest request = newRequest() .header(HOST, "bbc.co.uk") .build(); assertThat(condition.evaluate(request, context), is(true)); LiveHttpRequest request2 = request.newBuilder() .header(HOST, "hotels... | @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); } |
@Test public void pathPrefixReges() { Condition condition = condition("path() =~ '.foo.*'"); assertThat( condition.evaluate(get("/foo/bar").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); } |
@Test public void matchesAndExpressions() { Condition condition = condition("header('Host') == 'bbc.co.uk' AND header('Content-Length') == '7'"); LiveHttpRequest request = newRequest() .header(HOST, "bbc.co.uk") .header(CONTENT_LENGTH, "7") .build(); assertThat(condition.evaluate(request, context), is(true)); LiveHttpR... | @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); } |
@Test public void combinesStringEqualsAndStringRegexpMatchOperationsWithAndOperator() { Condition condition = condition("header('Host') == 'bbc.co.uk' AND header('Content-Length') =~ '[123][0-9]'"); LiveHttpRequest request = newRequest() .header(HOST, "bbc.co.uk") .header(CONTENT_LENGTH, "20") .build(); assertThat(cond... | @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); } |
@Test public void throwsExceptionIfClassDoesNotExist() { Exception e = assertThrows(IllegalArgumentException.class, () -> ClassFactories.newInstance(MyClass.class.getName() + "NonExistent", Runnable.class)); assertEquals("No such class 'com.hotels.styx.proxy.ClassFactoriesTest$MyClassNonExistent'", e.getMessage()); } | 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 retryUpToMaxTimesForIoException() throws IOException { doThrow(new IOException("Could not connect")).when(task).run(); try { tryTimes(3, task, (e) -> assertThat(e, is(instanceOf(IOException.class)))); fail("An exception should have been thrown"); } catch (UncheckedIOException e) { assertThat(e.getMess... | 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 matchesCompositionOfExpressionsWithEnd() { Condition condition = condition( "header('Host') == 'bbc.co.uk' AND header('Content-Length') == '7' AND header('App-Name')=='app1'"); LiveHttpRequest request = newRequest() .header(HOST, "bbc.co.uk") .header(CONTENT_LENGTH, "7") .header("App-Name", "app1") .b... | @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); } |
@Test public void matchesOrExpressions() { Condition condition = condition("header('Host') == 'bbc.co.uk' OR header('Content-Length') == '7'"); LiveHttpRequest request = newRequest() .header(HOST, "bbc.co.uk") .build(); assertThat(condition.evaluate(request, context), is(true)); LiveHttpRequest request2 = newRequest() ... | @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); } |
@Test public void andExpressionsHasHigherPrecedenceThanOrExpression() { Condition condition = condition("header('Host') == 'bbc.co.uk' " + "AND header('Content-Length') == '7' " + "OR header('App-Name') =~ 'app[0-9]'"); LiveHttpRequest request = newRequest() .header("App-Name", "app5") .build(); assertThat(condition.ev... | @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); } |
@Test public void andExpressionsHasHigherPrecedenceThanOrExpressionOrBeforeAnd() { Condition condition = condition("header('App-Name') =~ 'app[0-9]' " + "OR header('Host') == 'bbc.co.uk' " + "AND header('Content-Length') == '7'"); LiveHttpRequest request = newRequest() .header("App-Name", "app5") .build(); assertThat(c... | @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); } |
@Test public void notExpressionNegatesTheExpressionResult() { Condition condition = condition("NOT header('Host')"); LiveHttpRequest request1 = newRequest() .header(HOST, "bbc.co.uk") .build(); assertThat(condition.evaluate(request1, context), is(false)); LiveHttpRequest request2 = newRequest() .header(CONTENT_LENGTH, ... | @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); } |
@Test public void parenthesisChangesOperatorPrecedence() { Condition condition = condition("header('Host') " + "AND (header('App-Name') =~ 'app[0-9]' OR header('App-Name') =~ 'shop[0-9]')"); LiveHttpRequest request1 = newRequest() .header(HOST, "bbc.co.uk") .header("App-Name", "app1") .build(); assertThat(condition.eva... | @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); } |
@Test public void notExpressionHasHigherPrecedenceThanAndExpression() { Condition condition = condition("header('Host') " + "AND NOT header('App-Name') =~ 'app[0-9]' OR header('App-Name') =~ 'shop[0-9]'"); LiveHttpRequest request1 = newRequest() .header(HOST, "bbc.co.uk") .header("App-Name", "landing1") .build(); asser... | @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); } |
@Test public void cookieValueIsPresent() { Condition condition = condition("cookie('TheCookie')"); LiveHttpRequest request = newRequest() .cookies(requestCookie("TheCookie", "foobar-foobar-baz")) .header("App-Name", "app3") .build(); assertThat(condition.evaluate(request, context), is(true)); request = newRequest() .co... | @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); } |
@Test public void cookieValueMatchesWithString() { Condition condition = condition("cookie('TheCookie') == 'foobar-foobar-baz'"); LiveHttpRequest request = newRequest() .cookies(requestCookie("TheCookie", "foobar-foobar-baz")) .header("App-Name", "app3") .build(); assertThat(condition.evaluate(request, context), is(tru... | @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); } |
@Test public void cookieValueMatchesWithRegexp() { Condition condition = condition("cookie('TheCookie') =~ 'foobar-.*-baz'"); LiveHttpRequest request = newRequest() .cookies(requestCookie("TheCookie", "foobar-foobar-baz")) .header("App-Name", "app3") .build(); assertThat(condition.evaluate(request, 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); } |
@Test public void loadsUnwiseCharsToEncodeFromConfigurations() { ConfigurableUnwiseCharsEncoder encoder = newUnwiseCharsEncoder("|,},{"); assertThat(encoder.encode("|}{"), is("%7C%7D%7B")); } | @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... |
@Test public void methodMatchesString() { Condition condition = condition("method() == 'GET'"); LiveHttpRequest request = get("/blah") .build(); assertThat(condition.evaluate(request, context), is(true)); request = post("/blah") .build(); assertThat(condition.evaluate(request, context), is(false)); } | @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); } |
@Test public void userAgentMatchesUserAgent() { Condition condition = condition("userAgent() == 'Mozilla Firefox 1.1.2' OR userAgent() =~ 'Safari.*'"); LiveHttpRequest request = get("/blah") .header(USER_AGENT, "Mozilla Firefox 1.1.2") .build(); assertThat(condition.evaluate(request, context), is(true)); request = get(... | @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); } |
@Test public void resolvesZeroArgumentFunctions() { LiveHttpRequest request = get("/foo").build(); assertThat(functionResolver.resolveFunction("path", emptyList()).call(request, context), is("/foo")); assertThat(functionResolver.resolveFunction("method", emptyList()).call(request, context), is("GET")); } | PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d] arguments=[%s]", n... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... |
@Test public void throwsExceptionIfZeroArgumentFunctionDoesNotExist() { LiveHttpRequest request = get("/foo").build(); Exception e = assertThrows(DslFunctionResolutionError.class, () -> functionResolver.resolveFunction("foobar", emptyList()).call(request, context)); assertThat(e.getMessage(), matchesPattern("No such fu... | PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d] arguments=[%s]", n... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... |
@Test public void resolvesOneArgumentFunctions() { LiveHttpRequest request = get("/foo") .header("Host", "www.hotels.com") .cookies(requestCookie("lang", "en_US|en-us_hotels_com")) .build(); assertThat(functionResolver.resolveFunction("header", singletonList("Host")).call(request, context), is("www.hotels.com")); asser... | PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d] arguments=[%s]", n... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... |
@Test public void throwsExceptionIfOneArgumentFunctionDoesNotExist() { LiveHttpRequest request = get("/foo") .header("Host", "www.hotels.com") .cookies(requestCookie("lang", "en_US|en-us_hotels_com")) .build(); Exception e = assertThrows(DslFunctionResolutionError.class, () -> functionResolver.resolveFunction("foobar",... | PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d] arguments=[%s]", n... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... | FunctionResolver { PartialFunction resolveFunction(String name, List<String> arguments) { int argumentSize = arguments.size(); String argumentsRepresentation = join(", ", arguments); switch (argumentSize) { case 0: Function0 function0 = ensureNotNull( zeroArgumentFunctions.get(name), "No such function=[%s], with n=[%d]... |
@Test public void sanitisesHeadersInBadRequestException() throws Throwable { FullHttpRequest originalRequest = newHttpRequest("/uri"); HttpHeaders originalRequestHeaders = originalRequest.headers(); originalRequestHeaders.add("Foo", "foo"); originalRequestHeaders.add("secret-header", "secret"); originalRequestHeaders.a... | @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadRequestException("Error while decoding request: " + formattedHttpObject, httpM... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... |
@Test public void decodesNettyInternalRequestToStyxRequest() throws Exception { FullHttpRequest originalRequest = newHttpRequest("/uri"); HttpHeaders originalRequestHeaders = originalRequest.headers(); originalRequestHeaders.add("Foo", "Bar"); originalRequestHeaders.add("Bar", "Bar"); originalRequestHeaders.add("Host",... | @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadRequestException("Error while decoding request: " + formattedHttpObject, httpM... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... |
@Test public void removesExpectHeaderBeforePassingThroughTheRequest() throws Exception { FullHttpRequest originalRequest = newHttpRequest("/uri"); originalRequest.headers().set(EXPECT, CONTINUE); originalRequest.headers().set(HOST, "foo.com"); LiveHttpRequest styxRequest = decode(originalRequest); assertThat(styxReques... | @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadRequestException("Error while decoding request: " + formattedHttpObject, httpM... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... |
@Test public void overridesTheHostHeaderWithTheHostAndPortInTheAbsoluteURI() { HttpRequest request = newHttpRequest(URI.create("http: request.headers().set(HOST, "www.example.com:8000"); LiveHttpRequest styxRequest = decode(request); assertThat(styxRequest.headers().get(HOST).get(), is("example.net")); } | @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadRequestException("Error while decoding request: " + formattedHttpObject, httpM... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @Override protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception { if (msg.getDecoderResult().isFailure()) { String formattedHttpObject = httpMessageFormatter.formatNettyMessage(msg); throw new BadReques... |
@Test public void shouldHandleEmptyUnwiseChars() { ConfigurableUnwiseCharsEncoder encoder = newUnwiseCharsEncoder(""); assertThat(encoder.encode("|}{"), is("|}{")); } | @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... |
@Test public void canHandleNettyCookies() { HttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "http: request.headers().set(HOST, "http: request.headers().set("Cookie", "ABC01=\"1\"; ABC02=1; guid=xxxxx-xxx-xxx-xxx-xxxxxxx"); NettyToStyxRequestDecoder decoder = new NettyToStyxRequestDecoder.Builder() .uniq... | @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .method(toStyxMethod(request.method())) .url(url) .version(toStyxVersion(re... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .me... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .me... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .me... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .me... |
@Test public void acceptsMalformedCookiesWithRelaxedValidation() { HttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "http: request.headers().set(HOST, "http: request.headers().set("Cookie", "ABC01=\"1\"; ABC02=1; guid=a,b"); NettyToStyxRequestDecoder decoder = new NettyToStyxRequestDecoder.Builder() .uni... | @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .method(toStyxMethod(request.method())) .url(url) .version(toStyxVersion(re... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .me... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .me... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .me... | NettyToStyxRequestDecoder extends MessageToMessageDecoder<HttpObject> { @VisibleForTesting LiveHttpRequest.Builder makeAStyxRequestFrom(HttpRequest request, Publisher<Buffer> content) { Url url = UrlDecoder.decodeUrl(unwiseCharEncoder, request); LiveHttpRequest.Builder requestBuilder = new LiveHttpRequest.Builder() .me... |
@Test public void decodesOriginForm() { DefaultFullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/foo"); request.headers().add(HOST, "example.com"); Url url = UrlDecoder.decodeUrl(x -> x, request); assertThat(url.authority(), is(Optional.empty())); assertThat(url.path(), is("/foo")); assertThat(url.e... | static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragment()) .build(... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... |
@Test public void exposesPathComponentsWithDoubleSlashSeparators() { DefaultFullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, " request.headers().add(HOST, "example.com"); Url url = UrlDecoder.decodeUrl(x -> x, request); assertThat(url.authority(), is(Optional.empty())); assertThat(url.path(), is(" as... | static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragment()) .build(... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... |
@Test public void decodesOriginFormWithUppercaseHostHeader() { DefaultFullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/foo"); request.headers().add("HOST", "example.com"); Url url = UrlDecoder.decodeUrl(x -> x, request); assertThat(url.authority(), is(Optional.empty())); assertThat(url.path(), is("... | static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragment()) .build(... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... |
@Test public void decodesAbsoluteForm() { DefaultFullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "http: Url url = UrlDecoder.decodeUrl(x -> x, request); assertThat(url.authority().isPresent(), is(true)); assertThat(url.path(), is("/foo")); assertThat(url.encodedUri(), is("http: assertThat(url.isAbso... | static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragment()) .build(... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... | UrlDecoder { static Url decodeUrl(UnwiseCharsEncoder unwiseCharEncoder, HttpRequest request) { String host = request.headers().get(HOST); if (request.uri().startsWith("/") && host != null) { URI uri = URI.create("http: return new Url.Builder() .path(uri.getRawPath()) .rawQuery(uri.getRawQuery()) .fragment(uri.getFragme... |
@Test public void countsReceivedBytes() throws Exception { ByteBuf buf = httpRequestAsBuf(POST, "/foo/bar", "Hello, world"); this.handler.channelRead(mock(ChannelHandlerContext.class), buf); assertThat(countOf("connections.bytes-received"), is((long) buf.readableBytes())); } | @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof ByteBuf) { receivedBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { receivedBytesCount.inc(((ByteBufHolder) msg).content().readableBytes()); } else { LOGGER.warn(form... | ChannelStatisticsHandler extends ChannelDuplexHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof ByteBuf) { receivedBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { receivedBytesCount.inc(((ByteBufHolder) ms... | ChannelStatisticsHandler extends ChannelDuplexHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof ByteBuf) { receivedBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { receivedBytesCount.inc(((ByteBufHolder) ms... | ChannelStatisticsHandler extends ChannelDuplexHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof ByteBuf) { receivedBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { receivedBytesCount.inc(((ByteBufHolder) ms... | ChannelStatisticsHandler extends ChannelDuplexHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof ByteBuf) { receivedBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { receivedBytesCount.inc(((ByteBufHolder) ms... |
@Test public void countsSentBytes() throws Exception { ByteBuf buf = httpResponseAsBuf(OK, "Response from server"); this.handler.write(mock(ChannelHandlerContext.class), buf, mock(ChannelPromise.class)); assertThat(countOf("connections.bytes-sent"), is((long) buf.readableBytes())); } | @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { sentBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { sentBytesCount.inc(((ByteBufHolder) msg).content().readableBytes()); } super.write(c... | ChannelStatisticsHandler extends ChannelDuplexHandler { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { sentBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { sentBytesCount.inc(((ByteBuf... | ChannelStatisticsHandler extends ChannelDuplexHandler { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { sentBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { sentBytesCount.inc(((ByteBuf... | ChannelStatisticsHandler extends ChannelDuplexHandler { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { sentBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { sentBytesCount.inc(((ByteBuf... | ChannelStatisticsHandler extends ChannelDuplexHandler { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBuf) { sentBytesCount.inc(((ByteBuf) msg).readableBytes()); } else if (msg instanceof ByteBufHolder) { sentBytesCount.inc(((ByteBuf... |
@Test public void mapsUnrecoverableInternalErrorsToInternalServerError500ResponseCode() { HttpHandler handler = (request, context) -> { throw new RuntimeException("Forced exception for testing"); }; EmbeddedChannel channel = buildEmbeddedChannel(handlerWithMocks(handler)); channel.writeInbound(httpRequestAsBuf(GET, "ht... | private static HttpResponseStatus status(Throwable exception) { return EXCEPTION_STATUSES.statusFor(exception) .orElseGet(() -> { if (exception instanceof DecoderException) { Throwable cause = exception.getCause(); if (cause instanceof BadRequestException) { if (cause.getCause() instanceof TooLongFrameException) { retu... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { private static HttpResponseStatus status(Throwable exception) { return EXCEPTION_STATUSES.statusFor(exception) .orElseGet(() -> { if (exception instanceof DecoderException) { Throwable cause = exception.getCause(); if (cause instanceof BadReques... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { private static HttpResponseStatus status(Throwable exception) { return EXCEPTION_STATUSES.statusFor(exception) .orElseGet(() -> { if (exception instanceof DecoderException) { Throwable cause = exception.getCause(); if (cause instanceof BadReques... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { private static HttpResponseStatus status(Throwable exception) { return EXCEPTION_STATUSES.statusFor(exception) .orElseGet(() -> { if (exception instanceof DecoderException) { Throwable cause = exception.getCause(); if (cause instanceof BadReques... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { private static HttpResponseStatus status(Throwable exception) { return EXCEPTION_STATUSES.statusFor(exception) .orElseGet(() -> { if (exception instanceof DecoderException) { Throwable cause = exception.getCause(); if (cause instanceof BadReques... |
@Test public void requestTimeoutExceptionOccursInAcceptingRequestsStateAndTcpConnectionRemainsActive() throws Exception { RuntimeException cause = new RequestTimeoutException("timeout occurred"); handler.exceptionCaught(ctx, cause); verify(errorListener).proxyErrorOccurred(REQUEST_TIMEOUT, cause); verify(responseEnhanc... | @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... |
@Test public void shouldEncodeUnwiseCharsMixedWithOtherChars() { ConfigurableUnwiseCharsEncoder encoder = newUnwiseCharsEncoder("|,{,}"); 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... | @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... |
@Test public void tooLongFrameExceptionOccursInIdleStateAndTcpConnectionRemainsActive() throws Exception { setupHandlerTo(WAITING_FOR_RESPONSE); RuntimeException cause = new DecoderException("timeout occurred", new BadRequestException("bad request", new TooLongFrameException("too long frame"))); handler.exceptionCaught... | @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... |
@Test public void badRequestExceptionExceptionOccursInIdleStateAndTcpConnectionRemainsActive() throws Exception { setupHandlerTo(WAITING_FOR_RESPONSE); RuntimeException cause = new DecoderException("timeout occurred", new BadRequestException("bad request", new RuntimeException("random bad request failure"))); handler.e... | @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... |
@Test public void responseObservableEmitsErrorInWaitingForResponseState() throws Exception { setupHandlerTo(WAITING_FOR_RESPONSE); responseObservable.onError(new RuntimeException("Request Send Error")); assertThat(responseUnsubscribed.get(), is(true)); writerFuture.complete(null); verify(statsCollector).onComplete(requ... | @VisibleForTesting State state() { return this.stateMachine.currentState(); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActive(ChannelHandlerContext ctx); @Override void channelInactive(ChannelH... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActive(ChannelHandlerContext ctx); @Override void channelInactive(ChannelH... |
@Test public void requestTimeoutExceptionOccursInWaitingForResponseStateAndTcpConnectionRemainsActive() throws Exception { setupHandlerTo(WAITING_FOR_RESPONSE); RuntimeException cause = new RequestTimeoutException("timeout occurred"); handler.exceptionCaught(ctx, cause); verify(errorListener).proxyErrorOccurred(REQUEST... | @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... |
@Test public void tooLongFrameExceptionOccursInWaitingForResponseStateAndTcpConnectionRemainsActive() throws Exception { setupHandlerTo(WAITING_FOR_RESPONSE); RuntimeException cause = new DecoderException("timeout occurred", new BadRequestException("bad request", new TooLongFrameException("too long frame"))); handler.e... | @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... |
@Test public void badRequestExceptionExceptionOccursInWaitingForResponseStateAndTcpConnectionRemainsActive() throws Exception { setupHandlerTo(WAITING_FOR_RESPONSE); RuntimeException cause = new DecoderException("timeout occurred", new BadRequestException("bad request", new RuntimeException("random bad request failure"... | @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { eventProcessor.submit(new ChannelExceptionEvent(ctx, cause)); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActi... |
@Test public void responseObservableEmitsErrorInSendingResponseState() throws Exception { setupHandlerTo(SENDING_RESPONSE); responseObservable.onError(new RuntimeException("Spurious error occurred")); assertThat(handler.state(), is(SENDING_RESPONSE)); verify(errorListener).proxyingFailure(any(LiveHttpRequest.class), an... | @VisibleForTesting State state() { return this.stateMachine.currentState(); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActive(ChannelHandlerContext ctx); @Override void channelInactive(ChannelH... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActive(ChannelHandlerContext ctx); @Override void channelInactive(ChannelH... |
@Test public void responseWriteFailsInSendingResponseState() throws Exception { RuntimeException cause = new RuntimeException("Response write failed"); setupHandlerTo(SENDING_RESPONSE); writerFuture.completeExceptionally(cause); assertThat(responseUnsubscribed.get(), is(true)); verify(statsCollector).onTerminate(reques... | @VisibleForTesting State state() { return this.stateMachine.currentState(); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); } | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActive(ChannelHandlerContext ctx); @Override void channelInactive(ChannelH... | HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActive(ChannelHandlerContext ctx); @Override void channelInactive(ChannelH... |
@Test public void completesFutureOnlyAfterContentObservableIsCompleted() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new SimpleChannelInboundHandler<LiveHttpResponse>() { @Override protected void channelRead0(ChannelHandlerContext ctx, LiveHttpResponse response) throws Exception { HttpResponseWriter wr... | public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to send response headers. W... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... |
@Test public void completesFutureOnlyAfterAllWritesAreSuccessfullyCompleted() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new CaptureChannelArgumentsHandler(channelArgs), new LoggingHandler(), new SimpleChannelInboundHandler<LiveHttpResponse>() { @Override protected void channelRead0(ChannelHandlerCont... | public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to send response headers. W... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... |
@Test public void shouldLogErrorMessageInCaseOfEncodingUnwiseChars() throws Exception { Logger logger = mock(Logger.class); ConfigurableUnwiseCharsEncoder encoder = new ConfigurableUnwiseCharsEncoder(newStyxConfig("|"), logger); assertThat(encoder.encode("|}{"), is("%7C}{")); verify(logger).warn("Value contains unwise ... | @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... |
@Test public void ignoresLastEmptyHttpContentWriteOutcome() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new CaptureChannelArgumentsHandler(channelArgs), new LoggingHandler(), new SimpleChannelInboundHandler<LiveHttpResponse>() { @Override protected void channelRead0(ChannelHandlerContext ctx, LiveHttpR... | public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to send response headers. W... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... |
@Test public void failsTheResultWhenResponseWriteFails() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new CaptureChannelArgumentsHandler(channelArgs), new SimpleChannelInboundHandler<LiveHttpResponse>() { @Override protected void channelRead0(ChannelHandlerContext ctx, LiveHttpResponse response) throws ... | public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to send response headers. W... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... |
@Test public void failsTheResultWhenContentWriteFails() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new CaptureChannelArgumentsHandler(channelArgs), new SimpleChannelInboundHandler<LiveHttpResponse>() { @Override protected void channelRead0(ChannelHandlerContext ctx, LiveHttpResponse response) throws E... | public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to send response headers. W... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... |
@Test public void sendsEmptyLastHttpContentWhenContentObservableCompletes() throws Exception { CaptureHttpResponseWriteEventsHandler writeEventsCollector = new CaptureHttpResponseWriteEventsHandler(); EmbeddedChannel ch = new EmbeddedChannel( new CaptureChannelArgumentsHandler(channelArgs), writeEventsCollector, new Si... | public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to send response headers. W... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... |
@Test public void unsubscribesFromContentWhenCancelled() throws Exception { CaptureHttpResponseWriteEventsHandler writeEventsCollector = new CaptureHttpResponseWriteEventsHandler(); AtomicBoolean unsubscribed = new AtomicBoolean(false); EmbeddedChannel ch = new EmbeddedChannel( new CaptureChannelArgumentsHandler(channe... | public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to send response headers. W... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... |
@Test public void releasesContentChunksWhenFailsToConvertToNettyHeaders() throws Exception { CaptureHttpResponseWriteEventsHandler writeEventsCollector = new CaptureHttpResponseWriteEventsHandler(); Buffer chunk1 = new Buffer("aaa", UTF_8); Buffer chunk2 = new Buffer("aaa", UTF_8); AtomicBoolean unsubscribed = new Atom... | public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to send response headers. W... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... |
@Test public void logsSentAndAcknowledgedBytes() { EmbeddedChannel ch = new EmbeddedChannel( new SimpleChannelInboundHandler<LiveHttpResponse>() { @Override protected void channelRead0(ChannelHandlerContext ctx, LiveHttpResponse response) throws Exception { HttpResponseWriter writer = new HttpResponseWriter(ctx); Compl... | public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to send response headers. W... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... | HttpResponseWriter { public CompletableFuture<Void> write(LiveHttpResponse response) { CompletableFuture<Void> future = new CompletableFuture<>(); try { writeHeaders(response).addListener((ChannelFutureListener) writeOp -> { if (writeOp.isSuccess()) { writeOpsAcked.incrementAndGet(); } else { LOGGER.warn("Unable to sen... |
@Test public void shouldCreateNettyResponseWithoutHeaders() throws Exception { LiveHttpResponse styxResponse = new LiveHttpResponse.Builder(OK) .version(HTTP_1_1) .build(); io.netty.handler.codec.http.HttpResponse nettyResponse = translator.toNettyResponse(styxResponse); assertThat(nettyResponse.status(), equalTo(io.ne... | public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); DefaultHttpResponse nettyResponse = new DefaultHttpResponse(ver... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... |
@Test public void shouldCreateNettyResponseWithHostHeader() { LiveHttpResponse styxResponse = new LiveHttpResponse.Builder(OK) .header("Host", "localhost") .build(); io.netty.handler.codec.http.HttpResponse nettyResponse = translator.toNettyResponse(styxResponse); assertTrue(nettyResponse.headers().containsValue("Host"... | public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); DefaultHttpResponse nettyResponse = new DefaultHttpResponse(ver... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... |
@Test public void shouldCreateNettyResponseWithCookieWithAttributes() { ResponseCookie cookie = responseCookie("cookie-test", "cookie-value") .domain("cookie-domain") .path("cookie-path") .maxAge(1234) .httpOnly(true) .secure(true) .build(); LiveHttpResponse styxResponse = new LiveHttpResponse.Builder(OK) .cookies(cook... | public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); DefaultHttpResponse nettyResponse = new DefaultHttpResponse(ver... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... | StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); D... |
@Test public void shouldNotLogIfNotEncoding() throws Exception { Logger logger = mock(Logger.class); ConfigurableUnwiseCharsEncoder encoder = new ConfigurableUnwiseCharsEncoder(newStyxConfig(""), logger); assertThat(encoder.encode("|}{"), is("|}{")); verifyZeroInteractions(logger); } | @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } } | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... | ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } Configur... |
@Test public void returnsEmptyIfNoStatusMatches() { assertThat(mapper.statusFor(new UnmappedException()), isAbsent()); } | Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (matchingStatuses.size() >... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... |
@Test public void retrievesStatus() { assertThat(mapper.statusFor(new Exception1()), isValue(REQUEST_TIMEOUT)); } | Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (matchingStatuses.size() >... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... |
@Test public void exceptionMayNotBeMappedToMultipleExceptions() { ExceptionStatusMapper mapper = new ExceptionStatusMapper.Builder() .add(BAD_GATEWAY, Exception1.class) .add(GATEWAY_TIMEOUT, DoubleMappedException.class) .build(); LoggingTestSupport support = new LoggingTestSupport(ExceptionStatusMapper.class); Optional... | Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (matchingStatuses.size() >... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... | ExceptionStatusMapper { Optional<HttpResponseStatus> statusFor(Throwable throwable) { List<HttpResponseStatus> matchingStatuses = this.multimap.entries().stream() .filter(entry -> entry.getValue().isInstance(throwable)) .sorted(comparing(entry -> entry.getKey().code())) .map(Map.Entry::getKey) .collect(toList()); if (m... |
@Test public void should404ForMissingFiles() { assertThat(handle(get("/index.html").build()), hasStatus(NOT_FOUND)); assertThat(handle(get("/notfound.html").build()), hasStatus(NOT_FOUND)); assertThat(handle(get("/foo/bar").build()), hasStatus(NOT_FOUND)); } | @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(resolvedFile.content, UTF_8) .build() .strea... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... |
@Test public void shouldServeExistingFiles() throws Exception { writeFile("index.html", "Hello world"); writeFile("foo.js", "Blah"); mkdir("/a/b"); writeFile("a/b/good", "hi"); assertThat("asking for /index.html", handle(get("/index.html").build()), hasStatus(OK)); assertThat(handle(get("/foo.js").build()), hasStatus(O... | @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(resolvedFile.content, UTF_8) .build() .strea... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... |
@Test public void shouldIgnoreQueryParams() throws Exception { writeFile("index.html", "Hello world"); writeFile("foo.js", "Blah"); mkdir("/a/b"); writeFile("a/b/good", "hi"); assertThat(handle(get("/index.html?foo=x").build()), hasStatus(OK)); assertThat(handle(get("/foo.js?sdfsd").build()), hasStatus(OK)); assertThat... | @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(resolvedFile.content, UTF_8) .build() .strea... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... |
@Test public void shouldDisallowDirectoryTraversals() throws Exception { mkdir("/a/public"); writeFile("a/public/index.html", "hi"); mkdir("/a/private"); writeFile("a/private/index.html", "hi"); handler = new StaticFileHandler(new File(dir, "/a/public")); assertThat(handle(get("/index.html").build()), hasStatus(OK)); a... | @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(resolvedFile.content, UTF_8) .build() .strea... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... |
@Test public void shouldDisallowDirectoryTraversalsWithEncodedRequests() throws Exception { mkdir("/a/public"); writeFile("a/public/index.html", "hi"); mkdir("/a/private"); writeFile("a/private/index.html", "hi"); handler = new StaticFileHandler(new File(dir, "/a/public")); assertThat(handle(get("/index.html").build())... | @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(resolvedFile.content, UTF_8) .build() .strea... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... | StaticFileHandler implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { try { return resolveFile(request.path()) .map(ResolvedFile::new) .map(resolvedFile -> HttpResponse.response() .addHeader(CONTENT_TYPE, resolvedFile.mediaType) .body(r... |
@Test public void testTrackRequest() { tracker.trackRequest(req1); assertThat(tracker.currentRequests().iterator().next().request(), is(req1.toString())); } | public void trackRequest(LiveHttpRequest request, Supplier<String> state) { if (currentRequests.containsKey(request.id())) { currentRequests.get(request.id()).setCurrentThread(Thread.currentThread()); } else { currentRequests.put(request.id(), new CurrentRequest(request, state)); } } | CurrentRequestTracker implements RequestTracker { public void trackRequest(LiveHttpRequest request, Supplier<String> state) { if (currentRequests.containsKey(request.id())) { currentRequests.get(request.id()).setCurrentThread(Thread.currentThread()); } else { currentRequests.put(request.id(), new CurrentRequest(request... | CurrentRequestTracker implements RequestTracker { public void trackRequest(LiveHttpRequest request, Supplier<String> state) { if (currentRequests.containsKey(request.id())) { currentRequests.get(request.id()).setCurrentThread(Thread.currentThread()); } else { currentRequests.put(request.id(), new CurrentRequest(request... | CurrentRequestTracker implements RequestTracker { public void trackRequest(LiveHttpRequest request, Supplier<String> state) { if (currentRequests.containsKey(request.id())) { currentRequests.get(request.id()).setCurrentThread(Thread.currentThread()); } else { currentRequests.put(request.id(), new CurrentRequest(request... | CurrentRequestTracker implements RequestTracker { public void trackRequest(LiveHttpRequest request, Supplier<String> state) { if (currentRequests.containsKey(request.id())) { currentRequests.get(request.id()).setCurrentThread(Thread.currentThread()); } else { currentRequests.put(request.id(), new CurrentRequest(request... |
@Test public void testEndTrack() { tracker.trackRequest(req1); assertThat(tracker.currentRequests().size(), is(1)); assertThat(tracker.currentRequests().iterator().next().request(), is(req1.toString())); tracker.endTrack(req1); assertThat(tracker.currentRequests().size(), is(0)); } | public void endTrack(LiveHttpRequest request) { currentRequests.remove(request.id()); } | CurrentRequestTracker implements RequestTracker { public void endTrack(LiveHttpRequest request) { currentRequests.remove(request.id()); } } | CurrentRequestTracker implements RequestTracker { public void endTrack(LiveHttpRequest request) { currentRequests.remove(request.id()); } } | CurrentRequestTracker implements RequestTracker { public void endTrack(LiveHttpRequest request) { currentRequests.remove(request.id()); } void trackRequest(LiveHttpRequest request, Supplier<String> state); void trackRequest(LiveHttpRequest request); void markRequestAsSent(LiveHttpRequest request); void endTrack(LiveHt... | CurrentRequestTracker implements RequestTracker { public void endTrack(LiveHttpRequest request) { currentRequests.remove(request.id()); } void trackRequest(LiveHttpRequest request, Supplier<String> state); void trackRequest(LiveHttpRequest request); void markRequestAsSent(LiveHttpRequest request); void endTrack(LiveHt... |
@Test public void createsClients() { StyxBackendServiceClientFactory factory = new StyxBackendServiceClientFactory(environment); OriginsInventory originsInventory = newOriginsInventoryBuilder(backendService.id()) .connectionPoolFactory(simplePoolFactory()) .initialOrigins(backendService.origins()) .build(); OriginStats... | @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = styxConfig.get("originRestrictionCookie").orElse(null); boolean stickySes... | StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ... | StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ... | StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ... | StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ... |
@Test public void ignoresAdditionalCallsToOnRequestWithSameRequestId() { sink.onRequest(requestId); assertThat(metrics.counter("outstanding").getCount(), is(1L)); sink.onRequest(requestId); assertThat(metrics.counter("outstanding").getCount(), is(1L)); } | @Override public void onRequest(Object requestId) { Long previous = this.ongoingRequests.putIfAbsent(requestId, nanoClock.nanoTime()); if (previous == null) { this.outstandingRequests.inc(); this.requestsIncoming.mark(); } } | RequestStatsCollector implements RequestProgressListener { @Override public void onRequest(Object requestId) { Long previous = this.ongoingRequests.putIfAbsent(requestId, nanoClock.nanoTime()); if (previous == null) { this.outstandingRequests.inc(); this.requestsIncoming.mark(); } } } | RequestStatsCollector implements RequestProgressListener { @Override public void onRequest(Object requestId) { Long previous = this.ongoingRequests.putIfAbsent(requestId, nanoClock.nanoTime()); if (previous == null) { this.outstandingRequests.inc(); this.requestsIncoming.mark(); } } RequestStatsCollector(MetricRegistry... | RequestStatsCollector implements RequestProgressListener { @Override public void onRequest(Object requestId) { Long previous = this.ongoingRequests.putIfAbsent(requestId, nanoClock.nanoTime()); if (previous == null) { this.outstandingRequests.inc(); this.requestsIncoming.mark(); } } RequestStatsCollector(MetricRegistry... | RequestStatsCollector implements RequestProgressListener { @Override public void onRequest(Object requestId) { Long previous = this.ongoingRequests.putIfAbsent(requestId, nanoClock.nanoTime()); if (previous == null) { this.outstandingRequests.inc(); this.requestsIncoming.mark(); } } RequestStatsCollector(MetricRegistry... |
@Test public void mapExactlyMatchingUrls() { PathTrie<Integer> pathTrie = defaultPathTrie(); assertThat(pathTrie.get("/"), isValue(1)); assertThat(pathTrie.get(""), isValue(1)); assertThat(pathTrie.get("/a/b"), isValue(2)); assertThat(pathTrie.get("/a/b/"), isValue(1)); assertThat(pathTrie.get("/a/c"), isValue(3)); ass... | public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { value = bestVa... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... |
@Test public void matchesDefaultWhenNothingElseMatches() { PathTrie<Integer> pathTrie = defaultpathTrieWithStar(); assertThat(pathTrie.get("/a/b"), isValue(1)); } | public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { value = bestVa... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... |
@Test public void mapExactlyMatchingUrlsWithStarConfig() { PathTrie<Integer> pathTrie = defaultpathTrieWithStar(); assertThat(pathTrie.get("/"), isValue(1)); assertThat(pathTrie.get(""), isValue(1)); assertThat(pathTrie.get("/a/b/"), isValue(2)); assertThat(pathTrie.get("/a/c/"), isValue(3)); assertThat(pathTrie.get("/... | public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { value = bestVa... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... |
@Test public void nonMatchingUrlsMapToRoot() { PathTrie<Integer> pathTrie = defaultPathTrie(); assertThat(pathTrie.get("foobar"), isValue(1)); assertThat(pathTrie.get("/d"), isValue(1)); assertThat(pathTrie.get("/d/"), isValue(1)); assertThat(pathTrie.get("/d/foo"), isValue(1)); } | public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { value = bestVa... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... |
@Test public void nonMatchingUrlsMapToRootWithStarConfig() { PathTrie<Integer> pathTrie = defaultpathTrieWithStar(); assertThat(pathTrie.get("foobar"), isValue(1)); assertThat(pathTrie.get("/d"), isValue(1)); assertThat(pathTrie.get("/d/"), isValue(1)); assertThat(pathTrie.get("/d/foo"), isValue(1)); } | public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { value = bestVa... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... |
@Test public void partiallyMatchingUrlsMapToRootWhenApplicationIdNotAvailable() { PathTrie<Integer> pathTrie = defaultPathTrie(); assertThat(pathTrie.get("/a/bar"), isValue(1)); assertThat(pathTrie.get("/a/foo"), isValue(1)); } | public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { value = bestVa... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... |
@Test public void partiallyMatchingUrlsMapToRootWhenApplicationIdNotAvailableWithStarConfig() { PathTrie<Integer> pathTrie = defaultpathTrieWithStar(); assertThat(pathTrie.get("/a/bar"), isValue(1)); assertThat(pathTrie.get("/a/foo"), isValue(1)); } | public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { value = bestVa... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... |
@Test public void mapToBestMatch() { PathTrie<Integer> pathTrie = defaultPathTrie(); assertThat(pathTrie.get("/a/b/foo"), isValue(1)); assertThat(pathTrie.get("/a/b/foo/bar"), isValue(1)); assertThat(pathTrie.get("/a/c/foo"), isValue(1)); assertThat(pathTrie.get("/a/c/foo/bar"), isValue(1)); assertThat(pathTrie.get("/a... | public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { value = bestVa... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... |
@Test public void mapToBestMatchWithStarConfig() { PathTrie<Integer> pathTrie = defaultpathTrieWithStar(); assertThat(pathTrie.get("/a/b/foo"), isValue(2)); assertThat(pathTrie.get("/a/b/foo/bar"), isValue(2)); assertThat(pathTrie.get("/a/c/foo"), isValue(3)); assertThat(pathTrie.get("/a/c/foo/bar"), isValue(3)); asser... | public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { value = bestVa... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... | PathTrie { public Optional<T> get(String path) { List<String> components = getPathComponents(path); MatchTreeNode<T> node = tree.getLongestMatchingNode(components); if (node == null) { return Optional.empty(); } T value; if (isExactlyMatchingPath(node, path, components)) { value = node.value(); if (value == null) { val... |
@Test public void usesTheOriginSpecifiedInTheStickySessionCookie() { BackendService backendService = newBackendServiceBuilder() .origins( newOriginBuilder("localhost", 9091).id("x").build(), newOriginBuilder("localhost", 9092).id("y").build(), newOriginBuilder("localhost", 9093).id("z").build()) .stickySessionConfig( n... | @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = styxConfig.get("originRestrictionCookie").orElse(null); boolean stickySes... | StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ... | StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ... | StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ... | StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ... |
@Test public void failWhenIdenticalPathsConfigured() { PathTrie<Integer> pathTrie = new PathTrie<>(); pathTrie.put("/a/b/c", 1); assertThrows(DuplicatePathException.class, () -> pathTrie.put("/a/b/c", 2)); } | public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String message = f... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... |
@Test public void failWhenIdenticalPathsConfiguredWithStar() { PathTrie<Integer> pathTrie = new PathTrie<>(); pathTrie.put("/a/b/c/", 1); assertThrows(DuplicatePathException.class, () -> pathTrie.put("/a/b/c/*", 2)); } | public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String message = f... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... |
@Test public void failWhenIdenticalPathsConfiguredInRoot() { PathTrie<Integer> pathTrie = new PathTrie<>(); pathTrie.put("/", 1); assertThrows(DuplicatePathException.class, () -> pathTrie.put("/", 2)); } | public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String message = f... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... |
@Test public void failWhenIdenticalPathsConfiguredInRootWithStar() { PathTrie<Integer> pathTrie = new PathTrie<>(); pathTrie.put("/", 1); assertThrows(DuplicatePathException.class, () -> pathTrie.put("/*", 2)); } | public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String message = f... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... |
@Test public void failWhenPathIsNull() { PathTrie<Integer> pathTrie = new PathTrie<>(); assertThrows(IllegalArgumentException.class, () -> pathTrie.put(null, 1)); } | public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String message = f... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... |
@Test public void failWhenPathIsEmpty() { PathTrie<Integer> pathTrie = new PathTrie<>(); assertThrows(IllegalArgumentException.class, () -> pathTrie.put("", 1)); } | public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String message = f... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... |
@Test public void failWhenValueIsNull() { PathTrie<Integer> pathTrie = new PathTrie<>(); assertThrows(NullPointerException.class, () -> pathTrie.put("/", null)); } | public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String message = f... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... | PathTrie { public void put(String path, T value) { checkNotEmpty(path); requireNonNull(value); List<String> components = pathToComponents(Paths.get(removeAsterisk(path))); if (path.endsWith("/") || path.endsWith("/*")) { components.add("/"); } T existing = tree.getExactMatch(components); if (existing != null) { String ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.