### Question:
TpsLimitFilter implements Filter { @Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (!tpsLimiter.isAllowable(invoker.getUrl(), invocation)) { throw new RpcException( "Failed to invoke service " + invoker.getInterface().getName() + "." + invocation.getMethodName() + " because exceed max service tps."); } return invoker.invoke(invocation); }  @Override Result invoke(Invoker<?> invoker, Invocation invocation);  }### Answer:
@Test public void testWithoutCount() throws Exception { URL url = URL.valueOf("test: url = url.addParameter(Constants.INTERFACE_KEY, "org.apache.dubbo.rpc.file.TpsService"); url = url.addParameter(Constants.TPS_LIMIT_RATE_KEY, 5); Invoker<TpsLimitFilterTest> invoker = new MyInvoker<TpsLimitFilterTest>(url); Invocation invocation = new MockInvocation(); filter.invoke(invoker, invocation); }
@Test public void testFail() throws Exception { Assertions.assertThrows(RpcException.class, () -> { URL url = URL.valueOf("test: url = url.addParameter(Constants.INTERFACE_KEY, "org.apache.dubbo.rpc.file.TpsService"); url = url.addParameter(Constants.TPS_LIMIT_RATE_KEY, 5); Invoker<TpsLimitFilterTest> invoker = new MyInvoker<TpsLimitFilterTest>(url); Invocation invocation = new MockInvocation(); for (int i = 0; i < 10; i++) { try { filter.invoke(invoker, invocation); } catch (Exception e) { assertTrue(i >= 5); throw e; } } }); }