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

File TranslationMarkerTest.java

 

Code metrics

0
24
12
1
122
82
12
0.5
2
12
1

Classes

Class Line # Actions
TranslationMarkerTest 33 24 0% 12 0
1.0100%
 

Contributing tests

This file is covered by 11 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.marker;
21   
22    import org.junit.Assert;
23    import org.junit.Before;
24    import org.junit.Test;
25    import org.slf4j.Marker;
26    import org.slf4j.MarkerFactory;
27   
28    /**
29    * Test {@link TranslationMarker}.
30    *
31    * @version $Id: c4da1afce60e20163a96a3fc954a9d5d84dfc067 $
32    */
 
33    public class TranslationMarkerTest
34    {
35    private TranslationMarker marker;
36   
 
37  11 toggle @Before
38    public void setUp()
39    {
40  11 this.marker = new TranslationMarker("translation.key");
41    }
42   
 
43  1 toggle @Test
44    public void getTranslationKey()
45    {
46  1 Assert.assertEquals("translation.key", this.marker.getTranslationKey());
47    }
48   
 
49  1 toggle @Test
50    public void getName()
51    {
52  1 Assert.assertEquals(TranslationMarker.NAME, this.marker.getName());
53    }
54   
 
55  1 toggle @Test
56    public void add()
57    {
58  1 this.marker.add(MarkerFactory.getMarker("marker"));
59    }
60   
 
61  1 toggle @Test
62    public void remove()
63    {
64  1 Assert.assertFalse(this.marker.remove(null));
65    }
66   
 
67  1 toggle @Test
68    public void hasChildren()
69    {
70  1 Assert.assertFalse(this.marker.hasChildren());
71    }
72   
 
73  1 toggle @Test
74    public void hasReferences()
75    {
76  1 Assert.assertFalse(this.marker.hasReferences());
77    }
78   
 
79  1 toggle @Test
80    public void iterator()
81    {
82  1 Assert.assertFalse(this.marker.iterator().hasNext());
83    }
84   
 
85  1 toggle @Test
86    public void containsString()
87    {
88  1 Assert.assertFalse(this.marker.contains("name"));
89  1 Assert.assertTrue(this.marker.contains(this.marker.getName()));
90    }
91   
 
92  1 toggle @Test
93    public void containsMarker()
94    {
95  1 Assert.assertFalse(this.marker.contains(MarkerFactory.getMarker("name")));
96  1 Assert.assertTrue(this.marker.contains(this.marker));
97    }
98   
 
99  1 toggle @Test
100    public void testHashCode()
101    {
102  1 Marker equalsTMarker = new TranslationMarker("translation.key");
103  1 Marker otherTMarker = new TranslationMarker("translation.otherkey");
104  1 Marker otherMarker = MarkerFactory.getMarker("name");
105   
106  1 Assert.assertEquals(equalsTMarker.hashCode(), this.marker.hashCode());
107  1 Assert.assertFalse(this.marker.hashCode() == otherTMarker.hashCode());
108  1 Assert.assertFalse(this.marker.hashCode() == otherMarker.hashCode());
109    }
110   
 
111  1 toggle @Test
112    public void testEquals()
113    {
114  1 Marker equalsTMarker = new TranslationMarker("translation.key");
115  1 Marker otherTMarker = new TranslationMarker("translation.otherkey");
116  1 Marker otherMarker = MarkerFactory.getMarker("name");
117   
118  1 Assert.assertEquals(equalsTMarker, this.marker);
119  1 Assert.assertFalse(this.marker.equals(otherTMarker));
120  1 Assert.assertFalse(this.marker.equals(otherMarker));
121    }
122    }