1 |
1 |
package eu.dnetlib.enabling.locators;
|
2 |
2 |
|
3 |
|
import static org.junit.Assert.assertEquals;
|
4 |
|
import static org.junit.Assert.assertTrue;
|
5 |
|
import static org.mockito.Matchers.anyString;
|
6 |
|
import static org.mockito.Mockito.never;
|
7 |
|
import static org.mockito.Mockito.times;
|
8 |
|
import static org.mockito.Mockito.verify;
|
9 |
|
import static org.mockito.Mockito.when;
|
10 |
|
|
11 |
3 |
import java.util.Map;
|
12 |
4 |
import java.util.Set;
|
13 |
5 |
|
|
6 |
import com.google.common.collect.Lists;
|
|
7 |
import com.google.common.collect.Maps;
|
|
8 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
|
9 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
|
10 |
import eu.dnetlib.enabling.locators.comparators.PreferLocalRunningInstanceComparator;
|
|
11 |
import eu.dnetlib.enabling.resultset.rmi.ResultSetService;
|
|
12 |
import eu.dnetlib.enabling.tools.OpaqueResource;
|
|
13 |
import eu.dnetlib.enabling.tools.registration.ServiceNameResolver;
|
|
14 |
import eu.dnetlib.enabling.tools.registration.ServiceRegistrationManager;
|
14 |
15 |
import org.antlr.stringtemplate.StringTemplate;
|
15 |
16 |
import org.apache.commons.io.IOUtils;
|
16 |
17 |
import org.junit.Before;
|
17 |
|
import org.junit.Ignore;
|
18 |
18 |
import org.junit.Test;
|
19 |
19 |
import org.junit.runner.RunWith;
|
20 |
20 |
import org.mockito.Mock;
|
21 |
21 |
import org.mockito.junit.MockitoJUnitRunner;
|
22 |
22 |
import org.springframework.context.ApplicationContext;
|
23 |
23 |
|
24 |
|
import com.google.common.collect.Lists;
|
25 |
|
import com.google.common.collect.Maps;
|
|
24 |
import static org.junit.Assert.assertEquals;
|
|
25 |
import static org.junit.Assert.assertTrue;
|
|
26 |
import static org.mockito.Matchers.anyString;
|
|
27 |
import static org.mockito.Mockito.*;
|
26 |
28 |
|
27 |
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
28 |
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
29 |
|
import eu.dnetlib.enabling.locators.comparators.PreferLocalRunningInstanceComparator;
|
30 |
|
import eu.dnetlib.enabling.resultset.rmi.ResultSetService;
|
31 |
|
import eu.dnetlib.enabling.tools.OpaqueResource;
|
32 |
|
import eu.dnetlib.enabling.tools.registration.ServiceNameResolver;
|
33 |
|
import eu.dnetlib.enabling.tools.registration.ServiceRegistrationManager;
|
34 |
|
|
35 |
29 |
@RunWith(MockitoJUnitRunner.class)
|
36 |
30 |
public class DefaultUniqueServiceLocatorTest {
|
37 |
31 |
|
... | ... | |
97 |
91 |
assertEquals(lookupService, locator.getService(ISLookUpService.class));
|
98 |
92 |
}
|
99 |
93 |
|
100 |
|
@Ignore
|
101 |
94 |
@Test
|
102 |
95 |
public void testGetServiceClassOfT_2() throws ISLookUpException {
|
103 |
96 |
assertEquals(resultsetService, locator.getService(ResultSetService.class, false));
|
104 |
97 |
verify(lookupService, times(1)).quickSearchProfile(XQUERY);
|
105 |
98 |
}
|
106 |
99 |
|
107 |
|
@Ignore
|
108 |
100 |
@Test
|
109 |
101 |
public void testGetServiceClassOfTComparatorOfServiceRunningInstance() throws ISLookUpException {
|
110 |
102 |
assertEquals(resultsetService, locator.getService(ResultSetService.class, new PreferLocalRunningInstanceComparator()));
|
111 |
103 |
verify(lookupService, times(1)).quickSearchProfile(XQUERY);
|
112 |
104 |
}
|
113 |
105 |
|
114 |
|
@Ignore
|
115 |
106 |
@Test
|
116 |
107 |
public void testGetServiceClassOfTString() {
|
117 |
108 |
assertEquals(resultsetService, locator.getService(ResultSetService.class, "rs-1234"));
|
118 |
109 |
}
|
119 |
110 |
|
120 |
|
@Ignore
|
121 |
111 |
@Test
|
122 |
112 |
public void testGetServiceClassOfTBoolean() throws ISLookUpException {
|
123 |
113 |
assertEquals(resultsetService, locator.getService(ResultSetService.class, true));
|
124 |
114 |
verify(lookupService, never()).quickSearchProfile(XQUERY);
|
125 |
115 |
}
|
126 |
116 |
|
127 |
|
@Ignore
|
128 |
117 |
@Test
|
129 |
118 |
public void testGetServiceIdClassOfT() {
|
130 |
119 |
assertEquals("2222", locator.getServiceId(ResultSetService.class));
|
131 |
120 |
}
|
132 |
121 |
|
133 |
|
@Ignore
|
134 |
122 |
@Test
|
135 |
123 |
public void testGetServiceIdClassOfTComparatorOfServiceRunningInstance() {
|
136 |
124 |
assertEquals("2222", locator.getServiceId(ResultSetService.class, new PreferLocalRunningInstanceComparator()));
|
... | ... | |
141 |
129 |
assertEquals("2222", locator.getServiceId(ResultSetService.class, "rs-1234"));
|
142 |
130 |
}
|
143 |
131 |
|
144 |
|
@Ignore
|
145 |
132 |
@Test
|
146 |
133 |
public void testGetAllServices() {
|
147 |
134 |
final Set<ResultSetService> list = locator.getAllServices(ResultSetService.class);
|
reverted pom