Revision 45126
Added by Claudio Atzori over 7 years ago
ServiceRegistratorTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.enabling.tools.registration; |
2 | 2 |
|
3 |
|
|
4 | 3 |
import static org.junit.Assert.assertEquals; |
5 | 4 |
import static org.mockito.Mockito.when; |
6 | 5 |
import static org.mockito.Matchers.anyString; |
... | ... | |
8 | 7 |
|
9 | 8 |
import javax.xml.namespace.QName; |
10 | 9 |
|
10 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException; |
|
11 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
12 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
11 | 13 |
import org.apache.cxf.endpoint.Endpoint; |
12 | 14 |
import org.apache.cxf.endpoint.ServerImpl; |
13 | 15 |
import org.apache.cxf.jaxws.EndpointImpl; |
14 | 16 |
import org.apache.cxf.service.Service; |
15 | 17 |
import org.apache.cxf.service.model.EndpointInfo; |
16 |
//import org.junit.Before; |
|
18 |
|
|
19 |
import org.junit.Before; |
|
17 | 20 |
import org.junit.Test; |
18 | 21 |
import org.junit.Ignore; |
19 | 22 |
import org.junit.runner.RunWith; |
20 | 23 |
import org.mockito.Mock; |
21 |
import org.mockito.runners.MockitoJUnit44Runner;
|
|
24 |
import org.mockito.junit.MockitoJUnitRunner;
|
|
22 | 25 |
|
23 | 26 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException; |
24 | 27 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
... | ... | |
33 | 36 |
* @author marko |
34 | 37 |
* |
35 | 38 |
*/ |
36 |
@RunWith(MockitoJUnit44Runner.class)
|
|
39 |
@RunWith(MockitoJUnitRunner.class) |
|
37 | 40 |
public class ServiceRegistratorTest { |
38 | 41 |
/** |
39 | 42 |
* instance under test. |
... | ... | |
65 | 68 |
private transient ISRegistryService registryService; |
66 | 69 |
|
67 | 70 |
/** |
71 |
* isLookup service mock. |
|
72 |
*/ |
|
73 |
@Mock |
|
74 |
private transient ISLookUpService isLookUpService; |
|
75 |
|
|
76 |
/** |
|
68 | 77 |
* jaxws endpoint mock. |
69 | 78 |
*/ |
70 | 79 |
@Mock |
... | ... | |
88 | 97 |
* setup common stuff. |
89 | 98 |
* |
90 | 99 |
*/ |
91 |
//@Before |
|
92 |
public void disabled() { |
|
93 |
when(service.getName()).thenReturn(new QName("http://my.test", "TestService")); |
|
100 |
@Before |
|
101 |
public void disabled() throws ISLookUpException { |
|
102 |
final String service = "TestService"; |
|
103 |
when(this.service.getName()).thenReturn(new QName("http://my.test", service)); |
|
94 | 104 |
|
95 | 105 |
when(endpoint.getEndpointInfo()).thenReturn(endpointInfo); |
96 |
when(endpoint.getService()).thenReturn(service); |
|
106 |
when(endpoint.getService()).thenReturn(this.service);
|
|
97 | 107 |
when(endpointInfo.getAddress()).thenReturn("http://localhost/something"); |
98 | 108 |
when(endpointInfo.getName()).thenReturn(new QName("http://my.test", "TestServiceEndpoint")); |
99 | 109 |
|
... | ... | |
102 | 112 |
|
103 | 113 |
when(hnmLocator.getHNMForUrl("http://localhost/something")).thenReturn("555444"); |
104 | 114 |
|
105 |
when(serviceLocator.getService(ISRegistryService.class)).thenReturn(registryService); |
|
115 |
// serviceLocator.getService(ISLookUpService.class).getResourceTypeSchema(serviceName); |
|
116 |
|
|
117 |
when(isLookUpService.getResourceTypeSchema(service)).thenThrow(ISLookUpDocumentNotFoundException.class); |
|
118 |
|
|
119 |
when(serviceLocator.getService(ISLookUpService.class)).thenReturn(isLookUpService); |
|
106 | 120 |
when(serviceLocator.getService(ISRegistryService.class, true)).thenReturn(registryService); |
107 | 121 |
|
108 | 122 |
|
... | ... | |
123 | 137 |
* @throws ISRegistryException shouldn't happen |
124 | 138 |
*/ |
125 | 139 |
@Test |
126 |
@Ignore
|
|
140 |
//@Ignore
|
|
127 | 141 |
public void testRegisterService() throws ISRegistryException { |
128 | 142 |
when(registryService.insertProfileForValidation(eq("TestServiceResourceType"), anyString())).thenReturn("123"); |
129 | 143 |
|
Also available in: Unified diff
migrated to dnet45, using updated mockito version in tests