1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.internal.macro.ctsreport

File TestParser.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

8
20
1
1
72
34
5
0.25
20
1
5

Classes

Class Line # Actions
TestParser 32 20 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.internal.macro.ctsreport;
21   
22    import java.util.regex.Matcher;
23    import java.util.regex.Pattern;
24   
25    /**
26    * Parses JUnit test results of the form {@code testname [syntax, IN|OUT:extension, CTS:extension] cause}, where
27    * {@code cause} is either "Failing", "Missing" or "Passed".
28    *
29    * @version $Id: b1e62806e3b530b56cae99c0274af7a12216c753 $
30    * @since 4.1M2
31    */
 
32    public class TestParser
33    {
34    /**
35    * The regex to parse test result.
36    */
37    private static final Pattern PATTERN = Pattern.compile("(.*) \\[(.*), (.*):(.*), CTS:(.*)\\](.*)");
38   
39    /**
40    * @param syntaxTest the string to parse
41    * @return the parsed Result
42    */
 
43  21 toggle public Result parse(String syntaxTest)
44    {
45  21 Result data = new Result();
46  21 Matcher matcher = PATTERN.matcher(syntaxTest);
47  21 if (matcher.matches()) {
48  20 data.syntaxId = matcher.group(2);
49  20 data.isSyntaxInputTest = "IN".equals(matcher.group(3));
50   
51  20 Test test = new Test();
52  20 data.test = test;
53  20 test.prefix = matcher.group(1);
54  20 test.syntaxExtension = matcher.group(4);
55  20 test.ctsExtension = matcher.group(5);
56   
57  20 String cause = matcher.group(6);
58  20 if (cause.contains("Failing")) {
59  1 test.state = State.FAILING;
60  19 } else if (cause.contains("Missing")) {
61  1 test.state = State.MISSING;
62  18 } else if (cause.contains("Passed")) {
63  17 test.state = State.PASSED;
64    } else {
65  1 test.state = State.UNKNOWN;
66    }
67    } else {
68  1 throw new RuntimeException(String.format("Invalid Syntax Test format for [%s]", syntaxTest));
69    }
70  20 return data;
71    }
72    }