1 17 package org.apache.tools.ant.taskdefs.optional.metamata; 18 19 import java.io.File ; 20 21 import junit.framework.TestCase; 22 23 import org.apache.tools.ant.util.StringUtils; 24 25 29 public class MAuditParserTest extends TestCase { 30 31 private MAuditParser parser; 32 33 public MAuditParserTest(String s) { 34 super(s); 35 } 36 37 protected void setUp() { 38 parser = new MAuditParser(); 39 } 40 41 public void testViolation() { 42 String line = "file:\\WebGain\\QA\\examples\\auditexamples\\Vector.java:55: Array declarators (\"[]\") should be placed with their component types and not after field/method declarations (5.27)."; 43 line = StringUtils.replace(line, "\\", File.separator); 46 MAuditParser.Violation violation = parser.parseLine(line); 47 assertEquals("\\WebGain\\QA\\examples\\auditexamples\\Vector.java", 48 StringUtils.replace(violation.file, File.separator, "\\")); 49 assertEquals("55", violation.line); 50 assertEquals("Array declarators (\"[]\") should be placed with their component types and not after field/method declarations (5.27).", violation.error); 51 } 52 53 public void testNonViolation(){ 54 String line = "Audit completed with 36 violations."; 55 Object violation = parser.parseLine(line); 56 assertNull(violation); 57 } 58 59 public void testFilePathInViolation(){ 60 String line = "file:\\WebGain\\QA\\examples\\auditexamples\\Hashtable.java:302: Loop variable defined at file:\\WebGain\\QA\\examples\\auditexamples\\Hashtable.java:300 is being modified (5.16)."; 61 line = StringUtils.replace(line, "\\", File.separator); 62 MAuditParser.Violation violation = parser.parseLine(line); 63 assertEquals("\\WebGain\\QA\\examples\\auditexamples\\Hashtable.java", 64 StringUtils.replace(violation.file, File.separator, "\\")); 65 assertEquals("302", violation.line); 66 assertEquals("Loop variable defined at Hashtable.java:300 is being modified (5.16).", violation.error); 67 } 68 69 } 70 | Popular Tags |