1 29 package net.sourceforge.groboutils.pmti.v1.autodoc.v1.server; 30 31 32 import java.io.File ; 33 import java.io.Writer ; 34 import java.io.IOException ; 35 36 import net.sourceforge.groboutils.autodoc.v1.testserver.TestData; 37 import net.sourceforge.groboutils.autodoc.v1.testserver.TestInfo; 38 39 import net.sourceforge.groboutils.pmti.v1.autodoc.v1.ITFTestData; 40 41 42 51 public class LogFileServer extends AbstractAppendFileServer 52 { 53 public LogFileServer( File f ) 54 { 55 super( f ); 56 } 57 58 59 60 61 65 protected void writeTestData( TestData td, Writer w ) 66 throws IOException 67 { 68 if (td == null || !(td instanceof ITFTestData)) 69 { 70 return; 71 } 72 String newline = System.getProperty( "line.separator" ); 73 ITFTestData itd = (ITFTestData)td; 74 TestInfo ti = td.getTestInfo(); 75 76 StringBuffer sb = new StringBuffer ( ti.getSuite() ); 77 sb.append( '#' ). 78 append( ti.getMethod() ). 79 append( " test count=" ). 80 append( itd.getTestCount() ). 81 append( " runtime in ms=" ). 82 append( itd.getRunTime() ). 83 append( newline ). 84 append( " Failures:" ); 85 appendArray( sb, itd.getFailures(), newline ); 86 sb.append( newline ). 87 append( " Errors:" ); 88 appendArray( sb, itd.getErrors(), newline ); 89 sb.append( newline ). 90 append( " Bugs: " ); 91 String logs[] = itd.getIssues(); 92 if (logs.length <= 0) 93 { 94 sb.append("none" ); 95 } 96 else 97 { 98 sb.append( logs[0] ); 99 for (int i = 1; i < logs.length; ++i) 100 { 101 sb.append( ", " ). 102 append( logs[i] ); 103 } 104 } 105 sb.append( newline ); 106 107 w.write( sb.toString() ); 108 w.flush(); 109 } 110 111 112 void appendArray( StringBuffer sb, Object [] list, String newline ) 113 { 114 if (list == null || list.length <= 0) 115 { 116 sb.append( " none" ); 117 } 118 else 119 { 120 for (int i = 0; i < list.length; ++i) 121 { 122 sb.append( newline ). 123 append( " " ). 124 append( list[i] ); 125 } 126 } 127 } 128 } 129 130 | Popular Tags |