@Test public void testMatch() { Pattern pattern = Pattern.compile("<<([\\w]*)>>"); String value = "<<target>>"; assertEquals(StringUtils.match(pattern, value, 1), "target"); try { StringUtils.match(pattern, null, 1); fail("was expecting IllegalArgumentException"); } catch (IllegalArgumentException e) { } try { StringUtils.match(null, value, 1); fail("was expecting IllegalArgumentException"); } catch (IllegalArgumentException e) { } assertNull(StringUtils.match(pattern, "hello world!", 1)); }
@Test public void testMatch() { Pattern pattern = Pattern.compile("<<([\\w]*)>>"); String value = "<<target>>"; assertEquals(StringUtils.match(pattern, value, 1), "target"); try { StringUtils.match(pattern, null, 1); fail("was expecting IllegalArgumentException"); } catch (IllegalArgumentException e) { } try { StringUtils.match(null, value, 1); fail("was expecting IllegalArgumentException"); } catch (IllegalArgumentException e) { } assertNull(StringUtils.match(pattern, "hello world!", 1)); }