public void test_vmstat_header_and_data_parse(){
  final Pattern pattern=VMStatCollector.pattern;
  final String h0="Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 0%)";
  final String h1="  free active   spec inactive   wire   faults     copy    0fill reactive  pageins  pageout";
  final String d1="404670  1238K  42678   161330 183963  144830K  2032186 81929280  1353888   351293   149940";
{
    final String[] fields=pattern.split(h0.trim(),0);
    for (int i=0; i < fields.length; i++) {
      if (log.isInfoEnabled())       log.info("fields[" + i + "]=["+ fields[i]+ "]");
    }
    assertField(h0,fields,0,"Mach");
    assertField(h0,fields,7,"4096");
  }
{
    final String[] fields=pattern.split(h1.trim(),0);
    for (int i=0; i < fields.length; i++) {
      if (log.isInfoEnabled())       log.info("fields[" + i + "]=["+ fields[i]+ "]");
    }
    assertField(h1,fields,0,"free");
    assertField(h1,fields,1,"active");
    assertField(h1,fields,2,"spec");
    assertField(h1,fields,3,"inactive");
    assertField(h1,fields,4,"wire");
    assertField(h1,fields,5,"faults");
    assertField(h1,fields,6,"copy");
    assertField(h1,fields,7,"0fill");
    assertField(h1,fields,8,"reactive");
    assertField(h1,fields,9,"pageins");
    assertField(h1,fields,10,"pageout");
  }
{
    final String[] fields=pattern.split(d1.trim(),0);
    assertField(d1,fields,0,"404670");
    assertField(d1,fields,1,"1238K");
    assertField(d1,fields,2,"42678");
    assertField(d1,fields,3,"161330");
    assertField(d1,fields,4,"183963");
    assertField(d1,fields,5,"144830K");
    assertField(d1,fields,6,"2032186");
    assertField(d1,fields,7,"81929280");
    assertField(d1,fields,8,"1353888");
    assertField(d1,fields,9,"351293");
    assertField(d1,fields,10,"149940");
  }
}

public void test_vmstat_header_and_data_parse ( ) { final Pattern pattern = VMStatCollector . pattern ; final String h0 = "Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 0%)" ; final String h1 = "  free active   spec inactive   wire   faults     copy    0fill reactive  pageins  pageout" ; final String d1 = "404670  1238K  42678   161330 183963  144830K  2032186 81929280  1353888   351293   149940" ; { final String [ ] fields = pattern . split ( h0 . trim ( ) , 0 ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { if ( log . isInfoEnabled ( ) ) log . info ( "fields[" + i + "]=[" + fields [ i ] + "]" ) ; } assertField ( h0 , fields , 0 , "Mach" ) ; assertField ( h0 , fields , 7 , "4096" ) ; } { final String [ ] fields = pattern . split ( h1 . trim ( ) , 0 ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { if ( log . isInfoEnabled ( ) ) log . info ( "fields[" + i + "]=[" + fields [ i ] + "]" ) ; } assertField ( h1 , fields , 0 , "free" ) ; assertField ( h1 , fields , 1 , "active" ) ; assertField ( h1 , fields , 2 , "spec" ) ; assertField ( h1 , fields , 3 , "inactive" ) ; assertField ( h1 , fields , 4 , "wire" ) ; assertField ( h1 , fields , 5 , "faults" ) ; assertField ( h1 , fields , 6 , "copy" ) ; assertField ( h1 , fields , 7 , "0fill" ) ; assertField ( h1 , fields , 8 , "reactive" ) ; assertField ( h1 , fields , 9 , "pageins" ) ; assertField ( h1 , fields , 10 , "pageout" ) ; } { final String [ ] fields = pattern . split ( d1 . trim ( ) , 0 ) ; assertField ( d1 , fields , 0 , "404670" ) ; assertField ( d1 , fields , 1 , "1238K" ) ; assertField ( d1 , fields , 2 , "42678" ) ; assertField ( d1 , fields , 3 , "161330" ) ; assertField ( d1 , fields , 4 , "183963" ) ; assertField ( d1 , fields , 5 , "144830K" ) ; assertField ( d1 , fields , 6 , "2032186" ) ; assertField ( d1 , fields , 7 , "81929280" ) ; assertField ( d1 , fields , 8 , "1353888" ) ; assertField ( d1 , fields , 9 , "351293" ) ; assertField ( d1 , fields , 10 , "149940" ) ; } }
test based on some sample data .
