From 75080e1159ea4e7f307e9df1e14cc42d170159f9 Mon Sep 17 00:00:00 2001 From: Ming Deng <mindeng@ebay.com> Date: Wed, 16 Oct 2019 13:02:34 +0800 Subject: [PATCH] Add UT --- ...ejected_execution_handler_only_log_impl.go | 6 ++-- ...ed_execution_handler_only_log_impl_test.go | 35 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 filter/impl/rejected_execution_handler_only_log_impl_test.go diff --git a/filter/impl/rejected_execution_handler_only_log_impl.go b/filter/impl/rejected_execution_handler_only_log_impl.go index 1ea44efb4..bc67fa4ec 100644 --- a/filter/impl/rejected_execution_handler_only_log_impl.go +++ b/filter/impl/rejected_execution_handler_only_log_impl.go @@ -36,8 +36,8 @@ import ( const HandlerName = "log" func init() { - extension.SetTpsRejectedExecutionHandler(HandlerName, GetOnlyRejectedExecutionHandler) - extension.SetTpsRejectedExecutionHandler(constant.DEFAULT_KEY, GetOnlyRejectedExecutionHandler) + extension.SetTpsRejectedExecutionHandler(HandlerName, GetOnlyLogRejectedExecutionHandler) + extension.SetTpsRejectedExecutionHandler(constant.DEFAULT_KEY, GetOnlyLogRejectedExecutionHandler) } var onlyLogHandlerInstance *OnlyLogRejectedExecutionHandler @@ -55,7 +55,7 @@ func (handler *OnlyLogRejectedExecutionHandler) RejectedExecution(url common.URL return &protocol.RPCResult{} } -func GetOnlyRejectedExecutionHandler() filter.RejectedExecutionHandler { +func GetOnlyLogRejectedExecutionHandler() filter.RejectedExecutionHandler { onlyLogHandlerOnce.Do(func() { onlyLogHandlerInstance = &OnlyLogRejectedExecutionHandler{} }) diff --git a/filter/impl/rejected_execution_handler_only_log_impl_test.go b/filter/impl/rejected_execution_handler_only_log_impl_test.go new file mode 100644 index 000000000..da54d8a10 --- /dev/null +++ b/filter/impl/rejected_execution_handler_only_log_impl_test.go @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package impl + +import ( + "net/url" + "testing" +) +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" +) + +func TestOnlyLogRejectedExecutionHandler_RejectedExecution(t *testing.T) { + handler := GetOnlyLogRejectedExecutionHandler() + invokeUrl := common.NewURLWithOptions( + common.WithParams(url.Values{}), + common.WithParamsValue(constant.INTERFACE_KEY, "methodName")) + handler.RejectedExecution(*invokeUrl, nil) +} -- GitLab