1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.logging.internal.helpers

File ExtendedMessageFormatterTest.java

 

Code metrics

0
10
10
1
100
64
10
1
1
10
1

Classes

Class Line # Actions
ExtendedMessageFormatterTest 32 10 0% 10 0
1.0100%
 

Contributing tests

This file is covered by 10 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.logging.internal.helpers;
21   
22    import java.util.Arrays;
23   
24    import org.junit.Assert;
25    import org.junit.Test;
26   
27    /**
28    * Validate {@link ExtendedMessageFormatter}.
29    *
30    * @version $Id: 8d4fe0fb3707185edce0f6ebfe54821e3d43cd46 $
31    */
 
32    public class ExtendedMessageFormatterTest
33    {
 
34  1 toggle @Test
35    public void testNullMessage()
36    {
37  1 Assert.assertNull(ExtendedMessageFormatter.parseMessage(null, new Object[] {}));
38    }
39   
 
40  1 toggle @Test
41    public void testEmptyMessage()
42    {
43  1 Assert.assertEquals(Arrays.asList(""), ExtendedMessageFormatter.parseMessage("", new Object[] {}));
44    }
45   
 
46  1 toggle @Test
47    public void testNullArguments()
48    {
49  1 Assert.assertEquals(Arrays.asList("message"), ExtendedMessageFormatter.parseMessage("message", null));
50    }
51   
 
52  1 toggle @Test
53    public void testEmptyArguments()
54    {
55  1 Assert
56    .assertEquals(Arrays.asList("message"), ExtendedMessageFormatter.parseMessage("message", new Object[] {}));
57    }
58   
 
59  1 toggle @Test
60    public void testPlain()
61    {
62  1 Assert.assertEquals(Arrays.asList("message"),
63    ExtendedMessageFormatter.parseMessage("message", new Object[] { "0" }));
64    }
65   
 
66  1 toggle @Test
67    public void testWithArguments()
68    {
69  1 Assert.assertEquals(Arrays.asList("hello ", " world"),
70    ExtendedMessageFormatter.parseMessage("hello {} world", new Object[] { "0" }));
71    }
72   
 
73  1 toggle @Test
74    public void testWithoutArguments()
75    {
76  1 Assert.assertEquals(Arrays.asList("hello {} world"),
77    ExtendedMessageFormatter.parseMessage("hello {} world", new Object[] {}));
78    }
79   
 
80  1 toggle @Test
81    public void testWithEndingArgument()
82    {
83  1 Assert.assertEquals(Arrays.asList("hello ", ""),
84    ExtendedMessageFormatter.parseMessage("hello {}", new Object[] { "0" }));
85    }
86   
 
87  1 toggle @Test
88    public void testWithoutTooMuchArguments()
89    {
90  1 Assert.assertEquals(Arrays.asList("hello ", " world"),
91    ExtendedMessageFormatter.parseMessage("hello {} world", new Object[] { "0", "1" }));
92    }
93   
 
94  1 toggle @Test
95    public void testWithOnlyArguments()
96    {
97  1 Assert.assertEquals(Arrays.asList("", "", ""),
98    ExtendedMessageFormatter.parseMessage("{}{}", new Object[] { "0", "1" }));
99    }
100    }