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();
}
private static String FORCED_URL = null;
protected static void forceToURL(String url){
FORCED_URL = url;
}
public static ResourceRegistryClient create() {
String address = null;
if(FORCED_URL!=null){
address = FORCED_URL;
}else {
address = String.format("%s/%s", ServiceInstance.getServiceURL(),Constants.SERVICE_NAME);
}
String address = String.format("%s/%s", ServiceInstance.getServiceURL(),Constants.SERVICE_NAME);
logger.trace("The {} will be contacted at {}", Constants.SERVICE_NAME, address);
return new ResourceRegistryClientImpl(address);
}

View File

@ -81,9 +81,6 @@ public class ContextTest {
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 {

View File

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

View File

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