Skip to content

Commit

Permalink
use async filter example to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
argha-c committed Mar 15, 2024
1 parent 6fd4aa7 commit ed782d1
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import rx.Observable;

/**
* Tests for {@link BaseFilter}. Currently named BaseFilter2Test as there is an existing class named BaseFilterTest.
Expand Down Expand Up @@ -79,12 +80,12 @@ public ZuulMessage apply(ZuulMessage req) {
@Test
void validateDefaultConcurrencyLimit() {
final int[] limit = {0};
class ConcInboundFilter extends BaseSyncFilter {
class ConcInboundFilter extends BaseFilter {

@Override
public ZuulMessage apply(ZuulMessage input) {
public Observable applyAsync(ZuulMessage input) {
limit[0] = Math.max(filterConcurrencyCustom.get(), filterConcurrencyDefault.get());
return null;
return Observable.just("Done");
}

@Override
Expand All @@ -97,7 +98,7 @@ public boolean shouldFilter(ZuulMessage msg) {
return true;
}
}
new ConcInboundFilter().apply(new ZuulMessageImpl(new SessionContext(), new Headers()));
new ConcInboundFilter().applyAsync(new ZuulMessageImpl(new SessionContext(), new Headers()));
Truth.assertThat(limit[0]).isEqualTo(4000);
}

Expand All @@ -108,12 +109,12 @@ void validateFilterConcurrencyLimitOverride() {
configuration.setProperty("zuul.ConcInboundFilter.in.concurrency.limit", 4000);
final int[] limit = {0};

class ConcInboundFilter extends BaseSyncFilter {
class ConcInboundFilter extends BaseFilter {

@Override
public ZuulMessage apply(ZuulMessage input) {
public Observable applyAsync(ZuulMessage input) {
limit[0] = Math.max(filterConcurrencyCustom.get(), filterConcurrencyDefault.get());
return null;
return Observable.just("Done");
}

@Override
Expand All @@ -126,7 +127,7 @@ public boolean shouldFilter(ZuulMessage msg) {
return true;
}
}
new ConcInboundFilter().apply(new ZuulMessageImpl(new SessionContext(), new Headers()));
new ConcInboundFilter().applyAsync(new ZuulMessageImpl(new SessionContext(), new Headers()));
Truth.assertThat(limit[0]).isEqualTo(7000);
}
}

0 comments on commit ed782d1

Please sign in to comment.