Removed force URL in factory

This commit is contained in:
Luca Frosini 2022-07-25 11:07:32 +02:00
parent 888d666b79
commit 85ed707f44
4 changed files with 12 additions and 20 deletions

View File

@ -26,21 +26,8 @@ public class ResourceRegistryClientFactory {
return authorizationEntry.getContext(); return authorizationEntry.getContext();
} }
private static String FORCED_URL = null;
protected static void forceToURL(String url){
FORCED_URL = url;
}
public static ResourceRegistryClient create() { public static ResourceRegistryClient create() {
String address = null; String address = String.format("%s/%s", ServiceInstance.getServiceURL(),Constants.SERVICE_NAME);
if(FORCED_URL!=null){
address = FORCED_URL;
}else {
address = String.format("%s/%s", ServiceInstance.getServiceURL(),Constants.SERVICE_NAME);
}
logger.trace("The {} will be contacted at {}", Constants.SERVICE_NAME, address); logger.trace("The {} will be contacted at {}", Constants.SERVICE_NAME, address);
return new ResourceRegistryClientImpl(address); return new ResourceRegistryClientImpl(address);
} }

View File

@ -80,10 +80,7 @@ public class ContextTest {
} }
RESOURCE_REGISTRY_URL = registryProperties.getProperty(RESOURCE_REGISTRY_URL_PROPERTY); RESOURCE_REGISTRY_URL = registryProperties.getProperty(RESOURCE_REGISTRY_URL_PROPERTY);
if(RESOURCE_REGISTRY_URL!=null){
ResourceRegistryClientFactory.forceToURL(RESOURCE_REGISTRY_URL);
}
} }
public static String getCurrentScope(String token) throws ObjectNotFound, Exception { public static String getCurrentScope(String token) throws ObjectNotFound, Exception {

View File

@ -44,7 +44,11 @@ public class ResourceRegistryClientTest extends ContextTest {
protected ResourceRegistryClient resourceRegistryClient; protected ResourceRegistryClient resourceRegistryClient;
public ResourceRegistryClientTest() { public ResourceRegistryClientTest() {
resourceRegistryClient = ResourceRegistryClientFactory.create(); if(ContextTest.RESOURCE_REGISTRY_URL !=null && !ContextTest.RESOURCE_REGISTRY_URL.isEmpty()) {
resourceRegistryClient = new ResourceRegistryClientImpl(ContextTest.RESOURCE_REGISTRY_URL);
}else {
resourceRegistryClient = ResourceRegistryClientFactory.create();
}
} }
@Test @Test

View File

@ -38,7 +38,11 @@ public class ResourceRegistryClientTestWikiExamples extends ContextTest {
protected ResourceRegistryClient resourceRegistryClient; protected ResourceRegistryClient resourceRegistryClient;
public ResourceRegistryClientTestWikiExamples() { public ResourceRegistryClientTestWikiExamples() {
resourceRegistryClient = ResourceRegistryClientFactory.create(); if(ContextTest.RESOURCE_REGISTRY_URL !=null && !ContextTest.RESOURCE_REGISTRY_URL.isEmpty()) {
resourceRegistryClient = new ResourceRegistryClientImpl(ContextTest.RESOURCE_REGISTRY_URL);
}else {
resourceRegistryClient = ResourceRegistryClientFactory.create();
}
} }
@Before @Before