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

File DefaultComponentDescriptorTest.java

 

Code metrics

0
54
1
5
122
76
1
0.02
54
0.2
1

Classes

Class Line # Actions
DefaultComponentDescriptorTest 31 54 0% 1 0
1.0100%
DefaultComponentDescriptorTest.Role 33 0 - 0 0
-1.0 -
DefaultComponentDescriptorTest.OtherRole 37 0 - 0 0
-1.0 -
DefaultComponentDescriptorTest.ImplRole 41 0 - 0 0
-1.0 -
DefaultComponentDescriptorTest.ImplOtherRole 45 0 - 0 0
-1.0 -
 

Contributing tests

This file is covered by 1 test. .

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.component.descriptor;
21   
22    import org.junit.Assert;
23    import org.junit.Test;
24   
25    /**
26    * Unit tests for {@link DefaultComponentDescriptor}.
27    *
28    * @version $Id: f5c90e05e30d7ee77802196112c3a49f3a9c67be $
29    * @since 3.3M1
30    */
 
31    public class DefaultComponentDescriptorTest
32    {
 
33    private interface Role
34    {
35    }
36   
 
37    private interface OtherRole
38    {
39    }
40   
 
41    private class ImplRole
42    {
43    }
44   
 
45    private class ImplOtherRole
46    {
47    }
48   
 
49  1 toggle @Test
50    public void equals()
51    {
52  1 DefaultComponentDescriptor cd1 = new DefaultComponentDescriptor();
53  1 cd1.setImplementation(ImplRole.class);
54  1 cd1.setRoleType(Role.class);
55  1 cd1.setRoleHint("hint");
56   
57  1 Assert.assertEquals(cd1, cd1);
58   
59  1 DefaultComponentDescriptor cd2 = new DefaultComponentDescriptor();
60  1 cd2.setImplementation(ImplRole.class);
61  1 cd2.setRoleType(Role.class);
62  1 cd2.setRoleHint("hint");
63   
64  1 Assert.assertEquals(cd1, cd2);
65   
66  1 DefaultComponentDescriptor cd3 = new DefaultComponentDescriptor();
67  1 cd3.setImplementation(ImplRole.class);
68  1 cd3.setRoleType(OtherRole.class);
69  1 cd3.setRoleHint("hint");
70   
71  1 Assert.assertFalse(cd1.equals(cd3));
72   
73  1 DefaultComponentDescriptor cd4 = new DefaultComponentDescriptor();
74  1 cd4.setImplementation(ImplOtherRole.class);
75  1 cd4.setRoleType(Role.class);
76  1 cd4.setRoleHint("hint");
77   
78  1 Assert.assertFalse(cd1.equals(cd4));
79   
80  1 DefaultComponentDescriptor cd5 = new DefaultComponentDescriptor();
81  1 cd5.setImplementation(ImplRole.class);
82  1 cd5.setRoleType(Role.class);
83  1 cd5.setRoleHint("hint");
84  1 cd5.setInstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP);
85   
86  1 Assert.assertFalse(cd1.equals(cd5));
87   
88  1 DefaultComponentDescriptor cd6 = new DefaultComponentDescriptor();
89  1 cd6.setImplementation(ImplRole.class);
90  1 cd6.setRoleType(Role.class);
91  1 cd6.setRoleHint("hint");
92  1 DefaultComponentDependency dep = new DefaultComponentDependency();
93  1 dep.setName("name");
94  1 dep.setMappingType(String.class);
95  1 cd6.addComponentDependency(dep);
96   
97  1 Assert.assertFalse(cd1.equals(cd6));
98   
99  1 DefaultComponentDescriptor cd7 = new DefaultComponentDescriptor();
100  1 cd7.setImplementation(ImplRole.class);
101  1 cd7.setRoleType(Role.class);
102  1 cd7.setRoleHint("hint");
103  1 DefaultComponentDependency dep2 = new DefaultComponentDependency();
104  1 dep2.setName("name");
105  1 dep2.setMappingType(String.class);
106  1 cd7.addComponentDependency(dep2);
107   
108  1 Assert.assertEquals(cd6, cd7);
109   
110  1 DefaultComponentDescriptor cd8 = new DefaultComponentDescriptor();
111  1 cd8.setImplementation(ImplRole.class);
112  1 cd8.setRoleType(Role.class);
113  1 cd8.setRoleHint("hint");
114  1 DefaultComponentDependency dep3 = new DefaultComponentDependency();
115  1 dep3.setName("name");
116  1 dep3.setMappingType(String.class);
117  1 cd8.addComponentDependency(dep3);
118  1 cd8.addComponentDependency(dep3);
119   
120  1 Assert.assertFalse(cd7.equals(cd8));
121    }
122    }