### Question:
PatternStringTokenizer implements StringTokenizer { @Override public List<String> tokenize(String line) { Matcher matcher = myPattern.matcher(line); if (matcher.matches()) { List<String> cells = new ArrayList<>(matcher.groupCount()); for (int index = 1; index <= matcher.groupCount(); ++index) { cells.add(matcher.group(index)); } return cells; } String[] cells = new String[matcher.groupCount()]; Arrays.fill(cells, StringUtilities.EMPTY); return Arrays.asList(cells); } PatternStringTokenizer(Pattern pattern);  PatternStringTokenizer(String pattern); static PatternStringTokenizer createFromDivisions(int[] divisions); static PatternStringTokenizer createFromWidths(int[] widths); static String generatePatternFromColumnDivisions(final int[] divisions); static String generatePatternFromColumnWidths(final int[] widths); @Override List<String> tokenize(String line);  }### Answer:
@Test public void testMatch() { PatternStringTokenizer tokenizer = new PatternStringTokenizer("(.{5})(\\S+)\\s*(.{7}).*"); List<String> actual = tokenizer.tokenize("a abb cccccccxxxx"); Assert.assertEquals(3, actual.size()); Assert.assertEquals("a a", actual.get(0)); Assert.assertEquals("bb", actual.get(1)); Assert.assertEquals("ccccccc", actual.get(2)); }
@Test public void testNoMatch() { PatternStringTokenizer tokenizer = new PatternStringTokenizer("(.{5})(\\S+)\\s*(.{7}).*"); List<String> actual = tokenizer.tokenize("a accccccc"); Assert.assertEquals(3, actual.size()); Assert.assertEquals("", actual.get(0)); Assert.assertEquals("", actual.get(1)); Assert.assertEquals("", actual.get(2)); }