Removed force URL in factory
This commit is contained in:
parent
7a0eb867fe
commit
31c19f3c49
|
@ -1,7 +1,5 @@
|
|||
package org.gcube.informationsystem.resourceregistry.schema;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
@ -28,21 +26,8 @@ public class ResourceRegistrySchemaClientFactory {
|
|||
return authorizationEntry.getContext();
|
||||
}
|
||||
|
||||
private static String FORCED_URL = null;
|
||||
|
||||
protected static void forceToURL(String url){
|
||||
FORCED_URL = url;
|
||||
}
|
||||
|
||||
public static ResourceRegistrySchemaClient 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 ResourceRegistrySchemaClientImpl(address);
|
||||
}
|
||||
|
|
|
@ -80,10 +80,7 @@ public class ContextTest {
|
|||
}
|
||||
|
||||
RESOURCE_REGISTRY_URL = registryProperties.getProperty(RESOURCE_REGISTRY_URL_PROPERTY);
|
||||
|
||||
if(RESOURCE_REGISTRY_URL!=null){
|
||||
ResourceRegistrySchemaClientFactory.forceToURL(RESOURCE_REGISTRY_URL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
||||
|
|
|
@ -15,6 +15,17 @@ public class ResourceRegistrySchemaClientTest extends ContextTest {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(ResourceRegistrySchemaClientTest.class);
|
||||
|
||||
protected ResourceRegistrySchemaClient resourceRegistrySchemaClient;
|
||||
|
||||
public ResourceRegistrySchemaClientTest() {
|
||||
if(ContextTest.RESOURCE_REGISTRY_URL !=null && !ContextTest.RESOURCE_REGISTRY_URL.isEmpty()) {
|
||||
resourceRegistrySchemaClient = new ResourceRegistrySchemaClientImpl(ContextTest.RESOURCE_REGISTRY_URL);
|
||||
}else {
|
||||
resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Abstract
|
||||
interface AuxFacet extends Facet {
|
||||
public static final String NAME = "aux"; //AuxFacet.class.getSimpleName();
|
||||
|
@ -24,14 +35,12 @@ public class ResourceRegistrySchemaClientTest extends ContextTest {
|
|||
|
||||
// @Test
|
||||
public void testCreate() throws Exception {
|
||||
ResourceRegistrySchemaClient resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create();
|
||||
Type td = resourceRegistrySchemaClient.create(AuxFacet.class);
|
||||
logger.debug("{}", td);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() throws Exception {
|
||||
ResourceRegistrySchemaClient resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create();
|
||||
List<Type> types = resourceRegistrySchemaClient.read(Facet.class, true);
|
||||
Assert.assertTrue(types.size()>1);
|
||||
for(Type td : types) {
|
||||
|
@ -49,5 +58,4 @@ public class ResourceRegistrySchemaClientTest extends ContextTest {
|
|||
//Assert.assertTrue(gotFacetDefinition.getDescription().compareTo(facetDefinition.getDescription())==0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue