You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/03/22 01:58:32 UTC

[incubator-servicecomb-java-chassis] 03/03: simplify unit test case

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit f37cbfdf829197504beeec5a85929ef1e7bcf903
Author: liubao <ba...@huawei.com>
AuthorDate: Thu Mar 22 09:04:45 2018 +0800

    simplify unit test case
---
 .../servicecomb/loadbalance/TestLoadBalancer.java  |  5 +--
 .../org/apache/servicecomb/loadbalance/Utils.java  | 37 ----------------------
 2 files changed, 3 insertions(+), 39 deletions(-)

diff --git a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalancer.java b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalancer.java
index 1aa8775..1ebce0e 100644
--- a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalancer.java
+++ b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalancer.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertNotNull;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.apache.servicecomb.loadbalance.filter.SimpleTransactionControlFilter;
 import org.apache.servicecomb.loadbalance.filter.TransactionControlFilter;
 import org.junit.Assert;
@@ -172,11 +173,11 @@ public class TestLoadBalancer {
     
     long time =  Deencapsulation.getField(rule, "lastAccessedTime");
     Deencapsulation.setField(rule, "lastAccessedTime", time - 1000 * 10);
-    Utils.updateProperty("cse.loadbalance.service.SessionStickinessRule.sessionTimeoutInSeconds", 9);
+    ArchaiusUtils.setProperty("cse.loadbalance.service.SessionStickinessRule.sessionTimeoutInSeconds", 9);
     s = lb.chooseServer("test");
     Assert.assertEquals(server, s);
     
-    Utils.updateProperty("cse.loadbalance.service.SessionStickinessRule.successiveFailedTimes", 5);
+    ArchaiusUtils.setProperty("cse.loadbalance.service.SessionStickinessRule.successiveFailedTimes", 5);
     lb.getLoadBalancerStats().incrementSuccessiveConnectionFailureCount(s);
     lb.getLoadBalancerStats().incrementSuccessiveConnectionFailureCount(s);
     lb.getLoadBalancerStats().incrementSuccessiveConnectionFailureCount(s);
diff --git a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/Utils.java b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/Utils.java
deleted file mode 100644
index a00a93d..0000000
--- a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/Utils.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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 org.apache.servicecomb.loadbalance;
-
-import java.lang.reflect.Method;
-
-import org.springframework.util.ReflectionUtils;
-
-import com.netflix.config.DynamicProperty;
-
-public class Utils {
-  private static Method updatePropertyMethod =
-      ReflectionUtils.findMethod(DynamicProperty.class, "updateProperty", String.class, Object.class);
-
-  static {
-    updatePropertyMethod.setAccessible(true);
-  }
-
-  public static void updateProperty(String key, Object value) {
-    ReflectionUtils.invokeMethod(updatePropertyMethod, null, key, value);
-  }
-}

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.