source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/testcases/org/apache/tools/ant/taskdefs/optional/metamata/MAuditParserTest.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 2.8 KB
Line 
1/*
2 * Copyright 2002,2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17package org.apache.tools.ant.taskdefs.optional.metamata;
18
19import java.io.File;
20
21import junit.framework.TestCase;
22
23import org.apache.tools.ant.util.StringUtils;
24
25/**
26 * Test for the Audit parser.
27 *
28 */
29public 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 // the replace is done to simulate a platform dependant separator since
44 // the parser may do some magic with the file separator
45 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}
Note: See TracBrowser for help on using the repository browser.