1
|
package eu.dnetlib.enabling.tools.registration;
|
2
|
|
3
|
import static org.junit.Assert.assertEquals;
|
4
|
|
5
|
import org.junit.Before;
|
6
|
import org.junit.Test;
|
7
|
import org.junit.runner.RunWith;
|
8
|
import org.mockito.Mock;
|
9
|
import org.mockito.junit.MockitoJUnitRunner;
|
10
|
|
11
|
import eu.dnetlib.enabling.is.registry.ISRegistryServiceImpl;
|
12
|
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
|
13
|
|
14
|
/**
|
15
|
* test heuristic service name generator.
|
16
|
* @author marko
|
17
|
*
|
18
|
*/
|
19
|
@RunWith(MockitoJUnitRunner.class)
|
20
|
public class InterfaceServiceNameGeneratorTest {
|
21
|
|
22
|
/**
|
23
|
* instance under test.
|
24
|
*/
|
25
|
private transient ServiceNameResolver generator = new InterfaceServiceNameResolver();
|
26
|
|
27
|
/**
|
28
|
* simulates the extension of the service interface.
|
29
|
*
|
30
|
* @author marko
|
31
|
*
|
32
|
*/
|
33
|
interface SomeDummyInterface extends ISRegistryService {
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* simulates the implementation of the service interface.
|
38
|
* @author marko
|
39
|
*
|
40
|
*/
|
41
|
abstract class AbstractDummyService implements SomeDummyInterface {
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* simulates the subclassing of the service implementation class.
|
46
|
*
|
47
|
* @author marko
|
48
|
*
|
49
|
*/
|
50
|
abstract class AbstractDummyServiceImpl extends AbstractDummyService {
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* service mock.
|
55
|
*/
|
56
|
@Mock
|
57
|
private transient AbstractDummyServiceImpl service;
|
58
|
|
59
|
/**
|
60
|
* setup.
|
61
|
*/
|
62
|
@Before
|
63
|
public void setUp() {
|
64
|
generator = new InterfaceServiceNameResolver();
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
* test getName().
|
69
|
*/
|
70
|
@Test
|
71
|
public void testGetName() {
|
72
|
assertEquals("check service name", "ISRegistryService", generator.getName(service));
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* test getName() on real classes.
|
77
|
*/
|
78
|
@Test
|
79
|
public void testGetNameReal() {
|
80
|
assertEquals("check service name", "ISRegistryService", generator.getName(new ISRegistryServiceImpl()));
|
81
|
}
|
82
|
|
83
|
|
84
|
}
|