1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.test.cts

File TestDataParserTest.java

 

Code metrics

0
50
2
1
106
70
2
0.04
25
2
1

Classes

Class Line # Actions
TestDataParserTest 39 50 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 2 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.test.cts;
21   
22    import java.util.Arrays;
23    import java.util.List;
24    import java.util.Properties;
25    import java.util.Set;
26   
27    import org.junit.Test;
28   
29    import org.junit.Assert;
30    import static org.junit.Assert.assertThat;
31    import static org.hamcrest.Matchers.containsInAnyOrder;
32   
33    /**
34    * Unit tests for {@link TestDataParser}.
35    *
36    * @version $Id: 88342b2f7208d15c99711408c0a4dfea01af0350 $
37    * @since 4.1M1
38    */
 
39    public class TestDataParserTest
40    {
 
41  1 toggle @Test
42    public void findRelativeTestDirectoryNames()
43    {
44  1 TestDataParser parser = new TestDataParser();
45  1 Set<String> prefixes = parser.findRelativeTestDirectoryNames("ctstest", "type", ".*\\.xml");
46  1 Assert.assertEquals(1, prefixes.size());
47  1 Assert.assertEquals("type/test/test1", prefixes.iterator().next());
48    }
49   
 
50  1 toggle @Test
51    public void readTestData() throws Exception
52    {
53  1 TestDataParser parser = new TestDataParser();
54  1 List<TestData> data = parser.parseTestData("syntax/1.0", "ctstest", "type", ".*\\.xml");
55  1 Assert.assertEquals(4, data.size());
56   
57  1 TestDataConfiguration configuration = new TestDataConfiguration();
58  1 Properties properties = new Properties();
59  1 properties.setProperty("type/test/test1", "Description1");
60  1 configuration.testDescriptions = properties;
61  1 configuration.failingTests = Arrays.asList("failingregex");
62  1 configuration.notApplicableTests = Arrays.asList("notapplicableregex");
63   
64  1 TestData test1 = new TestData();
65  1 test1.isSyntaxInputTest = true;
66  1 test1.prefix = "type/test/test1";
67  1 test1.syntaxData = "in";
68  1 test1.syntaxExtension = ".in.txt";
69  1 test1.syntaxId = "syntax/1.0";
70  1 test1.ctsData = "<cts/>";
71  1 test1.ctsExtension = ".inout.xml";
72  1 test1.configuration = configuration;
73   
74  1 TestData test2 = new TestData();
75  1 test2.isSyntaxInputTest = true;
76  1 test2.prefix = "type/test/test1";
77  1 test2.syntaxData = "in1";
78  1 test2.syntaxExtension = ".in.1.txt";
79  1 test2.syntaxId = "syntax/1.0";
80  1 test2.ctsData = "<cts/>";
81  1 test2.ctsExtension = ".inout.xml";
82  1 test2.configuration = configuration;
83   
84  1 TestData test3 = new TestData();
85  1 test3.isSyntaxInputTest = true;
86  1 test3.prefix = "type/test/test1";
87  1 test3.syntaxData = "in2";
88  1 test3.syntaxExtension = ".in.2.txt";
89  1 test3.syntaxId = "syntax/1.0";
90  1 test3.ctsData = "<cts/>";
91  1 test3.ctsExtension = ".inout.xml";
92  1 test3.configuration = configuration;
93   
94  1 TestData test4 = new TestData();
95  1 test4.isSyntaxInputTest = false;
96  1 test4.prefix = test1.prefix;
97  1 test4.syntaxData = "out";
98  1 test4.syntaxExtension = ".out.txt";
99  1 test4.syntaxId = test1.syntaxId;
100  1 test4.ctsData = test1.ctsData;
101  1 test4.ctsExtension = test1.ctsExtension;
102  1 test4.configuration = configuration;
103   
104  1 assertThat(data, containsInAnyOrder(test1, test2, test3, test4));
105    }
106    }