### Question:
AuthorityRuleChecker { static boolean passCheck(AuthorityRule rule, Context context) { String requester = context.getOrigin(); if (StringUtil.isEmpty(requester) || StringUtil.isEmpty(rule.getLimitApp())) { return true; } int pos = rule.getLimitApp().indexOf(requester); boolean contain = pos > -1; if (contain) { boolean exactlyMatch = false; String[] appArray = rule.getLimitApp().split(","); for (String app : appArray) { if (requester.equals(app)) { exactlyMatch = true; break; } } contain = exactlyMatch; } int strategy = rule.getStrategy(); if (strategy == RuleConstant.AUTHORITY_BLACK && contain) { return false; } if (strategy == RuleConstant.AUTHORITY_WHITE && !contain) { return false; } return true; } private  AuthorityRuleChecker();   }### Answer:
@Test public void testPassCheck() { String origin = "appA"; ContextUtil.enter("entrance", origin); try { String resourceName = "testPassCheck"; AuthorityRule ruleA = new AuthorityRule() .setResource(resourceName) .setLimitApp(origin + ",appB") .as(AuthorityRule.class) .setStrategy(RuleConstant.AUTHORITY_WHITE); AuthorityRule ruleB = new AuthorityRule() .setResource(resourceName) .setLimitApp("appB") .as(AuthorityRule.class) .setStrategy(RuleConstant.AUTHORITY_WHITE); AuthorityRule ruleC = new AuthorityRule() .setResource(resourceName) .setLimitApp(origin) .as(AuthorityRule.class) .setStrategy(RuleConstant.AUTHORITY_BLACK); AuthorityRule ruleD = new AuthorityRule() .setResource(resourceName) .setLimitApp("appC") .as(AuthorityRule.class) .setStrategy(RuleConstant.AUTHORITY_BLACK); assertTrue(AuthorityRuleChecker.passCheck(ruleA, ContextUtil.getContext())); assertFalse(AuthorityRuleChecker.passCheck(ruleB, ContextUtil.getContext())); assertFalse(AuthorityRuleChecker.passCheck(ruleC, ContextUtil.getContext())); assertTrue(AuthorityRuleChecker.passCheck(ruleD, ContextUtil.getContext())); } finally { ContextUtil.exit(); } }