Java 11 migrate all remaining s (#1120)
* Moves saga to Java 11 * Moves semaphore to Java 11 * Moves servant to Java 11 * Moves serverless to Java 11 * Moves service-layer to Java 11 * Moves service-locator to Java 11 * Moves sharding to Java 11 * Moves singleton to Java 11 * Moves spatial-partition to Java 11 * Moves specification to Java 11 * Moves state to Java 11 * Moves step-builder to Java 11 * Moves strategy to Java 11 * Moves subclass-sandbox to Java 11 * Fixes checkstyle issues
This commit is contained in:
committed by
Ilkka Seppälä
parent
310ae50248
commit
cd2a2e7711
@ -53,15 +53,14 @@ public class ServiceCache {
|
||||
* @return {@link Service}
|
||||
*/
|
||||
public Service getService(String serviceName) {
|
||||
Service cachedService = null;
|
||||
for (String serviceJndiName : serviceCache.keySet()) {
|
||||
if (serviceJndiName.equals(serviceName)) {
|
||||
cachedService = serviceCache.get(serviceJndiName);
|
||||
LOGGER.info("(cache call) Fetched service {}({}) from cache... !",
|
||||
cachedService.getName(), cachedService.getId());
|
||||
}
|
||||
if (serviceCache.containsKey(serviceName)) {
|
||||
var cachedService = serviceCache.get(serviceName);
|
||||
var name = cachedService.getName();
|
||||
var id = cachedService.getId();
|
||||
LOGGER.info("(cache call) Fetched service {}({}) from cache... !", name, id);
|
||||
return cachedService;
|
||||
}
|
||||
return cachedService;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,15 +26,12 @@ package com.iluwatar.servicelocator;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
App.main(new String[]{});
|
||||
}
|
||||
}
|
||||
|
@ -23,14 +23,15 @@
|
||||
|
||||
package com.iluwatar.servicelocator;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/29/15 - 19:07 PM
|
||||
*
|
||||
@ -52,12 +53,10 @@ public class ServiceLocatorTest {
|
||||
*/
|
||||
@Test
|
||||
public void testServiceCache() {
|
||||
final String[] serviceNames = new String[]{
|
||||
"jndi/serviceA", "jndi/serviceB"
|
||||
};
|
||||
final var serviceNames = List.of("jndi/serviceA", "jndi/serviceB");
|
||||
|
||||
for (final String serviceName : serviceNames) {
|
||||
final Service service = ServiceLocator.getService(serviceName);
|
||||
for (final var serviceName : serviceNames) {
|
||||
final var service = ServiceLocator.getService(serviceName);
|
||||
assertNotNull(service);
|
||||
assertEquals(serviceName, service.getName());
|
||||
assertTrue(service.getId() > 0); // The id is generated randomly, but the minimum value is '1'
|
||||
|
Reference in New Issue
Block a user