@Test public void testConsumeLine() { Collection<File> nonMemberElements = new ArrayList<File>(); Collection<File> memberElements = new ArrayList<File>(); String line1 = "./hello.world maventst/1 (2/1) (member)"; String line2 = "./tcktests/readme.txt (no such elem)"; String line3 = "./src maventst/1 (2/1) (member)"; String line4 = "./target (no such elem)"; StatBackingConsumer consumer = new StatBackingConsumer( memberElements, nonMemberElements ); consumer.consumeLine( line1 ); consumer.consumeLine( line2 ); consumer.consumeLine( line3 ); consumer.consumeLine( line4 ); assertThat( memberElements.size(), is( 2 ) ); assertThat( nonMemberElements.size(), is( 2 ) ); assertThat( memberElements, hasItem( new File( "./hello.world" ) ) ); assertThat( memberElements, hasItem( new File( "./src" ) ) ); assertThat( nonMemberElements, hasItem( new File( "./tcktests/readme.txt" ) ) ); assertThat( nonMemberElements, hasItem( new File( "./target" ) ) ); }
public void consumeLine( String line ) { Pattern pattern = STAT_PATTERN; Matcher matcher = pattern.matcher( line ); if ( matcher.matches() ) { File file = new File( matcher.group( 1 ) ); String indicator = matcher.group( 2 ); if ( NO_SUCH_ELEM.equals( indicator ) ) { nonMemberElements.add( file ); } else { memberElements.add( file ); } } }
StatBackingConsumer implements StreamConsumer { public void consumeLine( String line ) { Pattern pattern = STAT_PATTERN; Matcher matcher = pattern.matcher( line ); if ( matcher.matches() ) { File file = new File( matcher.group( 1 ) ); String indicator = matcher.group( 2 ); if ( NO_SUCH_ELEM.equals( indicator ) ) { nonMemberElements.add( file ); } else { memberElements.add( file ); } } } }
StatBackingConsumer implements StreamConsumer { public void consumeLine( String line ) { Pattern pattern = STAT_PATTERN; Matcher matcher = pattern.matcher( line ); if ( matcher.matches() ) { File file = new File( matcher.group( 1 ) ); String indicator = matcher.group( 2 ); if ( NO_SUCH_ELEM.equals( indicator ) ) { nonMemberElements.add( file ); } else { memberElements.add( file ); } } } StatBackingConsumer( Collection<File> memberElements, Collection<File> nonMemberElements ); }
StatBackingConsumer implements StreamConsumer { public void consumeLine( String line ) { Pattern pattern = STAT_PATTERN; Matcher matcher = pattern.matcher( line ); if ( matcher.matches() ) { File file = new File( matcher.group( 1 ) ); String indicator = matcher.group( 2 ); if ( NO_SUCH_ELEM.equals( indicator ) ) { nonMemberElements.add( file ); } else { memberElements.add( file ); } } } StatBackingConsumer( Collection<File> memberElements, Collection<File> nonMemberElements ); void consumeLine( String line ); }
StatBackingConsumer implements StreamConsumer { public void consumeLine( String line ) { Pattern pattern = STAT_PATTERN; Matcher matcher = pattern.matcher( line ); if ( matcher.matches() ) { File file = new File( matcher.group( 1 ) ); String indicator = matcher.group( 2 ); if ( NO_SUCH_ELEM.equals( indicator ) ) { nonMemberElements.add( file ); } else { memberElements.add( file ); } } } StatBackingConsumer( Collection<File> memberElements, Collection<File> nonMemberElements ); void consumeLine( String line );  }