@Test @Configuration("{}") public void testIsMatch() { Assert.assertTrue(CircuitBreakerPolicy.isMatch(404, "404")); Assert.assertTrue(CircuitBreakerPolicy.isMatch(404, "40*")); Assert.assertTrue(CircuitBreakerPolicy.isMatch(404, "4**")); Assert.assertTrue(CircuitBreakerPolicy.isMatch(404, "***")); Assert.assertTrue(CircuitBreakerPolicy.isMatch(500, "500")); Assert.assertTrue(CircuitBreakerPolicy.isMatch(500, "50*")); Assert.assertFalse(CircuitBreakerPolicy.isMatch(500, "400")); Assert.assertFalse(CircuitBreakerPolicy.isMatch(500, "501")); Assert.assertFalse(CircuitBreakerPolicy.isMatch(500, "4**")); }
protected static boolean isMatch(int code, String codePattern) { String scode = String.valueOf(code); byte [] c = scode.getBytes(); byte [] cp = codePattern.getBytes(); if (c.length != cp.length) { return false; } for (int idx = 0; idx < c.length; idx++) { byte cb = c[idx]; byte cpb = cp[idx]; if (cb != cpb && cpb != '*') { return false; } } return true; }
CircuitBreakerPolicy extends AbstractMappedPolicy<CircuitBreakerConfigBean> { protected static boolean isMatch(int code, String codePattern) { String scode = String.valueOf(code); byte [] c = scode.getBytes(); byte [] cp = codePattern.getBytes(); if (c.length != cp.length) { return false; } for (int idx = 0; idx < c.length; idx++) { byte cb = c[idx]; byte cpb = cp[idx]; if (cb != cpb && cpb != '*') { return false; } } return true; } }
CircuitBreakerPolicy extends AbstractMappedPolicy<CircuitBreakerConfigBean> { protected static boolean isMatch(int code, String codePattern) { String scode = String.valueOf(code); byte [] c = scode.getBytes(); byte [] cp = codePattern.getBytes(); if (c.length != cp.length) { return false; } for (int idx = 0; idx < c.length; idx++) { byte cb = c[idx]; byte cpb = cp[idx]; if (cb != cpb && cpb != '*') { return false; } } return true; } CircuitBreakerPolicy(); }
CircuitBreakerPolicy extends AbstractMappedPolicy<CircuitBreakerConfigBean> { protected static boolean isMatch(int code, String codePattern) { String scode = String.valueOf(code); byte [] c = scode.getBytes(); byte [] cp = codePattern.getBytes(); if (c.length != cp.length) { return false; } for (int idx = 0; idx < c.length; idx++) { byte cb = c[idx]; byte cpb = cp[idx]; if (cb != cpb && cpb != '*') { return false; } } return true; } CircuitBreakerPolicy();  }
CircuitBreakerPolicy extends AbstractMappedPolicy<CircuitBreakerConfigBean> { protected static boolean isMatch(int code, String codePattern) { String scode = String.valueOf(code); byte [] c = scode.getBytes(); byte [] cp = codePattern.getBytes(); if (c.length != cp.length) { return false; } for (int idx = 0; idx < c.length; idx++) { byte cb = c[idx]; byte cpb = cp[idx]; if (cb != cpb && cpb != '*') { return false; } } return true; } CircuitBreakerPolicy();   }