浏览代码

Some code update and rearrangement

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 6 年前
父节点
当前提交
fe6b4f4865
共有 6 个文件被更改,包括 28 次插入15 次删除
  1. +8
    -0
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slotchain/StringResourceWrapper.java
  2. +0
    -0
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/base/Striped64.java
  3. +2
    -5
      sentinel-core/src/test/java/com/alibaba/csp/sentinel/AsyncEntryIntegrationTest.java
  4. +13
    -5
      sentinel-core/src/test/java/com/alibaba/csp/sentinel/context/ContextTestUtil.java
  5. +2
    -2
      sentinel-core/src/test/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleCheckerTest.java
  6. +3
    -3
      sentinel-core/src/test/java/com/alibaba/csp/sentinel/slots/block/authority/AuthoritySlotTest.java

+ 8
- 0
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slotchain/StringResourceWrapper.java 查看文件

@@ -47,4 +47,12 @@ public class StringResourceWrapper extends ResourceWrapper {
public EntryType getType() {
return type;
}

@Override
public String toString() {
return "StringResourceWrapper{" +
"name='" + name + '\'' +
", type=" + type +
'}';
}
}

sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/base/Stripe64.java → sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/base/Striped64.java 查看文件


+ 2
- 5
sentinel-core/src/test/java/com/alibaba/csp/sentinel/AsyncEntryIntegrationTest.java 查看文件

@@ -20,9 +20,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import com.alibaba.csp.sentinel.context.ContextTestUtil;
import com.alibaba.csp.sentinel.context.ContextUtil;
import com.alibaba.csp.sentinel.node.DefaultNode;
import com.alibaba.csp.sentinel.node.EntranceNode;
import com.alibaba.csp.sentinel.node.Node;
import com.alibaba.csp.sentinel.slots.block.BlockException;

@@ -41,10 +41,7 @@ public class AsyncEntryIntegrationTest {

@Before
public void clearContext() {
if (ContextUtil.getContext() != null) {
ContextUtil.getContext().setCurEntry(null);
ContextUtil.exit();
}
ContextTestUtil.cleanUpContext();
}

private final ExecutorService pool = Executors.newFixedThreadPool(10);


sentinel-core/src/test/java/com/alibaba/csp/sentinel/TestUtil.java → sentinel-core/src/test/java/com/alibaba/csp/sentinel/context/ContextTestUtil.java 查看文件

@@ -13,15 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel;
package com.alibaba.csp.sentinel.context;

import com.alibaba.csp.sentinel.context.Context;
import com.alibaba.csp.sentinel.context.ContextUtil;
import com.alibaba.csp.sentinel.Constants;

/**
* Util class for testing context-related functions.
* Only for test. DO NOT USE IN PRODUCTION!
*
* @author Eric Zhao
* @since 0.2.0
*/
public final class TestUtil {
public final class ContextTestUtil {

public static void cleanUpContext() {
Context context = ContextUtil.getContext();
@@ -31,5 +34,10 @@ public final class TestUtil {
}
}

private TestUtil() {}
public static void resetContextMap() {
ContextUtil.resetContextMap();
Constants.ROOT.removeChildList();
}

private ContextTestUtil() {}
}

+ 2
- 2
sentinel-core/src/test/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleCheckerTest.java 查看文件

@@ -1,6 +1,6 @@
package com.alibaba.csp.sentinel.slots.block.authority;

import com.alibaba.csp.sentinel.TestUtil;
import com.alibaba.csp.sentinel.context.ContextTestUtil;
import com.alibaba.csp.sentinel.context.ContextUtil;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;

@@ -18,7 +18,7 @@ public class AuthorityRuleCheckerTest {

@Before
public void setUp() {
TestUtil.cleanUpContext();
ContextTestUtil.cleanUpContext();
}

@Test


+ 3
- 3
sentinel-core/src/test/java/com/alibaba/csp/sentinel/slots/block/authority/AuthoritySlotTest.java 查看文件

@@ -3,7 +3,7 @@ package com.alibaba.csp.sentinel.slots.block.authority;
import java.util.Collections;

import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.TestUtil;
import com.alibaba.csp.sentinel.context.ContextTestUtil;
import com.alibaba.csp.sentinel.context.ContextUtil;
import com.alibaba.csp.sentinel.slotchain.ResourceWrapper;
import com.alibaba.csp.sentinel.slotchain.StringResourceWrapper;
@@ -120,13 +120,13 @@ public class AuthoritySlotTest {

@Before
public void setUp() {
TestUtil.cleanUpContext();
ContextTestUtil.cleanUpContext();
AuthorityRuleManager.loadRules(null);
}

@After
public void tearDown() {
TestUtil.cleanUpContext();
ContextTestUtil.cleanUpContext();
AuthorityRuleManager.loadRules(null);
}
}

正在加载...
取消
保存